//
// sub_CEBD04 from 0xcebd04 to 0xcebf54 (592 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
//
_QWORD *__usercall sub_CEBD04@(unsigned int **a1@, _QWORD *a2@)
{
unsigned __int8 v4; // w0
unsigned int *v5; // x1
__int64 v6; // x23
unsigned int v7; // w2
unsigned int *v8; // x2
char *v9; // x2
char *v10; // x0
unsigned int *v12; // x2
int v13; // w1
int v14; // w1
char *locale; // [xsp+48h] [xbp+48h] BYREF
sub_CEBC8C();
v4 = atomic_load((unsigned __int8 *)&byte_124A6B0);
if ( (v4 & 1) != 0 || !_cxa_guard_acquire((__guard *)&byte_124A6B0) )
{
if ( !&pthread_create )
{
LABEL_14:
v8 = *a1;
v6 = qword_124A218;
++**a1;
goto LABEL_7;
}
}
else
{
qword_124B310 = 0;
qword_124B318 = 0;
qword_124B320 = 0;
qword_124B328 = 0;
qword_124B330 = 0;
_cxa_guard_release((__guard *)&byte_124A6B0);
if ( !&pthread_create )
goto LABEL_14;
}
if ( pthread_mutex_lock((pthread_mutex_t *)&qword_124B310) )
sub_CEAFC4();
v5 = *a1;
v6 = qword_124A218;
do
v7 = __ldaxr(v5);
while ( __stlxr(v7 + 1, v5) );
v8 = *a1;
LABEL_7:
qword_124A218 = (__int64)v8;
sub_CE9CC0((__int64)a1, (__int64 *)&locale);
if ( (unsigned int)sub_D171E0((int)&locale, "*") )
{
setlocale(6, locale);
v9 = locale;
v10 = locale - 24;
if ( locale - 24 == (char *)&qword_124B6B0 )
goto LABEL_9;
}
else
{
v9 = locale;
v10 = locale - 24;
if ( locale - 24 == (char *)&qword_124B6B0 )
goto LABEL_9;
}
if ( !&pthread_create )
{
v14 = *((_DWORD *)v9 - 2);
*((_DWORD *)v9 - 2) = v14 - 1;
if ( v14 > 0 )
goto LABEL_11;
goto LABEL_20;
}
v12 = (unsigned int *)(v9 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
if ( v13 <= 0 )
{
LABEL_20:
operator delete(v10);
LABEL_9:
if ( !&pthread_create )
goto LABEL_11;
}
if ( pthread_mutex_unlock((pthread_mutex_t *)&qword_124B310) )
sub_CE9C50();
LABEL_11:
sub_CE9CB8(a2, v6);
return a2;
}