//
// sub_86C158 from 0x86c158 to 0x86c1c6 (110 bytes)
//
// 0 xrefs:
//
// 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:54 +0000
//
signed int __fastcall sub_86C158(int a1, unsigned __int8 *a2, unsigned __int8 *a3)
{
signed int result; // r0
unsigned __int8 *v4; // r7
char *v5; // r5
char *v6; // lr
int v7; // r6
unsigned __int8 v8; // r3
int v9; // r12
int v10; // t1
unsigned __int8 v11; // r2
int v12; // r4
char v13; // r8
signed int v14; // r3
int v15; // r4
unsigned __int8 v16; // r1
signed int v17; // r2
unsigned __int8 v18; // r2
result = *(_DWORD *)(a1 + 4);
v4 = a3 + 1;
v5 = (char *)(a2 + 1);
v6 = (char *)&a2[result];
v7 = *a3;
v8 = *a2 + v7;
*a2 = v8;
if ( &a2[result] > a2 + 1 )
{
do
{
v10 = *v4++;
v9 = v10;
v11 = v8;
v12 = v8 - v7;
v13 = *v5;
v14 = abs32(v12);
v15 = v12 + v10 - v7;
result = abs32(v10 - v7);
if ( result <= v14 )
v16 = v11;
else
v16 = v9;
v17 = abs32(v15);
if ( result >= v14 )
result = v14;
if ( result <= v17 )
v18 = v16;
else
v18 = v7;
v7 = v9;
v8 = v13 + v18;
*v5++ = v13 + v18;
}
while ( v5 != v6 );
}
return result;
}