//
// cocos2d::ZipUtils::compressString from 0x1002da590 to 0x1002da79c (524 bytes)
//
// 16 xrefs:
// > sub_1000AF6A4 @ 0x1000af6d0
// > sub_1000B2924 @ 0x1000b2bb0
// > GJGameLevel::copyLevelInfo @ 0x1000d19bc
// > GJGameLevel::dataLoaded @ 0x1000d3228
// > GJGameLevel::encodeWithCoder @ 0x1000d3a70
// > GJGameLevel::encodeWithCoder @ 0x1000d3c18
// > PlayLayer::writePersistentSave @ 0x10014aa2c
// > PlayLayer::addLiveStartPosObject @ 0x10014b204
// > LocalLevelManager::exportLevelsToFile @ 0x100260d5c
// > GJBaseGameLayer::getRecordString @ 0x10029eaf8
// > GManager::getCompressedSaveString @ 0x1002e7988
// > LevelEditorLayer::saveLevel @ 0x100404c64
// > LevelEditorLayer::prepareSaveData @ 0x10040bdf8
// > sub_1004149FC @ 0x100414a6c
// > sub_100414B90 @ 0x100414c04
// > sub_1004CAA78 @ 0x1004caaa8
//
// 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 11:02:44 +0000
//
void __usercall cocos2d::ZipUtils::compressString(
__int64 *a1@,
char a2@,
__int64 a3@,
char a4@,
__int64 a5@)
{
void **v7; // x22
unsigned int v9; // w11
__int64 v10; // x1
__int64 v11; // x0
void *v12; // x20
int v13; // w0
unsigned __int64 size; // x22
__int64 v15; // x8
std::string *v16; // x11
std::string::value_type v17; // w11
std::string *v18; // x12
std::string v19; // [xsp+0h] [xbp-70h] BYREF
std::string v20; // [xsp+18h] [xbp-58h] BYREF
std::string::value_type *__s; // [xsp+30h] [xbp-40h] BYREF
void *__p; // [xsp+38h] [xbp-38h] BYREF
v7 = (void **)a1;
__p = nullptr;
v9 = *((_DWORD *)a1 + 2);
if ( *((char *)a1 + 23) >= 0 )
{
v10 = *((unsigned __int8 *)a1 + 23);
}
else
{
a1 = (__int64 *)*a1;
v10 = v9;
}
v11 = cocos2d::ZipUtils::ccDeflateMemory(a1, v10, &__p, a3);
if ( (int)v11 < 1 )
{
if ( __p )
operator delete[](__p);
if ( *((char *)v7 + 23) < 0 )
{
sub_1000097D0((_BYTE *)a5, *v7, (unsigned __int64)v7[1]);
return;
}
goto LABEL_32;
}
__s = nullptr;
v12 = __p;
v13 = sub_1002DD990(__p, v11, &__s, 1);
if ( v13 < 1 )
{
if ( __s )
{
operator delete[](__s);
__s = nullptr;
}
if ( v12 )
operator delete[](v12);
if ( *((char *)v7 + 23) < 0 )
{
sub_1000097D0((_BYTE *)a5, *v7, (unsigned __int64)v7[1]);
return;
}
LABEL_32:
*(_OWORD *)a5 = *(_OWORD *)v7;
*(_QWORD *)(a5 + 16) = v7[2];
return;
}
*(_QWORD *)a5 = 0;
*(_QWORD *)(a5 + 8) = 0;
*(_QWORD *)(a5 + 16) = 0;
if ( (a2 & 1) != 0 )
{
memset(&v20, 0, sizeof(v20));
std::string::append(&v20, __s, (unsigned int)v13);
memset(&v19, 0, sizeof(v19));
if ( (v20.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
size = HIBYTE(v20.__r_.__value_.__r.__words[2]);
else
size = v20.__r_.__value_.__l.__size_;
std::string::resize(&v19, size, 0);
if ( size )
{
v15 = 0;
do
{
if ( (v20.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v16 = &v20;
else
v16 = (std::string *)v20.__r_.__value_.__r.__words[0];
v17 = v16->__r_.__value_.__s.__data_[v15] ^ a4;
if ( (v19.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v18 = &v19;
else
v18 = (std::string *)v19.__r_.__value_.__r.__words[0];
v18->__r_.__value_.__s.__data_[v15++] = v17;
}
while ( size > (unsigned int)v15 );
}
if ( *(char *)(a5 + 23) < 0 )
operator delete(*(void **)a5);
*(std::string *)a5 = v19;
if ( SHIBYTE(v20.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v20.__r_.__value_.__l.__data_);
}
else
{
std::string::append((std::string *)a5, __s, (unsigned int)v13);
}
if ( __s )
{
operator delete[](__s);
__s = nullptr;
}
if ( v12 )
operator delete[](v12);
}