//
// sub_CD5FA4 from 0xcd5fa4 to 0xcd60d8 (308 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
//
unsigned int **__fastcall sub_CD5FA4(unsigned int **a1, _DWORD *a2)
{
_QWORD *v4; // x0
int *v5; // x1
int v6; // w2
char v8; // [xsp+38h] [xbp+38h] BYREF
sub_CD43C0(&v8, a1, 0);
if ( !v8 )
return a1;
v4 = *(unsigned int **)((char *)a1 + *((_QWORD *)*a1 - 3) + 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 )
{
*a2 = v6;
return a1;
}
sub_CCF1DC((__int64)a1 + *((_QWORD *)*a1 - 3), *(_DWORD *)((char *)a1 + *((_QWORD *)*a1 - 3) + 32) | 6);
return a1;
}