//
// sub_18006C540 from 0x18006c540 to 0x18006c6c2 (386 bytes)
//
// 7 xrefs:
// > cocos2d::CCFileUtils::addSearchPath @ 0x18006d956
// > cocos2d::CCFileUtils::init @ 0x180070673
// > cocos2d::CCFileUtils::setSearchPaths @ 0x180071523
// > cocos2d::CCFileUtils::setSearchPaths @ 0x180071601
// > cocos2d::CCFileUtils::setSearchResolutionsOrder @ 0x180071866
// > sub_180073010 @ 0x180073167
// > ??> @ 0x1801b3f60
//
// 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
//
__int64 __fastcall sub_18006C540(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v5; // r14
__int64 v6; // rax
unsigned __int64 v7; // r13
unsigned __int64 v8; // rcx
unsigned __int64 v9; // rdx
unsigned __int64 v10; // rdi
size_t v11; // rcx
void *v12; // rax
_OWORD *v13; // rbx
__int64 v14; // r14
_OWORD *v15; // r15
__int64 v16; // rdx
__int64 v17; // rcx
__int64 v19; // [rsp+28h] [rbp-40h]
__int64 v21; // [rsp+78h] [rbp+10h]
__int64 v22; // [rsp+80h] [rbp+18h]
__int64 v23; // [rsp+88h] [rbp+20h]
v22 = a3;
v5 = a2 - *a1;
v6 = (a1[1] - *a1) >> 5;
if ( v6 == 0x7FFFFFFFFFFFFFFLL )
std::vector::_Xlen();
v7 = v6 + 1;
v8 = (a1[2] - *a1) >> 5;
v9 = v8 >> 1;
if ( v8 > 0x7FFFFFFFFFFFFFFLL - (v8 >> 1) )
goto LABEL_21;
v10 = v6 + 1;
if ( v9 + v8 >= v7 )
v10 = v9 + v8;
if ( v10 > 0x7FFFFFFFFFFFFFFLL )
goto LABEL_21;
v11 = 32 * v10;
v23 = v10;
if ( 32 * v10 < 0x1000 )
{
if ( v11 )
{
v13 = operator new(v11);
a3 = v22;
}
else
{
v13 = nullptr;
}
v23 = v10;
goto LABEL_15;
}
if ( v11 + 39 < v11 )
LABEL_21:
Concurrency::cancel_current_task();
v12 = operator new(v11 + 39);
if ( !v12 )
invalid_parameter_noinfo_noreturn();
v13 = (_OWORD *)(((unsigned __int64)v12 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*((_QWORD *)v13 - 1) = v12;
a3 = v22;
LABEL_15:
v14 = (__int64)v13 + (v5 & 0xFFFFFFFFFFFFFFE0uLL);
v15 = (_OWORD *)(v14 + 32);
v19 = v14 + 32;
try
{
sub_180016C80(v14, a3);
v21 = v14;
v16 = a1[1];
v17 = *a1;
if ( a2 == v16 )
{
v15 = v13;
}
else
{
sub_18000D200(v17, a2, v13);
v21 = (__int64)v13;
v17 = a2;
v16 = a1[1];
}
sub_18000D200(v17, v16, v15);
}
catch ( ... )
{
sub_18000CF70(v21, v19);
sub_18000E060((__int64)a1, v13, v23);
throw;
}
sub_18006D220(a1, v13, v7, v10, v13, v19);
return v14;
}