//
// sub_CD2804 from 0xcd2804 to 0xcd2964 (352 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 __int64 *__fastcall sub_CD2804(unsigned __int64 *a1, unsigned __int8 a2)
{
unsigned __int64 v3; // x0
unsigned int v4; // w20
_QWORD *v5; // x0
unsigned __int64 v6; // x1
__int64 v7; // x0
char v9; // [xsp+38h] [xbp+38h] BYREF
v3 = *a1;
v4 = a2;
a1[1] = 0;
sub_CCE830((__int64)a1 + *(_QWORD *)(v3 - 24), *(_DWORD *)((_BYTE *)a1 + *(_QWORD *)(v3 - 24) + 32) & 0xFFFFFFFD);
sub_CD14C0(&v9, a1, 1);
if ( !v9 )
return a1;
v5 = *(_QWORD **)((char *)a1 + *(_QWORD *)(*a1 - 24) + 232);
if ( !v5 )
{
v7 = (__int64)a1 + *(_QWORD *)(*a1 - 24);
goto LABEL_6;
}
v6 = v5[2];
if ( v5[1] >= v6 || *(unsigned __int8 *)(v6 - 1) != v4 )
{
if ( (*(unsigned int (__fastcall **)(_QWORD *, _QWORD))(*v5 + 88LL))(v5, v4) != -1 )
return a1;
v7 = (__int64)a1 + *(_QWORD *)(*a1 - 24);
LABEL_6:
sub_CCE830(v7, *(_DWORD *)(v7 + 32) | 1);
return a1;
}
v5[2] = v6 - 1;
return a1;
}