//
// cocos2d::CCFileUtils::addSearchPath from 0xb067cc to 0xb06a20 (596 bytes)
//
// 3 xrefs:
// > ??> @ 0x2e920
// > ??> @ 0x1217b08
// > ??> @ 0x1217fc8
//
// 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 cocos2d::CCFileUtils::addSearchPath(cocos2d::CCFileUtils *a1, const char *a2)
{
void *v3; // x0
__int64 v4; // x1
__int64 v5; // x0
__int64 v6; // x24
cocos2d::CCFileUtils *v7; // x19
cocos2d::CCFileUtils_vtbl *v8; // x0
void *v9; // x0
char *v10; // x0
unsigned int *v11; // x1
int v12; // w2
unsigned int *v13; // x1
int v14; // w2
unsigned int *v15; // x19
int v16; // w1
char *v17; // [xsp+50h] [xbp+50h] BYREF
__int64 v18; // [xsp+58h] [xbp+58h] BYREF
__int64 v19; // [xsp+60h] [xbp+60h] BYREF
v17 = &byte_124B6C8;
sub_D153B8((int)&v18, (char *)a2);
if ( !((unsigned __int8 (__fastcall *)(cocos2d::CCFileUtils *, __int64 *))a1->loadFilenameLookupDictionaryFromFile)(
a1,
&v18) )
sub_D18EA8(&v17, &a1[8]);
sub_D18D28(&v19);
sub_D15E14(&v19, &v18);
sub_D163D4(&v18, &v19);
v3 = (void *)(v19 - 24);
if ( (__int64 *)(v19 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v19 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *(_DWORD *)(v19 - 8);
*(_DWORD *)(v19 - 8) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v3);
}
v4 = v18;
v5 = *(_QWORD *)(v18 - 24);
if ( v5 )
{
v6 = v5 - 1;
if ( (*(_DWORD *)(v18 - 8) & 0x80000000) == 0 )
{
sub_D176A8(&v18);
v4 = v18;
}
if ( *(_BYTE *)(v4 + v6) != 47 )
sub_D15FD4(&v18, &word_F2A0A8, 1);
}
v7 = a1 + 5;
v8 = v7[1].__vftable;
if ( v8 == v7[2].__vftable )
{
std::vector::_M_emplace_back_aux((__int64)v7, (__int64)&v18);
}
else
{
if ( v8 )
{
sub_D18D28(v8);
v8 = v7[1].__vftable;
}
v7[1].__vftable = (cocos2d::CCFileUtils_vtbl *)&v8->~CCFileUtils;
}
v9 = (void *)(v18 - 24);
if ( (__int64 *)(v18 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v18 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *(_DWORD *)(v18 - 8);
*(_DWORD *)(v18 - 8) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v9);
}
v10 = v17 - 24;
if ( v17 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v17 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v17 - 2);
*((_DWORD *)v17 - 2) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v10);
}
}