//
// sub_CBB1F0 from 0xcbb1f0 to 0xcbb32c (316 bytes)
//
// 2 xrefs:
// > WebPSetWorkerInterface @ 0xcbb370
// > ??> @ 0x1233e40
//
// 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
//
bool __fastcall sub_CBB1F0(__int64 a1)
{
int v2; // w0
bool v3; // cc
_BOOL8 result; // x0
pthread_mutex_t *v5; // x0
pthread_mutex_t *v6; // x0
v2 = *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 40) = 0;
if ( v2 )
{
v3 = v2 != 1;
result = 1;
if ( v3 && *(_QWORD *)a1 )
{
pthread_mutex_lock(*(pthread_mutex_t **)a1);
if ( *(_DWORD *)(a1 + 8) > 1u )
{
do
pthread_cond_wait((pthread_cond_t *)(*(_QWORD *)a1 + 40LL), *(pthread_mutex_t **)a1);
while ( *(_DWORD *)(a1 + 8) != 1 );
}
pthread_mutex_unlock(*(pthread_mutex_t **)a1);
return *(_DWORD *)(a1 + 40) == 0;
}
}
else
{
v5 = (pthread_mutex_t *)WebPSafeCalloc(1, 96);
*(_QWORD *)a1 = v5;
if ( v5 )
{
if ( !pthread_mutex_init(v5, nullptr) )
{
if ( pthread_cond_init((pthread_cond_t *)(*(_QWORD *)a1 + 40LL), nullptr) )
{
pthread_mutex_destroy(*(pthread_mutex_t **)a1);
}
else
{
pthread_mutex_lock(*(pthread_mutex_t **)a1);
if ( !pthread_create((pthread_t *)(*(_QWORD *)a1 + 88LL), nullptr, (void *(*)(void *))sub_CBAF98, (void *)a1) )
{
v6 = *(pthread_mutex_t **)a1;
*(_DWORD *)(a1 + 8) = 1;
pthread_mutex_unlock(v6);
return 1;
}
pthread_mutex_unlock(*(pthread_mutex_t **)a1);
pthread_mutex_destroy(*(pthread_mutex_t **)a1);
pthread_cond_destroy((pthread_cond_t *)(*(_QWORD *)a1 + 40LL));
}
}
WebPSafeFree(*(void **)a1);
*(_QWORD *)a1 = 0;
return 0;
}
return 0;
}
return result;
}