//
// sub_87CC58 from 0x87cc58 to 0x87cd3c (228 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:03:07 +0000
//
char *__fastcall sub_87CC58(char *result)
{
char *v1; // r5
int v2; // r8
int v3; // r3
int v4; // r4
_DWORD *v5; // r6
int v6; // r7
int v7; // t1
unsigned int v8; // r3
unsigned int v9; // r10
int v10; // r1
unsigned int v11; // r3
unsigned int v12; // r7
int v13; // r1
int v14; // r0
int v15; // r0
unsigned int v16; // [sp+4h] [bp-28h]
unsigned int v17; // [sp+4h] [bp-28h]
_DWORD v18[4]; // [sp+8h] [bp-24h] BYREF
_DWORD v19[5]; // [sp+18h] [bp-14h] BYREF
v1 = result;
v2 = *((_DWORD *)result + 106);
if ( *((_DWORD *)result + 67) )
result = (char *)sub_87BCD4(*((_DWORD *)result + 106));
v3 = *((_DWORD *)v1 + 73);
v4 = 0;
memset(v18, 0, sizeof(v18));
memset(v19, 0, 16);
if ( v3 > 0 )
{
v5 = v1 + 292;
do
{
v7 = v5[1];
++v5;
v6 = v7;
if ( !*((_DWORD *)v1 + 91) && !*((_DWORD *)v1 + 93) )
{
v8 = *(_DWORD *)(v6 + 20);
v9 = 4 * v8;
if ( !v18[v8] )
{
v10 = *(_DWORD *)&v1[v9 + 120];
if ( !v10 )
{
v17 = *(_DWORD *)(v6 + 20);
v15 = jpeg_alloc_huff_table(v1);
v8 = v17;
v10 = v15;
*(_DWORD *)&v1[v9 + 120] = v15;
}
result = sub_87BA0C((int)v1, v10, *(_DWORD *)(v2 + 4 * v8 + 76));
v19[v9 / 4 - 4] = 1;
}
}
if ( *((_DWORD *)v1 + 92) )
{
v11 = *(_DWORD *)(v6 + 24);
v12 = 4 * v11;
if ( !v19[v11] )
{
v13 = *(_DWORD *)&v1[v12 + 136];
if ( !v13 )
{
v16 = v11;
v14 = jpeg_alloc_huff_table(v1);
v11 = v16;
v13 = v14;
*(_DWORD *)&v1[v12 + 136] = v14;
}
result = sub_87BA0C((int)v1, v13, *(_DWORD *)(v2 + 4 * v11 + 92));
v19[v12 / 4] = 1;
}
}
++v4;
}
while ( *((_DWORD *)v1 + 73) > v4 );
}
return result;
}