//
// sub_877FFC from 0x877ffc to 0x8781f2 (502 bytes)
//
// 5 xrefs:
// > sub_878208 @ 0x8784f0
// > sub_878518 @ 0x878688
// > sub_87869C @ 0x8786f2
// > sub_878708 @ 0x8788b4
// > sub_8788DC @ 0x878a56
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:03:04 +0000
//
void *__fastcall sub_877FFC(_DWORD *a1, char a2)
{
int v4; // r5
int v5; // r3
_BYTE *v6; // r2
void *result; // r0
int v8; // r2
int v9; // r3
_BYTE *v10; // r2
int v11; // r2
int v12; // r6
int v13; // r6
int v14; // r6
int v15; // r6
v4 = a1[106];
sub_877C74((int)a1);
v5 = a1[6];
v6 = *(_BYTE **)v5;
result = (void *)(*(_DWORD *)v5 + 1);
*(_DWORD *)v5 = result;
*v6 = -1;
v8 = *(_DWORD *)(v5 + 4) - 1;
*(_DWORD *)(v5 + 4) = v8;
if ( !v8 )
{
result = (void *)(*(int (__fastcall **)(_DWORD *))(v5 + 12))(a1);
if ( !result )
{
*(_DWORD *)(*a1 + 20) = 25;
result = (void *)(*(int (__fastcall **)(_DWORD *))*a1)(a1);
}
}
v9 = a1[6];
v10 = (_BYTE *)(*(_DWORD *)v9)++;
*v10 = a2 - 48;
v11 = *(_DWORD *)(v9 + 4) - 1;
*(_DWORD *)(v9 + 4) = v11;
if ( !v11 )
{
result = (void *)(*(int (__fastcall **)(_DWORD *))(v9 + 12))(a1);
if ( !result )
{
*(_DWORD *)(*a1 + 20) = 25;
result = (void *)(*(int (__fastcall **)(_DWORD *))*a1)(a1);
}
}
if ( (int)a1[73] <= 0 )
goto LABEL_15;
v12 = a1[74];
if ( a1[91] || a1[93] )
{
if ( !a1[92] )
goto LABEL_6;
}
else
{
result = memset(*(void **)(v4 + 4 * *(_DWORD *)(v12 + 20) + 76), 0, 0x40u);
*(_DWORD *)(v4 + 36) = 0;
*(_DWORD *)(v4 + 52) = 0;
if ( !a1[92] )
goto LABEL_6;
}
result = memset(*(void **)(v4 + 4 * *(_DWORD *)(v12 + 24) + 140), 0, 0x100u);
LABEL_6:
if ( (int)a1[73] <= 1 )
goto LABEL_15;
v13 = a1[75];
if ( a1[91] || a1[93] )
{
if ( !a1[92] )
goto LABEL_9;
}
else
{
result = memset(*(void **)(v4 + 4 * *(_DWORD *)(v13 + 20) + 76), 0, 0x40u);
*(_DWORD *)(v4 + 40) = 0;
*(_DWORD *)(v4 + 56) = 0;
if ( !a1[92] )
goto LABEL_9;
}
result = memset(*(void **)(v4 + 4 * *(_DWORD *)(v13 + 24) + 140), 0, 0x100u);
LABEL_9:
if ( (int)a1[73] <= 2 )
goto LABEL_15;
v14 = a1[76];
if ( a1[91] || a1[93] )
{
if ( !a1[92] )
goto LABEL_12;
}
else
{
result = memset(*(void **)(v4 + 4 * *(_DWORD *)(v14 + 20) + 76), 0, 0x40u);
*(_DWORD *)(v4 + 44) = 0;
*(_DWORD *)(v4 + 60) = 0;
if ( !a1[92] )
goto LABEL_12;
}
result = memset(*(void **)(v4 + 4 * *(_DWORD *)(v14 + 24) + 140), 0, 0x100u);
LABEL_12:
if ( (int)a1[73] > 3 )
{
v15 = a1[77];
if ( a1[91] || a1[93] )
{
if ( a1[92] )
LABEL_18:
result = memset(*(void **)(v4 + 4 * *(_DWORD *)(v15 + 24) + 140), 0, 0x100u);
}
else
{
result = memset(*(void **)(v4 + 4 * *(_DWORD *)(v15 + 20) + 76), 0, 0x40u);
*(_DWORD *)(v4 + 48) = 0;
*(_DWORD *)(v4 + 64) = 0;
if ( a1[92] )
goto LABEL_18;
}
}
LABEL_15:
*(_QWORD *)(v4 + 12) = 0x1000000000000LL;
*(_QWORD *)(v4 + 20) = 0;
*(_QWORD *)(v4 + 28) = -4294967285LL;
return result;
}