//
// png_set_hIST from 0xe59a84 to 0xe59b54 (208 bytes)
//
// 2 xrefs:
// > png_handle_hIST @ 0xe56bac
// > ??> @ 0xeda48
//
// 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:20 +0000
//
__int64 __fastcall png_set_hIST(__int64 result, __int64 a2, const void *a3)
{
__int64 v5; // x20
void *v6; // x0
int v7; // w20
if ( result && a2 )
{
if ( (unsigned __int16)(*(_WORD *)(a2 + 32) - 1) > 0xFFu )
{
return png_warning(result, "Invalid palette size, hIST allocation skipped");
}
else
{
v5 = result;
png_free_data(result, a2, 8, 0);
v6 = png_malloc_warn(v5, 0x200u);
*(_QWORD *)(a2 + 240) = v6;
if ( v6 )
{
v7 = *(unsigned __int16 *)(a2 + 32);
*(_DWORD *)(a2 + 284) |= 8u;
if ( v7 )
memcpy(v6, a3, 2 * ((unsigned int)(v7 - 1) + 1LL));
result = *(_DWORD *)(a2 + 8) | 0x40u;
*(_DWORD *)(a2 + 8) = result;
}
else
{
return png_warning(v5, "Insufficient memory for hIST chunk data");
}
}
}
return result;
}