//
// sub_100589658 from 0x100589658 to 0x1005897cc (372 bytes)
//
// 2 xrefs:
// > sub_10058A138 @ 0x10058bd88
// > sub_10058A138 @ 0x10058bdd0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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:08:34 +0000
//
__int64 __fastcall sub_100589658(
__int64 a1,
int *a2,
__int64 a3,
int a4,
__int64 a5,
int a6,
int a7,
int a8,
int a9,
int a10,
char a11)
{
int v11; // w8
int v12; // w13
int v13; // w14
unsigned __int16 *v14; // x15
int v15; // w16
int v16; // w17
int v17; // w14
int v18; // w0
int v19; // w9
v11 = *a2;
v12 = a2[1];
if ( v12 >= a4 )
{
LABEL_26:
a2[3] = *((__int16 *)a2 + 5);
*a2 = v11 + 1;
*(_BYTE *)(a3 + 60) |= a11;
return 0;
}
v13 = *(unsigned __int16 *)(a5 + 3LL * v12 + 1);
if ( v11 != v13 )
{
v19 = a2[2] + a2[4];
if ( v19 < 0 && a6 == 2 )
v19 = 0;
a2[2] = v19;
goto LABEL_26;
}
while ( 2 )
{
v14 = (unsigned __int16 *)(a5 + 4 + 3LL * v12);
while ( 1 )
{
v15 = *v14;
v16 = *((char *)v14 - 4);
if ( (a6 & 2) != 0 && v12 >= a10 && !*(_BYTE *)(a3 + 188) )
break;
if ( (a6 & 4) != 0 && v12 >= a8 )
{
v12 = a7;
if ( a8 <= a7 )
{
a2[3] = *(char *)(a5 + 3LL * a7);
return 0;
}
goto LABEL_19;
}
if ( a4 - 1 == v12 )
{
a2[3] = v16;
*((_BYTE *)a2 + 20) = 1;
return 0;
}
if ( v15 == v13 )
v17 = 0;
else
v17 = ((*((char *)v14 - 1) - v16) << 16) / (v15 - v13);
v18 = v12 + 1;
a2[4] = v17;
a2[1] = v12 + 1;
a2[2] = v16 << 16;
if ( v11 == v15 )
{
v14 = (unsigned __int16 *)((char *)v14 + 3);
++v12;
v13 = v15;
if ( v18 < a4 )
continue;
}
goto LABEL_26;
}
v12 = a9;
if ( a10 != a9 )
{
LABEL_19:
v13 = *(unsigned __int16 *)(a5 + 3LL * v12 + 1);
v11 = v13 - 1;
*a2 = v13 - 1;
a2[1] = v12;
continue;
}
break;
}
a2[3] = v16;
return 0;
}