//
// sub_76180C from 0x76180c to 0x7618c0 (180 bytes)
//
// 3 xrefs:
// > sub_74801C @ 0x74804e
// > sub_75AAB4 @ 0x75aae6
// > sub_761738 @ 0x761740
//
// 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
//
int __fastcall sub_76180C(_DWORD *a1, _DWORD *a2, _BYTE *a3)
{
int *v4; // r3
unsigned int v6; // r2
int v8; // r0
int v9; // r6
int v10; // r0
int v11; // r4
int *v12; // r3
int *v13; // r3
int v14; // r0
int *v15; // r3
v4 = (int *)a1[2];
v6 = a1[3];
*a3 = 1;
if ( (unsigned int)v4 >= v6 )
v8 = (*(int (__fastcall **)(_DWORD *))(*a1 + 36))(a1);
else
v8 = *v4;
v9 = 0;
while ( v8 != -1 )
{
v11 = (a1[3] - a1[2]) >> 2;
if ( v11 > 1 )
{
v10 = (*(int (__fastcall **)(_DWORD *))(*a2 + 48))(a2);
v9 += v10;
a1[2] += 4 * v10;
if ( v11 > v10 )
goto LABEL_17;
}
else
{
v12 = (int *)a2[5];
if ( (unsigned int)v12 >= a2[6] )
{
if ( (*(int (__fastcall **)(_DWORD *, int))(*a2 + 52))(a2, v8) == -1 )
{
LABEL_17:
*a3 = 0;
return v9;
}
}
else
{
*v12 = v8;
a2[5] = v12 + 1;
}
v13 = (int *)a1[2];
++v9;
if ( (unsigned int)v13 >= a1[3] )
{
v14 = (*(int (__fastcall **)(_DWORD *))(*a1 + 40))(a1);
}
else
{
v14 = *v13;
a1[2] = v13 + 1;
}
if ( v14 == -1 )
return v9;
v15 = (int *)a1[2];
if ( (unsigned int)v15 < a1[3] )
{
v8 = *v15;
continue;
}
}
v8 = (*(int (__fastcall **)(_DWORD *))(*a1 + 36))(a1);
}
return v9;
}