//
// sub_CD4AF8 from 0xcd4af8 to 0xcd4c7c (388 bytes)
//
// 0 xrefs:
//
// 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_CD4AF8(__int64 a1, _DWORD *a2)
{
_QWORD *v4; // x0
int *v5; // x1
int v6; // w2
int v8; // w1
char v9; // [xsp+38h] [xbp+38h] BYREF
*(_QWORD *)(a1 + 8) = 0;
sub_CD43C0(&v9, (unsigned int **)a1, 1u);
if ( v9 )
{
v4 = *(_QWORD **)(a1 + *(_QWORD *)(*(_QWORD *)a1 - 24LL) + 232);
v5 = (int *)v4[2];
if ( (unsigned __int64)v5 >= v4[3] )
{
v6 = (*(__int64 (__fastcall **)(_QWORD *))(*v4 + 80LL))(v4);
}
else
{
v6 = *v5;
v4[2] = v5 + 1;
}
if ( v6 != -1 )
{
*(_QWORD *)(a1 + 8) = 1;
*a2 = v6;
return a1;
}
if ( *(_QWORD *)(a1 + 8) )
v8 = 2;
else
v8 = 6;
sub_CCF1DC(a1 + *(_QWORD *)(*(_QWORD *)a1 - 24LL), v8 | *(_DWORD *)(a1 + *(_QWORD *)(*(_QWORD *)a1 - 24LL) + 32));
}
else
{
if ( *(_QWORD *)(a1 + 8) )
return a1;
sub_CCF1DC(a1 + *(_QWORD *)(*(_QWORD *)a1 - 24LL), *(_DWORD *)(a1 + *(_QWORD *)(*(_QWORD *)a1 - 24LL) + 32) | 4);
}
return a1;
}