//
// cocos2d::ZipUtils::ccDeflateMemory from 0x1800a6f20 to 0x1800a7090 (368 bytes)
//
// 3 xrefs:
// > cocos2d::ZipUtils::compressString @ 0x1800a75bc
// > ??> @ 0x18014cf68
// > ??> @ 0x1801c1d58
//
// 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 11:22:16 +0000
//
__int64 __fastcall cocos2d::ZipUtils::ccDeflateMemory(
unsigned __int8 *a1,
int a2,
unsigned __int8 **a3,
unsigned int a4)
{
int v5; // ebp
unsigned __int8 *v9; // rax
__int64 result; // rax
unsigned int v11; // ebx
unsigned __int8 *v12; // rax
unsigned int v13; // ebp
unsigned __int8 *v14; // [rsp+40h] [rbp-68h] BYREF
int v15; // [rsp+48h] [rbp-60h]
unsigned __int8 *v16; // [rsp+50h] [rbp-58h]
int v17; // [rsp+58h] [rbp-50h]
__int64 v18; // [rsp+70h] [rbp-38h]
__int64 v19; // [rsp+78h] [rbp-30h]
__int64 v20; // [rsp+80h] [rbp-28h]
v5 = 0x100000;
v9 = (unsigned __int8 *)sub_1800E4C6C(0x100000u);
*a3 = v9;
v16 = v9;
v18 = 0;
v19 = 0;
v20 = 0;
v14 = a1;
v15 = a2;
v17 = 0x100000;
result = ((__int64 (__fastcall *)(unsigned __int8 **, _QWORD, __int64, __int64, int, _DWORD, const char *, int))deflateInit2_)(
&v14,
a4,
8,
31,
8,
0,
"1.3.0",
88);
if ( !(_DWORD)result )
{
v11 = deflate(&v14, 4);
if ( v11 == 1 )
{
LABEL_7:
v13 = v5 - v17;
deflateEnd(&v14);
return v13;
}
else
{
while ( v11 + 4 > 1 )
{
if ( v11 == 2 )
{
v11 = -3;
break;
}
v12 = (unsigned __int8 *)realloc(*a3, 2 * v5);
*a3 = v12;
if ( !v12 )
{
deflateEnd(&v14);
return 4294967292LL;
}
v17 = v5;
v16 = &v12[v5];
v5 *= 2;
v11 = deflate(&v14, 4);
if ( v11 == 1 )
goto LABEL_7;
}
deflateEnd(&v14);
return v11;
}
}
return result;
}