//
// sub_CEA32C from 0xcea32c to 0xcea4b8 (396 bytes)
//
// 3 xrefs:
// > sub_CEA4CC @ 0xcea524
// > sub_CEA56C @ 0xcea5a8
// > sub_CEA5D8 @ 0xcea7cc
//
// 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
//
void __fastcall sub_CEA32C(_QWORD *a1)
{
_QWORD *v1; // x2
unsigned __int64 v3; // x1
unsigned __int64 i; // x19
unsigned int *v5; // x0
unsigned int *v6; // x2
unsigned int v7; // w1
_QWORD *v8; // x2
unsigned __int64 v9; // x1
unsigned __int64 j; // x19
unsigned int *v11; // x0
unsigned int *v12; // x2
unsigned int v13; // w1
char *v14; // x1
__int64 v15; // x19
void *v16; // x0
v1 = (_QWORD *)a1[1];
if ( v1 )
{
v3 = a1[2];
if ( !v3 )
goto LABEL_14;
for ( i = 0; i < v3; ++i )
{
v5 = (unsigned int *)v1[i];
if ( v5 )
{
if ( &pthread_create )
{
v6 = v5 + 2;
do
v7 = __ldaxr(v6);
while ( __stlxr(v7 - 1, v6) );
}
else
{
v7 = v5[2];
v5[2] = v7 - 1;
}
if ( v7 == 1 )
(*(void (__fastcall **)(unsigned int *))(*(_QWORD *)v5 + 8LL))(v5);
v1 = (_QWORD *)a1[1];
v3 = a1[2];
}
}
if ( v1 )
LABEL_14:
operator delete[](v1);
}
v8 = (_QWORD *)a1[3];
if ( v8 )
{
v9 = a1[2];
if ( !v9 )
goto LABEL_28;
for ( j = 0; j < v9; ++j )
{
v11 = (unsigned int *)v8[j];
if ( v11 )
{
if ( &pthread_create )
{
v12 = v11 + 2;
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = v11[2];
v11[2] = v13 - 1;
}
if ( v13 == 1 )
(*(void (__fastcall **)(unsigned int *))(*(_QWORD *)v11 + 8LL))(v11);
v8 = (_QWORD *)a1[3];
v9 = a1[2];
}
}
if ( v8 )
LABEL_28:
operator delete[](v8);
}
v14 = (char *)a1[4];
v15 = 0;
if ( v14 )
{
do
{
v16 = *(void **)&v14[v15];
if ( v16 )
{
operator delete[](v16);
v14 = (char *)a1[4];
}
v15 += 8;
}
while ( v15 != 48 );
if ( v14 )
operator delete[](v14);
}
}