//
// cocos2d::CCLabelBMFont::updateLabel from 0x1002fc474 to 0x1002fcaa0 (1580 bytes)
//
// 2 xrefs:
// > ??> @ 0x10076cde0
// > ??> @ 0x1007e9e98
//
// 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
//
void __fastcall cocos2d::CCLabelBMFont::updateLabel(cocos2d::CCLabelBMFont *a1)
{
signed __int64 v2; // x22
__int64 v3; // x20
unsigned int v4; // w23
int v5; // w24
bool v6; // w26
bool v7; // w25
__int64 v8; // x27
float v9; // s10
float v10; // s9
__int64 v11; // x28
__int64 v12; // x0
__int64 v13; // x21
int v14; // w0
float v15; // s10
float v16; // s11
float m_fScaleX; // s12
float v18; // s11
float v19; // s12
float v20; // s13
float *v21; // x0
float v22; // s0
std::__vector_base::pointer begin; // x2
std::__vector_base::pointer v24; // x21
unsigned __int64 v25; // x22
const mach_header_64 *v26; // x8
size_t v27; // x0
char *v28; // x0
void *v29; // x20
__int64 v30; // x9
_WORD *v31; // x10
__int16 v32; // t1
int v33; // w0
__int64 v34; // x23
int v35; // w24
int v36; // w21
__int64 v37; // x25
__int16 *v38; // x1
int v39; // w8
unsigned __int64 v41; // x27
int v42; // w26
__int64 v43; // x0
__int64 v44; // x20
float v45; // s8
float v46; // s8
cocos2d::CCTextAlignment m_pAlignment; // w8
float v48; // s8
__int64 v49; // x20
__int64 v50; // x0
__int64 v51; // x21
float32x2_t *v52; // x22
__n128 v53; // q1
__n128 v54; // q0
double v55; // d0
__int16 v56; // [xsp+4h] [xbp-CCh] BYREF
unsigned __int16 v57; // [xsp+6h] [xbp-CAh] BYREF
std::vector __p; // [xsp+8h] [xbp-C8h] BYREF
std::vector v59; // [xsp+20h] [xbp-B0h] BYREF
std::vector v60; // [xsp+38h] [xbp-98h] BYREF
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int16 *, _QWORD))a1->setString_1)(
a1,
a1->m_sInitialString,
0);
if ( a1->m_fWidth <= 0.0 )
goto LABEL_45;
cocos2d::cc_utf16_vec_from_utf16_str(&v60, a1->m_sString);
v2 = v60.__end_ - v60.__begin_;
memset(&v59, 0, sizeof(v59));
sub_1002FCB38(&v59, (unsigned int)v2);
memset(&__p, 0, sizeof(__p));
sub_1002FCB38(&__p, (unsigned int)v2);
v3 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->getChildren)(a1);
v4 = 0;
v5 = 0;
v6 = 0;
v7 = 0;
v8 = 0;
v9 = -1.0;
v10 = -1.0;
while ( 1 )
{
v11 = v8;
if ( v4 >= (unsigned int)sub_10024A36C(v3) )
{
LABEL_32:
begin = __p.__begin_;
goto LABEL_33;
}
while ( 1 )
{
v12 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->getChildByTag)(a1, v4 + v5);
v13 = v12;
if ( v12 )
break;
v11 = (unsigned int)(v11 + 1);
++v5;
}
if ( !(*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v12 + 336LL))(v12) )
goto LABEL_31;
if ( (unsigned int)v8 >= (unsigned int)v2 )
goto LABEL_32;
v14 = v60.__begin_[(unsigned int)v8];
v57 = v60.__begin_[(unsigned int)v8];
if ( !v6 )
{
v15 = *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 312LL))(v13);
v16 = *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 192LL))(v13);
m_fScaleX = a1->m_fScaleX;
v9 = (float)((float)-(float)(v15 * m_fScaleX)
* *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 288LL))(v13))
+ (float)(v16 * m_fScaleX);
v14 = v57;
}
if ( !v7 )
v10 = v9;
v7 = v14 != 10;
if ( v14 == 10 )
break;
LABEL_15:
if ( cocos2d::isspace_unicode(v14) )
{
sub_1001AD2B8((__int64)&__p, (__int16 *)&v57);
sub_1002FCF98((int)&v59, v59.__end_, __p.__begin_);
v6 = 0;
__p.__end_ = __p.__begin_;
v9 = -1.0;
LABEL_30:
v8 = (unsigned int)(v8 + 1);
goto LABEL_31;
}
v18 = *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 312LL))(v13);
v19 = *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 192LL))(v13);
v20 = a1->m_fScaleX;
v21 = (float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 288LL))(v13);
if ( v18 > 0.0 )
v22 = v18;
else
v22 = 0.0;
if ( (float)((float)((float)((float)(v22 * v20) * *v21) + (float)(v19 * v20)) - v10) <= a1->m_fWidth )
{
sub_1001AD2B8((__int64)&__p, (__int16 *)&v57);
v6 = v7;
goto LABEL_30;
}
if ( !a1->m_bLineBreakWithoutSpaces )
{
sub_1001AD2B8((__int64)&__p, (__int16 *)&v57);
if ( cocos2d::cc_utf8_find_last_not_char(&v59, 0x20u) == -1 )
{
v59.__end_ = v59.__begin_;
v10 = -1.0;
}
else
{
cocos2d::cc_utf8_trim_ws(&v59);
v10 = -1.0;
if ( v59.__end_ != v59.__begin_ )
{
v56 = 10;
sub_1001AD2B8((__int64)&v59, &v56);
}
}
v6 = v7;
v7 = 0;
goto LABEL_30;
}
cocos2d::cc_utf8_trim_ws(&__p);
v56 = 10;
sub_1001AD2B8((__int64)&__p, &v56);
sub_1002FCF98((int)&v59, v59.__end_, __p.__begin_);
__p.__end_ = __p.__begin_;
if ( (unsigned int)v8 >= (unsigned int)v2 )
goto LABEL_32;
v7 = 0;
v6 = 0;
--v4;
v10 = -1.0;
v9 = -1.0;
LABEL_31:
++v4;
}
cocos2d::cc_utf8_trim_ws(&__p);
v56 = 10;
sub_1001AD2B8((__int64)&__p, &v56);
sub_1002FCF98((int)&v59, v59.__end_, __p.__begin_);
__p.__end_ = __p.__begin_;
if ( (unsigned int)v11 < (unsigned int)v2 )
{
LOWORD(v14) = v60.__begin_[(unsigned int)v11];
v57 = v14;
v9 = -1.0;
v10 = -1.0;
v8 = v11;
goto LABEL_15;
}
begin = __p.__begin_;
LABEL_33:
sub_1002FCF98((int)&v59, v59.__end_, begin);
v24 = v59.__begin_;
v25 = (char *)v59.__end_ - (char *)v59.__begin_;
v26 = &_mh_execute_header + 0x4000000 * ((char *)v59.__end_ - (char *)v59.__begin_);
if ( (__int64)v26 < 0 )
v27 = -1;
else
v27 = (__int64)v26 >> 31;
v28 = (char *)operator new[](v27);
v29 = v28;
if ( (int)(v25 >> 1) >= 1 )
{
v30 = (unsigned int)v25 >> 1;
v31 = v28;
do
{
v32 = *v24++;
*v31++ = v32;
--v30;
}
while ( v30 );
}
*(_WORD *)&v28[(__int64)(v25 << 31) >> 31] = 0;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, char *, _QWORD))a1->setString_1)(a1, v28, 0);
operator delete[](v29);
if ( __p.__begin_ )
{
__p.__end_ = __p.__begin_;
operator delete(__p.__begin_);
}
if ( v59.__begin_ )
{
v59.__end_ = v59.__begin_;
operator delete(v59.__begin_);
}
if ( v60.__begin_ )
{
v60.__end_ = v60.__begin_;
operator delete(v60.__begin_);
}
LABEL_45:
if ( a1->m_pAlignment )
{
v33 = cocos2d::cc_wcslen(a1->m_sString);
memset(&v60, 0, sizeof(v60));
if ( (v33 & 0x80000000) == 0 )
{
v34 = 0;
v35 = 0;
v36 = 0;
v37 = (unsigned int)(v33 + 1);
while ( 1 )
{
v38 = (__int16 *)&a1->m_sString[v34];
v39 = (unsigned __int16)*v38;
if ( v39 == 10 || v39 == 0 )
{
v41 = (unsigned __int64)((char *)v60.__end_ - (char *)v60.__begin_) >> 1;
if ( (_DWORD)v41 )
{
v42 = v36 + v41;
if ( v35 + v36 + (int)v41 - 1 < 0 )
goto LABEL_68;
v43 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->getChildByTag)(
a1,
(unsigned int)(v35 + v36 + v41 - 1));
v44 = v43;
if ( !v43 )
goto LABEL_68;
v45 = *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v43 + 192LL))(v43);
v46 = v45 + (float)(*(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v44 + 312LL))(v44) * 0.5);
m_pAlignment = a1->m_pAlignment;
if ( m_pAlignment != kCCTextAlignmentRight )
{
if ( m_pAlignment == kCCTextAlignmentCenter )
{
v48 = (float)(*(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->getContentSize)(a1) * 0.5)
- (float)(v46 * 0.5);
LABEL_61:
if ( v48 != 0.0 )
{
v49 = (unsigned int)(v35 + v36);
do
{
if ( (v49 & 0x80000000) == 0 )
{
v50 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))a1->getChildByTag)(a1, v49);
v51 = v50;
if ( v50 )
{
v52 = (float32x2_t *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v50 + 192LL))(v50);
v53.n128_u32[0] = 0;
v54.n128_f32[0] = v48;
sub_100022980(v54, v53, &__p);
*(float32x2_t *)&v55 = sub_1000229DC(v52, (float32x2_t *)&__p, (float32x2_t *)&v59);
(*(void (__fastcall **)(__int64, std::vector *, double))(*(_QWORD *)v51 + 184LL))(
v51,
&v59,
v55);
}
}
v49 = (unsigned int)(v49 + 1);
LODWORD(v41) = v41 - 1;
}
while ( (_DWORD)v41 );
}
}
++v35;
v60.__end_ = v60.__begin_;
v36 = v42;
goto LABEL_68;
}
v48 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->getContentSize)(a1) - v46;
goto LABEL_61;
}
++v35;
}
else
{
sub_1001AD2B8((__int64)&v60, v38);
}
LABEL_68:
if ( ++v34 == v37 )
{
if ( v60.__begin_ )
{
v60.__end_ = v60.__begin_;
operator delete(v60.__begin_);
}
return;
}
}
}
}
}