//
// sub_1005AE6EC from 0x1005ae6ec to 0x1005ae74c (96 bytes)
//
// 5 xrefs:
// > sub_1005B06A0 @ 0x1005b08d0
// > sub_1005B06A0 @ 0x1005b0a10
// > sub_1005B06A0 @ 0x1005b0a20
// > sub_1005B06A0 @ 0x1005b0a84
// > sub_1005B0CB4 @ 0x1005b0e70
//
// 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
//
unsigned __int64 __fastcall sub_1005AE6EC(__int64 *a1, unsigned __int64 a2)
{
__int64 v3; // x9
unsigned __int64 result; // x0
__int64 v5; // x8
__int64 v6; // x9
__int128 v7; // t2
__int64 v8; // x10
if ( !a2 )
return -1;
v3 = *((int *)a1 + 2);
if ( (int)v3 < 1 )
return 0;
result = 0;
v5 = *a1;
v6 = v3 - 1;
do
{
*((_QWORD *)&v7 + 1) = result;
*(_QWORD *)&v7 = *(_QWORD *)(v5 + 8 * v6);
result = ((unsigned int)v7 | ((unsigned __int64)(unsigned int)((unsigned __int64)(v7 >> 32) % a2) << 32)) % a2;
v8 = v6-- + 1;
}
while ( v8 > 1 );
return result;
}