//
// sub_8416F4 from 0x8416f4 to 0x84178e (154 bytes)
//
// 2 xrefs:
// > sub_8419F8 @ 0x841b92
// > sub_8419F8 @ 0x841be2
//
// 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:02:21 +0000
//
int __fastcall sub_8416F4(_BYTE *a1, int a2, _DWORD *a3)
{
char v3; // r6
int v5; // r3
_BYTE *v6; // r4
_BYTE *v7; // r0
int v8; // r0
v3 = a1[3];
if ( a1[2] != 8 || (a1[3] & 0xE0) != 0 )
return 1;
v5 = a2 - 10;
v6 = a1 + 10;
if ( (a1[3] & 4) != 0 )
{
if ( v5 <= 1 )
return 2;
v8 = (unsigned __int8)a1[10] | ((unsigned __int8)a1[11] << 8);
if ( v5 <= v8 + 1 )
return 2;
v5 += -2 - v8;
v6 += v8 + 2;
}
if ( (v3 & 8) != 0 )
{
if ( !v5 )
return 2;
if ( *v6 )
{
v7 = v6 + 1;
do
{
--v5;
v6 = v7++;
if ( !v5 )
return 2;
}
while ( *v6 );
}
--v5;
++v6;
}
if ( (v3 & 0x10) != 0 )
{
if ( !v5 )
return 2;
if ( *v6 )
{
while ( --v5 )
{
if ( !*++v6 )
goto LABEL_23;
}
return 2;
}
LABEL_23:
--v5;
}
if ( (v3 & 2) != 0 )
{
if ( v5 > 1 )
{
v5 -= 2;
goto LABEL_27;
}
return 2;
}
LABEL_27:
*a3 = a2 - v5;
return 0;
}