//
// png_colorspace_set_rgb_coefficients from 0xe3e518 to 0xe3e698 (384 bytes)
//
// 2 xrefs:
// > png_init_read_transformations @ 0xe4ed5c
// > ??> @ 0x5b690
//
// 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:01 +0000
//
__int64 __fastcall png_colorspace_set_rgb_coefficients(__int64 result)
{
int v1; // w1
__int64 v2; // x19
int v3; // w2
unsigned int v4; // w0
int v5; // w20
signed int v6; // w2
int v7; // w1
int v8; // w3
int v9; // w4
int v10; // w4
signed int v11; // [xsp+24h] [xbp+24h] BYREF
int v12; // [xsp+28h] [xbp+28h] BYREF
unsigned int v13; // [xsp+2Ch] [xbp+2Ch] BYREF
if ( !*(_BYTE *)(result + 1097) && (*(_WORD *)(result + 1370) & 2) != 0 )
{
v1 = *(_DWORD *)(result + 1336);
v2 = result;
v3 = *(_DWORD *)(result + 1348);
v4 = *(_DWORD *)(result + 1360);
v11 = v1;
v5 = v4 + v1 + v3;
v12 = v3;
v13 = v4;
if ( v5 <= 0
|| v1 < 0
|| !(unsigned int)png_muldiv(&v11, v1, 0x8000, v5)
|| (unsigned int)v11 > 0x8000
|| v12 < 0
|| !(unsigned int)png_muldiv(&v12, v12, 0x8000, v5)
|| (unsigned int)v12 > 0x8000
|| (v13 & 0x80000000) != 0
|| !(unsigned int)png_muldiv(&v13, v13, 0x8000, v5)
|| (result = v13, v13 > 0x8000)
|| (LOWORD(v6) = v11, LOWORD(v7) = v12, v8 = v11 + v12, v9 = v13 + v11 + v12, v9 > 32769) )
{
png_error(v2, "internal error handling cHRM->XYZ");
}
if ( v9 == 32769 )
{
v10 = -1;
if ( v11 > v12 )
goto LABEL_17;
}
else
{
if ( v9 == 0x8000 )
{
LABEL_20:
*(_WORD *)(v2 + 1098) = v6;
*(_WORD *)(v2 + 1100) = v7;
return result;
}
v10 = 1;
if ( v11 > v12 )
goto LABEL_17;
}
if ( (int)v13 <= v12 )
{
v7 = v12 + v10;
v12 = v7;
v8 = v11 + v7;
goto LABEL_19;
}
if ( v11 < v12 )
goto LABEL_18;
LABEL_17:
if ( (int)v13 > v11 )
{
LABEL_18:
LODWORD(result) = v13 + v10;
v13 += v10;
goto LABEL_19;
}
v6 = v11 + v10;
v11 = v6;
v8 = v12 + v6;
LABEL_19:
result = (unsigned int)(v8 + result);
if ( (_DWORD)result != 0x8000 )
png_error(v2, "internal error handling cHRM coefficients");
goto LABEL_20;
}
return result;
}