//
// png_image_write_to_stdio from 0xe5f1a4 to 0xe5f31c (376 bytes)
//
// 2 xrefs:
// > png_image_write_to_file @ 0xe5f3a8
// > ??> @ 0x5a610
//
// 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_image_write_to_stdio(
_DWORD *a1,
__int64 a2,
unsigned int a3,
void *a4,
unsigned int a5,
void *a6)
{
_DWORD *v13; // x0
_QWORD *v14; // x0
__int64 v15; // x2
void *v16; // x3
char v17; // w1
unsigned int v18; // w20
_DWORD *v19; // [xsp+48h] [xbp+48h] BYREF
void *v20[8]; // [xsp+50h] [xbp+50h] BYREF
if ( !a1 )
return 0;
if ( a1[2] == 1 )
{
if ( !a2 )
return png_image_error((__int64)a1, (__int64)"png_image_write_to_stdio: invalid argument");
v13 = png_create_write_struct((__int64)"1.6.16", (__int64)a1, (__int64)png_safe_error, (__int64)png_safe_warning);
v19 = v13;
if ( v13 )
{
v20[0] = png_create_info_struct((__int64)v13);
if ( v20[0] )
{
v14 = png_malloc_warn((__int64)v19, 0x30u);
if ( v14 )
{
v14[4] = 0;
v14[5] = 0;
v15 = (__int64)v19;
v16 = v20[0];
v17 = *((_BYTE *)v14 + 40) | 1;
*v14 = v19;
v14[2] = 0;
v14[3] = 0;
v14[1] = v16;
*(_QWORD *)a1 = v14;
*((_BYTE *)v14 + 40) = v17;
LABEL_14:
*(_QWORD *)(v15 + 320) = a2;
v20[0] = a1;
memset(&v20[5], 0, 24);
v20[1] = a4;
v20[2] = (void *)a5;
v20[3] = a6;
v20[4] = (void *)a3;
v18 = png_safe_execute((__int64)a1, sub_E5EAE4, (__int64)v20);
png_image_free((__int64)a1);
return v18;
}
png_destroy_info_struct((__int64)v19, v20);
}
png_destroy_write_struct((__int64 *)&v19, nullptr);
}
if ( (unsigned int)png_image_error((__int64)a1, (__int64)"png_image_write_: out of memory") )
{
v15 = **(_QWORD **)a1;
goto LABEL_14;
}
return 0;
}
return png_image_error((__int64)a1, (__int64)"png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
}