//
// cocos2d::CCTexturePVR::unpackPVRv2Data from 0x100415178 to 0x100415388 (528 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x10041590c
//
// 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 11:04:52 +0000
//
__int64 __fastcall cocos2d::CCTexturePVR::unpackPVRv2Data(__int64 a1, __int64 a2)
{
__int64 v4; // x0
__int64 v5; // x22
__int64 v6; // x0
int v7; // w0
__int64 v8; // x9
__int64 *i; // x8
int v10; // w8
__int64 v12; // x21
__int64 v13; // x21
__int64 v14; // x9
int32x2_t v15; // d8
unsigned int v16; // w21
unsigned int v17; // w8
unsigned int v18; // w23
__int64 v19; // x20
int v20; // w24
uint32x2_t v21; // d0
int v22; // w9
__int64 v23; // x0
__int32 v24; // w10
__int32 v25; // w11
unsigned int v26; // w9
__int64 v27; // x11
int8x8_t v28; // d1
if ( *(_DWORD *)(a2 + 44) != 559044176 )
return 0;
v4 = cocos2d::CCConfiguration::sharedConfiguration();
v5 = *(unsigned __int8 *)(a2 + 16);
if ( (cocos2d::CCConfiguration::supportsNPOT(v4) & 1) == 0 )
{
v12 = *(unsigned int *)(a2 + 8);
if ( sub_10008E7D4(v12) != v12 )
return 0;
v13 = *(unsigned int *)(a2 + 4);
if ( sub_10008E7D4(v13) != v13 )
return 0;
}
v6 = cocos2d::CCConfiguration::sharedConfiguration();
v7 = cocos2d::CCConfiguration::supportsPVRTC(v6);
v8 = 11;
if ( !v7 )
v8 = 9;
for ( i = (__int64 *)&off_10094D250; *(i - 1) != v5; i += 2 )
{
if ( !--v8 )
{
v10 = 1;
return v10 & (unsigned int)v8;
}
}
v14 = *i;
*(_QWORD *)(a1 + 336) = *i;
*(_DWORD *)(a1 + 312) = 0;
v15 = *(int32x2_t *)(a2 + 4);
*(int32x2_t *)(a1 + 316) = vrev64_s32(v15);
*(_BYTE *)(a1 + 328) = *(_DWORD *)(a2 + 40) != 0;
v16 = *(_DWORD *)(a2 + 20);
*(_DWORD *)(a1 + 332) = *(_DWORD *)(v14 + 20);
if ( !v16 )
{
LABEL_30:
v10 = 1;
LODWORD(v8) = 1;
return v10 & (unsigned int)v8;
}
v17 = 0;
v18 = 0;
v19 = a2 + 52;
v20 = *(_DWORD *)(v14 + 12);
while ( (_DWORD)v5 != 26 )
{
if ( (_DWORD)v5 == 25 )
{
v21 = vshr_n_u32((uint32x2_t)v15, 2u);
v22 = 16;
}
else
{
if ( (_DWORD)v5 != 24 )
goto LABEL_22;
v21 = vshl_u32((uint32x2_t)v15, (uint32x2_t)0xFFFFFFFDFFFFFFFELL);
v22 = 32;
}
LABEL_23:
v24 = v21.i32[1];
if ( v21.i32[1] <= 2u )
v24 = 2;
v25 = v21.i32[0];
if ( v21.i32[0] <= 2u )
v25 = 2;
v26 = ((unsigned int)(v22 * v20) >> 3) * v24 * v25;
if ( v16 - v18 < v26 )
v26 = v16 - v18;
v27 = a1 + 56 + 16LL * v17;
*(_QWORD *)v27 = v19 + v18;
*(_DWORD *)(v27 + 8) = v26;
*(_DWORD *)(a1 + 312) = ++v17;
v18 += v26;
v28 = (int8x8_t)vcgt_u32((uint32x2_t)v15, (uint32x2_t)0x100000001LL);
v15 = vsub_s32((int32x2_t)vand_s8((int8x8_t)vshr_n_u32((uint32x2_t)v15, 1u), v28), (int32x2_t)vmvn_s8(v28));
if ( v18 >= v16 )
goto LABEL_30;
}
v23 = cocos2d::CCConfiguration::sharedConfiguration();
if ( (unsigned int)cocos2d::CCConfiguration::supportsBGRA8888(v23) )
{
v17 = *(_DWORD *)(a1 + 312);
LABEL_22:
v22 = 1;
v21 = (uint32x2_t)v15;
goto LABEL_23;
}
v10 = 0;
LODWORD(v8) = 0;
return v10 & (unsigned int)v8;
}