//
// png_image_write_to_file from 0x873480 to 0x873550 (208 bytes)
//
// 0 xrefs:
//
// 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:59 +0000
//
int __fastcall png_image_write_to_file(int **a1, char *filename, void *a3, void *a4, void *a5, void *a6)
{
int **v6; // r4
char *v7; // r1
FILE *v11; // r11
int v12; // r5
int v13; // r5
char *v14; // r1
int *v16; // r0
v6 = a1;
if ( !a1 )
return 0;
if ( a1[1] == (int *)((char *)&dword_0 + 1) )
{
if ( !filename )
{
v7 = "png_image_write_to_file: invalid argument";
return png_image_error((int)a1, (int)v7);
}
v11 = fopen(filename, "wb");
if ( !v11 )
{
v16 = (int *)_errno();
v7 = strerror(*v16);
a1 = v6;
return png_image_error((int)a1, (int)v7);
}
v12 = png_image_write_to_stdio(v6, (int)v11, a3, a4, a5, a6);
if ( v12 )
{
if ( fflush(v11) || ((int)v11->_IO_read_base & 0x40) != 0 )
{
v13 = *(_DWORD *)_errno();
fclose(v11);
LABEL_12:
remove(filename);
v14 = strerror(v13);
return png_image_error((int)v6, (int)v14);
}
v12 = 1;
if ( fclose(v11) )
{
v13 = *(_DWORD *)_errno();
goto LABEL_12;
}
}
else
{
fclose(v11);
remove(filename);
}
return v12;
}
v7 = "png_image_write_to_file: incorrect PNG_IMAGE_VERSION";
return png_image_error((int)a1, (int)v7);
}