//
// png_handle_gAMA from 0x65cb74 to 0x65cc02 (142 bytes)
//
// 3 xrefs:
// > png_push_read_chunk @ 0x652a14
// > png_read_info @ 0x65589a
// > png_read_end @ 0x6573a6
//
// 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_handle_gAMA(_DWORD *a1, int a2, unsigned int a3)
{
int v4; // r3
int result; // r0
int v7; // r3
_BYTE v8[2]; // [sp+4h] [bp-8h] BYREF
unsigned __int8 v9; // [sp+6h] [bp-6h]
unsigned __int8 v10; // [sp+7h] [bp-5h]
v4 = a1[77];
if ( (v4 & 1) == 0 )
png_chunk_error((int)a1, "missing IHDR");
if ( (v4 & 6) != 0 )
{
png_crc_finish(a1, a3);
return png_chunk_benign_error((int)a1, "out of place");
}
else if ( a3 == 4 )
{
png_crc_read(a1, (int)v8, 4);
result = png_crc_finish(a1, 0);
if ( !result )
{
v7 = (v8[1] << 16) + (v8[0] << 24) + v10;
png_colorspace_set_gamma((int)a1, (int)(a1 + 231), (v7 + (v9 << 8)) | ((v7 + (v9 << 8)) >> 31));
return png_colorspace_sync((int)a1, a2);
}
}
else
{
png_crc_finish(a1, a3);
return png_chunk_benign_error((int)a1, "invalid");
}
return result;
}