//
// png_set_longjmp_fn from 0xbcd360 to 0xbcd424 (196 bytes)
//
// 3 xrefs:
// > cocos2d::CCImage::_initWithPngData @ 0xb0bf38
// > cocos2d::CCImage::_saveImageToPNG @ 0xb0c928
// > ??> @ 0x66750
//
// 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
//
_QWORD *__fastcall png_set_longjmp_fn(_QWORD *a1, __int64 a2, unsigned __int64 a3)
{
_QWORD *v5; // x1
__int64 v7; // x3
__int64 v9; // x0
if ( !a1 )
return nullptr;
v5 = (_QWORD *)a1[33];
if ( !v5 )
{
a1[34] = 0;
if ( a3 > 0x100 )
{
v9 = png_malloc_warn(a1, a3);
a1[33] = v9;
if ( !v9 )
return nullptr;
a1[34] = a3;
v5 = (_QWORD *)v9;
}
else
{
v5 = a1;
a1[33] = a1;
}
LABEL_6:
a1[32] = a2;
return v5;
}
v7 = a1[34];
if ( !v7 )
{
v7 = 256;
if ( v5 != a1 )
png_error((__int64)a1, "Libpng jmp_buf still allocated");
}
if ( v7 == a3 )
goto LABEL_6;
png_warning((__int64)a1, "Application jmp_buf size changed");
return nullptr;
}