//
// sub_CE4804 from 0xce4804 to 0xce49f4 (496 bytes)
//
// 1 xrefs:
// > ??> @ 0x111e0f8
//
// 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
//
_QWORD *__fastcall sub_CE4804(
__int64 a1,
_QWORD *a2,
__int64 a3,
_QWORD *a4,
__int64 a5,
unsigned __int8 a6,
__int64 a7,
_DWORD *a8,
void **a9)
{
int v12; // w24
_BYTE *v13; // x23
_QWORD *v14; // x0
_DWORD *v15; // x2
_QWORD *v16; // x22
size_t v17; // x21
char *v18; // x0
_QWORD *v20; // x0
char *v21; // x25
void *v22; // x24
unsigned int *v23; // x2
int v24; // w1
void *v29; // [xsp+88h] [xbp+88h] BYREF
v12 = a6;
v13 = sub_CDB730(a7 + 208);
v29 = &byte_124B6C8;
if ( v12 )
{
v14 = sub_CE2BCC(a1, a2, a3, a4, a5, a7, a8, (__int64)&v29);
v15 = v29;
v16 = v14;
v17 = *((_QWORD *)v29 - 3);
if ( !v17 )
goto LABEL_3;
}
else
{
v20 = sub_CE3958(a1, a2, a3, a4, a5, a7, a8, (__int64)&v29);
v15 = v29;
v16 = v20;
v17 = *((_QWORD *)v29 - 3);
if ( !v17 )
goto LABEL_3;
}
sub_D17E50(a9, v17, 0);
v21 = (char *)v29;
v22 = *a9;
if ( (*((_DWORD *)*a9 - 2) & 0x80000000) == 0 )
{
sub_D176A8(a9);
v22 = *a9;
}
if ( v13[56] == 1 )
{
memcpy(v22, v21, v17);
v15 = v29;
LABEL_3:
v18 = (char *)(v15 - 6);
if ( v15 - 6 == (_DWORD *)&qword_124B6B0 )
return v16;
goto LABEL_12;
}
if ( !v13[56] )
sub_D204B0(v13);
(*(void (__fastcall **)(_BYTE *, char *, char *, void *))(*(_QWORD *)v13 + 56LL))(v13, v21, &v21[v17], v22);
v15 = v29;
v18 = (char *)v29 - 24;
if ( (char *)v29 - 24 != (char *)&qword_124B6B0 )
{
LABEL_12:
if ( &pthread_create )
{
v23 = v15 - 2;
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(v15 - 2);
*(v15 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v18);
}
return v16;
}