//
// cocos2d::ZipUtils::ccInflateCCZFile from 0xb2aaa0 to 0xb2ae1c (892 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0xb37c84
// > ??> @ 0x83328
//
// 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::ZipUtils::ccInflateCCZFile(cocos2d::ZipUtils *this, char *a2, unsigned __int8 **a3)
{
cocos2d::CCFileUtils *v5; // x0
unsigned int *v6; // x0
unsigned int *v7; // x21
__int64 v8; // x22
__int64 result; // x0
unsigned __int64 v10; // x14
_DWORD *v11; // x3
unsigned int v12; // w11
unsigned int v13; // w1
int *v14; // x4
int v15; // w2
unsigned int v16; // w10
int v17; // w6
int v18; // w6
int v19; // w1
int v20; // w7
unsigned int *v21; // x0
int v22; // w2
unsigned int v23; // w23
void *v24; // x0
int v25; // w22
__int64 v26; // [xsp+58h] [xbp+58h] BYREF
__int64 v27; // [xsp+60h] [xbp+60h] BYREF
v26 = 0;
v5 = cocos2d::CCFileUtils::sharedFileUtils();
v6 = (unsigned int *)((__int64 (__fastcall *)(cocos2d::CCFileUtils *, cocos2d::ZipUtils *, char *, __int64 *))v5->addSearchResolutionsOrder)(
v5,
this,
"rb",
&v26);
v7 = v6;
if ( !v6 )
return 0xFFFFFFFFLL;
v8 = v26;
if ( !v26 )
return 0xFFFFFFFFLL;
if ( *v6 == 559563587 )
{
if ( (((unsigned __int8)*((_WORD *)v6 + 3) << 8) | HIBYTE(*((unsigned __int16 *)v6 + 3))) > 2 )
goto LABEL_8;
if ( ((unsigned __int8)*((_WORD *)v6 + 2) << 8) | HIBYTE(*((unsigned __int16 *)v6 + 2)) )
goto LABEL_5;
}
else
{
if ( *v6 != 1884963651 )
{
LABEL_5:
operator delete[](v6);
return 0xFFFFFFFFLL;
}
if ( ((unsigned __int8)*((_WORD *)v6 + 3) << 8) | HIBYTE(*((unsigned __int16 *)v6 + 3))
|| ((unsigned __int8)*((_WORD *)v6 + 2) << 8) | HIBYTE(*((unsigned __int16 *)v6 + 2)) )
{
LABEL_8:
v6 = v7;
goto LABEL_5;
}
v10 = (unsigned __int64)(v26 - 12) >> 2;
v11 = v6 + 3;
if ( !cocos2d::ZipUtils::s_bEncryptionKeyIsValid )
{
v12 = 0;
v13 = dword_124714C;
do
{
v14 = cocos2d::ZipUtils::s_uEncryptionKey;
v15 = 0;
v12 -= 1640531527;
v16 = v12 >> 2;
do
{
v17 = cocos2d::ZipUtils::s_uEncryptedPvrKeyParts[((unsigned __int8)v15++ ^ (unsigned __int8)v16) & 3];
v13 = (((v13 ^ v17) + (v14[1] ^ v12))
^ (((16 * v13) ^ ((unsigned int)v14[1] >> 3)) + ((v13 >> 5) ^ (4 * v14[1]))))
+ *v14;
*v14++ = v13;
}
while ( v15 != 1023 );
v13 = (((((unsigned int)cocos2d::ZipUtils::s_uEncryptionKey[0] >> 3) ^ (16 * v13))
+ ((4 * cocos2d::ZipUtils::s_uEncryptionKey[0]) ^ (v13 >> 5)))
^ ((v13 ^ cocos2d::ZipUtils::s_uEncryptedPvrKeyParts[~(_BYTE)v16 & 3])
+ (v12 ^ cocos2d::ZipUtils::s_uEncryptionKey[0])))
+ dword_124714C;
dword_124714C = v13;
}
while ( v12 != -1253254570 );
cocos2d::ZipUtils::s_bEncryptionKeyIsValid = 1;
}
if ( (int)v10 > 0 )
{
v18 = 0;
v19 = 0;
do
{
++v18;
v20 = cocos2d::ZipUtils::s_uEncryptionKey[v19];
if ( v19 + 1 > 1023 )
v19 = 0;
else
++v19;
*v11++ ^= v20;
}
while ( (int)v10 > v18 && v18 <= 511 );
if ( (int)v10 > v18 )
{
v21 = &v6[v18];
do
{
v21 += 64;
v22 = cocos2d::ZipUtils::s_uEncryptionKey[v19];
if ( v19 + 1 > 1023 )
v19 = 0;
else
++v19;
*(v21 - 61) ^= v22;
}
while ( v21 != &v7[64 * (unsigned __int64)((unsigned int)(v10 - 1 - v18) >> 6) + 64 + v18] );
}
}
}
v23 = bswap32(v7[3]);
v24 = malloc(v23);
*(_QWORD *)a2 = v24;
if ( !v24 )
goto LABEL_8;
v27 = v23;
v25 = uncompress(v24, &v27, v7 + 4, v8 - 16);
operator delete[](v7);
result = v23;
if ( v25 )
{
free(*(void **)a2);
*(_QWORD *)a2 = 0;
return 0xFFFFFFFFLL;
}
return result;
}