//
// sub_7568EC from 0x7568ec to 0x756a2e (322 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
//
_DWORD *__fastcall sub_7568EC(_DWORD *a1, _DWORD *a2, int a3)
{
size_t v4; // r0
bool v6; // cc
_DWORD *v7; // r0
unsigned int v8; // r1
size_t v9; // r3
unsigned int v10; // r3
unsigned int *v11; // r2
unsigned int v12; // r1
int v13; // r2
_DWORD *v14; // r0
unsigned int v15; // r1
unsigned int v16; // r3
unsigned int *v17; // r2
unsigned int v18; // r1
int v19; // r2
_DWORD *v20; // r0
int v21; // r6
const char *v22; // r0
int v23; // r8
size_t v24; // r7
void *v25; // r0
const void *v26; // r1
v4 = a2[2];
*a1 = a3;
a1[1] = 0;
v6 = v4 > 0x1FC00000;
a1[3] = 0;
a1[2] = v4;
if ( v4 <= 0x1FC00000 )
v4 *= 4;
a1[4] = 0;
if ( v6 )
v4 = -1;
v7 = operator new[](v4);
v8 = a1[2];
a1[1] = v7;
v9 = v8;
if ( v8 )
{
v10 = 0;
while ( 1 )
{
v7[v10] = *(_DWORD *)(a2[1] + 4 * v10);
v13 = *(_DWORD *)(a1[1] + 4 * v10);
if ( !v13 )
goto LABEL_10;
if ( &pthread_create )
break;
++v10;
++*(_DWORD *)(v13 + 4);
v8 = a1[2];
if ( v8 <= v10 )
{
LABEL_15:
if ( v8 > 0x1FC00000 )
v9 = -1;
else
v9 = 4 * v8;
goto LABEL_18;
}
LABEL_11:
v7 = (_DWORD *)a1[1];
}
v11 = (unsigned int *)(v13 + 4);
__dmb(0xFu);
do
v12 = __ldrex(v11);
while ( __strex(v12 + 1, v11) );
__dmb(0xFu);
v8 = a1[2];
LABEL_10:
if ( v8 <= ++v10 )
goto LABEL_15;
goto LABEL_11;
}
LABEL_18:
v14 = operator new[](v9);
v15 = a1[2];
a1[3] = v14;
if ( v15 )
{
v16 = 0;
while ( 1 )
{
v14[v16] = *(_DWORD *)(a2[3] + 4 * v16);
v19 = *(_DWORD *)(a1[3] + 4 * v16);
if ( !v19 )
goto LABEL_23;
if ( &pthread_create )
break;
++v16;
++*(_DWORD *)(v19 + 4);
v15 = a1[2];
if ( v15 <= v16 )
goto LABEL_28;
LABEL_24:
v14 = (_DWORD *)a1[3];
}
v17 = (unsigned int *)(v19 + 4);
__dmb(0xFu);
do
v18 = __ldrex(v17);
while ( __strex(v18 + 1, v17) );
__dmb(0xFu);
v15 = a1[2];
LABEL_23:
if ( v15 <= ++v16 )
goto LABEL_28;
goto LABEL_24;
}
LABEL_28:
v20 = operator new[](0x18u);
a1[4] = v20;
*v20 = 0;
v21 = 0;
*(_DWORD *)(a1[4] + 4) = 0;
*(_DWORD *)(a1[4] + 8) = 0;
*(_DWORD *)(a1[4] + 12) = 0;
*(_DWORD *)(a1[4] + 16) = 0;
*(_DWORD *)(a1[4] + 20) = 0;
do
{
v22 = *(const char **)(a2[4] + v21);
if ( !v22 )
break;
v23 = a1[4];
v24 = strlen(v22) + 1;
*(_DWORD *)(v23 + v21) = operator new[](v24);
v25 = *(void **)(a1[4] + v21);
v26 = *(const void **)(a2[4] + v21);
v21 += 4;
memcpy(v25, v26, v24);
}
while ( v21 != 24 );
return a1;
}