//
// sub_1005B489C from 0x1005b489c to 0x1005b4934 (152 bytes)
//
// 1 xrefs:
// > sub_1005BFF1C @ 0x1005bff5c
//
// 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_1005B489C(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // x9
__int64 result; // x0
__int64 v6; // x11
__int64 v8; // x10
int v9; // w12
unsigned __int64 v10; // x13
int v11; // w14
LODWORD(v4) = *(_DWORD *)(a1 + 8);
if ( !(_DWORD)v4 )
return 0;
result = 0;
LABEL_3:
v4 = (int)v4;
v6 = 8LL * ((int)v4 - 1);
while ( v4-- >= 1 )
{
v8 = *(_QWORD *)(*(_QWORD *)a1 + v6);
v6 -= 8;
if ( v8 )
{
v9 = 0;
v10 = 0x8000000000000000LL;
do
{
if ( (v8 & v10) != 0 )
{
if ( (int)result < a3 )
*(_DWORD *)(a2 + 4LL * (int)result) = (((_DWORD)v4 << 6) | 0x3F) + v9;
result = (unsigned int)(result + 1);
}
v10 >>= 1;
v11 = v9 + 63;
--v9;
}
while ( v11 > 0 );
goto LABEL_3;
}
}
if ( (int)result < a3 )
{
*(_DWORD *)(a2 + 4LL * (int)result) = -1;
return (unsigned int)(result + 1);
}
return result;
}