//
// sub_1004B8564 from 0x1004b8564 to 0x1004b86f8 (404 bytes)
//
// 1 xrefs:
// > sub_1004B872C @ 0x1004b8804
//
// 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_1004B8564(__int64 a1)
{
__int64 v2; // x8
__int64 v3; // x21
__int64 v4; // x19
__int64 v5; // x22
__int64 v6; // x8
__int64 *v7; // x23
__int64 *i; // x24
int v9; // w8
__int64 v10; // x0
void (*v11)(void); // x8
int v12; // w9
__int64 v13; // x2
int v14; // w10
int v15; // w12
int v16; // w11
int v17; // w13
v2 = *(_QWORD *)(a1 + 72);
v3 = *(_QWORD *)(v2 + 67960);
v4 = v2 + 1764;
sub_1004B5E08();
sub_1004D8560(v4);
v5 = *(_QWORD *)(a1 + 72);
if ( v5 )
{
sub_100442B5C(*(_QWORD *)(a1 + 72), 0x17u);
v6 = *(_QWORD *)(a1 + 72);
}
else
{
v6 = 0;
}
v7 = (__int64 *)(v6 + 1728);
for ( i = *(__int64 **)(v6 + 1728); i != v7; i = (__int64 *)*i )
{
if ( *((_BYTE *)i + 82) )
{
sub_1004469D0(i[2], v3, 0, 1);
*((_BYTE *)i + 82) = 0;
}
}
if ( v5 )
sub_100442B7C(v5, 0x17u);
v9 = *(_DWORD *)(v3 + 24);
if ( (*(_DWORD *)(v3 + 44) - *(_DWORD *)(v3 + 40)) * v9 <= (*(_DWORD *)(v3 + 36) - 1) * *(_DWORD *)(v3 + 12) )
{
v12 = *(_DWORD *)(v3 + 28);
v13 = *(unsigned int *)(v3 + 8);
do
{
sub_1004B78D0(a1, (void *)(*(_QWORD *)v3 + v12 * v9), v13);
v9 = *(_DWORD *)(v3 + 24);
v13 = *(unsigned int *)(v3 + 8);
v14 = *(_DWORD *)(v3 + 12);
v12 = ((int)v13 + *(_DWORD *)(v3 + 28)) % *(_DWORD *)(v3 + 16);
v15 = *(_DWORD *)(v3 + 40);
v16 = *(_DWORD *)(v3 + 44) + v13;
*(_DWORD *)(v3 + 44) = v16;
v17 = *(_DWORD *)(v3 + 36);
*(_DWORD *)(v3 + 28) = v12;
}
while ( (v16 - v15) * v9 <= (v17 - 1) * v14 );
}
else
{
v10 = *(_QWORD *)(a1 + 72);
v11 = *(void (**)(void))(v10 + 70200);
if ( v11 && (*(_BYTE *)(v10 + 70209) & 0x20) != 0 )
v11();
}
sub_1004D858C(v4, 95);
return sub_1004B5E10();
}