//
// png_handle_sRGB from 0xe55d28 to 0xe55e10 (232 bytes)
//
// 4 xrefs:
// > png_push_read_chunk @ 0xe45978
// > png_read_info @ 0xe49834
// > png_read_end @ 0xe4bdbc
// > ??> @ 0xf6c70
//
// 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:18 +0000
//
__int64 __fastcall png_handle_sRGB(__int64 a1, __int64 a2, unsigned int a3)
{
int v3; // w3
__int64 result; // x0
unsigned __int8 v7; // [xsp+2Fh] [xbp+2Fh] BYREF
v3 = *(_DWORD *)(a1 + 356);
if ( (v3 & 1) == 0 )
png_chunk_error(a1, "missing IHDR");
if ( (v3 & 6) != 0 )
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "out of place");
}
else if ( a3 == 1 )
{
png_crc_read(a1, (__int64)&v7, 1u);
result = png_crc_finish((_DWORD *)a1, 0);
if ( !(_DWORD)result )
{
result = *(unsigned __int16 *)(a1 + 1370);
if ( (result & 0x8000) == 0 )
{
if ( (result & 4) != 0 )
{
*(_WORD *)(a1 + 1370) = result | 0x8000;
png_colorspace_sync(a1, a2);
return png_chunk_benign_error(a1, "too many profiles");
}
else
{
png_colorspace_set_sRGB(a1, a1 + 1296, v7);
return png_colorspace_sync(a1, a2);
}
}
}
}
else
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "invalid");
}
return result;
}