//
// sub_872E84 from 0x872e84 to 0x873174 (752 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:02:59 +0000
//
int __fastcall sub_872E84(int *a1)
{
int v2; // r11
unsigned int v3; // r6
int v4; // r3
int v5; // r10
_DWORD *v6; // r4
_DWORD *v7; // r7
int v8; // r9
unsigned int v9; // r8
int v10; // r3
unsigned int v11; // r1
unsigned __int8 v12; // r1
int v13; // r1
_DWORD ***v14; // r2
int v15; // r3
size_t rowbytes; // r0
_DWORD ***v17; // r9
int v18; // r6
int result; // r0
unsigned __int8 v20; // lr
char v21; // r1
char *v22; // r6
_DWORD ***v23; // r8
int v24; // r5
int v25; // [sp+18h] [bp-Ch]
int v26; // [sp+1Ch] [bp-8h]
v2 = *a1;
v3 = *(_DWORD *)(*a1 + 16);
v4 = *(_DWORD *)*a1;
v5 = v3 & 8;
v6 = *(_DWORD **)v4;
v7 = *(_DWORD **)(v4 + 4);
if ( (v3 & 8) != 0 )
{
v8 = 0;
v25 = 0;
v26 = 0;
v9 = 0;
}
else
{
v8 = (v3 >> 2) & 1;
v25 = v8;
v26 = *(_DWORD *)(*a1 + 16) & 1;
if ( v8 )
{
v9 = a1[4] == 0;
}
else
{
v8 = 1;
v9 = 0;
}
}
png_set_benign_errors((int)v6, 0);
if ( !a1[2] )
{
if ( (*(_DWORD *)(v2 + 16) & 8) != 0 )
v10 = 1;
else
v10 = (*(_DWORD *)(v2 + 16) & 3) + 1;
a1[2] = *(_DWORD *)(v2 + 8) * v10;
}
if ( (v3 & 8) != 0 )
{
if ( !a1[3] || (v11 = *(_DWORD *)(v2 + 24)) == 0 )
png_error(**(_DWORD **)v2, "no color-map for color-mapped image");
if ( v11 <= 0x10 )
{
if ( v11 <= 4 )
{
if ( v11 <= 2 )
v12 = 1;
else
v12 = 2;
}
else
{
v12 = 4;
}
}
else
{
v12 = 8;
}
png_set_IHDR((int)v6, (int)v7, *(_DWORD *)(v2 + 8), *(_DWORD *)(v2 + 12), v12, 3u, 0, 0, 0);
sub_8713B8((_DWORD ***)*a1, a1[3]);
if ( !v9 )
goto LABEL_20;
}
else
{
if ( v9 )
v20 = 16;
else
v20 = 8;
if ( (v3 & 1) != 0 )
v21 = 4;
else
v21 = 0;
png_set_IHDR(
(int)v6,
(int)v7,
*(_DWORD *)(v2 + 8),
*(_DWORD *)(v2 + 12),
v20,
(v3 & 2) + v21,
v3 & 8,
v3 & 8,
v3 & 8);
if ( !v9 )
{
LABEL_20:
if ( (*(_DWORD *)(v2 + 20) & 1) != 0 )
png_set_gAMA_fixed((int)v6, (int)v7, 45455);
else
png_set_sRGB((int)v6, (int)v7, v9);
png_write_info((int)v6, (int)v7);
goto LABEL_23;
}
}
png_set_gAMA_fixed((int)v6, (int)v7, (int)&stru_1869C.st_value);
if ( (*(_DWORD *)(v2 + 20) & 1) == 0 )
png_set_cHRM_fixed((int)v6, (int)v7, 31270, 32900, 64000, 33000, 30000, 60000, 15000, 6000);
png_write_info((int)v6, (int)v7);
png_set_swap((int)v6);
LABEL_23:
if ( (v3 & 0x10) != 0 )
{
if ( v8 && (v3 & 2) != 0 )
png_set_bgr((int)v6);
v3 &= ~0x10u;
}
if ( (v3 & 0x20) != 0 )
{
if ( v8 && (v3 & 1) != 0 )
png_set_swap_alpha((int)v6);
v3 &= ~0x20u;
}
if ( v5 && *(_DWORD *)(v2 + 24) <= 0x10u )
png_set_packing((int)v6);
if ( (v3 & 0xFFFFFFF0) != 0 )
png_error((int)v6, "png_write_image: unsupported transformation");
v13 = v25;
v14 = (_DWORD ***)a1[1];
v15 = a1[2];
if ( v25 )
v15 *= 2;
if ( v15 < 0 )
v13 = *(_DWORD *)(v2 + 12);
a1[6] = v15;
if ( v15 < 0 )
v14 = (_DWORD ***)((char *)v14 + (1 - v13) * v15);
a1[5] = (int)v14;
if ( (*(_DWORD *)(v2 + 20) & 2) != 0 )
{
png_set_filter(v6, 0, 0);
png_set_compression_level((int)v6, 3);
}
if ( (v25 & v26) == 0 && (!v8 || !a1[4]) )
{
v22 = (char *)a1[5];
v23 = (_DWORD ***)a1[6];
if ( *(_DWORD *)(v2 + 12) )
{
v24 = *(_DWORD *)(v2 + 12);
do
{
png_write_row((int)v6, v22);
--v24;
v22 = (char *)v23 + (_DWORD)v22;
}
while ( v24 );
}
goto LABEL_51;
}
rowbytes = png_get_rowbytes((int)v6, (int)v7);
v17 = (_DWORD ***)png_malloc(v6, rowbytes);
a1[7] = (int)v17;
if ( v9 )
v18 = png_safe_execute(v2, (int (__fastcall *)(int))sub_872554, (int)a1);
else
v18 = png_safe_execute(v2, (int (__fastcall *)(int))sub_872210, (int)a1);
a1[7] = 0;
png_free((int)v6, v17);
result = v18;
if ( v18 )
{
LABEL_51:
png_write_end((int)v6, v7);
return 1;
}
return result;
}