//
// png_colorspace_set_gamma from 0x64fdf4 to 0x64fea4 (176 bytes)
//
// 2 xrefs:
// > png_handle_gAMA @ 0x65cbec
// > png_set_gAMA_fixed @ 0x65f9c6
//
// 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_colorspace_set_gamma(int a1, int a2, int a3)
{
int v6; // r3
int v7; // r4
int result; // r0
const char *v9; // r1
int v10; // [sp+4h] [bp-8h] BYREF
if ( (unsigned int)(a3 - 16) > 0x2540BE30 )
{
v7 = *(unsigned __int16 *)(a2 + 74);
v9 = "gamma value out of range";
goto LABEL_10;
}
v6 = *(_DWORD *)(a1 + 308);
v7 = *(unsigned __int16 *)(a2 + 74);
result = v6 << 16;
if ( (v6 & 0x8000) != 0 && (v7 & 8) != 0 )
{
v9 = "duplicate";
LABEL_10:
*(_WORD *)(a2 + 74) = ~((unsigned int)~(v7 << 17) >> 17);
return png_chunk_report(a1, v9, 1);
}
if ( (v7 & 0x8000) == 0 )
{
if ( (v7 & 1) != 0 )
{
if ( !png_muldiv(&v10, *(_DWORD *)a2, (int)&stru_1869C.st_value, a3) || (result = png_gamma_significant(v10)) != 0 )
{
if ( (*(_WORD *)(a2 + 74) & 0x20) != 0 )
return png_chunk_report(a1, "gamma value does not match sRGB", 2);
result = png_chunk_report(a1, "gamma value does not match libpng estimate", *(_WORD *)(a2 + 74) & 0x20);
}
LOWORD(v7) = *(_WORD *)(a2 + 74);
}
*(_DWORD *)a2 = a3;
*(_WORD *)(a2 + 74) = v7 | 9;
}
return result;
}