//
// cocos2d::ZipUtils::compressString from 0x100204f50 to 0x100205152 (514 bytes)
//
// 5 xrefs:
// > GJBaseGameLayer::getRecordString @ 0x100158b03
// > DS_Dictionary::saveRootSubDictToCompressedFile @ 0x10017c1cd
// > EditorPauseLayer::saveLevel @ 0x10029493d
// > GManager::getCompressedSaveString @ 0x1004ac0f7
// > GJGameLevel::dataLoaded @ 0x10055e947
//
// 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
//
std::string *__fastcall cocos2d::ZipUtils::compressString(
std::string *this,
unsigned __int8 *a2,
char a3,
char a4,
double a5)
{
unsigned int v9; // esi
int v10; // eax
void *v11; // rdi
void *v12; // r14
int v13; // eax
unsigned __int64 size; // r12
__int64 v15; // rdx
std::string::pointer data; // rsi
std::string::pointer v17; // rdi
std::string v19; // [rsp+0h] [rbp-70h] BYREF
void *__p; // [rsp+18h] [rbp-58h] BYREF
std::string v21; // [rsp+20h] [rbp-50h] BYREF
std::string::value_type *__s; // [rsp+40h] [rbp-30h] BYREF
__p = nullptr;
v9 = *a2;
if ( (v9 & 1) != 0 )
{
v10 = cocos2d::ZipUtils::ccDeflateMemory(
*((unsigned __int8 **)a2 + 2),
*((_DWORD *)a2 + 2),
(unsigned __int8 **)&__p);
if ( v10 <= 0 )
goto LABEL_3;
}
else
{
v10 = cocos2d::ZipUtils::ccDeflateMemory(a2 + 1, v9 >> 1, (unsigned __int8 **)&__p);
if ( v10 <= 0 )
{
LABEL_3:
v11 = __p;
if ( !__p )
{
LABEL_15:
if ( (*a2 & 1) != 0 )
{
sub_100006B70(this, *((const void **)a2 + 2), *((_QWORD *)a2 + 1), a5);
}
else
{
this->__r_.__value_.__r.__words[2] = *((_QWORD *)a2 + 2);
*(_OWORD *)&this->__r_.__value_.__l.0 = *(_OWORD *)a2;
}
return this;
}
LABEL_14:
operator delete[](v11);
goto LABEL_15;
}
}
__s = nullptr;
v12 = __p;
v13 = sub_100329370(__p, (unsigned int)v10, &__s, 1);
if ( v13 <= 0 )
{
if ( __s )
{
operator delete[](__s);
__s = nullptr;
}
if ( !v12 )
goto LABEL_15;
v11 = v12;
goto LABEL_14;
}
*(_OWORD *)&this->__r_.__value_.__l.0 = 0;
this->__r_.__value_.__r.__words[2] = 0;
if ( a3 )
{
memset(&v21, 0, sizeof(v21));
std::string::append(&v21, __s, (unsigned int)v13);
memset(&v19, 0, sizeof(v19));
if ( (*(_BYTE *)&v21.__r_.__value_.__s.0 & 1) != 0 )
size = v21.__r_.__value_.__l.__size_;
else
size = *(_BYTE *)&v21.__r_.__value_.__l.0 >> 1;
std::string::resize(&v19, size, 0);
if ( size )
{
v15 = 0;
do
{
data = v21.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v21.__r_.__value_.__s.0 & 1) != 0 )
data = v21.__r_.__value_.__l.__data_;
v17 = v19.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v19.__r_.__value_.__s.0 & 1) != 0 )
v17 = v19.__r_.__value_.__l.__data_;
v17[v15] = a4 ^ data[v15];
++v15;
}
while ( size > (unsigned int)v15 );
}
if ( (*(_BYTE *)&this->__r_.__value_.__s.0 & 1) != 0 )
operator delete(this->__r_.__value_.__l.__data_);
*this = v19;
if ( (*(_BYTE *)&v21.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v21.__r_.__value_.__l.__data_);
}
else
{
std::string::append(this, __s, (unsigned int)v13);
}
if ( __s )
{
operator delete[](__s);
__s = nullptr;
}
if ( v12 )
operator delete[](v12);
return this;
}