//
// png_colorspace_set_gamma from 0x85fe74 to 0x85ff24 (176 bytes)
//
// 2 xrefs:
// > png_handle_gAMA @ 0x86cc6c
// > png_set_gAMA_fixed @ 0x86fa46
//
// 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:42 +0000
//
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;
}