//
// cocos2d::extension::AssetsManager::setSearchPath from 0x5a0420 to 0x5a0616 (502 bytes)
//
// 2 xrefs:
// > cocos2d::extension::AssetsManager::checkUpdate @ 0x5a06f0
// > cocos2d::extension::AssetsManager::Helper::handleUpdateSucceed @ 0x5a0778
//
// 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
//
void __fastcall cocos2d::extension::AssetsManager::setSearchPath(cocos2d::extension::AssetsManager *this)
{
cocos2d::CCFileUtils *v1; // r0
_DWORD *v2; // r0
int v3; // r4
int v4; // r5
_DWORD *v5; // r9
signed int v6; // r4
unsigned int v7; // r5
char *v8; // r4
int v9; // r9
int v10; // r10
_DWORD *v11; // t0
char *v12; // r5
char *v13; // r10
char *v14; // r9
int i; // r4
cocos2d::CCFileUtils *v16; // r0
unsigned int v17; // r0
int v18; // r9
int v19; // r10
char *v20; // r4
char *v21; // r0
char *v22; // r5
void *v23; // [sp+0h] [bp-18h] BYREF
void *v24; // [sp+4h] [bp-14h] BYREF
void *p; // [sp+8h] [bp-10h] BYREF
char *v26; // [sp+Ch] [bp-Ch]
char *v27; // [sp+10h] [bp-8h]
v1 = cocos2d::CCFileUtils::sharedFileUtils();
v2 = (_DWORD *)((int (__fastcall *)(cocos2d::CCFileUtils *))v1->getWritablePath2)(v1);
v3 = *v2;
v4 = v2[1];
v5 = v2;
p = nullptr;
v6 = v4 - v3;
v26 = nullptr;
v27 = nullptr;
v7 = v6 >> 2;
if ( v6 >> 2 )
{
if ( v7 >= 0x40000000 )
sub_772FB4(v2);
v7 = operator new(v6);
}
p = (void *)v7;
v27 = (char *)(v6 + v7);
v8 = (char *)v7;
v26 = (char *)v7;
v11 = v5;
v9 = *v5;
v10 = v11[1];
while ( v9 != v10 )
{
if ( v8 )
sub_775C20(v8);
v8 += 4;
v9 += 4;
}
v26 = v8;
v12 = (char *)p;
if ( v8 == v27 || p != v8 )
{
if ( v8 == v27 )
{
std::vector::_M_insert_aux((int)&p, (char *)p);
}
else
{
sub_775C20(&v23);
v13 = v26;
if ( v26 == v27 )
{
v17 = std::vector::_M_check_len(&p, 1u, (int)"vector::_M_insert_aux");
v18 = 4 * v17;
v19 = v12 - (_BYTE *)p;
if ( v17 )
{
if ( v17 >= 0x40000000 )
sub_772FB4(v17);
v17 = operator new(4 * v17);
}
v20 = (char *)v17;
if ( v17 + v19 )
{
*(_DWORD *)(v17 + v19) = v23;
v23 = &unk_ACDDA8;
}
v21 = sub_59FD04((char *)p, v12, (_DWORD *)v17);
v22 = sub_59FD04(v12, v26, (_DWORD *)v21 + 1);
std::_Destroy_aux::__destroy((int)p, (int)v26);
if ( p )
operator delete(p);
p = v20;
v26 = v22;
v27 = &v20[v18];
}
else
{
if ( v26 )
{
*(_DWORD *)v26 = *((_DWORD *)v26 - 1);
*((_DWORD *)v13 - 1) = &unk_ACDDA8;
}
v14 = v13 - 4;
v26 = v13 + 4;
for ( i = (v13 - 4 - v12) >> 2; i > 0; --i )
{
v13 -= 4;
v14 -= 4;
sub_774794(v13, v14);
}
v24 = v23;
v23 = &unk_ACDDA8;
sub_774794(v12, &v24);
sub_774008(&v24);
}
sub_774008(&v23);
}
}
else
{
if ( v8 )
sub_775C20(v8);
v26 += 4;
}
v16 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(cocos2d::CCFileUtils *, void **))v16->getPathForFilename)(v16, &p);
std::_Destroy_aux::__destroy((int)p, (int)v26);
if ( p )
operator delete(p);
}