//
// png_write_chunk from 0x664180 to 0x664202 (130 bytes)
//
// 3 xrefs:
// > png_write_info_before_PLTE @ 0x661926
// > png_write_info @ 0x661c04
// > png_write_end @ 0x661dbe
//
// 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_write_chunk(int result, unsigned int *a2, int a3, int a4)
{
int v4; // r5
_DWORD *v7; // r4
_BYTE v8[4]; // [sp+0h] [bp-Ch] BYREF
_BYTE v9[8]; // [sp+4h] [bp-8h] BYREF
v4 = _byteswap_ulong(*a2);
if ( result )
{
if ( a4 < 0 )
png_error(result, "length exceeds PNG maximum");
v7 = (_DWORD *)result;
*(_DWORD *)(result + 900) = 34;
png_save_uint_32(v8, a4);
png_save_uint_32(v9, v4);
png_write_data((int)v7);
v7[119] = v4;
png_reset_crc((int)v7);
png_calculate_crc(v7, (int)v9, 4);
v7[225] = 66;
png_write_chunk_data(v7, a3, a4);
return png_write_chunk_end((int)v7);
}
return result;
}