//
// cocos2d::CCTexturePVR::unpackPVRv3Data from 0x100415388 to 0x100415558 (464 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x100415920
//
// 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::unpackPVRv3Data(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // x0
unsigned __int64 v7; // x22
__int64 v8; // x0
int v9; // w0
__int64 v10; // x9
__int64 *i; // x8
__int64 v12; // x8
int v13; // w10
int32x2_t v14; // d8
unsigned __int64 v15; // x9
int v16; // w10
unsigned __int64 v17; // x23
unsigned int v18; // w24
unsigned __int32 *v19; // x25
uint32x2_t v20; // d0
int v21; // w10
__int64 v22; // x0
int32x2_t v23; // d0
unsigned __int32 v24; // w10
int8x8_t v25; // d1
if ( a3 < 0x34 )
return 0;
if ( *(_DWORD *)a2 != 55727696 )
return 0;
v7 = *(_QWORD *)(a2 + 8);
v8 = cocos2d::CCConfiguration::sharedConfiguration();
v9 = cocos2d::CCConfiguration::supportsPVRTC(v8);
v10 = 13;
if ( !v9 )
v10 = 9;
for ( i = (__int64 *)&off_1009D4490; *(i - 1) != v7; i += 2 )
{
if ( !--v10 )
return 0;
}
v12 = *i;
*(_QWORD *)(a1 + 336) = v12;
*(_BYTE *)(a1 + 328) = *(_BYTE *)(v12 + 17);
v13 = *(_DWORD *)(a2 + 4);
*(_BYTE *)(a1 + 330) = 1;
if ( (v13 & 2) != 0 )
*(_BYTE *)(a1 + 329) = 1;
v14 = *(int32x2_t *)(a2 + 24);
*(int32x2_t *)(a1 + 316) = vrev64_s32(v14);
v15 = *(unsigned int *)(a2 + 44);
v16 = *(_DWORD *)(a2 + 48);
*(_DWORD *)(a1 + 312) = v15;
if ( (_DWORD)v15 )
{
v17 = 0;
v18 = v16 + 52;
v19 = (unsigned __int32 *)(a1 + 64);
do
{
if ( v7 < 2 )
{
v20 = vshl_u32((uint32x2_t)v14, (uint32x2_t)0xFFFFFFFDFFFFFFFELL);
v21 = 32;
}
else if ( v7 - 2 >= 2 )
{
if ( v7 == 0x808080861726762LL )
{
v22 = cocos2d::CCConfiguration::sharedConfiguration();
result = cocos2d::CCConfiguration::supportsBGRA8888(v22);
if ( !(_DWORD)result )
return result;
v12 = *(_QWORD *)(a1 + 336);
v15 = *(unsigned int *)(a1 + 312);
}
v21 = 1;
v20 = (uint32x2_t)v14;
}
else
{
v20 = vshr_n_u32((uint32x2_t)v14, 2u);
v21 = 16;
}
v23 = (int32x2_t)vmax_u32(v20, (uint32x2_t)0x200000002LL);
v24 = vmul_lane_s32(v23, v23, 1).u32[0] * ((unsigned int)(*(_DWORD *)(v12 + 12) * v21) >> 3);
if ( a3 - v18 < v24 )
v24 = a3 - v18;
*((_QWORD *)v19 - 1) = a2 + v18;
*v19 = v24;
v19 += 4;
v18 += v24;
v25 = (int8x8_t)vcgt_u32((uint32x2_t)v14, (uint32x2_t)0x100000001LL);
v14 = vsub_s32((int32x2_t)vand_s8((int8x8_t)vshr_n_u32((uint32x2_t)v14, 1u), v25), (int32x2_t)vmvn_s8(v25));
++v17;
}
while ( v17 < v15 );
}
return 1;
}