//
// cocos2d::ZipUtils::compressString from 0x10023d554 to 0x10023d75c (520 bytes)
//
// 4 xrefs:
// > GJGameLevel::dataLoaded @ 0x1000aeb34
// > GJBaseGameLayer::getRecordString @ 0x100201d94
// > GManager::getCompressedSaveString @ 0x10024a764
// > EditorPauseLayer::saveLevel @ 0x10039e394
//
// 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
//
void __usercall cocos2d::ZipUtils::compressString(__int64 *a1@, char a2@, char a3@, __int64 a4@)
{
void **v6; // x22
unsigned int v8; // w11
unsigned int v9; // w1
__int64 v10; // x0
void *v11; // x20
int v12; // w0
unsigned __int64 size; // x22
__int64 v14; // x8
std::string *v15; // x11
std::string::value_type v16; // w11
std::string *v17; // x12
std::string v18; // [xsp+0h] [xbp-70h] BYREF
std::string v19; // [xsp+18h] [xbp-58h] BYREF
std::string::value_type *__s; // [xsp+30h] [xbp-40h] BYREF
void *__p; // [xsp+38h] [xbp-38h] BYREF
v6 = (void **)a1;
__p = nullptr;
v8 = *((_DWORD *)a1 + 2);
if ( *((char *)a1 + 23) >= 0 )
{
v9 = *((unsigned __int8 *)a1 + 23);
}
else
{
a1 = (__int64 *)*a1;
v9 = v8;
}
v10 = cocos2d::ZipUtils::ccDeflateMemory((unsigned __int8 *)a1, v9, (unsigned __int8 **)&__p);
if ( (int)v10 < 1 )
{
if ( __p )
operator delete[](__p);
if ( *((char *)v6 + 23) < 0 )
{
sub_1000097D0((_BYTE *)a4, *v6, (unsigned __int64)v6[1]);
return;
}
goto LABEL_32;
}
__s = nullptr;
v11 = __p;
v12 = sub_10024092C(__p, v10, &__s, 1);
if ( v12 < 1 )
{
if ( __s )
{
operator delete[](__s);
__s = nullptr;
}
if ( v11 )
operator delete[](v11);
if ( *((char *)v6 + 23) < 0 )
{
sub_1000097D0((_BYTE *)a4, *v6, (unsigned __int64)v6[1]);
return;
}
LABEL_32:
*(_OWORD *)a4 = *(_OWORD *)v6;
*(_QWORD *)(a4 + 16) = v6[2];
return;
}
*(_QWORD *)a4 = 0;
*(_QWORD *)(a4 + 8) = 0;
*(_QWORD *)(a4 + 16) = 0;
if ( (a2 & 1) != 0 )
{
memset(&v19, 0, sizeof(v19));
std::string::append(&v19, __s, (unsigned int)v12);
memset(&v18, 0, sizeof(v18));
if ( (v19.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
size = HIBYTE(v19.__r_.__value_.__r.__words[2]);
else
size = v19.__r_.__value_.__l.__size_;
std::string::resize(&v18, size, 0);
if ( size )
{
v14 = 0;
do
{
if ( (v19.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v15 = &v19;
else
v15 = (std::string *)v19.__r_.__value_.__r.__words[0];
v16 = v15->__r_.__value_.__s.__data_[v14] ^ a3;
if ( (v18.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v17 = &v18;
else
v17 = (std::string *)v18.__r_.__value_.__r.__words[0];
v17->__r_.__value_.__s.__data_[v14++] = v16;
}
while ( size > (unsigned int)v14 );
}
if ( *(char *)(a4 + 23) < 0 )
operator delete(*(void **)a4);
*(std::string *)a4 = v18;
if ( SHIBYTE(v19.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v19.__r_.__value_.__l.__data_);
}
else
{
std::string::append((std::string *)a4, __s, (unsigned int)v12);
}
if ( __s )
{
operator delete[](__s);
__s = nullptr;
}
if ( v11 )
operator delete[](v11);
}