//
// png_destroy_write_struct from 0xe5e1e4 to 0xe5e320 (316 bytes)
//
// 6 xrefs:
// > cocos2d::CCImage::_saveImageToPNG @ 0xd7d9f8
// > cocos2d::CCImage::_saveImageToPNG @ 0xd7da1c
// > cocos2d::CCImage::_saveImageToPNG @ 0xd7da64
// > sub_E3B368 @ 0xe3b40c
// > png_image_write_to_stdio @ 0xe5f214
// > ??> @ 0x6d9a8
//
// 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:22 +0000
//
__int64 *__fastcall png_destroy_write_struct(__int64 *result, void **a2)
{
__int64 v2; // x19
__int64 *v3; // x20
int v4; // w0
void *v5; // x1
void *v6; // x1
void *v7; // x1
void *v8; // x1
if ( result )
{
v2 = *result;
if ( *result )
{
v3 = result;
png_destroy_info_struct(*result, a2);
v4 = *(_DWORD *)(v2 + 360);
*v3 = 0;
if ( (v4 & 2) != 0 )
deflateEnd(v2 + 376);
png_free_buffer_list(v2, v2 + 488);
png_free(v2, *(void **)(v2 + 608));
*(_QWORD *)(v2 + 608) = 0;
png_free(v2, *(void **)(v2 + 600));
png_free(v2, *(void **)(v2 + 616));
png_free(v2, *(void **)(v2 + 624));
png_free(v2, *(void **)(v2 + 632));
png_free(v2, *(void **)(v2 + 640));
*(_QWORD *)(v2 + 600) = 0;
v5 = *(void **)(v2 + 984);
*(_QWORD *)(v2 + 616) = 0;
*(_QWORD *)(v2 + 624) = 0;
*(_QWORD *)(v2 + 632) = 0;
*(_QWORD *)(v2 + 640) = 0;
*(_WORD *)(v2 + 976) = 1;
if ( v5 )
{
*(_QWORD *)(v2 + 984) = 0;
png_free(v2, v5);
}
v6 = *(void **)(v2 + 992);
if ( v6 )
{
*(_QWORD *)(v2 + 992) = 0;
png_free(v2, v6);
}
v7 = *(void **)(v2 + 1000);
if ( v7 )
{
*(_QWORD *)(v2 + 1000) = 0;
png_free(v2, v7);
}
png_free(v2, *(void **)(v2 + 1008));
png_free(v2, *(void **)(v2 + 1016));
*(_QWORD *)(v2 + 1008) = 0;
v8 = *(void **)(v2 + 1088);
*(_QWORD *)(v2 + 1016) = 0;
png_free(v2, v8);
*(_QWORD *)(v2 + 1088) = 0;
return (__int64 *)png_destroy_png_struct((void *)v2);
}
}
return result;
}