//
// sub_859A58 from 0x859a58 to 0x859adc (132 bytes)
//
// 2 xrefs:
// > lws_read @ 0x8563ea
// > lws_read @ 0x85644c
//
// 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:38 +0000
//
int __fastcall sub_859A58(int a1, int *a2, int a3)
{
int v4; // r6
unsigned __int8 *v6; // r3
int v7; // r3
int result; // r0
v4 = a3;
switch ( *(_BYTE *)(a1 + 263) )
{
case 4:
case 8:
case 9:
case 0xC:
case 0xD:
if ( !a3 )
goto LABEL_13;
if ( (*(_BYTE *)(a1 + 260) & 8) != 0 )
{
do
{
if ( (*(_BYTE *)(a1 + 179) & 0x40) != 0 )
{
if ( sub_858EA8(a1, 0, a3) < 0 )
return -1;
}
else
{
if ( *(_DWORD *)(a1 + 196) )
++*(_DWORD *)(a1 + 244);
v6 = (unsigned __int8 *)(*a2)++;
if ( sub_85ADF0(a1, *v6) )
return -1;
if ( !--v4 )
goto LABEL_13;
}
v7 = *(unsigned __int8 *)(a1 + 260);
a3 = v7 << 28;
}
while ( (v7 & 8) != 0 );
}
sub_8572F4((_DWORD *)a1, *a2, 0, v4);
result = 0;
break;
default:
LABEL_13:
result = 0;
break;
}
return result;
}