//
// sub_100314FA0 from 0x100314fa0 to 0x10031520d (621 bytes)
//
// 2 xrefs:
// > cocos2d::CCApplication::setResourceRootPath @ 0x100314f27
// > sub_10059ACB0 @ 0x10059ad17
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:28:40 +0000
//
std::string *__fastcall sub_100314FA0(char **a1, std::string *a2, unsigned __int64 a3)
{
std::string *v4; // rbx
unsigned __int64 v6; // r12
unsigned __int64 v7; // rcx
std::string *v8; // r13
unsigned __int64 v9; // rax
unsigned __int64 v10; // r12
char *v11; // r13
unsigned __int64 v12; // r12
unsigned __int64 v13; // rcx
char *v14; // rax
__int64 v15; // rsi
char *v16; // r12
size_t v17; // rbx
char *v18; // r15
char *v19; // rdi
char *v20; // rax
__int128 v21; // xmm0
char *v23; // [rsp+0h] [rbp-50h] BYREF
char *v24; // [rsp+8h] [rbp-48h]
void *__dst[2]; // [rsp+10h] [rbp-40h]
char **v26; // [rsp+20h] [rbp-30h]
v4 = a2;
v6 = (unsigned __int64)a1[1];
v7 = (unsigned __int64)a1[2];
if ( v6 >= v7 )
{
v11 = *a1;
v12 = 0xAAAAAAAAAAAAAAABLL * ((__int64)(v6 - (_QWORD)*a1) >> 3) + 1;
if ( v12 > 0xAAAAAAAAAAAAAAALL )
sub_100056A70();
v13 = 0xAAAAAAAAAAAAAAABLL * ((__int64)(v7 - (_QWORD)v11) >> 3);
if ( 2 * v13 > v12 )
v12 = 2 * v13;
if ( v13 >= 0x555555555555555LL )
v12 = 0xAAAAAAAAAAAAAAALL;
v26 = a1;
if ( v12 )
{
if ( v12 > 0xAAAAAAAAAAAAAAALL )
sub_10001ADB0();
v14 = (char *)operator new(24 * v12);
}
else
{
v14 = nullptr;
}
v23 = v14;
__dst[0] = &v14[8 * (((char *)a2 - v11) >> 3)];
v24 = (char *)__dst[0];
__dst[1] = &v14[24 * v12];
sub_100315BD0(&v23, a3);
v16 = v24;
memcpy(__dst[0], a2, a1[1] - (char *)a2);
__dst[0] = (char *)__dst[0] + a1[1] - (char *)a2;
a1[1] = (char *)a2;
v17 = (char *)a2 - *a1;
v18 = &v24[-v17];
memcpy(&v24[-v17], *a1, v17);
v19 = *a1;
*a1 = v18;
v24 = v19;
v20 = a1[2];
v21 = *(_OWORD *)__dst;
__dst[0] = v19;
*(_OWORD *)(a1 + 1) = v21;
__dst[1] = v20;
v23 = v19;
if ( v19 )
operator delete(v19);
return (std::string *)v16;
}
else if ( (std::string *)v6 == a2 )
{
if ( (*(_BYTE *)a3 & 1) != 0 )
{
sub_10001AD30(a1[1], *(const void **)(a3 + 16), *(_QWORD *)(a3 + 8));
}
else
{
*(_QWORD *)(v6 + 16) = *(_QWORD *)(a3 + 16);
*(_OWORD *)v6 = *(_OWORD *)a3;
}
a1[1] = (char *)(v6 + 24);
}
else
{
v8 = (std::string *)(v6 - 24);
v9 = (unsigned __int64)a1[1];
if ( v6 >= 0x18 )
{
v9 = v6 + 24;
*(_QWORD *)(v6 + 16) = v8->__r_.__value_.__l.__data_;
*(_OWORD *)v6 = *(_OWORD *)&v8->__r_.__value_.__l.0;
*(_OWORD *)&v8->__r_.__value_.__l.0 = 0;
v8->__r_.__value_.__r.__words[2] = 0;
}
a1[1] = (char *)v9;
if ( (std::string *)v6 != &a2[1] )
{
v10 = v6 - 24;
do
{
if ( (*(_BYTE *)v10 & 1) != 0 )
operator delete(*(void **)(v10 + 16));
*(_QWORD *)(v10 + 16) = v8[-1].__r_.__value_.__l.__data_;
*(_OWORD *)v10 = *(_OWORD *)&v8[-1].__r_.__value_.__l.0;
*(_WORD *)&v8[-1].__r_.__value_.__l.0 = 0;
v10 -= 24LL;
--v8;
}
while ( v8 != a2 );
v9 = (unsigned __int64)a1[1];
}
v15 = 24;
if ( v9 <= a3 )
v15 = 0;
if ( a3 < (unsigned __int64)v4 )
v15 = 0;
std::string::operator=(v4, (const std::string *)(a3 + v15));
}
return v4;
}