//
// cocos2d::CCTexturePVR::initWithContentsOfFile from 0xdaa294 to 0xdaa598 (772 bytes)
//
// 3 xrefs:
// > cocos2d::CCTexture2D::initWithPVRFile @ 0xda27b8
// > cocos2d::CCTexturePVR::create @ 0xdaa5c0
// > ??> @ 0x8b6a8
//
// 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:34 +0000
//
__int64 __fastcall cocos2d::CCTexturePVR::initWithContentsOfFile(cocos2d::CCTexturePVR *this, char *a2)
{
size_t v4; // x0
size_t v5; // x19
char *v6; // x3
unsigned int i; // w20
unsigned __int64 v8; // x2
_BYTE *v9; // x19
unsigned __int8 v10; // w1
__int64 v11; // x0
int v12; // w3
unsigned __int64 v13; // x0
char *v14; // x20
char *v15; // x19
unsigned __int8 **v16; // x2
unsigned int v17; // w2
unsigned __int8 *v18; // x1
unsigned __int8 GLTexture; // w0
unsigned int v20; // w19
unsigned __int64 v22; // x19
char *v23; // x24
__int64 v24; // x19
unsigned __int8 **v25; // x2
__int64 v26; // x0
unsigned int v27; // [xsp+54h] [xbp+54h] BYREF
unsigned __int8 *v28; // [xsp+58h] [xbp+58h] BYREF
__int64 v29; // [xsp+60h] [xbp+60h] BYREF
unsigned __int64 v30; // [xsp+68h] [xbp+68h]
void *v31; // [xsp+70h] [xbp+70h]
v28 = nullptr;
v27 = 0;
v29 = 0;
v30 = 0;
v31 = nullptr;
v4 = strlen(a2);
v5 = v4;
if ( v4 > 0x16 )
{
v13 = (v4 + 16) & 0xFFFFFFFFFFFFFFF0LL;
v29 = v13 | 1;
v6 = (char *)operator new(v13);
v31 = v6;
v30 = v5;
goto LABEL_11;
}
LOBYTE(v29) = 2 * v4;
v6 = (char *)&v29 + 1;
if ( v4 )
LABEL_11:
v6 = (char *)memcpy(v6, a2, v5);
v6[v5] = 0;
for ( i = 0; ; ++i )
{
v10 = v29;
v11 = i;
v12 = v29 & 1;
if ( !v12 )
break;
v8 = v30;
if ( i >= v30 )
{
v14 = (char *)v31;
v12 = 1;
if ( v30 <= 3 )
goto LABEL_26;
goto LABEL_13;
}
v9 = (char *)v31 + i;
LABEL_6:
*v9 = tolower((unsigned __int8)*v9);
}
v8 = (unsigned __int8)v29 >> 1;
if ( i < v8 )
{
v9 = (char *)&v29 + i + 1;
goto LABEL_6;
}
v14 = (char *)&v29 + 1;
if ( v8 <= 3 )
goto LABEL_26;
LABEL_13:
v15 = &v14[v8];
v11 = std::__search(
(__int64)v14,
(__int64)&v14[v8],
".ccz",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v15 != (char *)v11 && v11 - (_QWORD)v14 != -1 )
{
v17 = cocos2d::ZipUtils::ccInflateCCZFile((cocos2d::ZipUtils *)a2, (char *)&v28, v16);
v27 = v17;
goto LABEL_16;
}
v10 = v29;
v12 = v29 & 1;
LABEL_26:
if ( v12 )
{
v22 = v30;
v23 = (char *)v31;
if ( v30 > 2 )
{
LABEL_28:
v24 = (__int64)&v23[v22];
v11 = std::__search(
(__int64)v23,
v24,
".gz",
(unsigned __int8 *)"",
(unsigned __int8 (__fastcall *)(__int64, _QWORD))std::char_traits::eq);
if ( v24 != v11 && v11 - (_QWORD)v23 != -1 )
{
v17 = cocos2d::ZipUtils::ccInflateGZipFile((cocos2d::ZipUtils *)a2, (char *)&v28, v25);
v27 = v17;
goto LABEL_16;
}
}
}
else
{
v22 = v10 >> 1;
v23 = (char *)&v29 + 1;
if ( v22 > 2 )
goto LABEL_28;
}
v26 = cocos2d::CCFileUtils::sharedFileUtils((cocos2d::CCFileUtils *)v11);
v28 = (unsigned __int8 *)(*(__int64 (__fastcall **)(__int64, char *, char *, unsigned int *))(*(_QWORD *)v26 + 32LL))(
v26,
a2,
"rb",
&v27);
v17 = v27;
LABEL_16:
if ( (v17 & 0x80000000) != 0 )
{
LABEL_33:
v20 = 0;
cocos2d::CCObject::release(this);
goto LABEL_22;
}
v18 = v28;
*((_DWORD *)this + 78) = 0;
*((_DWORD *)this + 81) = 0;
*((_DWORD *)this + 80) = 0;
*((_DWORD *)this + 79) = 0;
*((_QWORD *)this + 42) = 0;
*((_BYTE *)this + 328) = 0;
*((_BYTE *)this + 330) = 0;
*((_BYTE *)this + 329) = 0;
*((_BYTE *)this + 331) = 0;
if ( !(unsigned __int8)cocos2d::CCTexturePVR::unpackPVRv2Data(this, v18)
&& !(unsigned __int8)cocos2d::CCTexturePVR::unpackPVRv3Data(this, v28, v27)
|| (GLTexture = cocos2d::CCTexturePVR::createGLTexture(this), (v20 = GLTexture) == 0) )
{
if ( v28 )
{
operator delete[](v28);
v28 = nullptr;
}
goto LABEL_33;
}
if ( v28 )
{
operator delete[](v28);
v28 = nullptr;
}
LABEL_22:
if ( (v29 & 1) != 0 )
operator delete(v31);
return v20;
}