//
// sub_1800AA090 from 0x1800aa090 to 0x1800aa45b (971 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexture2D::initWithPVRFile @ 0x1800a5a9e
// > ??> @ 0x1801b7f44
//
// 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
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall sub_1800AA090(cocos2d::CCObject *this, char *a2)
{
__int64 v4; // r14
size_t v5; // rbx
unsigned __int64 v6; // rdi
void *v7; // rsi
size_t v8; // rax
void *v9; // rax
unsigned int v10; // r15d
void **v11; // rax
void **v12; // rbx
void **v13; // r14
char *v14; // r9
__int64 v15; // rcx
unsigned __int8 v16; // al
int v17; // eax
void **v18; // r14
_BYTE *v19; // rax
bool v20; // cf
int v21; // ecx
int v22; // eax
struct cocos2d::CCFileUtils *v23; // rax
unsigned __int8 v24; // bl
_BYTE *v25; // rax
unsigned int v27; // [rsp+20h] [rbp-40h] BYREF
void *Block; // [rsp+28h] [rbp-38h] BYREF
void *Buf[2]; // [rsp+30h] [rbp-30h] BYREF
unsigned __int64 v30; // [rsp+40h] [rbp-20h]
__int64 v31; // [rsp+48h] [rbp-18h]
v4 = 0;
Block = nullptr;
v27 = 0;
*(_OWORD *)Buf = 0;
v30 = 0;
v31 = 0;
v5 = -1;
do
++v5;
while ( a2[v5] );
v6 = 0x7FFFFFFFFFFFFFFFLL;
if ( v5 > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
v31 = 15;
if ( v5 > 0xF )
{
if ( (v5 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v6 = v5 | 0xF;
if ( (v5 | 0xF) < 0x16 )
v6 = 22;
if ( v6 + 1 < 0x1000 )
{
if ( v6 == -1 )
v7 = nullptr;
else
v7 = operator new(v6 + 1);
LABEL_18:
Buf[0] = v7;
v30 = v5;
v31 = v6;
memcpy(v7, a2, v5);
*((_BYTE *)v7 + v5) = 0;
goto LABEL_19;
}
v8 = v6 + 40;
if ( v6 + 40 < v6 + 1 )
Concurrency::cancel_current_task();
}
else
{
v8 = 0x8000000000000027uLL;
}
v9 = operator new(v8);
if ( !v9 )
goto LABEL_60;
v7 = (void *)(((unsigned __int64)v9 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*((_QWORD *)v7 - 1) = v9;
goto LABEL_18;
}
v30 = v5;
memcpy(Buf, a2, v5);
*((_BYTE *)Buf + v5) = 0;
v6 = v31;
v5 = v30;
v7 = Buf[0];
LABEL_19:
v10 = 0;
if ( v5 )
{
do
{
v11 = Buf;
if ( v6 > 0xF )
v11 = (void **)v7;
v12 = Buf;
if ( v6 > 0xF )
v12 = (void **)v7;
*((_BYTE *)v12 + v4) = tolower(*((char *)v11 + v4));
v4 = ++v10;
v5 = v30;
v6 = v31;
v7 = Buf[0];
}
while ( v10 < v30 );
}
v13 = Buf;
if ( v6 > 0xF )
v13 = (void **)v7;
if ( v5 < 4 )
goto LABEL_36;
v14 = (char *)memchr(v13, 46, v5 - 3);
if ( !v14 )
goto LABEL_36;
while ( 1 )
{
v15 = 0;
while ( 1 )
{
v16 = v14[v15++];
if ( v16 != aCcz[v15 - 1] )
break;
if ( v15 == 4 )
{
v17 = 0;
goto LABEL_34;
}
}
v17 = v16 < (unsigned __int8)aCcz[v15 - 1] ? -1 : 1;
LABEL_34:
if ( !v17 )
break;
v14 = (char *)memchr(v14 + 1, 46, (char *)v13 + v5 - 3 - (v14 + 1));
if ( !v14 )
goto LABEL_36;
}
if ( v14 - (char *)v13 == -1 )
{
LABEL_36:
v18 = Buf;
if ( v6 > 0xF )
v18 = (void **)v7;
if ( v5 < 3 )
goto LABEL_49;
v19 = memchr(v18, 46, v5 - 2);
if ( !v19 )
goto LABEL_49;
while ( 1 )
{
v20 = *v19 < 0x2Eu;
if ( *v19 == 46 && (v20 = v19[1] < 0x67u, v19[1] == 103) && (v20 = v19[2] < 0x7Au, v19[2] == 122) )
v21 = 0;
else
v21 = v20 ? -1 : 1;
if ( !v21 )
break;
v19 = memchr(v19 + 1, 46, (char *)v18 + v5 - 2 - (v19 + 1));
if ( !v19 )
goto LABEL_49;
}
if ( v19 - (_BYTE *)v18 == -1 )
{
LABEL_49:
v23 = cocos2d::CCFileUtils::sharedFileUtils();
Block = (void *)((__int64 (__fastcall *)(struct cocos2d::CCFileUtils *, char *, const char *, unsigned int *))v23->addSearchResolutionsOrder)(
v23,
a2,
"rb",
&v27);
v22 = v27;
}
else
{
v22 = cocos2d::ZipUtils::ccInflateGZipFile(a2, (unsigned __int8 **)&Block);
v27 = v22;
}
}
else
{
v22 = cocos2d::ZipUtils::ccInflateCCZFile(a2, (unsigned __int8 **)&Block);
v27 = v22;
}
if ( v22 < 0 )
goto LABEL_56;
*((_QWORD *)this + 39) = 0;
*((_QWORD *)this + 40) = 0;
*((_QWORD *)this + 42) = 0;
*((_DWORD *)this + 82) = 0;
if ( !(unsigned __int8)sub_1800AA460(this, Block, (unsigned int)v22)
&& !(unsigned __int8)sub_1800AA690(this, Block, v27)
|| !sub_1800A9E90((__int64)this) )
{
if ( Block )
{
j_j_free_0(Block);
Block = nullptr;
}
LABEL_56:
cocos2d::CCObject::release(this);
v24 = 0;
goto LABEL_57;
}
if ( Block )
{
j_j_free_0(Block);
Block = nullptr;
}
v24 = 1;
LABEL_57:
if ( v6 > 0xF )
{
v25 = v7;
if ( v6 + 1 >= 0x1000 )
{
v7 = *((void **)v7 - 1);
if ( (unsigned __int64)(v25 - (_BYTE *)v7 - 8) > 0x1F )
LABEL_60:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v7);
}
return v24;
}