//
// cocos2d::extension::AssetsManager::setSearchPath from 0xa98bac to 0xa98ed0 (804 bytes)
//
// 3 xrefs:
// > cocos2d::extension::AssetsManager::checkUpdate @ 0xa9906c
// > cocos2d::extension::AssetsManager::Helper::handleUpdateSucceed @ 0xa99180
// > ??> @ 0xb6430
//
// 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 cocos2d::extension::AssetsManager::setSearchPath(cocos2d::extension::AssetsManager *this)
{
cocos2d::CCFileUtils *v1; // x0
__int64 *v2; // x0
__int64 v3; // x23
__int64 *v4; // x19
__int64 v5; // x0
signed __int64 v6; // x23
char *v7; // x24
char *v8; // x0
__int64 v9; // x20
__int64 v10; // x21
char *v11; // x19
_BOOL4 v12; // w1
void *v13; // x0
cocos2d::CCFileUtils *v14; // x0
__int64 *v15; // x19
__int64 *v16; // x20
__int64 v17; // x1
__int64 *v18; // x0
unsigned int *v19; // x1
int v20; // w2
char *v22; // x0
unsigned int *v23; // x1
int v24; // w2
__int64 v25; // [xsp+58h] [xbp+58h] BYREF
void *v26; // [xsp+60h] [xbp+60h] BYREF
void *p; // [xsp+68h] [xbp+68h]
char *v28; // [xsp+70h] [xbp+70h]
v1 = cocos2d::CCFileUtils::sharedFileUtils();
v2 = (__int64 *)((__int64 (__fastcall *)(cocos2d::CCFileUtils *))v1->getWritablePath2)(v1);
v3 = *v2;
v4 = v2;
v5 = v2[1];
v26 = nullptr;
v6 = v5 - v3;
p = nullptr;
v28 = nullptr;
if ( v6 >> 3 )
{
if ( (unsigned __int64)(v6 >> 3) > 0x1FFFFFFFFFFFFFFFLL )
sub_D1383C();
v7 = (char *)operator new(v6);
}
else
{
v7 = nullptr;
}
p = v7;
v8 = &v7[v6];
v26 = v7;
v28 = &v7[v6];
v9 = *v4;
v10 = v4[1];
if ( *v4 == v10 )
{
v12 = 1;
v11 = v7;
}
else
{
v11 = v7;
do
{
if ( v11 )
sub_D18D28(v11);
v9 += 8;
v11 += 8;
}
while ( v10 != v9 );
v7 = (char *)v26;
v8 = v28;
v12 = v11 == v26;
}
p = v11;
if ( v11 == v8 )
{
std::vector::_M_insert_aux((__int64 *)&v26, v7);
}
else if ( v12 )
{
v22 = nullptr;
if ( v11 )
{
sub_D18D28(v11);
v22 = (char *)p;
}
p = v22 + 8;
}
else
{
sub_D18D28(&v25);
std::vector::_M_insert_aux((char **)&v26, v7, &v25);
v13 = (void *)(v25 - 24);
if ( (__int64 *)(v25 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v25 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(_DWORD *)(v25 - 8);
*(_DWORD *)(v25 - 8) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v13);
}
}
v14 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(cocos2d::CCFileUtils *, void **))v14->getPathForFilename)(v14, &v26);
v15 = (__int64 *)v26;
v16 = (__int64 *)p;
if ( v26 != p )
{
do
{
while ( 1 )
{
v17 = *v15;
v18 = (__int64 *)(*v15 - 24);
if ( v18 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v17 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(_DWORD *)(v17 - 8);
*(_DWORD *)(v17 - 8) = v20 - 1;
}
if ( v20 <= 0 )
break;
}
if ( v16 == ++v15 )
goto LABEL_21;
}
++v15;
operator delete(v18);
}
while ( v16 != v15 );
LABEL_21:
v16 = (__int64 *)v26;
}
if ( v16 )
operator delete(v16);
return _stack_chk_guard;
}