//
// cocos2d::ZipUtils::ccDeflateMemory from 0x1800a3580 to 0x1800a36dd (349 bytes)
//
// 3 xrefs:
// > cocos2d::ZipUtils::compressString @ 0x1800a3bec
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b7aac
//
// 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
//
__int64 __fastcall cocos2d::ZipUtils::ccDeflateMemory(unsigned __int8 *a1, int a2, unsigned __int8 **a3)
{
int v4; // esi
unsigned __int8 *v7; // rax
__int64 result; // rax
unsigned int v9; // ebx
unsigned __int8 *v10; // rax
unsigned int v11; // esi
unsigned __int8 *v12; // [rsp+40h] [rbp-68h] BYREF
int v13; // [rsp+48h] [rbp-60h]
unsigned __int8 *v14; // [rsp+50h] [rbp-58h]
int v15; // [rsp+58h] [rbp-50h]
__int64 v16; // [rsp+70h] [rbp-38h]
__int64 v17; // [rsp+78h] [rbp-30h]
__int64 v18; // [rsp+80h] [rbp-28h]
v4 = 0x100000;
v7 = (unsigned __int8 *)operator new(0x100000u);
*a3 = v7;
v14 = v7;
v16 = 0;
v17 = 0;
v18 = 0;
v12 = a1;
v13 = a2;
v15 = 0x100000;
result = ((__int64 (__fastcall *)(unsigned __int8 **, __int64, __int64, __int64, int, _DWORD, const char *, int))deflateInit2_)(
&v12,
0xFFFFFFFFLL,
8,
31,
8,
0,
"1.3.0",
88);
if ( !(_DWORD)result )
{
v9 = deflate(&v12, 4);
if ( v9 == 1 )
{
LABEL_7:
v11 = v4 - v15;
deflateEnd(&v12);
return v11;
}
else
{
while ( v9 + 4 > 1 )
{
if ( v9 == 2 )
{
v9 = -3;
break;
}
v10 = (unsigned __int8 *)realloc(*a3, 2 * v4);
*a3 = v10;
if ( !v10 )
{
deflateEnd(&v12);
return 4294967292LL;
}
v15 = v4;
v14 = &v10[v4];
v4 *= 2;
v9 = deflate(&v12, 4);
if ( v9 == 1 )
goto LABEL_7;
}
deflateEnd(&v12);
return v9;
}
}
return result;
}