//
// cocos2d::CCFileUtils::addSuffix from 0x10043b1a0 to 0x10043b3c1 (545 bytes)
//
// 2 xrefs:
// > ??> @ 0x100938060
// > ??> @ 0x100980600
//
// 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
//
__int64 __fastcall cocos2d::CCFileUtils::addSuffix(
__int64 a1,
double a2,
__int64 a3,
std::string *a4,
unsigned __int8 *a5)
{
unsigned int v6; // edx
signed __int64 size; // rdx
unsigned int v8; // r13d
char *v9; // r14
signed __int64 v10; // r13
std::string::pointer v11; // r15
int v12; // ebx
size_t v13; // rdx
char *v14; // rax
char *v15; // r15
std::string::size_type v16; // rax
std::string::pointer data; // rcx
std::string::size_type v18; // rsi
unsigned __int64 v19; // rdx
bool v20; // zf
std::string::size_type v21; // rsi
unsigned int v22; // ecx
const std::string::value_type *v23; // rdx
std::string::size_type v24; // rcx
unsigned int v25; // edx
const std::string::value_type *v26; // rsi
std::string::size_type v27; // rdx
char v29; // [rsp+0h] [rbp-70h]
char *v30; // [rsp+8h] [rbp-68h]
std::string::value_type *v32; // [rsp+20h] [rbp-50h]
std::string::pointer __s; // [rsp+28h] [rbp-48h]
std::string v34; // [rsp+30h] [rbp-40h] BYREF
v6 = (unsigned int)a4->__r_.__value_.__l.0;
v29 = v6;
if ( (v6 & 1) != 0 )
{
size = a4->__r_.__value_.__l.__size_;
__s = a4->__r_.__value_.__l.__data_;
}
else
{
__s = a4->__r_.__value_.__s.__data_;
size = v6 >> 1;
}
v8 = *a5;
v9 = (char *)(a5 + 1);
v32 = (std::string::value_type *)(a5 + 1);
if ( (v8 & 1) != 0 )
{
v9 = *((char **)a5 + 2);
v10 = *((_QWORD *)a5 + 1);
if ( !v10 )
goto LABEL_37;
}
else
{
v10 = v8 >> 1;
if ( !v10 )
{
LABEL_37:
*(_QWORD *)(a1 + 16) = a4->__r_.__value_.__l.__data_;
*(_OWORD *)a1 = *(_OWORD *)&a4->__r_.__value_.__l.0;
*(_OWORD *)&a4->__r_.__value_.__l.0 = 0;
a4->__r_.__value_.__r.__words[2] = 0;
return a1;
}
}
if ( size >= v10 )
{
v11 = __s;
v30 = &__s[size];
v12 = *v9;
do
{
v13 = size - v10 + 1;
if ( !v13 )
break;
v14 = (char *)memchr(v11, v12, v13);
if ( !v14 )
break;
v15 = v14;
if ( !memcmp(v14, v9, v10) )
{
if ( v15 == v30 || v15 - __s == -1 )
break;
goto LABEL_37;
}
v11 = v15 + 1;
size = v30 - v11;
}
while ( v30 - v11 >= v10 );
}
if ( (v29 & 1) != 0 )
sub_100006B70(&v34, a4->__r_.__value_.__l.__data_, a4->__r_.__value_.__l.__size_, a2);
else
v34 = *a4;
v16 = *(_BYTE *)&v34.__r_.__value_.__l.0 >> 1;
data = v34.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) != 0 )
{
data = v34.__r_.__value_.__l.__data_;
v16 = v34.__r_.__value_.__l.__size_;
}
v18 = v16;
do
{
if ( !v18 )
{
v19 = -1;
break;
}
v19 = v18 - 1;
v20 = data[--v18] == 47;
}
while ( !v20 );
while ( v16 )
{
v21 = v16 - 1;
v20 = data[--v16] == 46;
if ( v20 )
{
if ( v21 != -1 && (v21 > v19 || v19 == -1) )
{
v22 = *a5;
if ( (v22 & 1) != 0 )
{
v23 = *((const std::string::value_type **)a5 + 2);
v24 = *((_QWORD *)a5 + 1);
}
else
{
v24 = v22 >> 1;
v23 = v32;
}
std::string::insert(&v34, v21, v23, v24);
goto LABEL_35;
}
break;
}
}
v25 = *a5;
if ( (v25 & 1) != 0 )
{
v26 = *((const std::string::value_type **)a5 + 2);
v27 = *((_QWORD *)a5 + 1);
}
else
{
v27 = v25 >> 1;
v26 = v32;
}
std::string::append(&v34, v26, v27);
LABEL_35:
*(std::string *)a1 = v34;
return a1;
}