//
// png_push_read_chunk from 0xe454d8 to 0xe45ba0 (1736 bytes)
//
// 2 xrefs:
// > png_process_some_data @ 0xe46434
// > ??> @ 0xc3f10
//
// 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:05 +0000
//
__int64 __fastcall png_push_read_chunk(unsigned __int64 a1, __int64 a2)
{
int v3; // w1
__int64 v4; // x19
int v5; // w20
int v6; // w0
__int64 result; // x0
int v8; // w3
int v9; // w4
int v10; // w5
int v11; // w6
int v12; // w7
int v13; // w0
int v14; // w2
unsigned __int64 v15; // x1
unsigned __int64 v16; // x0
unsigned int v17; // w0
unsigned int v18; // w1
__int64 v19; // x1
int v20; // w2
size_t v21; // x2
char v22; // [xsp+0h] [xbp+0h]
char v23[8]; // [xsp+30h] [xbp+30h] BYREF
unsigned int v24; // [xsp+38h] [xbp+38h] BYREF
v3 = *(_DWORD *)(a1 + 356);
v4 = a1;
if ( (v3 & 0x100) == 0 )
{
if ( *(_QWORD *)(a1 + 936) <= 7u )
return png_push_save_buffer(a1);
png_push_fill_buffer(a1, v23, 4u);
*(_DWORD *)(v4 + 912) = png_get_uint_31(v4, v23);
png_reset_crc(v4);
png_crc_read(v4, &v24, 4);
*(_DWORD *)(v4 + 592) = _byteswap_ulong(v24);
png_check_chunk_name(v4);
v3 = *(_DWORD *)(v4 + 356) | 0x100;
*(_DWORD *)(v4 + 356) = v3;
}
v5 = *(_DWORD *)(v4 + 592);
if ( v5 != 1229209940 )
{
if ( v5 == 1229472850 )
{
if ( *(_DWORD *)(v4 + 912) != 13 )
png_error(v4, "Invalid IHDR length");
if ( *(_QWORD *)(v4 + 936) > 0x10u )
{
png_handle_IHDR(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
goto LABEL_13;
}
if ( v5 == 1229278788 )
{
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_IEND(v4, a2);
*(_DWORD *)(v4 + 952) = 6;
png_push_have_end(v4);
v6 = *(_DWORD *)(v4 + 356);
LABEL_9:
result = v6 & 0xFFFFFEFF;
*(_DWORD *)(v4 + 356) = result;
return result;
}
goto LABEL_13;
}
v8 = png_chunk_unknown_handling(v4, v5);
if ( !v8 )
{
if ( v5 == 1347179589 )
{
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_PLTE(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
}
else
{
v13 = *(_DWORD *)(v4 + 592);
switch ( v13 )
{
case 1732332865:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_gAMA(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1933723988:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_sBIT(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1665684045:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_cHRM(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
default:
if ( v5 == 1934772034 )
{
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_sRGB(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
}
else if ( v13 == 1766015824 )
{
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_iCCP(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
}
else
{
switch ( v5 )
{
case 1934642260:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_sPLT(v4);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1951551059:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_tRNS(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1649100612:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_bKGD(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1749635924:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_hIST(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1883789683:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_pHYs(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1866876531:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_oFFs(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1883455820:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_pCAL(v4);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1933787468:
v20 = *(_DWORD *)(v4 + 912);
if ( (unsigned __int64)(unsigned int)(v20 + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_sCAL(v4, a2, v20, v8, v9, v10, v11, v12, v22);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1950960965:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_tIME(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 1950701684:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_tEXt(v4);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
case 2052348020:
v21 = *(unsigned int *)(v4 + 912);
if ( (unsigned __int64)(unsigned int)(v21 + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_zTXt(v4, a2, v21, v8, v9, v10, v11, v12, v22);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
default:
v14 = *(_DWORD *)(v4 + 912);
v15 = (unsigned int)(v14 + 4);
v16 = *(_QWORD *)(v4 + 936);
if ( v5 == 1767135348 )
{
if ( v15 <= v16 )
{
png_handle_iTXt(v4, a2, v14, v8, v9, v10, v11, v12, v22);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
}
else if ( v15 <= v16 )
{
png_handle_unknown(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
goto LABEL_9;
}
break;
}
}
break;
}
}
goto LABEL_13;
}
LABEL_47:
if ( (unsigned __int64)(unsigned int)(*(_DWORD *)(v4 + 912) + 4) <= *(_QWORD *)(v4 + 936) )
{
png_handle_unknown(v4, a2);
v6 = *(_DWORD *)(v4 + 356);
if ( v5 == 1347179589 )
v6 |= 2u;
goto LABEL_9;
}
LABEL_13:
a1 = v4;
return png_push_save_buffer(a1);
}
if ( (v3 & 8) != 0 )
{
v3 |= 0x2000u;
*(_DWORD *)(v4 + 356) = v3;
}
if ( (v3 & 1) == 0 )
png_error(v4, "Missing IHDR before IDAT");
if ( *(_BYTE *)(v4 + 687) == 3 && (v3 & 2) == 0 )
png_error(v4, "Missing PLTE before IDAT");
*(_DWORD *)(v4 + 356) = v3 | 4;
*(_DWORD *)(v4 + 952) = 2;
if ( (v3 & 0x2000) != 0 || (result = *(unsigned int *)(v4 + 912), (_DWORD)result) )
{
if ( (v3 & 8) != 0 )
png_benign_error((_DWORD *)v4, "Too many IDATs found");
if ( (unsigned int)png_chunk_unknown_handling(v4, 1229209940) )
goto LABEL_47;
*(_DWORD *)(v4 + 656) = *(_DWORD *)(v4 + 912);
*(_DWORD *)(v4 + 952) = 2;
png_push_have_info(v4);
v17 = *(unsigned __int8 *)(v4 + 690);
v18 = *(_DWORD *)(v4 + 584);
if ( v17 > 7 )
result = (v17 >> 3) * v18 + 1;
else
result = (unsigned int)((v18 * (unsigned __int64)*(unsigned __int8 *)(v4 + 690) + 7) >> 3) + 1;
v19 = *(_QWORD *)(v4 + 608);
*(_DWORD *)(v4 + 408) = result;
*(_QWORD *)(v4 + 400) = v19;
}
return result;
}