//
// png_colorspace_set_sRGB from 0xe3ff40 to 0xe401c4 (644 bytes)
//
// 5 xrefs:
// > png_icc_set_sRGB @ 0xe4048c
// > png_handle_sRGB @ 0xe55df0
// > png_set_sRGB @ 0xe5a3b8
// > png_set_sRGB_gAMA_and_cHRM @ 0xe5a3fc
// > ??> @ 0x58bb8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:10:02 +0000
//
__int64 __fastcall png_colorspace_set_sRGB(__int64 a1, __int64 a2, unsigned int a3)
{
__int16 v4; // w2
int v8; // [xsp+3Ch] [xbp+3Ch] BYREF
v4 = *(_WORD *)(a2 + 74);
if ( v4 < 0 )
return 0;
if ( a3 > 3 )
return sub_E3B438(a1, a2, (__int64)"sRGB", a3, (__int64)"invalid sRGB rendering intent");
if ( (v4 & 4) != 0 && *(unsigned __int16 *)(a2 + 72) != a3 )
return sub_E3B438(a1, a2, (__int64)"sRGB", a3, (__int64)"inconsistent rendering intents");
if ( (v4 & 0x20) != 0 )
{
png_benign_error(a1, "duplicate sRGB information ignored");
return 0;
}
else
{
if ( (v4 & 2) != 0
&& ((unsigned int)(*(_DWORD *)(a2 + 28) - 31170) > 0xC8
|| (unsigned int)(*(_DWORD *)(a2 + 32) - 32800) > 0xC8
|| (unsigned int)(*(_DWORD *)(a2 + 4) - 63900) > 0xC8
|| (unsigned int)(*(_DWORD *)(a2 + 8) - 32900) > 0xC8
|| (unsigned int)(*(_DWORD *)(a2 + 12) - 29900) > 0xC8
|| (unsigned int)(*(_DWORD *)(a2 + 16) - 59900) > 0xC8
|| (unsigned int)(*(_DWORD *)(a2 + 20) - 14900) > 0xC8
|| (unsigned int)(*(_DWORD *)(a2 + 24) - 5900) > 0xC8) )
{
png_chunk_report(a1, "cHRM chunk does not match sRGB", 2);
v4 = *(_WORD *)(a2 + 74);
}
if ( (v4 & 1) != 0 )
{
if ( !(unsigned int)png_muldiv(&v8, *(_DWORD *)a2, 100000, 45455) || png_gamma_significant(v8) )
{
png_chunk_report(a1, "gamma value does not match sRGB", 2);
v4 = *(_WORD *)(a2 + 74);
}
else
{
v4 = *(_WORD *)(a2 + 74);
}
}
*(_WORD *)(a2 + 72) = a3;
*(_QWORD *)a2 = 0xFA000000B18FLL;
*(_QWORD *)(a2 + 8) = 0x7530000080E8LL;
*(_QWORD *)(a2 + 16) = 64424509500000LL;
*(_QWORD *)(a2 + 24) = 0x7A2600001770LL;
*(_QWORD *)(a2 + 32) = 0xA11700008084LL;
*(_QWORD *)(a2 + 40) = 0x78D00005310LL;
*(_QWORD *)(a2 + 48) = 0x1175D00008BAELL;
*(_QWORD *)(a2 + 56) = 0x468000002E8FLL;
*(_QWORD *)(a2 + 64) = 0x1734D00001C33LL;
*(_WORD *)(a2 + 74) = v4 | 0xE7;
return 1;
}
}