//
// png_handle_PLTE from 0xe554fc to 0xe55740 (580 bytes)
//
// 4 xrefs:
// > png_push_read_chunk @ 0xe45900
// > png_read_info @ 0xe49794
// > png_read_end @ 0xe4bc94
// > ??> @ 0x5e468
//
// 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:18 +0000
//
__int64 __fastcall png_handle_PLTE(__int64 a1, __int64 a2, unsigned int a3)
{
int v3; // w19
char v6; // w1
unsigned int v7; // w23
_BYTE *v8; // x19
char v9; // w3
char v10; // w0
__int64 result; // x0
__int64 v12; // x0
const char *v13; // x1
_BYTE v14[8]; // [xsp+58h] [xbp+58h] BYREF
_BYTE v15[3]; // [xsp+60h] [xbp+60h] BYREF
_BYTE v16[5]; // [xsp+63h] [xbp+63h] BYREF
v3 = *(_DWORD *)(a1 + 356);
if ( (v3 & 1) == 0 )
png_chunk_error(a1, "missing IHDR");
if ( (v3 & 2) != 0 )
png_chunk_error(a1, "duplicate");
if ( (v3 & 4) != 0 )
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "out of place");
}
v6 = *(_BYTE *)(a1 + 687);
*(_DWORD *)(a1 + 356) = v3 | 2;
if ( (v6 & 2) == 0 )
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "ignored in grayscale PNG");
}
if ( a3 > 0x300 || a3 != 3 * (a3 / 3) )
{
png_crc_finish((_DWORD *)a1, a3);
v13 = "invalid";
v12 = a1;
if ( *(_BYTE *)(a1 + 687) == 3 )
png_chunk_error(a1, "invalid");
return png_chunk_benign_error(v12, v13);
}
v7 = (int)a3 / 3;
if ( (int)a3 / 3 )
{
v8 = v16;
do
{
v8 += 3;
png_crc_read(a1, (__int64)v14, 3u);
v9 = v14[1];
v10 = v14[2];
*(v8 - 6) = v14[0];
*(v8 - 5) = v9;
*(v8 - 4) = v10;
}
while ( v8 != &v15[3 * v7 + 3] );
}
png_crc_finish((_DWORD *)a1, 0);
png_set_PLTE(a1, a2, v15, v7);
result = *(unsigned __int16 *)(a1 + 680);
if ( *(_WORD *)(a1 + 680) )
{
*(_WORD *)(a1 + 680) = 0;
if ( !a2 )
return png_chunk_benign_error(a1, "tRNS must be after");
goto LABEL_12;
}
if ( !a2 )
return result;
result = *(unsigned int *)(a2 + 8);
if ( (result & 0x10) != 0 )
{
*(_WORD *)(a1 + 680) = 0;
LABEL_12:
*(_WORD *)(a2 + 34) = 0;
png_chunk_benign_error(a1, "tRNS must be after");
result = *(unsigned int *)(a2 + 8);
}
if ( (result & 0x40) != 0 )
{
png_chunk_benign_error(a1, "hIST must be after");
result = *(unsigned int *)(a2 + 8);
}
if ( (result & 0x20) != 0 )
{
v12 = a1;
v13 = "bKGD must be after";
return png_chunk_benign_error(v12, v13);
}
return result;
}