//
// sub_10024130C from 0x10024130c to 0x1002414a4 (408 bytes)
//
// 1 xrefs:
// > sub_10024124C @ 0x100241290
//
// 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_10024130C(__int64 a1)
{
std::__thread_specific_ptr *v1; // x0
const void *v2; // x1
__int64 v3; // x20
unsigned __int64 *v4; // x21
int v5; // w24
unsigned __int64 v6; // x8
unsigned __int64 v7; // x8
__int64 v8; // x8
__int64 v10; // [xsp+0h] [xbp-70h] BYREF
std::unique_lock __lk; // [xsp+8h] [xbp-68h] BYREF
_BYTE v12[24]; // [xsp+18h] [xbp-58h] BYREF
_BYTE *v13; // [xsp+30h] [xbp-40h]
v10 = a1;
v1 = std::__thread_local_data();
v2 = *(const void **)v10;
*(_QWORD *)v10 = 0;
pthread_setspecific(v1->__key_, v2);
v3 = *(_QWORD *)(v10 + 8);
v4 = (unsigned __int64 *)(v3 + 192);
do
{
v13 = nullptr;
__lk.__m_ = (std::unique_lock::mutex_type *)(v3 + 72);
__lk.__owns_ = 1;
std::mutex::lock((std::mutex *)(v3 + 72));
if ( (*(_BYTE *)(v3 + 184) & 1) == 0 )
{
while ( !*(_QWORD *)(v3 + 64) )
{
std::condition_variable::wait((std::condition_variable *)(v3 + 136), &__lk);
if ( *(_BYTE *)(v3 + 184) == 1 )
goto LABEL_5;
}
LABEL_6:
sub_100241560(
v12,
*(_QWORD *)(*(_QWORD *)(v3 + 32) + ((*(_QWORD *)(v3 + 56) >> 4) & 0xFFFFFFFFFFFFFF8LL))
+ 32 * (*(_QWORD *)(v3 + 56) & 0x7FLL));
sub_1002415EC(v3 + 24);
v5 = 1;
goto LABEL_8;
}
LABEL_5:
if ( *(_QWORD *)(v3 + 64) )
goto LABEL_6;
v5 = 0;
LABEL_8:
if ( __lk.__owns_ )
std::mutex::unlock(__lk.__m_);
if ( v5 )
{
do
v6 = __ldxr(v4);
while ( __stxr(v6 + 1, v4) );
if ( !v13 )
sub_1002416C4();
(*(void (__fastcall **)(_BYTE *))(*(_QWORD *)v13 + 48LL))(v13);
do
v7 = __ldxr(v4);
while ( __stxr(v7 - 1, v4) );
}
if ( v13 == v12 )
{
v8 = 32;
}
else
{
if ( !v13 )
continue;
v8 = 40;
}
(*(void (**)(void))(*(_QWORD *)v13 + v8))();
}
while ( (v5 & 1) != 0 );
sub_100241520(&v10);
return 0;
}