//
// cocos2d::CCLabelAtlas::initWithString from 0xd54790 to 0xd54bf8 (1128 bytes)
//
// 2 xrefs:
// > cocos2d::CCLabelAtlas::create @ 0xd54c5c
// > ??> @ 0x7cf90
//
// This function is hookable on this platform (idp: arm, 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 13:07:42 +0000
//
__int64 __fastcall cocos2d::CCLabelAtlas::initWithString(cocos2d::CCLabelAtlas *this, const char *a2, const char *a3)
{
__int64 v5; // x0
int v6; // w22
int v7; // w26
char *v8; // x1
size_t v9; // x20
char *v10; // x19
char *v11; // x27
int v12; // t1
size_t v13; // x2
__int64 *v14; // x0
void *v15; // x1
__int64 v16; // x2
size_t v17; // x3
CCContentManager *v18; // x0
CCContentManager *v19; // x0
__int64 v20; // x20
cocos2d::CCString *v21; // x0
cocos2d::CCString *v22; // x0
char *CString; // x0
char *v24; // x25
int v25; // w24
size_t v26; // x19
size_t v27; // x27
char *v28; // x1
size_t v29; // x0
char *v30; // x4
cocos2d::CCObject *v31; // x25
cocos2d::CCString *v32; // x0
cocos2d::CCDirector *v33; // x0
int v34; // w23
cocos2d::CCDirector *v35; // x0
int v36; // w26
cocos2d::CCString *v37; // x0
cocos2d::CCDirector *v38; // x0
int v39; // w19
cocos2d::CCDirector *v40; // x0
int v41; // w19
cocos2d::CCString *v42; // x0
int v43; // w20
char *v44; // x0
unsigned __int64 v46; // x0
__int64 v47; // x26
char *v48; // x0
char *v49; // [xsp+60h] [xbp+60h]
__int64 v51; // [xsp+78h] [xbp+78h] BYREF
size_t v52; // [xsp+80h] [xbp+80h]
void *v53; // [xsp+88h] [xbp+88h]
__int64 v54; // [xsp+90h] [xbp+90h] BYREF
size_t v55; // [xsp+98h] [xbp+98h]
void *v56; // [xsp+A0h] [xbp+A0h]
__int64 v57; // [xsp+A8h] [xbp+A8h] BYREF
size_t v58; // [xsp+B0h] [xbp+B0h]
void *v59; // [xsp+B8h] [xbp+B8h]
CCContentManager *v60; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v61; // [xsp+C8h] [xbp+C8h]
void *v62; // [xsp+D0h] [xbp+D0h]
v5 = cocos2d::CCFileUtils::sharedFileUtils(_stack_chk_guard);
(*(void (__fastcall **)(__int64 *__return_ptr, __int64, const char *, _QWORD))(*(_QWORD *)v5 + 48LL))(&v51, v5, a3, 0);
v6 = (unsigned __int8)v51;
v7 = v51 & 1;
if ( v7 )
{
v8 = (char *)v53;
v9 = v52;
v10 = (char *)v53;
v11 = (char *)v53 + v52;
if ( v10 != &v10[v52] )
goto LABEL_5;
v60 = nullptr;
v13 = -1;
v61 = 0;
v62 = nullptr;
}
else
{
v10 = (char *)&v51 + 1;
LODWORD(v9) = (int)(unsigned __int8)v51 >> 1;
v11 = (char *)&v51 + (int)v9 + 1;
if ( v11 == (char *)&v51 + 1 )
{
v60 = nullptr;
v13 = -1;
v61 = 0;
v62 = nullptr;
}
else
{
do
{
LABEL_5:
v12 = (unsigned __int8)*--v11;
if ( memchr(&word_11BA098, v12, 1u) )
{
v13 = v11 - v10;
goto LABEL_7;
}
}
while ( v11 != v10 );
v13 = -1;
LABEL_7:
v60 = nullptr;
LODWORD(v9) = v6 >> 1;
v61 = 0;
v62 = nullptr;
if ( v7 )
{
v8 = (char *)v53;
v9 = v52;
goto LABEL_9;
}
}
v9 = (int)v9;
v8 = (char *)&v51 + 1;
}
LABEL_9:
if ( v13 > v9 )
v13 = v9;
std::string::__init((__int64 *)&v60, v8, v13);
v14 = (__int64 *)std::string::append((__int64)&v60, &word_11BA098, 1u);
v15 = (void *)v14[2];
v16 = *v14;
v17 = v14[1];
v14[2] = 0;
*v14 = 0;
v14[1] = 0;
v54 = v16;
v55 = v17;
v18 = (CCContentManager *)(unsigned __int8)v60;
v56 = v15;
if ( ((unsigned __int8)v60 & 1) != 0 )
operator delete(v62);
v19 = (CCContentManager *)CCContentManager::sharedManager(v18);
v20 = CCContentManager::addDict(v19, a3, 0);
v60 = nullptr;
v61 = 0;
v62 = nullptr;
std::string::__init((__int64 *)&v60, "version", 7u);
v21 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v20, (__int64)&v60);
cocos2d::CCString::intValue(v21);
if ( ((unsigned __int8)v60 & 1) != 0 )
operator delete(v62);
v60 = nullptr;
v61 = 0;
v62 = nullptr;
std::string::__init((__int64 *)&v60, "textureFilename", 0xFu);
v22 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v20, (__int64)&v60);
CString = cocos2d::CCString::getCString(v22);
v57 = 0;
v24 = CString;
v58 = 0;
v25 = v54 & 1;
v59 = nullptr;
if ( v25 )
{
v26 = v55;
v27 = strlen(CString);
v28 = (char *)v56;
v29 = v27 + v26;
if ( v27 + v26 <= 0x16 )
{
LABEL_17:
v30 = (char *)&v57 + 1;
LOBYTE(v57) = 2 * v26;
goto LABEL_18;
}
}
else
{
v26 = (unsigned __int8)v54 >> 1;
v27 = strlen(CString);
v29 = v27 + v26;
v28 = (char *)&v54 + 1;
if ( v27 + v26 <= 0x16 )
goto LABEL_17;
}
v49 = v28;
v46 = (v29 + 16) & 0xFFFFFFFFFFFFFFF0LL;
v47 = v46 | 1;
v48 = (char *)operator new(v46);
v57 = v47;
v30 = v48;
v59 = v48;
v58 = v26;
v28 = v49;
LABEL_18:
if ( v26 )
v30 = (char *)memcpy(v30, v28, v26);
v30[v26] = 0;
std::string::append((__int64)&v57, v24, v27);
if ( ((unsigned __int8)v60 & 1) != 0 )
operator delete(v62);
v31 = cocos2d::CCString::create(&v57);
v60 = nullptr;
v61 = 0;
v62 = nullptr;
std::string::__init((__int64 *)&v60, "itemWidth", 9u);
v32 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v20, (__int64)&v60);
v33 = (cocos2d::CCDirector *)cocos2d::CCString::intValue(v32);
v34 = (int)v33;
v35 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v33);
v36 = (unsigned int)(float)((float)v34 / cocos2d::CCDirector::getContentScaleFactor(v35));
if ( ((unsigned __int8)v60 & 1) != 0 )
operator delete(v62);
v60 = nullptr;
v61 = 0;
v62 = nullptr;
std::string::__init((__int64 *)&v60, "itemHeight", 0xAu);
v37 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v20, (__int64)&v60);
v38 = (cocos2d::CCDirector *)cocos2d::CCString::intValue(v37);
v39 = (int)v38;
v40 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v38);
v41 = (unsigned int)(float)((float)v39 / cocos2d::CCDirector::getContentScaleFactor(v40));
if ( ((unsigned __int8)v60 & 1) != 0 )
operator delete(v62);
v60 = nullptr;
v61 = 0;
v62 = nullptr;
std::string::__init((__int64 *)&v60, "firstChar", 9u);
v42 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v20, (__int64)&v60);
v43 = cocos2d::CCString::intValue(v42);
if ( ((unsigned __int8)v60 & 1) != 0 )
operator delete(v62);
v44 = cocos2d::CCString::getCString(v31);
cocos2d::CCLabelAtlas::initWithString(this, a2, v44, v36, v41, v43);
if ( (v57 & 1) != 0 )
{
operator delete(v59);
if ( !v25 )
goto LABEL_30;
}
else if ( !v25 )
{
goto LABEL_30;
}
operator delete(v56);
LABEL_30:
if ( (v51 & 1) != 0 )
operator delete(v53);
return 1;
}