//
// png_colorspace_set_rgb_coefficients from 0x85ef70 to 0x85f06a (250 bytes)
//
// 1 xrefs:
// > png_init_read_transformations @ 0x869ade
//
// 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:42 +0000
//
int __fastcall png_colorspace_set_rgb_coefficients(int result)
{
int v1; // r4
int v2; // r2
int v3; // r3
int v4; // r5
bool v5; // cc
int v6; // r3
int v7; // r1
int v8; // r2
int v9; // r5
int v10; // r5
int v11; // [sp+4h] [bp-1Ch] BYREF
int v12; // [sp+8h] [bp-18h] BYREF
int v13; // [sp+Ch] [bp-14h] BYREF
if ( !*(_BYTE *)(result + 801) && (*(_WORD *)(result + 998) & 2) != 0 )
{
v1 = result;
v2 = *(_DWORD *)(result + 976);
v3 = *(_DWORD *)(result + 988);
v11 = *(_DWORD *)(result + 964);
v4 = v11 + v2 + v3;
v12 = v2;
v5 = v11 <= 0;
if ( v11 >= 0 )
v5 = v4 <= 0;
v13 = v3;
if ( v5
|| !png_muldiv(&v11, v11, 0x8000, v4)
|| (unsigned int)v11 > 0x8000
|| v12 < 0
|| !png_muldiv(&v12, v12, 0x8000, v4)
|| (unsigned int)v12 > 0x8000
|| v13 < 0
|| !png_muldiv(&v13, v13, 0x8000, v4)
|| (v6 = v13, (unsigned int)v13 > 0x8000)
|| (LOWORD(v7) = v11, LOWORD(v8) = v12, result = v11 + v12, v9 = v13 + v11 + v12, v9 > 32769) )
{
png_error(v1, "internal error handling cHRM->XYZ");
}
if ( v9 == 32769 )
{
v10 = -1;
if ( v11 > v12 )
goto LABEL_18;
}
else
{
if ( v9 == 0x8000 )
{
LABEL_21:
*(_WORD *)(v1 + 802) = v7;
*(_WORD *)(v1 + 804) = v8;
return result;
}
v10 = 1;
if ( v11 > v12 )
goto LABEL_18;
}
if ( v13 <= v12 )
{
v8 = v12 + v10;
v12 = v8;
result = v11 + v8;
goto LABEL_20;
}
if ( v11 < v12 )
goto LABEL_19;
LABEL_18:
if ( v13 > v11 )
{
LABEL_19:
v6 = v13 + v10;
v13 += v10;
goto LABEL_20;
}
v7 = v11 + v10;
v11 = v7;
result = v12 + v7;
LABEL_20:
if ( v6 + result != 0x8000 )
png_error(v1, "internal error handling cHRM coefficients");
goto LABEL_21;
}
return result;
}