//
// sub_1004C4E78 from 0x1004c4e78 to 0x1004c4f88 (272 bytes)
//
// 1 xrefs:
// > sub_1004C6350 @ 0x1004c6354
//
// 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_1004C4E78(_DWORD *a1, int *a2, char a3)
{
_QWORD *v6; // x9
__int64 v8; // x20
__int64 v9; // [xsp+0h] [xbp-20h] BYREF
int v10; // [xsp+Ch] [xbp-14h] BYREF
if ( !a2 )
return 31;
if ( *(_DWORD **)(a2 + 9) != a1 )
return 34;
v6 = *((_QWORD **)a2 + 1);
*v6 = *(_QWORD *)a2;
*(_QWORD *)(*(_QWORD *)a2 + 8LL) = v6;
*(_QWORD *)a2 = a2;
*((_QWORD *)a2 + 1) = a2;
a2[6] = -1;
*((_QWORD *)a2 + 2) = 0;
if ( !a2[13] )
sub_1004B1970(*((_QWORD *)off_1008524C8 + 54), a2);
--a1[57];
if ( (a3 & 1) == 0 )
{
v10 = 0;
if ( !(*(unsigned int (__fastcall **)(_DWORD *, int *))(*(_QWORD *)a1 + 232LL))(a1, &v10) && v10 >= 1 )
{
v8 = 0;
do
{
if ( !(*(unsigned int (__fastcall **)(_DWORD *, __int64, __int64 *))(*(_QWORD *)a1 + 240LL))(a1, v8, &v9) )
*(_WORD *)(v9 + 50) = v8;
v8 = (unsigned int)(v8 + 1);
}
while ( (int)v8 < v10 );
}
}
return 0;
}