//
// cocos2d::CCLabelAtlas::initWithString from 0x1800474a0 to 0x180047db8 (2328 bytes)
//
// 3 xrefs:
// > cocos2d::CCLabelAtlas::create @ 0x180047396
// > ??> @ 0x18014cf68
// > ??> @ 0x1801bb9bc
//
// 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 11:21:41 +0000
//
// Hidden C++ exception states: #wind=8
char __fastcall cocos2d::CCLabelAtlas::initWithString(cocos2d::CCLabelAtlas *this, const char *a2, char *a3)
{
struct cocos2d::CCFileUtils *v4; // rax
void **v5; // rdi
void **v6; // r15
unsigned __int64 v7; // r12
size_t v8; // r14
size_t v9; // rbx
size_t v10; // rsi
void **v11; // rcx
void **v12; // rdx
__m128i v13; // kr00_16
void **v14; // rax
__m128i *v15; // rax
__m128i v16; // xmm7
__m128i v17; // xmm6
unsigned __int64 v18; // rbx
void *v19; // rcx
CCContentManager *v20; // rax
struct cocos2d::CCDictionary *v21; // rdi
cocos2d::CCString *v22; // rax
void *v23; // rcx
cocos2d::CCString *v24; // rax
unsigned __int64 v25; // r13
_OWORD *v26; // r12
void *v27; // rsi
unsigned __int64 v28; // r14
_QWORD *v29; // rdi
size_t v30; // rax
__int64 v31; // rax
size_t v32; // rcx
void *v33; // rcx
cocos2d::CCObject *v34; // r14
cocos2d::CCString *v35; // rax
float v36; // xmm6_4
cocos2d::CCDirector *v37; // rax
unsigned int v38; // r15d
void *v39; // rcx
cocos2d::CCString *v40; // rax
float v41; // xmm6_4
cocos2d::CCDirector *v42; // rax
float v43; // xmm6_4
void *v44; // rcx
cocos2d::CCString *v45; // rax
unsigned int v46; // ebx
void *v47; // r8
const char *CString; // rax
void *v49; // rcx
void *v50; // rcx
const char *Src; // [rsp+38h] [rbp-D0h]
__int64 v53; // [rsp+40h] [rbp-C8h]
unsigned __int64 v56; // [rsp+58h] [rbp-B0h]
_OWORD v57[2]; // [rsp+60h] [rbp-A8h] BYREF
_BYTE v58[256]; // [rsp+88h] [rbp-80h] BYREF
void *Block[2]; // [rsp+188h] [rbp+80h] BYREF
__m128i si128; // [rsp+198h] [rbp+90h]
void *v61[2]; // [rsp+1A8h] [rbp+A0h] BYREF
__m128i v62; // [rsp+1B8h] [rbp+B0h]
void *v63[2]; // [rsp+1C8h] [rbp+C0h] BYREF
__m128i v64; // [rsp+1D8h] [rbp+D0h]
void *v65[2]; // [rsp+1E8h] [rbp+E0h] BYREF
size_t v66; // [rsp+1F8h] [rbp+F0h]
unsigned __int64 v67; // [rsp+200h] [rbp+F8h]
v4 = cocos2d::CCFileUtils::sharedFileUtils();
(*(void (__fastcall **)(struct cocos2d::CCFileUtils *, void **, char *, _QWORD))(*(_QWORD *)v4 + 40LL))(
v4,
v65,
a3,
0);
v5 = v65;
v6 = (void **)v65[0];
v7 = v67;
if ( v67 > 0xF )
v5 = (void **)v65[0];
v8 = v66;
v9 = -1;
if ( v66 )
{
v10 = v66 - 1;
if ( v66 - 1 + 2 < 0x10 )
{
memset(v58, 0, sizeof(v58));
v58[47] = 1;
v11 = (void **)((char *)v5 + v10);
if ( v58[*((unsigned __int8 *)v5 + v10)] )
{
LABEL_9:
v9 = (char *)v11 - (char *)v5;
}
else
{
while ( v11 != v5 )
{
v11 = (void **)((char *)v11 - 1);
if ( v58[*(unsigned __int8 *)v11] )
goto LABEL_9;
}
}
}
else
{
v9 = sub_1800E4900(v5, v66, &unk_1800F18D8, 1u);
v7 = v67;
v8 = v66;
v6 = (void **)v65[0];
}
}
*(_OWORD *)Block = 0;
si128 = 0;
if ( v8 < v9 )
v9 = v8;
v12 = v65;
if ( v7 > 0xF )
v12 = v6;
sub_18000CEF0(Block, v12, v9);
v13 = si128;
if ( si128.m128i_i64[1] == si128.m128i_i64[0] )
{
v15 = (__m128i *)sub_180007A50(Block, 1u, 0, &unk_1800F18D8, 1u);
}
else
{
++si128.m128i_i64[0];
v14 = Block;
if ( v13.m128i_i64[1] > 0xFuLL )
v14 = (void **)Block[0];
*(_WORD *)((char *)v14 + v13.m128i_i64[0]) = 47;
v15 = (__m128i *)Block;
}
v16 = *v15;
v57[0] = *v15;
v17 = v15[1];
v57[1] = v17;
v15[1].m128i_i64[0] = 0;
v18 = 15;
v15[1].m128i_i64[1] = 15;
v15->m128i_i8[0] = 0;
if ( si128.m128i_i64[1] > 0xFuLL )
{
v19 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v19);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_1800EC500);
LOBYTE(Block[0]) = 0;
v20 = CCContentManager::sharedManager();
v21 = CCContentManager::addDictDS(v20, a3);
v53 = (__int64)v21;
HIWORD(Block[1]) = 0;
si128 = _mm_load_si128((const __m128i *)&xmmword_1800F1920);
qmemcpy(Block, "versio", 6);
*(void **)((char *)Block + 6) = (void *)(unsigned __int8)aVersion[6];
v22 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey((__int64)v21, (__int64)Block);
cocos2d::CCString::uintValue(v22);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v23 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v23 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v23 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v23);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_1800F1950);
strcpy((char *)Block, "textureFilename");
v24 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey((__int64)v21, (__int64)Block);
Src = cocos2d::CCString::getCString(v24);
v25 = strlen(Src);
if ( 0x7FFFFFFFFFFFFFFFLL - v17.m128i_i64[0] < v25 )
std::vector::_Xlen();
v26 = v57;
v27 = (void *)v16.m128i_i64[0];
v56 = _mm_srli_si128(v17, 8).m128i_u64[0];
if ( v56 > 0xF )
v26 = (_OWORD *)v16.m128i_i64[0];
*(_OWORD *)v63 = 0;
v64 = 0;
v28 = v17.m128i_i64[0] + v25;
v29 = v63;
if ( v17.m128i_i64[0] + v25 > 0xF )
{
v18 = v28 | 0xF;
if ( (v28 | 0xF) > 0x7FFFFFFFFFFFFFFFLL )
{
v18 = 0x7FFFFFFFFFFFFFFFLL;
v30 = 0x8000000000000027uLL;
LABEL_35:
v31 = sub_1800E4AC0(v30);
if ( !v31 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
v29 = (_QWORD *)((v31 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*(v29 - 1) = v31;
goto LABEL_46;
}
if ( v18 < 0x16 )
v18 = 22;
v32 = v18 + 1;
if ( v18 == -1 )
{
v29 = nullptr;
}
else
{
if ( v32 >= 0x1000 )
{
v30 = v18 + 40;
if ( v18 + 40 < v18 + 1 )
Concurrency::cancel_current_task();
goto LABEL_35;
}
v29 = (_QWORD *)sub_1800E4AC0(v32);
}
LABEL_46:
v63[0] = v29;
}
v64.m128i_i64[0] = v17.m128i_i64[0] + v25;
v64.m128i_i64[1] = v18;
memcpy(v29, v26, v17.m128i_u64[0]);
memcpy((char *)v29 + v17.m128i_i64[0], Src, v25);
*((_BYTE *)v29 + v28) = 0;
if ( si128.m128i_i64[1] > 0xFuLL )
{
v33 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v33 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v33 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v33);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_1800EC500);
LOBYTE(Block[0]) = 0;
v34 = cocos2d::CCString::create((__int64)v63);
v61[1] = (void *)104;
v62 = _mm_load_si128((const __m128i *)&xmmword_1800F1930);
v61[0] = (void *)0x746469576D657469LL;
v35 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v53, (__int64)v61);
v36 = (float)cocos2d::CCString::uintValue(v35);
v37 = cocos2d::CCDirector::sharedDirector();
v38 = (int)(float)(v36 / cocos2d::CCDirector::getContentScaleFactor(v37));
if ( v62.m128i_i64[1] > 0xFuLL )
{
v39 = v61[0];
if ( (unsigned __int64)(v62.m128i_i64[1] + 1) >= 0x1000 )
{
v39 = *((void **)v61[0] - 1);
if ( (unsigned __int64)((char *)v61[0] - (char *)v39 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v39);
}
v61[1] = (void *)29800;
v62 = _mm_load_si128((const __m128i *)&xmmword_1800F1940);
v61[0] = (void *)0x676965486D657469LL;
v40 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v53, (__int64)v61);
v41 = (float)cocos2d::CCString::uintValue(v40);
v42 = cocos2d::CCDirector::sharedDirector();
v43 = v41 / cocos2d::CCDirector::getContentScaleFactor(v42);
if ( v62.m128i_i64[1] > 0xFuLL )
{
v44 = v61[0];
if ( (unsigned __int64)(v62.m128i_i64[1] + 1) >= 0x1000 )
{
v44 = *((void **)v61[0] - 1);
if ( (unsigned __int64)((char *)v61[0] - (char *)v44 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v44);
}
v61[1] = (void *)114;
v62 = _mm_load_si128((const __m128i *)&xmmword_1800F1930);
v61[0] = (void *)0x6168437473726966LL;
v45 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v53, (__int64)v61);
v46 = cocos2d::CCString::uintValue(v45);
if ( v62.m128i_i64[1] > 0xFuLL )
{
v47 = v61[0];
if ( (unsigned __int64)(v62.m128i_i64[1] + 1) >= 0x1000 )
{
v47 = *((void **)v61[0] - 1);
if ( (unsigned __int64)((char *)v61[0] - (char *)v47 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v47);
}
CString = cocos2d::CCString::getCString(v34);
cocos2d::CCLabelAtlas::initWithString(this, a2, CString, v38, (int)v43, v46);
if ( v64.m128i_i64[1] > 0xFuLL )
{
v49 = v63[0];
if ( (unsigned __int64)(v64.m128i_i64[1] + 1) >= 0x1000 )
{
v49 = *((void **)v63[0] - 1);
if ( (unsigned __int64)((char *)v63[0] - (char *)v49 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v49);
}
v64 = _mm_load_si128((const __m128i *)&xmmword_1800EC500);
LOBYTE(v63[0]) = 0;
if ( v56 > 0xF )
{
if ( v56 + 1 >= 0x1000 )
{
v27 = *(void **)(v16.m128i_i64[0] - 8);
if ( (unsigned __int64)(v16.m128i_i64[0] - (_QWORD)v27 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v27);
}
if ( v67 > 0xF )
{
v50 = v65[0];
if ( v67 + 1 >= 0x1000 )
{
v50 = *((void **)v65[0] - 1);
if ( (unsigned __int64)((char *)v65[0] - (char *)v50 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v50);
}
return 1;
}