//
// sub_CF814C from 0xcf814c to 0xcf8250 (260 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_CF814C(__int64 a1, __int64 *a2)
{
__int64 v3; // x1
__int64 v5; // x2
void *v6; // x0
__int64 v7; // x0
__int64 v8; // x0
__int64 v9; // x0
__int64 result; // x0
unsigned int *v11; // x2
int v12; // w1
v3 = *a2;
*(_QWORD *)a1 = v3;
v5 = *(_QWORD *)(a1 + 96);
v6 = (void *)(v5 - 24);
*(_QWORD *)(a1 + *(_QWORD *)(v3 - 24)) = a2[8];
*(_QWORD *)(a1 + 16) = a2[9];
*(_QWORD *)(a1 + 24) = off_121DA60;
if ( (__int64 *)(v5 - 24) != &qword_124B6D0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v5 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *(_DWORD *)(v5 - 8);
*(_DWORD *)(v5 - 8) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v6);
}
*(_QWORD *)(a1 + 24) = off_111E9B0;
sub_CEA56C((unsigned int **)(a1 + 80));
v7 = a2[1];
*(_QWORD *)a1 = v7;
*(_QWORD *)(a1 + *(_QWORD *)(v7 - 24)) = a2[6];
*(_QWORD *)(a1 + 16) = a2[7];
v8 = a2[4];
*(_QWORD *)(a1 + 16) = v8;
*(_QWORD *)(a1 + *(_QWORD *)(v8 - 24) + 16) = a2[5];
v9 = a2[2];
*(_QWORD *)a1 = v9;
result = *(_QWORD *)(v9 - 24);
*(_QWORD *)(a1 + result) = a2[3];
return result;
}