//
// sub_CBAF98 from 0xcbaf98 to 0xcbb054 (188 bytes)
//
// 2 xrefs:
// > sub_CBB1F0 @ 0xcbb2d0
// > sub_CBB1F0 @ 0xcbb2d8
//
// 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_CBAF98(__int64 a1)
{
int i; // w20
unsigned int (__fastcall *v4)(_QWORD, _QWORD); // x2
pthread_mutex_t *v5; // x0
do
{
while ( 1 )
{
pthread_mutex_lock(*(pthread_mutex_t **)a1);
for ( i = *(_DWORD *)(a1 + 8); i == 1; i = *(_DWORD *)(a1 + 8) )
pthread_cond_wait((pthread_cond_t *)(*(_QWORD *)a1 + 40LL), *(pthread_mutex_t **)a1);
if ( i != 2 )
break;
v4 = *(unsigned int (__fastcall **)(_QWORD, _QWORD))(a1 + 16);
if ( v4 )
*(_DWORD *)(a1 + 40) |= v4(*(_QWORD *)(a1 + 24), *(_QWORD *)(a1 + 32)) == 0;
v5 = *(pthread_mutex_t **)a1;
*(_DWORD *)(a1 + 8) = 1;
pthread_cond_signal((pthread_cond_t *)&v5[1]);
pthread_mutex_unlock(*(pthread_mutex_t **)a1);
}
pthread_cond_signal((pthread_cond_t *)(*(_QWORD *)a1 + 40LL));
pthread_mutex_unlock(*(pthread_mutex_t **)a1);
}
while ( i );
return 0;
}