//
// sub_75D944 from 0x75d944 to 0x75da88 (324 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
//
int __fastcall sub_75D944(_DWORD *a1, int a2)
{
int v4; // r1
unsigned int v5; // r3
_BYTE *v6; // r0
int v7; // r1
unsigned int v8; // r3
int result; // r0
unsigned int v10; // r1
int v11; // r1
_DWORD *v12; // r3
int v13; // r2
int v14; // r9
_DWORD *v15; // r3
char *v16; // r0
unsigned int *v17; // r3
int v18; // r2
_DWORD *v19; // [sp+4h] [bp-8h] BYREF
if ( (a1[8] & 0x10) == 0 )
return -1;
if ( a2 == -1 )
return 0;
v4 = a1[9];
v5 = a1[6];
v6 = (_BYTE *)a1[5];
v7 = *(_DWORD *)(v4 - 8);
v8 = (unsigned int)v6 < v5;
if ( (v7 == 1073741820) > v8 )
return -1;
if ( v8 )
{
*v6 = a2;
}
else
{
v10 = 2 * v7;
if ( v10 >= 0x200 )
{
if ( v10 > 0x3FFFFFFC )
v10 = 1073741820;
}
else
{
v10 = 512;
}
v19 = &unk_ACDDA8;
sub_7740F8(&v19, v10);
v11 = a1[4];
if ( v11 )
sub_7752BC(&v19, v11, a1[6] - v11);
v12 = v19;
v13 = *(v19 - 3);
v14 = v13 + 1;
if ( (unsigned int)(v13 + 1) > *(v19 - 2) || (int)*(v19 - 1) > 0 )
{
sub_7740F8(&v19, v13 + 1);
v12 = v19;
v13 = *(v19 - 3);
}
*((_BYTE *)v12 + v13) = a2;
v15 = v19;
if ( v19 - 3 != &dword_ACDD9C )
{
*(v19 - 3) = v14;
*(v15 - 1) = 0;
*((_BYTE *)v15 + v14) = 0;
}
sub_774794(a1 + 9, &v19);
sub_75D7BC(a1, a1[9], a1[2] - a1[1], a1[5] - a1[4]);
v16 = (char *)(v19 - 3);
if ( v19 - 3 != &dword_ACDD9C )
{
if ( &pthread_create )
{
v17 = v19 - 1;
__dmb(0xFu);
do
v18 = __ldrex(v17);
while ( __strex(v18 - 1, v17) );
__dmb(0xFu);
}
else
{
v18 = *(v19 - 1);
*(v19 - 1) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v16);
}
}
result = a2;
++a1[5];
return result;
}