//
// sub_86998 from 0x86998 to 0x86a90 (248 bytes)
//
// 4 xrefs:
// > sub_86C64 @ 0x86d3c
// > sub_86C64 @ 0x86d7a
// > sub_874A4 @ 0x875b4
// > sub_874A4 @ 0x875f0
//
// 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 11:41:20 +0000
//
int __fastcall sub_86998(int a1, int *a2, int a3, int a4, int a5, char a6, int a7, int a8, int a9, char a10)
{
int v10; // r4
int v12; // r11
bool v14; // zf
int v15; // r0
int v16; // r2
int v17; // r3
int v18; // r2
bool v19; // zf
int v20; // r1
int v21; // r0
int v22; // r9
int v25; // [sp+10h] [bp-20h]
v10 = a2[1];
if ( v10 >= a4 )
{
v12 = *a2;
v22 = a2[2];
goto LABEL_22;
}
v12 = *a2;
v14 = *a2 == 0;
if ( *a2 )
v14 = v12 == *(unsigned __int16 *)(a5 + 4 * v10);
if ( !v14 )
{
v22 = a2[2] + a2[4];
a2[2] = v22;
LABEL_22:
*a2 = v12 + 1;
v15 = v22 >> 16;
goto LABEL_23;
}
v25 = a4 - 1;
while ( 1 )
{
if ( (a6 & 4) != 0 && v10 == a8 )
{
v10 = a7;
a2[1] = a7;
v12 = *(unsigned __int16 *)(a5 + 4 * a7);
*a2 = v12;
}
v15 = *(unsigned __int16 *)(a5 + 4 * v10 + 2);
if ( v10 == v25 )
break;
v16 = a5 + 4 * v10;
v17 = *(unsigned __int16 *)(v16 + 4);
v18 = *(unsigned __int16 *)(v16 + 6);
if ( (a6 & 2) != 0 )
{
v19 = v10 == a9;
if ( v10 == a9 )
v19 = *(_BYTE *)(a3 + 164) == 0;
if ( v19 )
goto LABEL_23;
}
v20 = v17 - *(unsigned __int16 *)(a5 + 4 * v10);
v22 = v15 << 16;
if ( v20 )
v21 = ((v18 << 16) - v22) / v20;
else
v21 = 0;
++v10;
a2[4] = v21;
a2[1] = v10;
a2[2] = v22;
if ( v10 >= a4 || v12 != *(unsigned __int16 *)(a5 + 4 * v10) )
goto LABEL_22;
}
*((_BYTE *)a2 + 20) = 1;
LABEL_23:
a2[3] = v15;
*(_BYTE *)(a3 + 36) |= a10;
return 0;
}