//
// sub_CB9DC from 0xcb9dc to 0xcbb14 (312 bytes)
//
// 2 xrefs:
// > sub_7755C @ 0x77710
// > sub_CBB14 @ 0xcbbd0
//
// 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_CB9DC(__int64 a1, char a2, char a3, __int64 a4, char a5)
{
char v8; // w2
char v9; // w3
int v10; // w8
char v11; // zf
int v12; // w24
__int64 result; // x0
int v14; // w23
int i; // w25
__int64 v16; // x0
__int64 v17; // x1
unsigned __int64 v18; // x2
char v19; // w3
char v20; // w4
int v21; // w5
char v22; // w2
char v23; // w3
int v24; // w8
int v25; // w23
int v26; // w22
int j; // w24
unsigned __int64 v28; // [xsp+0h] [xbp-50h]
__int64 v29; // [xsp+8h] [xbp-48h]
int v30; // [xsp+18h] [xbp-38h] BYREF
int v31; // [xsp+1Ch] [xbp-34h] BYREF
if ( (a2 & 1) != 0 )
{
sub_CD6E0();
if ( v11 )
v12 = 0;
else
v12 = v10;
result = sub_C99C4(a1, &v31, v8, v9);
if ( (_DWORD)result )
return result;
v14 = 0;
for ( i = 0; i < v31; ++i )
{
sub_CD4E0();
result = sub_C7B34();
if ( (_DWORD)result )
return result;
if ( (*(_DWORD *)(v28 + 124) & v12) != 0 )
{
++v14;
}
else
{
v16 = sub_CD700();
result = sub_CAABC(v16, v17, v18, v19, v20, v21);
if ( (_DWORD)result )
return result;
}
}
}
if ( (a3 & 1) == 0 )
return 0;
sub_CD6E0();
if ( v11 )
v25 = 0;
else
v25 = v24;
result = sub_CB8B0(a1, &v30, v22, v23);
if ( !(_DWORD)result )
{
v26 = 0;
for ( j = 0; j < v30; ++j )
{
sub_CD4E0();
result = sub_C7BFC();
if ( (_DWORD)result )
return result;
if ( (*(_DWORD *)(v28 + 124) & v25) != 0 )
{
++v26;
}
else
{
result = sub_CAABC(v29, a1, v28, 1, a5 & 1, 4);
if ( (_DWORD)result )
return result;
}
}
return 0;
}
return result;
}