//
// sub_BC51A8 from 0xbc51a8 to 0xbc5278 (208 bytes)
//
// 2 xrefs:
// > png_image_free @ 0xbcc848
// > png_image_free @ 0xbcc850
//
// 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
//
__int64 __fastcall sub_BC51A8(__int64 **a1)
{
__int64 *v1; // x19
__int64 v2; // x2
__int64 v4; // x3
__int64 v5; // x3
__int64 v6; // x0
__int64 v7; // x2
__int64 v8; // x3
FILE *v10; // x0
__int64 v11; // [xsp+30h] [xbp+30h] BYREF
_QWORD v12[4]; // [xsp+38h] [xbp+38h] BYREF
__int64 v13; // [xsp+58h] [xbp+58h]
v1 = *a1;
v2 = **a1;
if ( !v2 )
return 0;
if ( (v1[5] & 2) != 0 )
{
v10 = *(FILE **)(v2 + 320);
*((_BYTE *)v1 + 40) &= ~2u;
if ( v10 )
{
*(_QWORD *)(v2 + 320) = 0;
fclose(v10);
}
}
v4 = v1[1];
v11 = *v1;
v12[0] = v4;
v5 = v1[3];
v12[1] = v1[2];
v12[2] = v5;
v6 = v11;
v7 = v1[4];
v8 = v1[5];
*a1 = &v11;
v12[3] = v7;
v13 = v8;
png_free(v6, v1);
if ( (v13 & 1) != 0 )
png_destroy_write_struct(&v11, v12);
else
png_destroy_read_struct(&v11, v12, 0);
return 1;
}