//
// cocos2d::ZipUtils::ccDeflateMemory from 0x10023d7a8 to 0x10023d8b4 (268 bytes)
//
// 1 xrefs:
// > cocos2d::ZipUtils::compressString @ 0x10023d5a0
//
// 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 cocos2d::ZipUtils::ccDeflateMemory(unsigned __int8 *a1, unsigned int a2, unsigned __int8 **a3)
{
unsigned __int8 *v6; // x0
int v7; // w20
signed int i; // w21
int v9; // w0
unsigned __int8 *v10; // x0
z_stream v12; // [xsp+0h] [xbp-90h] BYREF
v6 = (unsigned __int8 *)operator new[](0x100000u);
*a3 = v6;
memset(&v12.zalloc, 0, 24);
v12.next_in = a1;
v12.avail_in = a2;
v12.next_out = v6;
v12.avail_out = 0x100000;
v7 = deflateInit2_(&v12, -1, 8, 31, 8, 0, "1.2.12", 112);
if ( !v7 )
{
for ( i = 0x100000; ; i *= 2 )
{
v9 = deflate(&v12, 4);
v7 = v9;
if ( (unsigned int)(v9 + 4) < 2 )
break;
if ( v9 == 1 )
{
v7 = i - v12.avail_out;
break;
}
if ( v9 == 2 )
{
v7 = -3;
break;
}
v10 = (unsigned __int8 *)realloc(*a3, 2 * i);
*a3 = v10;
if ( !v10 )
{
v7 = -4;
break;
}
v12.next_out = &v10[i];
v12.avail_out = i;
}
deflateEnd(&v12);
}
return v7;
}