//
// sub_878AF0 from 0x878af0 to 0x878ce2 (498 bytes)
//
// 1 xrefs:
// > sub_878CE4 @ 0x878e06
//
// 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
//
int __fastcall sub_878AF0(_DWORD *a1)
{
_DWORD *v2; // r9
int v3; // r4
_DWORD *v4; // r5
int v5; // t1
int v6; // r0
int v7; // r3
int v8; // r3
unsigned int v9; // r1
int v10; // r3
int v11; // lr
_DWORD *v12; // r12
int v13; // r2
int v14; // r1
int v15; // t1
int v16; // r6
int v17; // r0
int v18; // r4
int v19; // r7
_DWORD *i; // r5
int v21; // r11
int v22; // r6
int v23; // r3
bool v24; // cc
int v25; // r3
_DWORD *v26; // r0
int result; // r0
unsigned int v28; // [sp+10h] [bp-24h]
int v29; // [sp+14h] [bp-20h]
int v30; // [sp+18h] [bp-1Ch]
_DWORD v31[5]; // [sp+20h] [bp-14h]
v2 = (_DWORD *)a1[101];
if ( (int)a1[73] > 0 )
{
v3 = 0;
v4 = a1 + 73;
do
{
v5 = v4[1];
++v4;
v6 = (*(int (__fastcall **)(_DWORD *, _DWORD, int, _DWORD, _DWORD))(a1[1] + 32))(
a1,
v2[*(_DWORD *)(v5 + 4) + 16],
v2[2] * *(_DWORD *)(v5 + 12),
*(_DWORD *)(v5 + 12),
0);
v7 = a1[73];
v31[v3++] = v6;
}
while ( v7 > v3 );
}
v30 = v2[4];
v8 = v2[5];
if ( v30 >= v8 )
goto LABEL_34;
v28 = v2[3];
v9 = v28;
v29 = 4 * v30;
LABEL_6:
if ( v9 >= a1[78] )
goto LABEL_33;
while ( 2 )
{
v10 = a1[73];
if ( v10 <= 0 )
goto LABEL_30;
v11 = 0;
v12 = a1 + 73;
v13 = 0;
do
{
v15 = v12[1];
++v12;
v14 = v15;
v16 = *(_DWORD *)(v15 + 60);
v17 = *(_DWORD *)(v15 + 56);
if ( v16 <= 0 )
goto LABEL_29;
v18 = 0;
v19 = v28 * (v17 << 7);
for ( i = (_DWORD *)(v31[v11] + v29); ; ++i )
{
v25 = *i + v19;
if ( v17 <= 0 )
goto LABEL_23;
v26 = &v2[v13];
v21 = v13 + 1;
v26[6] = v25;
if ( *(int *)(v14 + 56) <= 1 )
break;
v26[7] = v25 + 128;
v21 = v13 + 2;
if ( *(int *)(v14 + 56) <= 2 )
break;
v26[8] = v25 + 256;
v21 = v13 + 3;
if ( *(int *)(v14 + 56) <= 3 )
break;
v26[9] = v25 + 384;
v21 = v13 + 4;
if ( *(int *)(v14 + 56) <= 4 )
break;
v26[10] = v25 + 512;
v21 = v13 + 5;
if ( *(int *)(v14 + 56) <= 5 )
break;
v26[11] = v25 + 640;
v21 = v13 + 6;
if ( *(int *)(v14 + 56) <= 6 )
break;
v26[12] = v25 + 768;
v21 = v13 + 7;
if ( *(int *)(v14 + 56) <= 7 )
break;
v26[13] = v25 + 896;
v21 = v13 + 8;
if ( *(int *)(v14 + 56) <= 8 )
break;
v26[14] = v25 + 1024;
v22 = *(_DWORD *)(v14 + 56);
v23 = v25 + 1152;
v24 = v22 <= 9;
if ( v22 > 9 )
v26[15] = v23;
v16 = *(_DWORD *)(v14 + 60);
if ( v24 )
v13 += 9;
else
v13 += 10;
LABEL_23:
if ( ++v18 >= v16 )
goto LABEL_28;
LABEL_24:
v17 = *(_DWORD *)(v14 + 56);
}
v16 = *(_DWORD *)(v14 + 60);
++v18;
v13 = v21;
if ( v18 < v16 )
goto LABEL_24;
LABEL_28:
v10 = a1[73];
LABEL_29:
++v11;
}
while ( v11 < v10 );
LABEL_30:
result = (*(int (__fastcall **)(_DWORD *, _DWORD *))(a1[106] + 4))(a1, v2 + 6);
if ( result )
{
if ( a1[78] > ++v28 )
continue;
v8 = v2[5];
LABEL_33:
v2[3] = 0;
++v30;
v29 += 4;
v9 = 0;
v28 = 0;
if ( v30 >= v8 )
{
LABEL_34:
++v2[2];
sub_878AB8(a1);
return 1;
}
goto LABEL_6;
}
break;
}
v2[4] = v30;
v2[3] = v28;
return result;
}