//
// png_set_hIST from 0x86fa80 to 0x86fb08 (136 bytes)
//
// 1 xrefs:
// > png_handle_hIST @ 0x86dae6
//
// 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
//
_WORD *__fastcall png_set_hIST(_WORD *result, int a2, int a3)
{
bool v3; // zf
int v4; // r4
int v6; // r7
int v8; // r2
int v9; // r2
int v10; // r3
__int16 v11; // t1
v3 = a2 == 0;
if ( a2 )
v3 = result == nullptr;
v4 = v3;
if ( !v3 )
{
if ( (unsigned __int16)(*(_WORD *)(a2 + 20) - 1) > 0xFFu )
{
return (_WORD *)png_warning((int)result, "Invalid palette size, hIST allocation skipped");
}
else
{
v6 = (int)result;
png_free_data((int)result, a2, 8, v4);
result = png_malloc_warn(v6, 0x200u);
*(_DWORD *)(a2 + 204) = result;
if ( result )
{
v8 = *(unsigned __int16 *)(a2 + 20);
*(_DWORD *)(a2 + 232) |= 8u;
if ( v8 )
{
v9 = a3 - 2;
v10 = v4;
while ( 1 )
{
v11 = *(_WORD *)(v9 + 2);
v9 += 2;
result[v10++] = v11;
if ( *(unsigned __int16 *)(a2 + 20) <= v10 )
break;
result = *(_WORD **)(a2 + 204);
}
}
*(_DWORD *)(a2 + 8) |= 0x40u;
}
else
{
return (_WORD *)png_warning(v6, "Insufficient memory for hIST chunk data");
}
}
}
return result;
}