//
// cocos2d::ZipUtils::ccDeflateMemory from 0x1001e85c0 to 0x1001e86de (286 bytes)
//
// 2 xrefs:
// > cocos2d::ZipUtils::compressString @ 0x1001e838c
// > cocos2d::ZipUtils::compressString @ 0x1001e83b2
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:26:30 +0000
//
__int64 __fastcall cocos2d::ZipUtils::ccDeflateMemory(Bytef *a1, uInt a2, void **a3, int a4)
{
Bytef *v6; // rax
unsigned int v7; // r14d
signed int i; // r14d
int v9; // eax
char *v10; // rax
z_stream strm; // [rsp+0h] [rbp-90h] BYREF
v6 = (Bytef *)operator new[](0x100000u);
*a3 = v6;
memset(&strm.zalloc, 0, 24);
strm.next_in = a1;
strm.avail_in = a2;
strm.next_out = v6;
strm.avail_out = 0x100000;
v7 = deflateInit2_(&strm, a4, 8, 31, 8, 0, "1.2.12", 112);
if ( !v7 )
{
for ( i = 0x100000; ; i *= 2 )
{
v9 = deflate(&strm, 4);
if ( (unsigned int)(v9 + 4) < 2 )
{
v7 = v9;
goto LABEL_12;
}
if ( v9 == 1 )
{
v7 = i - strm.avail_out;
goto LABEL_12;
}
if ( v9 == 2 )
{
v7 = -3;
goto LABEL_12;
}
v10 = (char *)realloc(*a3, 2 * i);
*a3 = v10;
if ( !v10 )
break;
strm.next_out = (Bytef *)&v10[i];
strm.avail_out = i;
}
v7 = -4;
LABEL_12:
deflateEnd(&strm);
}
return v7;
}