//
// sub_D1D994 from 0xd1d994 to 0xd1da78 (228 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
//
_QWORD *__fastcall sub_D1D994(__int64 a1)
{
int v1; // w19
_QWORD *result; // x0
unsigned int *v3; // x1
unsigned int v4; // w2
__int64 *v6; // x20
size_t v7; // x2
v1 = *(_DWORD *)(a1 + 16);
if ( v1 < 0 )
{
v6 = sub_D1B424(*(_QWORD *)a1, *(_QWORD *)(a1 + 8));
v7 = *(_QWORD *)a1;
result = v6 + 3;
if ( *(_QWORD *)a1 )
{
if ( v7 == 1 )
{
result = v6 + 3;
*((_DWORD *)v6 + 6) = *(_DWORD *)(a1 + 24);
}
else
{
wmemcpy((wchar_t *)v6 + 6, (const wchar_t *)(a1 + 24), v7);
v7 = *(_QWORD *)a1;
result = v6 + 3;
}
}
if ( v6 != &qword_124B6D0 )
{
*((_DWORD *)v6 + 4) = 0;
*v6 = v7;
*((_DWORD *)v6 + v7 + 6) = 0;
}
}
else
{
if ( (__int64 *)a1 != &qword_124B6D0 )
{
if ( &pthread_create )
{
v3 = (unsigned int *)(a1 + 16);
do
v4 = __ldaxr(v3);
while ( __stlxr(v4 + 1, v3) );
}
else
{
*(_DWORD *)(a1 + 16) = v1 + 1;
}
}
return (_QWORD *)(a1 + 24);
}
return result;
}