//
// png_destroy_write_struct from 0x66266c to 0x66276e (258 bytes)
//
// 4 xrefs:
// > cocos2d::CCImage::_saveImageToPNG @ 0x5e2134
// > cocos2d::CCImage::_saveImageToPNG @ 0x5e2248
// > sub_64D010 @ 0x64d074
// > png_image_write_to_stdio @ 0x6633ba
//
// 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_write_struct(int *result, void **a2)
{
int v2; // r4
int *v3; // r5
void *v4; // r1
void *v5; // r1
void *v6; // r1
void *v7; // r1
if ( result )
{
v2 = *result;
if ( *result )
{
v3 = result;
png_destroy_info_struct(*result, a2);
*v3 = 0;
if ( (*(_DWORD *)(v2 + 312) & 2) != 0 )
deflateEnd(v2 + 324);
png_free_buffer_list(v2, v2 + 380);
png_free(v2, *(void **)(v2 + 484));
v4 = *(void **)(v2 + 480);
*(_DWORD *)(v2 + 484) = 0;
png_free(v2, v4);
png_free(v2, *(void **)(v2 + 488));
png_free(v2, *(void **)(v2 + 492));
png_free(v2, *(void **)(v2 + 496));
png_free(v2, *(void **)(v2 + 500));
v5 = *(void **)(v2 + 724);
*(_DWORD *)(v2 + 480) = 0;
*(_DWORD *)(v2 + 488) = 0;
*(_DWORD *)(v2 + 492) = 0;
*(_DWORD *)(v2 + 496) = 0;
*(_DWORD *)(v2 + 500) = 0;
*(_BYTE *)(v2 + 721) = 0;
*(_BYTE *)(v2 + 720) = 1;
if ( v5 )
{
*(_DWORD *)(v2 + 724) = 0;
png_free(v2, v5);
}
v6 = *(void **)(v2 + 728);
if ( v6 )
{
*(_DWORD *)(v2 + 728) = 0;
png_free(v2, v6);
}
v7 = *(void **)(v2 + 732);
if ( v7 )
{
*(_DWORD *)(v2 + 732) = 0;
png_free(v2, v7);
}
png_free(v2, *(void **)(v2 + 736));
png_free(v2, *(void **)(v2 + 740));
*(_DWORD *)(v2 + 736) = 0;
*(_DWORD *)(v2 + 740) = 0;
png_free(v2, *(void **)(v2 + 796));
*(_DWORD *)(v2 + 796) = 0;
return (int *)png_destroy_png_struct((void *)v2);
}
}
return result;
}