//
// sub_7789B0 from 0x7789b0 to 0x778a58 (168 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_7789B0(int *a1, _DWORD *a2)
{
_DWORD *v3; // r4
int v4; // r3
int v5; // r2
_DWORD *v6; // r0
void *v7; // r0
_DWORD *v9; // r0
unsigned int *v10; // r3
int v11; // r2
unsigned int *v12; // r3
unsigned int v13; // r2
char v14[8]; // [sp+4h] [bp-8h] BYREF
v3 = (_DWORD *)*a2;
v4 = *a1;
if ( *a1 != *a2 )
{
v5 = *(v3 - 1);
v6 = v3 - 3;
if ( v5 < 0 )
{
v9 = sub_7788F4((int)v6, (int)v14, 0);
v4 = *a1;
v3 = v9;
}
else if ( v6 != (_DWORD *)&unk_ACDDAC )
{
if ( &pthread_create )
{
v12 = v3 - 1;
__dmb(0xFu);
do
v13 = __ldrex(v12);
while ( __strex(v13 + 1, v12) );
__dmb(0xFu);
v4 = *a1;
}
else
{
*(v3 - 1) = v5 + 1;
}
}
v7 = (void *)(v4 - 12);
if ( (_UNKNOWN *)(v4 - 12) != &unk_ACDDAC )
{
if ( &pthread_create )
{
v10 = (unsigned int *)(v4 - 4);
__dmb(0xFu);
do
v11 = __ldrex(v10);
while ( __strex(v11 - 1, v10) );
__dmb(0xFu);
}
else
{
v11 = *(_DWORD *)(v4 - 4);
*(_DWORD *)(v4 - 4) = v11 - 1;
}
if ( v11 <= 0 )
operator delete(v7);
}
*a1 = (int)v3;
}
return a1;
}