//
// cocos2d::ZipUtils::ccDeflateMemory from 0x1002051c0 to 0x1002052de (286 bytes)
//
// 2 xrefs:
// > cocos2d::ZipUtils::compressString @ 0x100204f8c
// > cocos2d::ZipUtils::compressString @ 0x100204fb2
//
// 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 *v4; // rax
int v5; // r14d
signed int i; // r14d
int v7; // eax
unsigned __int8 *v8; // rax
z_stream strm; // [rsp+0h] [rbp-90h] BYREF
v4 = (unsigned __int8 *)operator new[](0x100000u);
*a3 = v4;
memset(&strm.zalloc, 0, 24);
strm.next_in = a1;
strm.avail_in = a2;
strm.next_out = v4;
strm.avail_out = 0x100000;
v5 = deflateInit2_(&strm, -1, 8, 31, 8, 0, "1.2.12", 112);
if ( !v5 )
{
for ( i = 0x100000; ; i *= 2 )
{
v7 = deflate(&strm, 4);
if ( (unsigned int)(v7 + 4) < 2 )
{
v5 = v7;
goto LABEL_12;
}
if ( v7 == 1 )
{
v5 = i - strm.avail_out;
goto LABEL_12;
}
if ( v7 == 2 )
{
v5 = -3;
goto LABEL_12;
}
v8 = (unsigned __int8 *)realloc(*a3, 2 * i);
*a3 = v8;
if ( !v8 )
break;
strm.next_out = &v8[i];
strm.avail_out = i;
}
v5 = -4;
LABEL_12:
deflateEnd(&strm);
}
return v5;
}