//
// png_set_PLTE from 0x86ffbc to 0x870076 (186 bytes)
//
// 3 xrefs:
// > png_handle_PLTE @ 0x86cafc
// > sub_8713B8 @ 0x871702
// > sub_8713B8 @ 0x871868
//
// 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:57 +0000
//
_DWORD *__fastcall png_set_PLTE(_DWORD *result, int a2, const void *a3, unsigned int a4)
{
bool v4; // zf
void *v8; // r6
_BOOL4 v9; // r2
_DWORD *v10; // r12
int v11; // r3
int v12; // r2
void *v13; // r0
v4 = a2 == 0;
if ( a2 )
v4 = result == nullptr;
if ( !v4 )
{
if ( a4 <= 0x100 )
{
v8 = result;
v9 = (int)a4 > 0;
if ( a3 )
v9 = 0;
if ( !v9 )
{
if ( a4 )
{
png_free_data((int)result, a2, 4096, 0);
v13 = png_calloc(v8, 0x300u);
*((_DWORD *)v8 + 129) = v13;
result = memcpy(v13, a3, 3 * a4);
v10 = result;
goto LABEL_11;
}
if ( (result[202] & 1) != 0 )
{
png_free_data((int)result, a2, 4096, 0);
result = png_calloc(v8, 0x300u);
v10 = result;
*((_DWORD *)v8 + 129) = result;
LABEL_11:
v11 = *(_DWORD *)(a2 + 8);
v12 = *(_DWORD *)(a2 + 232) | 0x1000;
*((_WORD *)v8 + 260) = a4;
*(_WORD *)(a2 + 20) = a4;
*(_DWORD *)(a2 + 16) = v10;
*(_DWORD *)(a2 + 232) = v12;
*(_DWORD *)(a2 + 8) = v11 | 8;
return result;
}
}
png_error((int)result, "Invalid palette");
}
if ( *(_BYTE *)(a2 + 25) == 3 )
png_error((int)result, "Invalid palette length");
return (_DWORD *)png_warning((int)result, "Invalid palette length");
}
return result;
}