//
// sub_D18DB8 from 0xd18db8 to 0xd18ea8 (240 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
//
__int64 *__fastcall sub_D18DB8(__int64 *a1, _QWORD *a2)
{
__int64 v2; // x2
_DWORD *v4; // x19
int v5; // w3
__int64 *v6; // x0
void *v7; // x0
unsigned int *v9; // x2
int v10; // w1
unsigned int *v11; // x0
unsigned int v12; // w2
char v13; // [xsp+28h] [xbp+28h] BYREF
v2 = *a1;
v4 = (_DWORD *)*a2;
if ( *a1 != *a2 )
{
v5 = *(v4 - 2);
v6 = (__int64 *)(v4 - 6);
if ( v5 < 0 )
{
v4 = sub_D18BF4((__int64)v6, (__int64)&v13, 0);
v2 = *a1;
}
else if ( v6 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = v4 - 2;
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 + 1, v11) );
v2 = *a1;
}
else
{
*(v4 - 2) = v5 + 1;
}
}
v7 = (void *)(v2 - 24);
if ( (__int64 *)(v2 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v9 = (unsigned int *)(v2 - 8);
do
v10 = __ldaxr(v9);
while ( __stlxr(v10 - 1, v9) );
}
else
{
v10 = *(_DWORD *)(v2 - 8);
*(_DWORD *)(v2 - 8) = v10 - 1;
}
if ( v10 <= 0 )
operator delete(v7);
}
*a1 = (__int64)v4;
}
return a1;
}