//
// sub_1005AE74C from 0x1005ae74c to 0x1005ae83c (240 bytes)
//
// 2 xrefs:
// > sub_1005AD588 @ 0x1005ad69c
// > sub_1005EDCBC @ 0x1005edfc8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall sub_1005AE74C(__int64 a1, unsigned __int64 a2)
{
int v4; // w19
__int64 v5; // x8
unsigned __int64 v6; // x0
unsigned __int64 v7; // x21
__int64 v8; // x9
__int64 v9; // x23
__int64 v10; // x22
__int64 v11; // x8
__int64 v12; // x8
int v13; // w8
bool v14; // vf
int v15; // w8
if ( !a2 )
return -1;
if ( !*(_DWORD *)(a1 + 8) )
return 0;
v4 = 64 - sub_1005AAB38(a2);
if ( !(unsigned int)sub_1005AE3C0(a1, (__int64 *)a1, v4) )
return -1;
v5 = *(int *)(a1 + 8);
if ( (int)v5 < 1 )
{
v6 = 0;
}
else
{
v6 = 0;
v7 = a2 << v4;
v8 = *(_QWORD *)a1;
v9 = v5 - 1;
do
{
v10 = *(_QWORD *)(v8 + 8 * v9);
v11 = sub_1005B1AB8(v6, v10, v7);
v6 = v10 - v11 * v7;
v8 = *(_QWORD *)a1;
*(_QWORD *)(*(_QWORD *)a1 + 8 * v9) = v11;
v12 = v9-- + 1;
}
while ( v12 > 1 );
v13 = *(_DWORD *)(a1 + 8);
v14 = __OFSUB__(v13, 1);
v15 = v13 - 1;
if ( v15 < 0 == v14 && !*(_QWORD *)(*(_QWORD *)a1 + 8LL * v15) )
*(_DWORD *)(a1 + 8) = v15;
}
return v6 >> v4;
}