//
// png_read_end from 0x867184 to 0x8674fa (886 bytes)
//
// 2 xrefs:
// > cocos2d::CCImage::_initWithPngData @ 0x7eba30
// > png_read_png @ 0x867742
//
// 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:48 +0000
//
int __fastcall png_read_end(int result, int a2)
{
int v3; // r4
int v4; // r3
int chunk_header; // r0
int v6; // r11
size_t v7; // r10
if ( result )
{
v3 = result;
if ( png_chunk_unknown_handling(result, 1229209940) )
{
if ( *(_BYTE *)(v3 + 535) != 3 )
goto LABEL_9;
}
else
{
png_read_finish_IDAT(v3);
if ( *(_BYTE *)(v3 + 535) != 3 )
goto LABEL_9;
}
if ( *(_DWORD *)(v3 + 524) > (int)*(unsigned __int16 *)(v3 + 520) )
png_benign_error((_DWORD *)v3, "Read palette index exceeding num_palette");
do
{
while ( 1 )
{
LABEL_9:
chunk_header = png_read_chunk_header(v3);
v6 = *(_DWORD *)(v3 + 476);
v7 = chunk_header;
if ( v6 == 1229278788 )
{
result = png_handle_IEND(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
}
if ( v6 == 1229472850 )
{
result = png_handle_IHDR(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
}
if ( a2 )
break;
LABEL_37:
result = png_crc_finish(v3, v7);
v4 = *(_DWORD *)(v3 + 308);
LABEL_8:
if ( (v4 & 0x10) != 0 )
return result;
}
if ( png_chunk_unknown_handling(v3, *(_DWORD *)(v3 + 476)) )
{
if ( v6 == 1229209940 )
{
if ( v7 || (*(_DWORD *)(v3 + 308) & 0x2000) != 0 )
png_benign_error((_DWORD *)v3, "Too many IDATs found");
result = png_handle_unknown(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
}
else
{
result = png_handle_unknown(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
if ( v6 == 1347179589 )
{
v4 |= 2u;
*(_DWORD *)(v3 + 308) = v4;
}
}
goto LABEL_8;
}
switch ( v6 )
{
case 1229209940:
if ( v7 || (*(_DWORD *)(v3 + 308) & 0x2000) != 0 )
png_benign_error((_DWORD *)v3, "Too many IDATs found");
goto LABEL_37;
case 1347179589:
result = png_handle_PLTE(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1649100612:
result = png_handle_bKGD(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1665684045:
result = png_handle_cHRM(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1732332865:
result = png_handle_gAMA(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1749635924:
result = png_handle_hIST(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1866876531:
result = png_handle_oFFs(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1883455820:
result = png_handle_pCAL(v3);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1933787468:
result = png_handle_sCAL(v3);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1883789683:
result = png_handle_pHYs(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1933723988:
result = png_handle_sBIT(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1934772034:
result = png_handle_sRGB(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1766015824:
result = png_handle_iCCP(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1934642260:
result = png_handle_sPLT(v3);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1950701684:
result = png_handle_tEXt(v3);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1950960965:
result = png_handle_tIME(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1951551059:
result = png_handle_tRNS(v3, a2);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 2052348020:
result = png_handle_zTXt(v3, a2, v7);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
case 1767135348:
result = png_handle_iTXt(v3);
v4 = *(_DWORD *)(v3 + 308);
goto LABEL_8;
}
result = png_handle_unknown(v3, a2);
}
while ( (*(_DWORD *)(v3 + 308) & 0x10) == 0 );
}
return result;
}