//
// png_write_hIST from 0x665228 to 0x6652c4 (156 bytes)
//
// 1 xrefs:
// > png_write_info @ 0x661afa
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall png_write_hIST(int a1, __int16 *a2, int a3)
{
int v5; // r7
__int16 v7; // t1
_BYTE v9[4]; // [sp+0h] [bp-8h] BYREF
_BYTE v10[4]; // [sp+4h] [bp-4h] BYREF
if ( *(unsigned __int16 *)(a1 + 520) < a3 )
return png_warning(a1, "Invalid number of histogram entries specified");
v5 = 2 * a3;
*(_DWORD *)(a1 + 900) = 34;
png_save_uint_32(v9, 2 * a3);
png_save_uint_32(v10, 1749635924);
png_write_data(a1);
*(_DWORD *)(a1 + 476) = 1749635924;
png_reset_crc(a1);
png_calculate_crc((_DWORD *)a1, (int)v10, 4);
if ( a3 > 0 )
v5 += (int)a2;
*(_DWORD *)(a1 + 900) = 66;
if ( a3 > 0 )
{
do
{
v7 = *a2++;
png_save_uint_16(v9, v7);
png_write_chunk_data((_DWORD *)a1, (int)v9, 2);
}
while ( a2 != (__int16 *)v5 );
}
return png_write_chunk_end(a1);
}