//
// cocos2d::ZipUtils::compressString from 0xd9b678 to 0xd9b97c (772 bytes)
//
// 18 xrefs:
// > GManager::getCompressedSaveString @ 0x6a8c94
// > PlayLayer::addLiveStartPosObject @ 0x700618
// > PlayLayer::writePersistentSave @ 0x70334c
// > sub_7888C8 @ 0x78898c
// > sub_7985D0 @ 0x79869c
// > LevelEditorLayer::prepareSaveData @ 0x7a4ca0
// > LevelEditorLayer::saveLevel @ 0x7a7c1c
// > GameLevelManager::uploadDeathData @ 0x81e80c
// > GJGameLevel::copyLevelInfo @ 0x82d5a8
// > sub_82F964 @ 0x82f9a8
// > GJGameLevel::dataLoaded @ 0x83dc8c
// > GJGameLevel::encodeWithCoder @ 0x856e40
// > GJGameLevel::encodeWithCoder @ 0x857120
// > LocalLevelManager::exportLevelsToFile @ 0x9139a4
// > GJBaseGameLayer::getRecordString @ 0x9ef1d0
// > EditorSFXManager::serializeCompressed @ 0xcc2fe4
// > DS_Dictionary::saveRootSubDictToCompressedFile @ 0xdb9a38
// > ??> @ 0xd2970
//
// This function is hookable on this platform (idp: arm, 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 13:08:26 +0000
//
__int64 *__usercall cocos2d::ZipUtils::compressString@(
__int64 *__return_ptr a1@,
__int64 a2@,
unsigned __int8 a3@,
unsigned int a4@,
char a5@)
{
int v6; // w22
unsigned int v9; // w0
unsigned __int64 v10; // x1
bool v11; // cc
void *v12; // x0
int v13; // w0
unsigned __int64 v14; // x25
unsigned int v15; // w4
__int64 v16; // x0
char *v17; // x1
char *v18; // x2
char *v19; // x23
int v20; // w22
char *v21; // x0
__int64 v22; // x2
size_t v23; // x2
void *v24; // x0
__int64 v25; // x1
unsigned int v27; // w0
__int64 v28; // x1
unsigned __int64 v29; // x0
unsigned __int64 v30; // x0
void *v31; // [xsp+50h] [xbp+50h] BYREF
void *v32; // [xsp+58h] [xbp+58h] BYREF
__int64 v33; // [xsp+60h] [xbp+60h] BYREF
__int64 v34; // [xsp+68h] [xbp+68h]
char *v35; // [xsp+70h] [xbp+70h]
__int64 v36; // [xsp+78h] [xbp+78h] BYREF
unsigned __int64 v37; // [xsp+80h] [xbp+80h]
void *v38; // [xsp+88h] [xbp+88h]
__int64 v39; // [xsp+90h] [xbp+90h] BYREF
__int64 v40; // [xsp+98h] [xbp+98h]
char *v41; // [xsp+A0h] [xbp+A0h]
v6 = a3;
v31 = nullptr;
if ( (*(_BYTE *)a2 & 1) != 0 )
{
v9 = cocos2d::ZipUtils::ccDeflateMemory(
*(cocos2d::ZipUtils **)(a2 + 16),
*(unsigned __int8 **)(a2 + 8),
&v31,
(unsigned __int8 **)a4);
v10 = v9;
v11 = (int)v9 <= 0;
v12 = v31;
if ( !v11 )
goto LABEL_3;
LABEL_31:
if ( !v12 )
goto LABEL_33;
goto LABEL_32;
}
v27 = cocos2d::ZipUtils::ccDeflateMemory(
(cocos2d::ZipUtils *)(a2 + 1),
(unsigned __int8 *)(*(_BYTE *)a2 >> 1),
&v31,
(unsigned __int8 **)a4);
v10 = v27;
v11 = (int)v27 <= 0;
v12 = v31;
if ( v11 )
goto LABEL_31;
LABEL_3:
v32 = nullptr;
v13 = base64Encode((__int64)v12, (const unsigned __int8 *)v10, &v32, 1u);
if ( v13 > 0 )
{
v33 = 0;
v34 = 0;
v35 = nullptr;
if ( !v6 )
{
std::string::append((__int64)&v33, v32, v13);
goto LABEL_24;
}
v36 = 0;
v37 = 0;
v38 = nullptr;
std::string::append((__int64)&v36, v32, v13);
v39 = 0;
v40 = 0;
v14 = (unsigned __int8)v36 >> 1;
v41 = nullptr;
if ( (v36 & 1) != 0 )
v14 = v37;
std::string::resize((unsigned __int8 *)&v39, v14, 0);
if ( v14 )
{
v15 = 0;
v16 = 0;
do
{
++v15;
v17 = v41;
v18 = (char *)v38;
if ( (v39 & 1) == 0 )
v17 = (char *)&v39 + 1;
if ( (v36 & 1) == 0 )
v18 = (char *)&v36 + 1;
v17[v16] = a5 ^ v18[v16];
v16 = v15;
}
while ( v14 > v15 );
}
if ( (v33 & 1) != 0 )
{
*v35 = 0;
v34 = 0;
if ( (v33 & 1) != 0 )
{
v19 = v35;
v20 = 1;
v21 = (char *)&v33 + 1;
goto LABEL_17;
}
v29 = (unsigned __int8)v33 >> 1;
if ( v29 > 0x16 )
{
v30 = (v29 + 16) & 0xFFFFFFFFFFFFFFF0LL;
if ( v30 != 23 )
{
v21 = (char *)operator new(v30);
v20 = v33 & 1;
if ( (v33 & 1) == 0 )
{
v19 = (char *)&v33 + 1;
v22 = (unsigned __int8)v33 >> 1;
goto LABEL_18;
}
v19 = v35;
LABEL_17:
v22 = v34;
LABEL_18:
v23 = v22 + 1;
if ( v23 )
memcpy(v21, v19, v23);
if ( v20 )
operator delete(v19);
}
}
}
v33 = v39;
v34 = v40;
v35 = v41;
if ( (v36 & 1) != 0 )
operator delete(v38);
LABEL_24:
if ( v32 )
{
operator delete[](v32);
v32 = nullptr;
v24 = v31;
if ( !v31 )
{
LABEL_27:
a1[2] = (__int64)v35;
v25 = v34;
*a1 = v33;
a1[1] = v25;
return a1;
}
}
else
{
v24 = v31;
if ( !v31 )
goto LABEL_27;
}
operator delete[](v24);
goto LABEL_27;
}
if ( v32 )
{
operator delete[](v32);
v32 = nullptr;
}
v12 = v31;
if ( v31 )
{
LABEL_32:
operator delete[](v12);
v31 = nullptr;
}
LABEL_33:
*a1 = 0;
a1[1] = 0;
a1[2] = 0;
if ( (*(_BYTE *)a2 & 1) != 0 )
{
std::string::__init(a1, *(void **)(a2 + 16), *(_QWORD *)(a2 + 8));
}
else
{
v28 = *(_QWORD *)(a2 + 8);
*a1 = *(_QWORD *)a2;
a1[1] = v28;
a1[2] = *(_QWORD *)(a2 + 16);
}
return a1;
}