//
// cocos2d::extension::AssetsManager::uncompress from 0xa97880 to 0xa97c7c (1020 bytes)
//
// 2 xrefs:
// > cocos2d::extension::assetsManagerDownloadAndUncompress @ 0xa9846c
// > ??> @ 0xc3540
//
// 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 __fastcall cocos2d::extension::AssetsManager::uncompress(cocos2d::extension::AssetsManager *this)
{
const char *v1; // x1
__int64 v2; // x0
cocos2d *v3; // x19
void *v4; // x1
unsigned __int64 v5; // x26
void *v6; // x1
size_t v7; // x0
void *v8; // x1
void *v9; // x1
void *v10; // x1
unsigned int v11; // w3
FILE *v12; // x21
int v13; // w0
unsigned int v14; // w24
cocos2d *v15; // x20
char *v16; // x21
void *v18; // x1
char *v19; // x0
char *v20; // x0
unsigned int *v21; // x20
int v22; // w0
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
cocos2d *v28; // [xsp+90h] [xbp+90h] BYREF
const char *v29; // [xsp+98h] [xbp+98h] BYREF
unsigned __int64 v30; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v31; // [xsp+B0h] [xbp+B0h] BYREF
char v32[512]; // [xsp+138h] [xbp+138h] BYREF
__int64 v33; // [xsp+338h] [xbp+338h] BYREF
sub_D18D28(&v28);
sub_D15FD4(&v28, "cocos2dx-update-temp-package.zip", 32);
v2 = cocos2d::unzOpen(v28, v1);
v3 = (cocos2d *)v2;
if ( !v2 )
goto LABEL_12;
if ( (unsigned int)cocos2d::unzGetGlobalInfo(v2, &v30) )
{
cocos2d::unzClose(v3, v4);
LABEL_12:
v14 = 0;
goto LABEL_13;
}
v5 = 0;
if ( !v30 )
{
LABEL_19:
v14 = 1;
LABEL_13:
v15 = v28;
v16 = (char *)v28 - 24;
if ( (__int64 *)((char *)v28 - 24) == &qword_124B6B0 )
return v14;
goto LABEL_24;
}
while ( 1 )
{
if ( (unsigned int)cocos2d::unzGetCurrentFileInfo(v3, &v31, v32, 512, 0, 0, 0, 0) )
{
cocos2d::unzClose(v3, v6);
v14 = 0;
goto LABEL_23;
}
sub_D18D28(&v29);
v7 = strlen(v32);
sub_D15FD4(&v29, v32, v7);
if ( v32[strlen(v32) - 1] != 47 )
break;
if ( !cocos2d::extension::AssetsManager::createDirectory(this, v29) )
goto LABEL_21;
LABEL_16:
cocos2d::unzCloseCurrentFile(v3, v9);
if ( ++v5 < v30 && (unsigned int)cocos2d::unzGoToNextFile(v3, v18) )
goto LABEL_21;
v19 = (char *)(v29 - 24);
if ( v29 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v29 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v29 - 2);
*((_DWORD *)v29 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v19);
}
if ( v30 <= v5 )
goto LABEL_19;
}
if ( !(unsigned int)cocos2d::unzOpenCurrentFile(v3, v8) )
{
v12 = fopen(v29, "wb");
if ( v12 )
{
while ( 1 )
{
v13 = cocos2d::unzReadCurrentFile(v3, &v33, &elf_hash_bucket[1922], v11);
v10 = (void *)v13;
if ( v13 < 0 )
break;
if ( !v13 )
{
fclose(v12);
goto LABEL_16;
}
fwrite(&v33, v13, 1u, v12);
}
}
cocos2d::unzCloseCurrentFile(v3, v10);
}
LABEL_21:
cocos2d::unzClose(v3, v9);
v20 = (char *)(v29 - 24);
if ( v29 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_22;
if ( &pthread_create )
{
v25 = (unsigned int *)(v29 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v29 - 2);
*((_DWORD *)v29 - 2) = v26 - 1;
}
if ( v26 > 0 )
{
LABEL_22:
v14 = 0;
}
else
{
v14 = 0;
operator delete(v20);
}
LABEL_23:
v15 = v28;
v16 = (char *)v28 - 24;
if ( (__int64 *)((char *)v28 - 24) != &qword_124B6B0 )
{
LABEL_24:
if ( &pthread_create )
{
v21 = (unsigned int *)((char *)v15 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v15 - 2);
*((_DWORD *)v15 - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v16);
}
return v14;
}