//
// png_handle_sRGB from 0x86d058 to 0x86d0f8 (160 bytes)
//
// 3 xrefs:
// > png_push_read_chunk @ 0x862ad0
// > png_read_info @ 0x86596e
// > png_read_end @ 0x867486
//
// 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:55 +0000
//
int __fastcall png_handle_sRGB(int a1, int a2, unsigned int a3)
{
int v4; // r3
int result; // r0
int v7; // r3
unsigned __int8 v8; // [sp+7h] [bp-1h] BYREF
v4 = *(_DWORD *)(a1 + 308);
if ( (v4 & 1) == 0 )
png_chunk_error(a1, "missing IHDR");
if ( (v4 & 6) != 0 )
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "out of place");
}
else if ( a3 == 1 )
{
png_crc_read((_DWORD *)a1, (int)&v8, 1);
result = png_crc_finish((_DWORD *)a1, 0);
if ( !result )
{
v7 = *(unsigned __int16 *)(a1 + 998);
if ( (v7 & 0x8000) == 0 )
{
if ( (v7 & 4) != 0 )
{
*(_WORD *)(a1 + 998) = ~((unsigned int)~(v7 << 17) >> 17);
png_colorspace_sync(a1, a2);
return png_chunk_benign_error(a1, "too many profiles");
}
else
{
png_colorspace_set_sRGB(a1, a1 + 924, v8);
return png_colorspace_sync(a1, a2);
}
}
}
}
else
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "invalid");
}
return result;
}