//
// sub_C8F5C from 0xc8f5c to 0xc90c6 (362 bytes)
//
// 3 xrefs:
// > ??> @ 0xc8f5a
// > sub_C7C28 @ 0xc8336
// > sub_C7C28 @ 0xc852c
//
// 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_C8F5C(int a1, int a2, unsigned int a3, unsigned int a4, _DWORD *a5, int a6, int a7)
{
unsigned int v9; // r6
unsigned int v10; // r0
unsigned int v11; // r8
int *v12; // r2
unsigned int v13; // r9
int *v14; // r2
int v15; // r6
unsigned int v16; // r1
int v17; // r11
unsigned int v18; // r2
unsigned int v19; // r10
unsigned int v20; // r5
unsigned int v21; // r9
unsigned int v22; // r2
unsigned int v23; // r5
unsigned int v25; // [sp+Ch] [bp-34h]
unsigned int v26; // [sp+10h] [bp-30h]
unsigned int v27; // [sp+14h] [bp-2Ch]
int v29; // [sp+1Ch] [bp-24h] BYREF
unsigned int v30; // [sp+20h] [bp-20h] BYREF
v9 = a4;
v10 = *(_DWORD *)(*(_DWORD *)(a2 + 4) + 1136);
v11 = v10 >> a4;
if ( !a4 )
v11 = v10 - a3;
v12 = &dword_41760;
if ( a7 )
v12 = &dword_41764;
v13 = *v12;
v14 = &dword_41754;
if ( a7 )
v14 = &dword_41758;
v27 = *v14;
if ( a4 )
{
if ( v11 < a3 )
{
LABEL_9:
sub_C8EEE(a2, 0);
**(_DWORD **)a2 = 2;
return 1;
}
}
else if ( v10 < a3 )
{
goto LABEL_9;
}
v16 = a4;
if ( a4 <= 6 )
v16 = 6;
if ( sub_C50E0((int)a5, v16) )
{
v25 = a3;
v17 = 0;
v18 = 0;
v26 = v9;
while ( !(v18 >> v9) )
{
v19 = v18;
if ( !sub_C460A(a1, *(_DWORD *)(*(_DWORD *)(a2 + 4) + 60), &v30, v27) )
return 0;
*(_DWORD *)(*a5 + 4 * v19) = v30;
if ( v30 >= v13 )
{
if ( !sub_C460A(a1, *(_DWORD *)(*(_DWORD *)(a2 + 4) + 60), &v30, 5u) )
return 0;
v22 = v19;
v23 = v25;
*(_DWORD *)(a5[1] + 4 * v19) = v30;
if ( v19 )
v23 = 0;
LOBYTE(v9) = v26;
if ( !v26 )
v23 = 0;
while ( v23 < v11 )
{
if ( !sub_C4784(a1, *(_DWORD *)(*(_DWORD *)(a2 + 4) + 60), &v29, v30) )
return 0;
++v23;
v22 = v19;
*(_DWORD *)(a6 + 4 * v17++) = v29;
}
}
else
{
v15 = 0;
v20 = v13;
v21 = v11;
*(_DWORD *)(a5[1] + 4 * v19) = 0;
if ( !v19 )
v21 = v11 - v25;
if ( !v26 )
v21 = v11;
if ( !(*(int (__fastcall **)(int, _DWORD, int, unsigned int, unsigned int))(*(_DWORD *)(a2 + 4) + 48))(
a1,
*(_DWORD *)(*(_DWORD *)(a2 + 4) + 60),
a6 + 4 * v17,
v21,
v30) )
return v15;
LOBYTE(v9) = v26;
v17 += v21;
v13 = v20;
v22 = v19;
}
v18 = v22 + 1;
}
return 1;
}
**(_DWORD **)a2 = 8;
return 0;
}