//
// cocos2d::CCLabelAtlas::initWithString_2 from 0x100799420 to 0x1007998b2 (1170 bytes)
//
// 1 xrefs:
// > cocos2d::CCLabelAtlas::create_1 @ 0x1007993eb
//
// 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
//
bool __fastcall cocos2d::CCLabelAtlas::initWithString_2(cocos2d::CCLabelAtlas *a1, const char *a2, const char *a3)
{
double v3; // xmm0_8
cocos2d::CCFileUtils *v5; // rax
size_t v6; // rax
char *v7; // rbx
size_t v8; // rcx
std::string::size_type v9; // r12
char *data; // r14
size_t v12; // r13
std::string *v13; // rax
CCContentManager *v14; // rax
cocos2d::CCDictionary *v15; // rbx
cocos2d::CCString *v16; // rax
cocos2d::CCString *v17; // rax
size_t v18; // rbx
size_t v19; // rax
std::string::size_type v20; // r15
size_t v21; // r13
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v22; // r15
char *v23; // r14
size_t v24; // r12
char *v25; // rsi
char *v26; // r14
cocos2d::CCString *v27; // r13
cocos2d::CCString *v28; // rax
int v29; // r12d
cocos2d::CCDirector *v30; // rax
cocos2d::CCString *v31; // rax
int v32; // ebx
cocos2d::CCDirector *v33; // rax
cocos2d::CCString *v34; // rax
int v35; // r15d
const char *CString; // r14
cocos2d::CCTextureCache *v37; // rax
cocos2d::CCTexture2D *v38; // r14
unsigned int v39; // eax
cocos2d::CCLabelAtlas *v40; // rdi
__int64 v42; // [rsp+0h] [rbp-C0h]
unsigned __int8 v43; // [rsp+8h] [rbp-B8h] BYREF
char v44; // [rsp+9h] [rbp-B7h] BYREF
size_t __len; // [rsp+10h] [rbp-B0h]
void *__src; // [rsp+18h] [rbp-A8h]
char *v47; // [rsp+20h] [rbp-A0h]
cocos2d::CCLabelAtlas *v48; // [rsp+28h] [rbp-98h]
size_t v49[2]; // [rsp+30h] [rbp-90h] BYREF
void *v50; // [rsp+40h] [rbp-80h]
float v51; // [rsp+4Ch] [rbp-74h]
char *__s; // [rsp+50h] [rbp-70h]
int v53; // [rsp+5Ch] [rbp-64h]
std::string __dst; // [rsp+60h] [rbp-60h] BYREF
char v55; // [rsp+80h] [rbp-40h] BYREF
_BYTE v56[46]; // [rsp+81h] [rbp-3Fh] BYREF
v47 = (char *)a2;
v48 = a1;
v5 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(unsigned __int8 *, cocos2d::CCFileUtils *, const char *, _QWORD))v5->createCCArrayWithContentsOfFile)(
&v43,
v5,
a3,
0);
v6 = v43 >> 1;
v7 = &v44;
if ( (v43 & 1) != 0 )
{
v7 = (char *)__src;
v6 = __len;
}
v8 = v6;
while ( v8 )
{
v9 = v8 - 1;
if ( v7[--v8] == 47 )
goto LABEL_8;
}
v9 = -1;
LABEL_8:
if ( v6 < v9 )
v9 = v6;
if ( v9 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v3);
data = __dst.__r_.__value_.__s.__data_;
if ( v9 >= 0x17 )
{
v12 = 26;
if ( (v9 | 7) != 0x17 )
v12 = (v9 | 7) + 1;
data = (char *)operator new(v12);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst.__r_.__value_.__r.__words[0] = v12 | 1;
__dst.__r_.__value_.__l.__size_ = v9;
goto LABEL_17;
}
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v9);
if ( v9 )
LABEL_17:
memmove(data, v7, v9);
data[v9] = 0;
v13 = std::string::append(&__dst, "/");
v50 = v13->__r_.__value_.__l.__data_;
*(_OWORD *)v49 = *(_OWORD *)&v13->__r_.__value_.__l.0;
*(_OWORD *)&v13->__r_.__value_.__l.0 = 0;
v13->__r_.__value_.__r.__words[2] = 0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
v14 = CCContentManager::sharedManager();
v15 = CCContentManager::addDict(v14, a3, 0);
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)14;
strcpy(__dst.__r_.__value_.__s.__data_, "version");
v16 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1((__int64)v15, (char *)&__dst);
cocos2d::CCString::intValue(v16);
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
v55 = 30;
strcpy(v56, "textureFilename");
v42 = (__int64)v15;
v17 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1((__int64)v15, &v55);
__s = (char *)cocos2d::CCString::getCString(v17);
v53 = LOBYTE(v49[0]);
if ( (v49[0] & 1) != 0 )
v18 = v49[1];
else
v18 = LOBYTE(v49[0]) >> 1;
v19 = strlen(__s);
v20 = v18 + v19;
if ( v18 + v19 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(0.0);
v21 = v19;
if ( v20 > 0x16 )
{
v24 = 26;
if ( (v20 | 7) != 0x17 )
v24 = (v20 | 7) + 1;
v23 = (char *)operator new(v24);
__dst.__r_.__value_.__r.__words[0] = v24 | 1;
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)v23;
__dst.__r_.__value_.__l.__size_ = v20;
v22 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(v24 | 1);
}
else
{
memset(&__dst, 0, sizeof(__dst));
v22 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v20);
__dst.__r_.__value_.__s.0 = v22;
v23 = nullptr;
}
if ( (*(_BYTE *)&v22 & 1) == 0 )
v23 = __dst.__r_.__value_.__s.__data_;
if ( v18 )
{
if ( (v53 & 1) != 0 )
v25 = (char *)v50;
else
v25 = (char *)v49 + 1;
memmove(v23, v25, v18);
}
v26 = &v23[v18];
if ( v21 )
memmove(v26, __s, v21);
v26[v21] = 0;
if ( (v55 & 1) != 0 )
operator delete(*(void **)&v56[15]);
v27 = (cocos2d::CCString *)sub_1007AB360(&__dst);
v55 = 18;
strcpy(v56, "itemWidth");
v28 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(v42, &v55);
v29 = cocos2d::CCString::intValue(v28);
v30 = cocos2d::CCDirector::sharedDirector();
LODWORD(__s) = sub_1004849C0((__int64)v30);
if ( (v55 & 1) != 0 )
operator delete(*(void **)&v56[15]);
v55 = 20;
strcpy(v56, "itemHeight");
v31 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(v42, &v55);
v32 = cocos2d::CCString::intValue(v31);
v33 = cocos2d::CCDirector::sharedDirector();
v51 = sub_1004849C0((__int64)v33);
if ( (v55 & 1) != 0 )
operator delete(*(void **)&v56[15]);
v55 = 18;
strcpy(v56, "firstChar");
v34 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(v42, &v55);
v35 = cocos2d::CCString::intValue(v34);
if ( (v55 & 1) != 0 )
operator delete(*(void **)&v56[15]);
CString = cocos2d::CCString::getCString(v27);
v37 = cocos2d::CCTextureCache::sharedTextureCache();
v38 = cocos2d::CCTextureCache::addImage(v37, CString, 0);
v39 = strlen(v47);
if ( cocos2d::CCAtlasNode::initWithTexture(
v48,
v38,
(int)(float)((float)v29 / *(float *)&__s),
(int)(float)((float)v32 / v51),
v39) )
{
v40 = v48;
v48->m_uMapStartChar = v35;
((void (__fastcall *)(cocos2d::CCLabelAtlas *, char *))v40->setString)(v40, v47);
}
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
{
if ( (v53 & 1) == 0 )
goto LABEL_52;
LABEL_56:
operator delete(v50);
if ( (v43 & 1) == 0 )
return 1;
goto LABEL_53;
}
operator delete(__dst.__r_.__value_.__l.__data_);
if ( (v53 & 1) != 0 )
goto LABEL_56;
LABEL_52:
if ( (v43 & 1) != 0 )
LABEL_53:
operator delete(__src);
return 1;
}