//
// sub_873B24 from 0x873b24 to 0x873c6c (328 bytes)
//
// 3 xrefs:
// > png_compress_IDAT @ 0x874644
// > png_compress_IDAT @ 0x8746c8
// > png_compress_IDAT @ 0x874812
//
// 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:00 +0000
//
int __fastcall sub_873B24(int a1)
{
unsigned int v1; // r12
unsigned int v2; // r3
bool v3; // cf
int result; // r0
int v5; // lr
int v6; // r3
unsigned int v7; // r11
int v8; // r9
int v9; // r2
int v10; // r4
int v11; // r2
unsigned int v12; // r4
unsigned int v13; // r1
unsigned int v14; // r2
bool v15; // r1
_BOOL4 v16; // r8
int v17; // r7
int v18; // r5
int v19; // r3
int v20; // r2
int v21; // r4
_BOOL4 v22; // r1
int v23; // r10
unsigned int v24; // r6
unsigned int v25; // r3
unsigned int v26; // r5
int v27; // r2
unsigned int v28; // r5
int v29; // r3
int v30; // [sp+0h] [bp-30h]
v1 = *(_DWORD *)(a1 + 452);
v2 = *(_DWORD *)(a1 + 464);
v3 = v2 >= 0x8000;
if ( v2 < 0x8000 )
v3 = v1 >= 0x8000;
if ( v3 )
return -1;
if ( !*(_BYTE *)(a1 + 532) )
return v1 * (v2 + 1);
v5 = 0;
v6 = *(_DWORD *)(a1 + 448);
v7 = *(unsigned __int8 *)(a1 + 538);
v8 = 1;
result = 0;
v30 = v6;
do
{
v9 = ((v5 & 1) << (3 - (v8 >> 1))) & 7;
v10 = (1 << ((7 - v5) >> 1)) - 1 - v9;
v11 = 7 - v9 + v30;
v12 = v10 + v30;
if ( v5 <= 1 )
{
v13 = v11;
LOBYTE(v11) = 3;
}
else
{
v11 = (7 - v5) >> 1;
v13 = v12;
}
v14 = v13 >> v11;
v15 = v14 != 0;
v16 = v14 != 0 && v7 > 7;
v17 = (8 - v5) >> 1;
v18 = v7 * v14;
v19 = (!(v5 & 1) << (3 - (v5 >> 1))) & 7;
v20 = (v7 >> 3) * v14;
v21 = v16 || v7 <= 7 && v15;
v22 = v5 > 2;
if ( v5 > 2 )
v22 = 1;
v23 = v21 & v22;
v24 = (1 << v17) - 1 - v19 + v1;
v25 = 7 - v19 + v1;
v26 = (unsigned int)(v18 + 7) >> 3;
if ( (v21 & v22) != 0 )
v25 = v24;
v27 = v20 + 1;
v28 = v26 + 1;
if ( !v23 )
LOBYTE(v17) = 3;
if ( v16 )
v28 = v27;
++v5;
v29 = result + v28 * (v25 >> v17);
++v8;
if ( v23 | v21 & !v22 )
result = v29;
}
while ( v5 != 7 );
return result;
}