//
// sub_100329890 from 0x100329890 to 0x100329afd (621 bytes)
//
// 2 xrefs:
// > cocos2d::CCApplication::setResourceRootPath @ 0x100329817
// > sub_10056DBF0 @ 0x10056dc57
//
// 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
//
std::string *__fastcall sub_100329890(char **a1, std::string *a2, unsigned __int64 a3, double a4)
{
std::string *v5; // rbx
unsigned __int64 v7; // r12
unsigned __int64 v8; // rcx
std::string *v9; // r13
unsigned __int64 v10; // rax
unsigned __int64 v11; // r12
char *v12; // r13
unsigned __int64 v13; // r12
unsigned __int64 v14; // rcx
char *v15; // rax
__int64 v16; // rsi
char *v17; // r12
size_t v18; // rbx
char *v19; // r15
char *v20; // rdi
char *v21; // rax
__int128 v22; // xmm0
char *v24; // [rsp+0h] [rbp-50h] BYREF
char *v25; // [rsp+8h] [rbp-48h]
void *__dst[2]; // [rsp+10h] [rbp-40h]
char **v27; // [rsp+20h] [rbp-30h]
v5 = a2;
v7 = (unsigned __int64)a1[1];
v8 = (unsigned __int64)a1[2];
if ( v7 >= v8 )
{
v12 = *a1;
v13 = 0xAAAAAAAAAAAAAAABLL * ((__int64)(v7 - (_QWORD)*a1) >> 3) + 1;
if ( v13 > 0xAAAAAAAAAAAAAAALL )
sub_100054A60();
v14 = 0xAAAAAAAAAAAAAAABLL * ((__int64)(v8 - (_QWORD)v12) >> 3);
if ( 2 * v14 > v13 )
v13 = 2 * v14;
if ( v14 >= 0x555555555555555LL )
v13 = 0xAAAAAAAAAAAAAAALL;
v27 = a1;
if ( v13 )
{
if ( v13 > 0xAAAAAAAAAAAAAAALL )
sub_100054850();
v15 = (char *)operator new(24 * v13);
}
else
{
v15 = nullptr;
}
v24 = v15;
__dst[0] = &v15[8 * (((char *)a2 - v12) >> 3)];
v25 = (char *)__dst[0];
__dst[1] = &v15[24 * v13];
sub_10032A4C0(&v24, a3);
v17 = v25;
memcpy(__dst[0], a2, a1[1] - (char *)a2);
__dst[0] = (char *)__dst[0] + a1[1] - (char *)a2;
a1[1] = (char *)a2;
v18 = (char *)a2 - *a1;
v19 = &v25[-v18];
memcpy(&v25[-v18], *a1, v18);
v20 = *a1;
*a1 = v19;
v25 = v20;
v21 = a1[2];
v22 = *(_OWORD *)__dst;
__dst[0] = v20;
*(_OWORD *)(a1 + 1) = v22;
__dst[1] = v21;
v24 = v20;
if ( v20 )
operator delete(v20);
return (std::string *)v17;
}
else if ( (std::string *)v7 == a2 )
{
if ( (*(_BYTE *)a3 & 1) != 0 )
{
sub_100006B70(a1[1], *(const void **)(a3 + 16), *(_QWORD *)(a3 + 8), a4);
}
else
{
*(_QWORD *)(v7 + 16) = *(_QWORD *)(a3 + 16);
*(_OWORD *)v7 = *(_OWORD *)a3;
}
a1[1] = (char *)(v7 + 24);
}
else
{
v9 = (std::string *)(v7 - 24);
v10 = (unsigned __int64)a1[1];
if ( v7 >= 0x18 )
{
v10 = v7 + 24;
*(_QWORD *)(v7 + 16) = v9->__r_.__value_.__l.__data_;
*(_OWORD *)v7 = *(_OWORD *)&v9->__r_.__value_.__l.0;
*(_OWORD *)&v9->__r_.__value_.__l.0 = 0;
v9->__r_.__value_.__r.__words[2] = 0;
}
a1[1] = (char *)v10;
if ( (std::string *)v7 != &a2[1] )
{
v11 = v7 - 24;
do
{
if ( (*(_BYTE *)v11 & 1) != 0 )
operator delete(*(void **)(v11 + 16));
*(_QWORD *)(v11 + 16) = v9[-1].__r_.__value_.__l.__data_;
*(_OWORD *)v11 = *(_OWORD *)&v9[-1].__r_.__value_.__l.0;
*(_WORD *)&v9[-1].__r_.__value_.__l.0 = 0;
v11 -= 24LL;
--v9;
}
while ( v9 != a2 );
v10 = (unsigned __int64)a1[1];
}
v16 = 24;
if ( v10 <= a3 )
v16 = 0;
if ( a3 < (unsigned __int64)v5 )
v16 = 0;
std::string::operator=(v5, (const std::string *)(a3 + v16));
}
return v5;
}