//
// cocos2d::ZipUtils::decompressString from 0x100205600 to 0x100205847 (583 bytes)
//
// 6 xrefs:
// > PlayLayer::init @ 0x1000aca55
// > GJAccountManager::onSyncAccountCompleted @ 0x1000d0de9
// > GJAccountManager::onSyncAccountCompleted @ 0x1000d0fdf
// > LevelEditorLayer::init @ 0x1000dbce6
// > GManager::loadFromCompressedString @ 0x1004ac20c
// > GameLevelManager::onGetLevelSaveDataCompleted @ 0x1005266f6
//
// 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::decompressString(std::string *this, char *a2, char a3, char a4, double a5)
{
std::string *v6; // rbx
unsigned __int8 v7; // si
std::string::size_type v8; // rax
unsigned __int8 v9; // di
std::string::size_type v11; // r15
__int64 v12; // rsi
char *v13; // rdi
std::string::pointer data; // r8
__int64 v15; // rsi
std::string::pointer v16; // rdi
const void *v17; // rsi
unsigned __int64 v18; // rdx
char *v19; // rdi
int v20; // eax
int v21; // r15d
int v22; // eax
void *v23; // r15
std::string::size_type v24; // rdx
int v26; // [rsp+Ch] [rbp-44h] BYREF
std::string v27; // [rsp+10h] [rbp-40h] BYREF
void *__p[5]; // [rsp+28h] [rbp-28h] BYREF
v6 = this;
v7 = *a2;
if ( (v7 & 1) != 0 )
{
v8 = *((_QWORD *)a2 + 1);
if ( (int)v8 <= 0 )
{
v17 = *((const void **)a2 + 2);
v18 = *((_QWORD *)a2 + 1);
goto LABEL_44;
}
__p[0] = nullptr;
v9 = v7;
if ( a3 )
goto LABEL_7;
v19 = *((char **)a2 + 2);
LABEL_21:
v20 = sub_1003292A0(v19, (unsigned int)v8, __p, 1);
goto LABEL_25;
}
if ( !v7 )
{
LABEL_42:
v6->__r_.__value_.__r.__words[2] = *((_QWORD *)a2 + 2);
*(_OWORD *)&v6->__r_.__value_.__l.0 = *(_OWORD *)a2;
return v6;
}
LODWORD(v8) = v7 >> 1;
__p[0] = nullptr;
if ( !a3 )
{
v19 = a2 + 1;
goto LABEL_21;
}
v9 = v7 >> 1;
v8 = *((_QWORD *)a2 + 1);
LABEL_7:
a5 = 0.0;
memset(&v27, 0, sizeof(v27));
v11 = v9;
if ( (v7 & 1) != 0 )
v11 = v8;
std::string::resize(&v27, v11, 0);
if ( v11 )
{
v12 = 0;
do
{
v13 = a2 + 1;
if ( (*a2 & 1) != 0 )
v13 = *((char **)a2 + 2);
data = v27.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v27.__r_.__value_.__s.0 & 1) != 0 )
data = v27.__r_.__value_.__l.__data_;
data[v12] = a4 ^ v13[v12];
++v12;
}
while ( v11 > (unsigned int)v12 );
}
if ( (*(_BYTE *)&v27.__r_.__value_.__s.0 & 1) != 0 )
{
v15 = LODWORD(v27.__r_.__value_.__r.__words[1]);
v16 = v27.__r_.__value_.__l.__data_;
}
else
{
v15 = *(_BYTE *)&v27.__r_.__value_.__l.0 >> 1;
v16 = v27.__r_.__value_.__s.__data_;
}
v20 = sub_1003292A0(v16, v15, __p, 1);
if ( (*(_BYTE *)&v27.__r_.__value_.__s.0 & 1) != 0 )
{
v21 = v20;
operator delete(v27.__r_.__value_.__l.__data_);
v20 = v21;
}
LABEL_25:
if ( v20 <= 0 )
{
if ( __p[0] )
{
operator delete[](__p[0]);
__p[0] = nullptr;
}
goto LABEL_41;
}
v27.__r_.__value_.__r.__words[0] = 0;
v26 = 0;
v22 = sub_1002065E0(__p[0], (unsigned int)v20, &v27, &v26, 0x100000);
v23 = (void *)v27.__r_.__value_.__r.__words[0];
if ( v22 )
{
if ( v27.__r_.__value_.__r.__words[0] )
operator delete[]((void *)v27.__r_.__value_.__r.__words[0]);
goto LABEL_36;
}
if ( !v27.__r_.__value_.__r.__words[0] )
{
LABEL_36:
v23 = nullptr;
goto LABEL_37;
}
v24 = v26;
if ( v26 <= 0 )
{
LABEL_37:
if ( __p[0] )
{
operator delete[](__p[0]);
__p[0] = nullptr;
}
if ( v23 )
operator delete[](v23);
LABEL_41:
if ( (*a2 & 1) == 0 )
goto LABEL_42;
v18 = *((_QWORD *)a2 + 1);
v17 = *((const void **)a2 + 2);
this = v6;
LABEL_44:
sub_100006B70(this, v17, v18, a5);
return v6;
}
*(_OWORD *)&v6->__r_.__value_.__l.0 = 0;
v6->__r_.__value_.__r.__words[2] = 0;
std::string::append(v6, (const std::string::value_type *)v23, v24);
if ( __p[0] )
{
operator delete[](__p[0]);
__p[0] = nullptr;
}
operator delete[](v23);
return v6;
}