//
// sub_180003320 from 0x180003320 to 0x180003517 (503 bytes)
//
// 4 xrefs:
// > cocos2d::extension::AssetsManager::setSearchPath @ 0x18000243c
// > ??> @ 0x18002d1f4
// > ??> @ 0x18002d204
// > ??> @ 0x1800491c8
//
// 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
//
_QWORD *__fastcall sub_180003320(__int64 *a1, _QWORD *a2, __int64 a3, __int64 a4)
{
_OWORD *v4; // rsi
_OWORD *v8; // rax
char *v9; // rdi
_QWORD *v10; // r15
char *v11; // rsi
void **v12; // r14
_QWORD *v13; // rcx
unsigned __int64 v14; // rdx
_QWORD *v15; // rcx
__int128 v16; // xmm0
__m128i v17; // xmm1
void *v18; // rcx
void *Block[2]; // [rsp+28h] [rbp-40h] BYREF
__m128i si128; // [rsp+38h] [rbp-30h]
v4 = (_OWORD *)a1[1];
if ( v4 != (_OWORD *)a1[2] )
{
if ( (_OWORD *)a3 == v4 )
{
sub_180003F50(v4, a4);
a1[1] += 32;
LABEL_26:
*a2 = a3;
return a2;
}
sub_180003F50(Block, a4);
v8 = v4 - 2;
*v4 = *(v4 - 2);
v4[1] = *(v4 - 1);
*((_QWORD *)v8 + 2) = 0;
*((_QWORD *)v8 + 3) = 15;
*(_BYTE *)v8 = 0;
a1[1] += 32;
if ( (_OWORD *)a3 != v4 - 2 )
{
v9 = (char *)v4 - 8;
do
{
v10 = v9;
v9 -= 32;
v11 = v9 - 24;
v12 = (void **)(v9 + 8);
if ( v9 + 8 != v9 - 24 )
{
if ( *v10 > 0xFu )
{
v13 = *v12;
if ( (unsigned __int64)(*v10 + 1LL) >= 0x1000 )
{
if ( (unsigned __int64)v13 - *(v13 - 1) - 8 > 0x1F )
goto LABEL_24;
v13 = (_QWORD *)*(v13 - 1);
}
j_j_free(v13);
}
*v10 = 15;
*(_OWORD *)v12 = *(_OWORD *)v11;
*(_OWORD *)(v9 + 24) = *((_OWORD *)v11 + 1);
*((_QWORD *)v9 - 1) = 0;
*(_QWORD *)v9 = 15;
*v11 = 0;
}
}
while ( (char *)a3 != v11 );
}
if ( (void **)a3 != Block )
{
v14 = *(_QWORD *)(a3 + 24);
if ( v14 > 0xF )
{
v15 = *(_QWORD **)a3;
if ( v14 + 1 >= 0x1000 )
{
if ( (unsigned __int64)v15 - *(v15 - 1) - 8 > 0x1F )
goto LABEL_24;
v15 = (_QWORD *)*(v15 - 1);
}
j_j_free(v15);
}
v16 = *(_OWORD *)Block;
LOBYTE(Block[0]) = 0;
v17 = si128;
*(_OWORD *)a3 = v16;
si128 = _mm_load_si128((const __m128i *)&xmmword_1800295E0);
*(__m128i *)(a3 + 16) = v17;
}
if ( si128.m128i_i64[1] <= 0xFuLL )
goto LABEL_26;
v18 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) < 0x1000
|| (v18 = *((void **)Block[0] - 1), (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) <= 0x1F) )
{
j_j_free(v18);
goto LABEL_26;
}
LABEL_24:
invalid_parameter_noinfo_noreturn();
}
*a2 = sub_180003160(a1, a3, a4);
return a2;
}