//
// png_destroy_read_struct from 0x657488 to 0x657580 (248 bytes)
//
// 3 xrefs:
// > cocos2d::CCImage::_initWithPngData @ 0x5e1cbe
// > sub_64D010 @ 0x64d04e
// > sub_657580 @ 0x657602
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int *__fastcall png_destroy_read_struct(int *result, void **a2, void **a3)
{
int v3; // r4
int *v5; // r6
void *v6; // r1
void *v7; // r1
void *v8; // r1
void *v9; // r1
int v10; // r2
unsigned int v11; // r3
void *v12; // r1
if ( result )
{
v3 = *result;
if ( *result )
{
v5 = result;
png_destroy_info_struct(*result, a3);
png_destroy_info_struct(v3, a2);
*v5 = 0;
png_destroy_gamma_table(v3);
png_free(v3, *(void **)(v3 + 828));
v6 = *(void **)(v3 + 904);
*(_DWORD *)(v3 + 828) = 0;
png_free(v3, v6);
v7 = *(void **)(v3 + 888);
*(_DWORD *)(v3 + 904) = 0;
png_free(v3, v7);
v8 = *(void **)(v3 + 712);
*(_DWORD *)(v3 + 888) = 0;
png_free(v3, v8);
v9 = *(void **)(v3 + 716);
*(_DWORD *)(v3 + 712) = 0;
png_free(v3, v9);
v10 = *(_DWORD *)(v3 + 776);
*(_DWORD *)(v3 + 716) = 0;
if ( (v10 & 0x1000) != 0 )
{
png_zfree(v3, *(_DWORD *)(v3 + 516));
v10 = *(_DWORD *)(v3 + 776);
*(_DWORD *)(v3 + 516) = 0;
}
v11 = v10 & 0xFFFFEFFF;
*(_DWORD *)(v3 + 776) = v10 & 0xFFFFEFFF;
if ( (v10 & 0x2000) != 0 )
{
png_free(v3, *(void **)(v3 + 628));
v11 = *(_DWORD *)(v3 + 776);
*(_DWORD *)(v3 + 628) = 0;
}
*(_DWORD *)(v3 + 776) = v11 & 0xFFFFDFFF;
inflateEnd(v3 + 324);
png_free(v3, *(void **)(v3 + 668));
v12 = *(void **)(v3 + 872);
*(_DWORD *)(v3 + 668) = 0;
png_free(v3, v12);
*(_DWORD *)(v3 + 872) = 0;
png_free(v3, *(void **)(v3 + 796));
*(_DWORD *)(v3 + 796) = 0;
return (int *)png_destroy_png_struct((void *)v3);
}
}
return result;
}