//
// png_write_info_before_PLTE from 0x87187c to 0x871a08 (396 bytes)
//
// 1 xrefs:
// > png_write_info @ 0x871a28
//
// 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:58 +0000
//
int __fastcall png_write_info_before_PLTE(int result, int a2)
{
bool v2; // zf
_DWORD *v3; // r5
__int16 v5; // r3
int v6; // r2
int v7; // r2
unsigned int v8; // r6
int v9; // r1
int v10; // r3
int v11; // r3
v2 = a2 == 0;
if ( a2 )
v2 = result == 0;
if ( !v2 )
{
v3 = (_DWORD *)result;
if ( (*(_DWORD *)(result + 308) & 0x400) == 0 )
{
png_write_sig();
if ( (v3[77] & 0x1000) != 0 && v3[202] )
{
png_warning((int)v3, "MNG features are not allowed in a PNG datastream");
v3[202] = 0;
}
result = png_write_IHDR(
v3,
*(_DWORD *)a2,
*(_DWORD *)(a2 + 4),
*(unsigned __int8 *)(a2 + 24),
*(unsigned __int8 *)(a2 + 25),
*(unsigned __int8 *)(a2 + 26),
*(unsigned __int8 *)(a2 + 27),
*(unsigned __int8 *)(a2 + 28));
v5 = *(_WORD *)(a2 + 114);
if ( (v5 & 0x8000) == 0 )
{
v6 = *(_DWORD *)(a2 + 8);
if ( (v5 & 8) == 0 || (v6 & 1) == 0 )
goto LABEL_11;
result = png_write_gAMA_fixed(v3, *(_DWORD *)(a2 + 40));
v5 = *(_WORD *)(a2 + 114);
if ( (v5 & 0x8000) == 0 )
{
v6 = *(_DWORD *)(a2 + 8);
LABEL_11:
if ( (v6 & 0x1000) != 0 )
{
if ( (v6 & 0x800) != 0 )
png_app_warning((int)v3, "profile matches sRGB but writing iCCP instead");
result = png_write_iCCP(v3, *(_DWORD *)(a2 + 116), *(_DWORD *)(a2 + 120));
LABEL_15:
if ( (*(_DWORD *)(a2 + 8) & 2) == 0 )
goto LABEL_16;
goto LABEL_24;
}
result = v6 << 20;
if ( (v6 & 0x800) != 0 )
{
result = png_write_sRGB(v3, *(unsigned __int16 *)(a2 + 112));
goto LABEL_15;
}
if ( (v6 & 2) == 0 )
goto LABEL_17;
LABEL_24:
result = png_write_sBIT(v3, a2 + 148, *(unsigned __int8 *)(a2 + 25));
LABEL_16:
v5 = *(_WORD *)(a2 + 114);
if ( (v5 & 0x8000) == 0 )
{
LABEL_17:
if ( (v5 & 0x10) != 0 && (*(_DWORD *)(a2 + 8) & 4) != 0 )
result = png_write_cHRM_fixed(v3, a2 + 44);
}
LABEL_20:
v7 = *(_DWORD *)(a2 + 240);
if ( v7 )
{
v8 = *(_DWORD *)(a2 + 236);
if ( v8 < v8 + 20 * v7 )
{
v9 = *(_DWORD *)(a2 + 236);
do
{
v10 = *(unsigned __int8 *)(v8 + 16);
result = v10 << 31;
if ( (v10 & 1) != 0 )
{
result = png_handle_as_unknown((int)v3, (void *)v8);
if ( result == 1 )
goto LABEL_38;
v11 = (*(unsigned __int8 *)(v8 + 3) >> 5) & 1;
if ( result == 3 )
v11 = 1;
if ( v11 || !result && v3[197] == 3 )
{
if ( !*(_DWORD *)(v8 + 12) )
png_warning((int)v3, "Writing zero-length unknown chunk");
result = png_write_chunk(v3, v8, *(_DWORD *)(v8 + 8));
v9 = *(_DWORD *)(a2 + 236);
v7 = *(_DWORD *)(a2 + 240);
}
else
{
LABEL_38:
v9 = *(_DWORD *)(a2 + 236);
v7 = *(_DWORD *)(a2 + 240);
}
}
v8 += 20;
}
while ( v8 < v9 + 20 * v7 );
}
}
v3[77] |= 0x400u;
return result;
}
}
if ( (*(_DWORD *)(a2 + 8) & 2) == 0 )
goto LABEL_20;
goto LABEL_24;
}
}
return result;
}