//
// png_gamma_16bit_correct from 0x6504d0 to 0x65054c (124 bytes)
//
// 14 xrefs:
// > png_gamma_correct @ 0x650572
// > png_build_gamma_table @ 0x65080a
// > sub_6535E0 @ 0x653658
// > sub_6535E0 @ 0x653664
// > sub_6535E0 @ 0x653672
// > sub_653A0C @ 0x653a3c
// > sub_653A0C @ 0x653a62
// > sub_653BE8 @ 0x653c72
// > sub_653BE8 @ 0x653c80
// > sub_653BE8 @ 0x653c90
// > sub_654424 @ 0x6550dc
// > sub_654424 @ 0x6550e6
// > sub_654424 @ 0x6550f0
// > sub_654424 @ 0x655462
//
// 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_gamma_16bit_correct(int result, int a2)
{
double v2; // r0
if ( (unsigned int)(result - 1) > 0xFFFD )
return (unsigned __int16)result;
v2 = pow((double)result / 65535.0, (double)a2 * 0.00001);
return (unsigned __int16)(unsigned int)floor(v2 * 65535.0 + 0.5);
}