//
// sub_7B21A8 from 0x7b21a8 to 0x7b2378 (464 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:00:08 +0000
//
int __fastcall sub_7B21A8(int a1)
{
pthread_key_t *v2; // r7
std::__thread_struct *v3; // r8
std::__thread_struct *v4; // r5
int v5; // r0
int i; // r5
int v7; // r3
unsigned int v8; // r5
int v9; // r3
int v10; // r5
int (__fastcall *v11)(_DWORD, _DWORD); // r3
unsigned int *v12; // r3
unsigned int v13; // r2
_DWORD *exception; // r0
unsigned int *v15; // r3
unsigned int v16; // r2
std::mutex *v18; // [sp+0h] [bp-2Ch]
_DWORD v19[4]; // [sp+8h] [bp-24h] BYREF
_DWORD *v20; // [sp+18h] [bp-14h]
v2 = (pthread_key_t *)std::__thread_local_data();
v3 = *(std::__thread_struct **)a1;
*(_DWORD *)a1 = 0;
v4 = (std::__thread_struct *)pthread_getspecific(*v2);
pthread_setspecific(*v2, v3);
if ( v4 )
{
std::__thread_struct::~__thread_struct(v4);
operator delete(v4);
}
while ( 1 )
{
v5 = *(_DWORD *)(a1 + 4);
v20 = nullptr;
v18 = (std::mutex *)(v5 + 36);
std::mutex::lock((std::mutex *)(v5 + 36));
for ( i = *(_DWORD *)(a1 + 4);
!*(_BYTE *)(i + 44) && !*(_DWORD *)(i + 32);
std::condition_variable::wait((pthread_cond_t *)(i + 40)) )
{
;
}
v7 = *(_DWORD *)(a1 + 4);
if ( *(_BYTE *)(v7 + 44) )
{
if ( !*(_DWORD *)(v7 + 32) )
break;
}
v8 = *(_DWORD *)(*(_DWORD *)(v7 + 16) + 4 * (*(_DWORD *)(v7 + 28) / 0xAAu)) + 24 * (*(_DWORD *)(v7 + 28) % 0xAAu);
if ( v20 == v19 )
{
(*(void (__fastcall **)(_DWORD *))(v19[0] + 16))(v19);
}
else if ( v20 )
{
(*(void (__fastcall **)(_DWORD *))(*v20 + 20))(v20);
}
v20 = nullptr;
v9 = *(_DWORD *)(v8 + 16);
if ( v9 )
{
if ( v9 == v8 )
{
v20 = v19;
(*(void (__fastcall **)(_DWORD, _DWORD *))(**(_DWORD **)(v8 + 16) + 12))(*(_DWORD *)(v8 + 16), v19);
}
else
{
v20 = *(_DWORD **)(v8 + 16);
*(_DWORD *)(v8 + 16) = 0;
}
}
v10 = *(_DWORD *)(a1 + 4);
std::function::~function((_DWORD *)(*(_DWORD *)(*(_DWORD *)(v10 + 16)
+ 4 * (*(_DWORD *)(v10 + 28) / 0xAAu))
+ 24 * (*(_DWORD *)(v10 + 28) % 0xAAu)));
--*(_DWORD *)(v10 + 32);
v11 = (int (__fastcall *)(_DWORD, _DWORD))(*(_DWORD *)(v10 + 28) + 1);
*(_DWORD *)(v10 + 28) = v11;
if ( (unsigned int)v11 >= 0x154 )
{
operator delete(**(void ***)(v10 + 16));
*(_DWORD *)(v10 + 16) += 4;
*(_DWORD *)(v10 + 28) -= 170;
}
std::mutex::unlock(v18);
v12 = (unsigned int *)(*(_DWORD *)(a1 + 4) + 48);
do
v13 = __ldrex(v12);
while ( __strex(v13 + 1, v12) );
if ( !v20 )
{
exception = _cxa_allocate_exception(4u);
*exception = &off_D02108;
_cxa_throw(
exception,
(struct type_info *)&`typeinfo for'std::bad_function_call,
(void (*)(void *))std::bad_function_call::~bad_function_call);
}
(*(void (__fastcall **)(_DWORD *))(*v20 + 24))(v20);
v15 = (unsigned int *)(*(_DWORD *)(a1 + 4) + 48);
do
v16 = __ldrex(v15);
while ( __strex(v16 - 1, v15) );
std::function::~function(v19);
}
std::mutex::unlock(v18);
std::function::~function(v19);
std::__tuple_leaf<0u,std::unique_ptr,false>::~__tuple_leaf((std::__thread_struct **)a1);
operator delete((void *)a1);
return 0;
}