//
// cocos2d::ZipUtils::decompressString2 from 0xb2a100 to 0xb2a3d4 (724 bytes)
//
// 4 xrefs:
// > MusicDownloadManager::parseSFXLibrary @ 0x8308d8
// > MusicDownloadManager::parseMusicLibrary @ 0x838264
// > DS_Dictionary::loadRootSubDictFromCompressedFile @ 0xb47eb4
// > ??> @ 0xb2830
//
// 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
//
__int64 *__usercall cocos2d::ZipUtils::decompressString2@(
__int64 *__return_ptr a1@,
cocos2d::ZipUtils *this@,
unsigned __int8 *a3@,
int a4@,
char a5@)
{
__int64 v6; // x19
unsigned __int64 v8; // x27
unsigned int v9; // w20
__int64 v10; // x19
cocos2d *v11; // x1
unsigned __int64 v12; // x3
int v13; // w20
char *v14; // x0
char *v15; // x0
unsigned int *v16; // x1
int v17; // w2
int v18; // w0
unsigned int *v20; // x1
int v21; // w2
void *p; // [xsp+80h] [xbp+80h] BYREF
void *v24; // [xsp+88h] [xbp+88h] BYREF
cocos2d *v25; // [xsp+90h] [xbp+90h] BYREF
LODWORD(v6) = a4;
if ( !this || a4 <= 0 )
{
sub_D153B8((int)a1, &byte_F288A0);
return a1;
}
p = nullptr;
if ( (_BYTE)a3 )
{
v24 = &byte_124B6C8;
sub_D15FD4(&v24, this, a4);
v25 = (cocos2d *)&byte_124B6C8;
v8 = *((_QWORD *)v24 - 3);
sub_D17E50(&v25, v8, 0);
if ( v8 )
{
v9 = 0;
v10 = 0;
do
{
v11 = v25;
if ( (*((_DWORD *)v25 - 2) & 0x80000000) == 0 )
{
sub_D176A8(&v25);
v11 = v25;
}
++v9;
*((_BYTE *)v11 + v10) = a5 ^ *((_BYTE *)v24 + v10);
v10 = v9;
}
while ( v8 > v9 );
}
v6 = *((_QWORD *)v25 - 3);
v13 = base64Decode(v25, (const unsigned __int8 *)(unsigned int)v6, &p, 1u);
v14 = (char *)v25 - 24;
if ( (__int64 *)((char *)v25 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)((char *)v25 - 8);
do
{
v21 = __ldaxr(v20);
v12 = (unsigned int)(v21 - 1);
}
while ( __stlxr(v12, v20) );
}
else
{
v21 = *((_DWORD *)v25 - 2);
v12 = (unsigned int)(v21 - 1);
*((_DWORD *)v25 - 2) = v12;
}
if ( v21 <= 0 )
operator delete(v14);
}
v15 = (char *)v24 - 24;
if ( (char *)v24 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v24 - 8);
do
{
v17 = __ldaxr(v16);
v12 = (unsigned int)(v17 - 1);
}
while ( __stlxr(v12, v16) );
}
else
{
v17 = *((_DWORD *)v24 - 2);
v12 = (unsigned int)(v17 - 1);
*((_DWORD *)v24 - 2) = v12;
}
if ( v17 <= 0 )
operator delete(v15);
}
}
else
{
v13 = base64Decode((cocos2d *)this, (const unsigned __int8 *)(unsigned int)a4, &p, 1u);
}
if ( v13 <= 0 )
{
if ( p )
{
operator delete[](p);
p = nullptr;
}
}
else
{
v24 = nullptr;
v18 = cocos2d::ZipUtils::ccInflateMemory(
(cocos2d::ZipUtils *)p,
(unsigned __int8 *)(unsigned int)v13,
&v24,
(unsigned __int8 **)v12);
if ( v18 > 0 )
{
v25 = (cocos2d *)&byte_124B6C8;
sub_D15FD4(&v25, v24, v18);
if ( p )
{
operator delete[](p);
p = nullptr;
}
if ( v24 )
operator delete[](v24);
goto LABEL_23;
}
if ( p )
{
operator delete[](p);
p = nullptr;
}
if ( v24 )
{
operator delete[](v24);
v24 = nullptr;
}
}
v25 = (cocos2d *)&byte_124B6C8;
sub_D15FD4(&v25, this, (int)v6);
LABEL_23:
*a1 = (__int64)v25;
return a1;
}