//
// png_icc_check_header from 0x85dde4 to 0x85e04c (616 bytes)
//
// 2 xrefs:
// > png_colorspace_set_ICC @ 0x860406
// > png_handle_iCCP @ 0x86d2ee
//
// 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:41 +0000
//
int __fastcall png_icc_check_header(int a1, int a2, int a3, unsigned int a4, unsigned __int8 *a5, char a6)
{
unsigned int v6; // r5
int v7; // r9
int v8; // r5
int v9; // r6
const char *v10; // r4
const char *v11; // r4
const char *v13; // r7
const char *v14; // [sp+28h] [bp+20h]
v6 = (a5[1] << 16) + (*a5 << 24) + a5[3] + (a5[2] << 8);
if ( v6 != a4 )
{
a4 = (a5[1] << 16) + (*a5 << 24) + a5[3] + (a5[2] << 8);
v14 = "length does not match profile";
return sub_85D108(a1, a2, a3, a4, (int)v14);
}
v7 = a2;
if ( a5[8] > 3u && v6 << 30 )
{
v11 = "invalid length";
goto LABEL_22;
}
a4 = (a5[129] << 16) + (a5[128] << 24) + a5[131] + (a5[130] << 8);
if ( a4 > 0x1555554A || v6 < 12 * a4 + 132 )
{
v11 = "tag count too large";
LABEL_22:
v14 = v11;
return sub_85D108(a1, a2, a3, a4, (int)v14);
}
a4 = (a5[65] << 16) + (a5[64] << 24) + a5[67] + (a5[66] << 8);
if ( a4 > 0xFFFE )
{
v11 = "invalid rendering intent";
goto LABEL_22;
}
v8 = a3;
v9 = a1;
if ( a4 > 3 )
sub_85D108(a1, 0, a3, a4, (int)"intent outside defined range");
a4 = (a5[37] << 16) + (a5[36] << 24) + a5[39] + (a5[38] << 8);
if ( a4 != 1633907568 )
{
v10 = "invalid signature";
goto LABEL_26;
}
if ( memcmp(a5 + 68, &unk_C20C38, 0xCu) )
sub_85D108(v9, 0, v8, 0, (int)"PCS illuminant is not D50");
a4 = (a5[17] << 16) + (a5[16] << 24) + a5[19] + (a5[18] << 8);
if ( a4 == 1196573017 )
{
if ( (a6 & 2) != 0 )
{
v10 = "Gray color space not permitted on RGB PNG";
goto LABEL_26;
}
}
else
{
if ( a4 != 1380401696 )
{
v10 = "invalid ICC profile color space";
goto LABEL_26;
}
if ( (a6 & 2) == 0 )
{
v10 = "RGB color space not permitted on grayscale PNG";
goto LABEL_26;
}
}
a4 = (a5[13] << 16) + (a5[12] << 24) + a5[15] + (a5[14] << 8);
if ( a4 == 1852662636 )
{
v13 = "unexpected NamedColor ICC profile class";
goto LABEL_36;
}
if ( a4 > 0x6E6D636C )
{
if ( a4 != 1935896178 && a4 != 1936744803 && a4 != 1886549106 )
{
LABEL_35:
v13 = "unrecognized ICC profile class";
LABEL_36:
sub_85D108(v9, 0, v8, a4, (int)v13);
}
}
else
{
if ( a4 == 1818848875 )
{
v10 = "unexpected DeviceLink ICC profile class";
goto LABEL_26;
}
if ( a4 != 1835955314 )
{
if ( a4 == 1633842036 )
{
v10 = "invalid embedded Abstract ICC profile";
LABEL_26:
a1 = v9;
a2 = v7;
a3 = v8;
v14 = v10;
return sub_85D108(a1, a2, a3, a4, (int)v14);
}
goto LABEL_35;
}
}
a4 = (a5[21] << 16) + (a5[20] << 24) + a5[23] + (a5[22] << 8);
if ( a4 != 1281450528 && a4 != 1482250784 )
{
v10 = "unexpected ICC PCS encoding";
goto LABEL_26;
}
return 1;
}