//
// sub_85587C from 0x85587c to 0x855a08 (396 bytes)
//
// 1 xrefs:
// > sub_852C2C @ 0x852f22
//
// 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:35 +0000
//
int __fastcall sub_85587C(int a1, int a2, int a3, int a4)
{
_DWORD *v5; // r10
int v6; // r4
int v7; // r11
int v8; // r9
char *v9; // r0
char *v10; // r7
int result; // r0
char *v12; // r6
_DWORD *v13; // r1
_DWORD *v14; // r1
unsigned int v15; // lr
int v16; // r0
int v17; // r2
int v18; // r3
void *v19; // r0
int v20; // lr
int v21; // [sp+4h] [bp-18h]
int v24; // [sp+10h] [bp-Ch]
_DWORD *v25; // [sp+14h] [bp-8h]
v5 = *(_DWORD **)a1;
v6 = *(_DWORD *)(*(_DWORD *)a1 + 34460);
v7 = *(_DWORD *)(v6 + 20);
if ( *(_DWORD *)(a1 + 248) != 2 || *(_BYTE *)(a4 + a1 + 645) )
{
v21 = 0;
v8 = a1 + 548;
v9 = off_D200B8(*(const char **)(a1 + 152));
}
else
{
v21 = 1;
v8 = a1 + 580;
v9 = off_D200B8(*(const char **)(a1 + 236));
}
v10 = v9;
result = 27;
if ( v10 )
{
if ( *(_BYTE *)(a1 + 615) )
{
v12 = off_D200B8(*(const char **)(a1 + 172));
if ( !v12 )
{
off_D200B0(v10);
return 27;
}
}
else
{
v12 = (char *)*(unsigned __int8 *)(a1 + 615);
}
if ( *(_BYTE *)(a1 + 616) )
v24 = *(_DWORD *)(a1 + 268);
else
v24 = -1;
v13 = (_DWORD *)v5[18];
if ( v13 && (*v13 & 0x10) != 0 )
v14 = v13 + 14;
else
v14 = v5 + 8616;
v15 = v5[208];
if ( v15 <= 1 )
{
if ( v15 != 1 )
{
v16 = 1;
LABEL_23:
v6 = v5[8615] + (v16 << 6);
goto LABEL_24;
}
}
else
{
v16 = 1;
v17 = v5[8615];
v18 = v17 + 64;
if ( !*(_DWORD *)(v17 + 76) )
goto LABEL_23;
while ( 1 )
{
++v16;
if ( *(_DWORD *)(v18 + 20) < v7 )
{
v6 = v18;
v7 = *(_DWORD *)(v18 + 20);
}
v18 += 64;
if ( v16 == v15 )
break;
if ( !*(_DWORD *)(v18 + 12) )
goto LABEL_23;
}
}
v25 = v14;
sub_8557E0((void **)v6);
v14 = v25;
LABEL_24:
v19 = *(void **)v6;
*(_DWORD *)(v6 + 12) = a2;
*(_DWORD *)(v6 + 16) = a3;
*(_DWORD *)(v6 + 20) = *v14;
off_D200B0(v19);
off_D200B0(*(void **)(v6 + 4));
*(_DWORD *)v6 = v10;
*(_DWORD *)(v6 + 4) = v12;
*(_DWORD *)(v6 + 28) = v24;
v20 = *(_DWORD *)(a1 + 260);
if ( !v21 )
v20 = *(_DWORD *)(a1 + 264);
*(_DWORD *)(v6 + 24) = v20;
*(_DWORD *)(v6 + 8) = **(_DWORD **)(a1 + 664);
if ( sub_855394(v8, v6 + 32) )
{
return 0;
}
else
{
*(_DWORD *)(v6 + 12) = 0;
off_D200B0(v10);
off_D200B0(v12);
return 27;
}
}
return result;
}