//
// cocos2d::CCFileUtils::addSearchPath from 0x10043d220 to 0x10043d4d4 (692 bytes)
//
// 2 xrefs:
// > ??> @ 0x100938000
// > ??> @ 0x1009805a0
//
// 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::CCFileUtils::addSearchPath(cocos2d::CCFileUtils *a1, const char *a2)
{
cocos2d::CCFileUtils *v2; // rbx
size_t v3; // rax
std::string::size_type v4; // r15
char *data; // r12
size_t v6; // r13
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v7; // cl
size_t size; // r15
unsigned int v9; // r13d
size_t v10; // r14
unsigned __int64 v11; // r12
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v12; // r12
std::string::value_type *v13; // rax
size_t v14; // rbx
bool v15; // zf
std::string::value_type *v16; // r12
std::string::pointer v17; // rsi
char *v18; // r12
std::string::pointer v19; // rsi
double v20; // xmm0_8
std::string::size_type v21; // rcx
std::string *v22; // r15
cocos2d::CCFileUtils_vtbl *v23; // r15
std::string v24; // [rsp+10h] [rbp-80h] BYREF
std::string __src; // [rsp+30h] [rbp-60h] BYREF
int v26; // [rsp+4Ch] [rbp-44h]
std::string __dst[2]; // [rsp+50h] [rbp-40h] BYREF
v2 = a1;
memset(&__src, 0, sizeof(__src));
v3 = strlen(a2);
if ( v3 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(0.0);
v4 = v3;
if ( v3 >= 0x17 )
{
v6 = 26;
if ( (v3 | 7) != 0x17 )
v6 = (v3 | 7) + 1;
data = (char *)operator new(v6);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v6 | 1;
__dst[0].__r_.__value_.__l.__size_ = v4;
goto LABEL_8;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v3);
data = __dst[0].__r_.__value_.__s.__data_;
if ( v3 )
LABEL_8:
memcpy(data, a2, v4);
data[v4] = 0;
if ( !((unsigned __int8 (__fastcall *)(cocos2d::CCFileUtils *, std::string *))a1->loadFilenameLookupDictionaryFromFile)(
a1,
__dst) )
std::string::operator=(&__src, (const std::string *)&a1[8]);
v7 = __src.__r_.__value_.__s.0;
if ( (*(_BYTE *)&__src.__r_.__value_.__s.0 & 1) != 0 )
{
size = __src.__r_.__value_.__l.__size_;
v9 = (unsigned int)__dst[0].__r_.__value_.__l.0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_13:
v10 = v9 >> 1;
goto LABEL_16;
}
}
else
{
size = *(_BYTE *)&__src.__r_.__value_.__l.0 >> 1;
v9 = (unsigned int)__dst[0].__r_.__value_.__l.0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_13;
}
v10 = __dst[0].__r_.__value_.__l.__size_;
LABEL_16:
v11 = v10 + size;
if ( v10 + size >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(0.0);
if ( v11 > 0x16 )
{
v26 = (int)__src.__r_.__value_.__l.0;
v14 = 26;
if ( (v11 | 7) != 0x17 )
v14 = (v11 | 7) + 1;
v13 = (std::string::value_type *)operator new(v14);
v24.__r_.__value_.__r.__words[0] = v14 | 1;
v24.__r_.__value_.__r.__words[2] = (std::string::size_type)v13;
v24.__r_.__value_.__l.__size_ = v10 + size;
v12 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(v14 | 1);
v2 = a1;
v7 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)v26;
}
else
{
memset(&v24, 0, sizeof(v24));
v12 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v11);
v24.__r_.__value_.__s.0 = v12;
v13 = nullptr;
}
v15 = (*(_BYTE *)&v12 & 1) == 0;
v16 = v24.__r_.__value_.__s.__data_;
if ( !v15 )
v16 = v13;
if ( size )
{
if ( (*(_BYTE *)&v7 & 1) != 0 )
v17 = __src.__r_.__value_.__l.__data_;
else
v17 = __src.__r_.__value_.__s.__data_;
memmove(v16, v17, size);
}
v18 = &v16[size];
if ( v10 )
{
if ( (v9 & 1) != 0 )
v19 = __dst[0].__r_.__value_.__l.__data_;
else
v19 = __dst[0].__r_.__value_.__s.__data_;
memmove(v18, v19, v10);
}
v18[v10] = 0;
if ( (v9 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
__dst[0] = v24;
v20 = *(double *)v24.__r_.__value_.__r.__words;
if ( (*(_BYTE *)&v24.__r_.__value_.__s.0 & 1) != 0 )
{
v21 = __dst[0].__r_.__value_.__l.__size_;
if ( !__dst[0].__r_.__value_.__l.__size_ )
goto LABEL_45;
}
else
{
if ( !*(_BYTE *)&v24.__r_.__value_.__s.0 )
goto LABEL_45;
v21 = *(_BYTE *)&v24.__r_.__value_.__l.0 >> 1;
}
if ( (*(_BYTE *)&v24.__r_.__value_.__s.0 & 1) == 0 )
{
if ( *((_BYTE *)&__dst[0].__r_.__value_.__l.0 + v21) == 47 )
goto LABEL_45;
goto LABEL_44;
}
if ( *(_BYTE *)(__dst[0].__r_.__value_.__r.__words[2] + v21 - 1) != 47 )
LABEL_44:
std::string::append(__dst, "/");
LABEL_45:
v22 = (std::string *)v2[6].__vftable;
if ( (cocos2d::CCFileUtils_vtbl *)v22 >= v2[7].__vftable )
{
v2[6].__vftable = (cocos2d::CCFileUtils_vtbl *)sub_100054890((__int64)&v2[5], (__int64)__dst, v20);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
LABEL_52:
operator delete(__dst[0].__r_.__value_.__l.__data_);
}
else
{
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
sub_100006B70(
&v2[6].getClassTypeInfo,
__dst[0].__r_.__value_.__l.__data_,
__dst[0].__r_.__value_.__l.__size_,
v20);
else
*v22 = __dst[0];
v23 = (cocos2d::CCFileUtils_vtbl *)&v22[1];
v2[6].__vftable = v23;
v2[6].__vftable = v23;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_52;
}
if ( (*(_BYTE *)&__src.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__src.__r_.__value_.__l.__data_);
}