//
// sub_C6839C from 0xc6839c to 0xc685e8 (588 bytes)
//
// 1 xrefs:
// > sub_C68714 @ 0xc68b48
//
// 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_C6839C(__int64 a1, unsigned int **a2)
{
unsigned int **v4; // x21
unsigned int **v5; // x20
int v6; // w25
unsigned int **v7; // x24
int v8; // w27
__int64 v9; // x22
void (__fastcall *v10)(unsigned int *, unsigned int *, unsigned int *, __int64, _QWORD); // x23
unsigned int v11; // w19
int v12; // w22
__int64 v13; // x19
int v15; // [xsp+60h] [xbp+60h]
int v16; // [xsp+64h] [xbp+64h]
int v17; // [xsp+68h] [xbp+68h]
unsigned int v18; // [xsp+6Ch] [xbp+6Ch]
v17 = *(_DWORD *)(a1 + 16);
v15 = (v17 + 1) >> 1;
if ( v17 <= 0 )
return 0;
v4 = a2 + 6;
v5 = a2 + 19;
v18 = 0;
v6 = 0;
v16 = 0;
v7 = a2 + 32;
do
{
LABEL_6:
v11 = v15 - v16;
v6 += sub_CBADE0(
v4,
(unsigned int)(v17 - v6),
*(_QWORD *)(a1 + 24) + *(_DWORD *)(a1 + 48) * v6,
*(unsigned int *)(a1 + 48));
if ( (unsigned int)sub_CBADC0(v5, (unsigned int)(v15 - v16)) )
{
v12 = v16;
v16 += sub_CBADE0(v5, v11, *(_QWORD *)(a1 + 32) + *(_DWORD *)(a1 + 52) * v16, *(unsigned int *)(a1 + 52));
sub_CBADE0(v7, v11, *(_QWORD *)(a1 + 40) + *(_DWORD *)(a1 + 52) * v12, *(unsigned int *)(a1 + 52));
}
v8 = 0;
v9 = (__int64)(*a2 + 4);
v10 = (void (__fastcall *)(unsigned int *, unsigned int *, unsigned int *, __int64, _QWORD))qword_1260628[**a2];
if ( *((_DWORD *)a2 + 26) > *((_DWORD *)a2 + 28)
&& *((int *)v4 + 6) <= 0
&& *((_DWORD *)a2 + 52) > *((_DWORD *)a2 + 54)
&& *((int *)v5 + 6) <= 0 )
{
v13 = *((_QWORD *)*a2 + 2) + (int)((*((_DWORD *)a2 + 8) + v18) * (*a2)[6]);
while ( 1 )
{
++v8;
sub_C8B3B8(v4);
sub_C8B3B8(v5);
sub_C8B3B8(v7);
v10(a2[15], a2[28], a2[41], v13, *((unsigned int *)a2 + 25));
v13 += *(int *)(v9 + 8);
if ( *((_DWORD *)a2 + 26) <= *((_DWORD *)a2 + 28)
|| *((int *)v4 + 6) > 0
|| *((_DWORD *)a2 + 52) <= *((_DWORD *)a2 + 54) )
{
break;
}
if ( *((int *)v5 + 6) > 0 )
{
v18 += v8;
if ( v17 > v6 )
goto LABEL_6;
return v18;
}
}
}
v18 += v8;
}
while ( v17 > v6 );
return v18;
}