//
// cocos2d::ZipUtils::ccInflateCCZFile from 0xd9a318 to 0xd9a698 (896 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0xdaa3f0
// > ??> @ 0xae658
//
// 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 13:08:23 +0000
//
__int64 __fastcall cocos2d::ZipUtils::ccInflateCCZFile(cocos2d::ZipUtils *this, char *a2, unsigned __int8 **a3)
{
__int64 v5; // x0
unsigned int *v6; // x0
unsigned int *v7; // x21
__int64 result; // x0
unsigned __int64 v9; // x13
_DWORD *v10; // x14
unsigned int v11; // w11
unsigned int v12; // w1
int *v13; // x3
int v14; // w2
unsigned int v15; // w10
int v16; // w5
int v17; // w5
int v18; // w1
int v19; // w6
unsigned int *v20; // x0
int v21; // w2
unsigned int v22; // w22
void *v23; // x0
int v24; // w23
__int64 v25; // [xsp+58h] [xbp+58h] BYREF
__int64 v26; // [xsp+60h] [xbp+60h] BYREF
v25 = 0;
v5 = cocos2d::CCFileUtils::sharedFileUtils(_stack_chk_guard);
v6 = (unsigned int *)(*(__int64 (__fastcall **)(__int64, cocos2d::ZipUtils *, char *, __int64 *))(*(_QWORD *)v5 + 32LL))(
v5,
this,
"rb",
&v25);
v7 = v6;
if ( !v6 || !v25 )
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;
}
v9 = (unsigned __int64)(v25 - 12) >> 2;
v10 = v6 + 3;
if ( !cocos2d::ZipUtils::s_bEncryptionKeyIsValid )
{
v11 = 0;
v12 = dword_15620FC;
do
{
v13 = cocos2d::ZipUtils::s_uEncryptionKey;
v14 = 0;
v11 -= 1640531527;
v15 = v11 >> 2;
do
{
v16 = cocos2d::ZipUtils::s_uEncryptedPvrKeyParts[((unsigned __int8)v14++ ^ (unsigned __int8)v15) & 3];
v12 = (((v12 ^ v16) + (v13[1] ^ v11))
^ (((16 * v12) ^ ((unsigned int)v13[1] >> 3)) + ((v12 >> 5) ^ (4 * v13[1]))))
+ *v13;
*v13++ = v12;
}
while ( v14 != 1023 );
v12 = (((((unsigned int)cocos2d::ZipUtils::s_uEncryptionKey[0] >> 3) ^ (16 * v12))
+ ((4 * cocos2d::ZipUtils::s_uEncryptionKey[0]) ^ (v12 >> 5)))
^ ((v12 ^ cocos2d::ZipUtils::s_uEncryptedPvrKeyParts[~(_BYTE)v15 & 3])
+ (v11 ^ cocos2d::ZipUtils::s_uEncryptionKey[0])))
+ dword_15620FC;
dword_15620FC = v12;
}
while ( v11 != -1253254570 );
cocos2d::ZipUtils::s_bEncryptionKeyIsValid = 1;
}
if ( (int)v9 > 0 )
{
v17 = 0;
v18 = 0;
do
{
++v17;
v19 = cocos2d::ZipUtils::s_uEncryptionKey[v18];
if ( v18 + 1 > 1023 )
v18 = 0;
else
++v18;
*v10++ ^= v19;
}
while ( (int)v9 > v17 && v17 <= 511 );
if ( (int)v9 > v17 )
{
v20 = &v6[v17];
do
{
v20 += 64;
v21 = cocos2d::ZipUtils::s_uEncryptionKey[v18];
if ( v18 + 1 > 1023 )
v18 = 0;
else
++v18;
*(v20 - 61) ^= v21;
}
while ( v20 != &v7[64 * (unsigned __int64)((unsigned int)(v9 - 1 - v17) >> 6) + 64 + v17] );
}
}
}
v22 = bswap32(v7[3]);
v23 = malloc(v22);
*(_QWORD *)a2 = v23;
if ( !v23 )
goto LABEL_8;
v26 = v22;
v24 = uncompress(v23, &v26, v7 + 4, v25 - 16);
operator delete[](v7);
result = v22;
if ( v24 )
{
free(*(void **)a2);
*(_QWORD *)a2 = 0;
return 0xFFFFFFFFLL;
}
return result;
}