//
// png_icc_set_sRGB from 0x6501a0 to 0x650340 (416 bytes)
//
// 2 xrefs:
// > png_colorspace_set_ICC @ 0x6503aa
// > png_handle_iCCP @ 0x65d39c
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall png_icc_set_sRGB(int result, int a2, unsigned __int8 *a3, int a4)
{
int v5; // r8
int v7; // r9
int v8; // r5
int v9; // r1
int v10; // lr
_DWORD *i; // r4
int *v12; // r5
int v13; // r0
int v14; // r0
int *v15; // r5
v5 = result;
if ( ((*(unsigned __int8 *)(result + 744) >> 4) & 3) != 3 )
{
v7 = 0;
v8 = 0;
result = a3[85] << 16;
v9 = 0x10000;
v10 = result + (a3[84] << 24) + a3[87] + (a3[86] << 8);
for ( i = &unk_9DE6F0; ; i += 8 )
{
if ( i[3] == v10 )
{
result = a3[91];
if ( (a3[89] << 16) + (a3[88] << 24) + result + (a3[90] << 8) == i[4] )
{
result = (a3[93] << 16) + (a3[92] << 24) + a3[95] + (a3[94] << 8);
if ( result == i[5] )
{
result = (a3[97] << 16) + (a3[96] << 24) + a3[99] + (a3[98] << 8);
if ( result == i[6] )
{
if ( !v7 )
{
result = (a3[1] << 16) + (*a3 << 24) + a3[3];
v7 = result + (a3[2] << 8);
v9 = (a3[65] << 16) + (a3[64] << 24) + a3[67] + (a3[66] << 8);
}
if ( i[2] == v7 && *((unsigned __int16 *)i + 15) == v9 )
break;
}
}
}
}
if ( ++v8 == 7 )
return result;
}
if ( !a4 )
{
v13 = adler32(0, 0, 0);
a4 = adler32(v13, a3, v7);
}
v12 = &dword_9DE628[8 * v8];
if ( v12[50] == a4 && (v14 = crc32(0, 0, 0), crc32(v14, a3, v7) == v12[51]) )
{
v15 = v12 + 56;
if ( *((_BYTE *)v15 + 5) )
{
png_chunk_report(v5, "known incorrect sRGB profile", 2);
}
else if ( !*((_BYTE *)v15 + 4) )
{
png_chunk_report(v5, "out-of-date sRGB profile with no signature", *((unsigned __int8 *)v15 + 4));
}
return png_colorspace_set_sRGB(v5, a2, (a3[65] << 16) + (a3[64] << 24) + a3[67] + (a3[66] << 8));
}
else
{
return png_chunk_report(v5, "Not recognizing known sRGB profile that has been edited", 0);
}
}
return result;
}