//
// sub_E4B034 from 0xe4b034 to 0xe4b284 (592 bytes)
//
// 2 xrefs:
// > png_image_finish_read @ 0xe4c6b8
// > png_image_finish_read @ 0xe4c6c4
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:10:08 +0000
//
__int64 __fastcall sub_E4B034(__int64 a1)
{
__int64 **v1; // x25
int v3; // w23
__int64 *v4; // x0
__int64 v5; // x21
__int64 v6; // x19
__int64 v7; // x22
__int64 v8; // x0
int v9; // w19
char *v10; // x20
void *v11; // x1
int v13; // w1
size_t rowbytes; // x0
void *v15; // x20
unsigned int v16; // w0
unsigned int v17; // w19
v1 = *(__int64 ***)a1;
v3 = 0;
v4 = **(__int64 ***)a1;
v5 = *v4;
v6 = v4[1];
png_set_keep_unknown_chunks(*v4, 1, 0, 0xFFFFFFFFLL);
png_set_keep_unknown_chunks(v5, 0, "bKGD", 6);
if ( !*(_DWORD *)(a1 + 72) )
v3 = png_set_interlace_handling(v5);
png_read_update_info(v5, v6);
switch ( *(_DWORD *)(a1 + 72) )
{
case 0:
if ( *(_BYTE *)(v6 + 37) && *(_BYTE *)(v6 + 37) != 3 || *(_BYTE *)(v6 + 36) != 8 )
goto LABEL_4;
goto LABEL_9;
case 1:
case 2:
if ( *(_WORD *)(v6 + 36) != 1032 || *(_DWORD *)(v5 + 748) != 220000 || *((_DWORD *)v1 + 7) != 256 )
goto LABEL_4;
v7 = *(int *)(a1 + 16);
v8 = *(_QWORD *)(a1 + 8);
if ( v7 < 0 )
goto LABEL_20;
goto LABEL_10;
case 3:
if ( *(_WORD *)(v6 + 36) == 520 && *(_DWORD *)(v5 + 748) == 220000 && *((_DWORD *)v1 + 7) == 216 )
goto LABEL_9;
goto LABEL_4;
case 4:
if ( *(_WORD *)(v6 + 36) != 1544 || *(_DWORD *)(v5 + 748) != 220000 || *((_DWORD *)v1 + 7) != 244 )
goto LABEL_4;
LABEL_9:
v7 = *(int *)(a1 + 16);
v8 = *(_QWORD *)(a1 + 8);
if ( v7 < 0 )
{
LABEL_20:
v13 = *((_DWORD *)v1 + 4);
*(_QWORD *)(a1 + 56) = v7;
*(_QWORD *)(a1 + 48) = v8 - v7 * (unsigned int)(v13 - 1);
if ( v3 )
{
LABEL_11:
while ( --v3 >= 0 )
{
while ( 1 )
{
v9 = *((_DWORD *)v1 + 4);
v10 = *(char **)(a1 + 48);
if ( !v9 )
break;
do
{
v11 = v10;
v10 += v7;
png_read_row(v5, v11, nullptr);
--v9;
}
while ( v9 );
if ( --v3 < 0 )
return 1;
}
}
return 1;
}
}
else
{
LABEL_10:
*(_QWORD *)(a1 + 48) = v8;
*(_QWORD *)(a1 + 56) = v7;
if ( v3 )
goto LABEL_11;
}
rowbytes = png_get_rowbytes(v5, v6);
v15 = png_malloc(v5, rowbytes);
*(_QWORD *)(a1 + 40) = v15;
v16 = png_safe_execute((__int64)v1, (__int64 (__fastcall *)(__int64))sub_E4B284, a1);
*(_QWORD *)(a1 + 40) = 0;
v17 = v16;
png_free(v5, v15);
return v17;
default:
LABEL_4:
png_error(v5, "bad color-map processing (internal error)");
}
}