//
// png_colorspace_set_sRGB from 0x860088 to 0x8601fe (374 bytes)
//
// 4 xrefs:
// > png_icc_set_sRGB @ 0x8603ae
// > png_handle_sRGB @ 0x86d0e2
// > png_set_sRGB @ 0x8700c6
// > png_set_sRGB_gAMA_and_cHRM @ 0x8700ea
//
// 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_sRGB(int a1, int a2, unsigned int a3)
{
__int16 v4; // r6
int v5; // r8
__int16 v6; // r5
int v9; // [sp+Ch] [bp-8h] BYREF
v4 = *(_WORD *)(a2 + 74);
if ( v4 < 0 )
return 0;
v6 = a3;
if ( a3 > 3 )
return sub_85D108(a1, a2, (int)"sRGB", a3, (int)"invalid sRGB rendering intent");
if ( (v4 & 4) != 0 && *(unsigned __int16 *)(a2 + 72) != a3 )
return sub_85D108(a1, a2, (int)"sRGB", a3, (int)"inconsistent rendering intents");
if ( (v4 & 0x20) == 0 )
{
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 ( !png_muldiv(&v9, *(_DWORD *)a2, (int)&stru_1869C.st_value, 45455) || png_gamma_significant(v9) )
{
png_chunk_report(a1, "gamma value does not match sRGB", 2);
v4 = *(_WORD *)(a2 + 74);
}
else
{
v4 = *(_WORD *)(a2 + 74);
}
}
*(_WORD *)(a2 + 72) = v6;
v5 = 1;
*(_DWORD *)(a2 + 4) = 64000;
*(_DWORD *)(a2 + 8) = 33000;
*(_DWORD *)(a2 + 12) = 30000;
*(_DWORD *)(a2 + 16) = 60000;
*(_DWORD *)(a2 + 20) = 15000;
*(_DWORD *)(a2 + 24) = 6000;
*(_DWORD *)(a2 + 28) = 31270;
*(_DWORD *)(a2 + 32) = 32900;
*(_DWORD *)(a2 + 36) = 41239;
*(_DWORD *)(a2 + 40) = 21264;
*(_DWORD *)(a2 + 44) = 1933;
*(_DWORD *)(a2 + 48) = 35758;
*(_DWORD *)(a2 + 52) = 71517;
*(_DWORD *)(a2 + 56) = 11919;
*(_DWORD *)(a2 + 60) = 18048;
*(_DWORD *)(a2 + 64) = 7219;
*(_DWORD *)(a2 + 68) = 95053;
*(_WORD *)(a2 + 74) = v4 | 0xE7;
*(_DWORD *)a2 = 45455;
return v5;
}
png_benign_error(a1, "duplicate sRGB information ignored");
return 0;
}