//
// cocos2d::CCComponentContainer::add from 0x180096320 to 0x18009668a (874 bytes)
//
// 4 xrefs:
// > ??> @ 0x1801045a0
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b68d0
// > ??> @ 0x1801b68dc
//
// 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
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall cocos2d::CCComponentContainer::add(
cocos2d::CCComponentContainer *this,
cocos2d::CCNotificationObserver *a2)
{
cocos2d::CCLabelBMFont *v2; // r15
unsigned __int8 v4; // r12
cocos2d::CCDictionary *v5; // rax
const char *String; // rax
const char *v7; // r13
void *v8; // r14
size_t v9; // rdi
size_t v10; // rbx
__int64 v11; // rsi
unsigned __int64 v12; // r15
size_t v13; // rax
void *v14; // rax
_QWORD *v15; // r12
__int64 v16; // rax
__int64 v17; // rbx
void *v18; // rcx
const char *v19; // rax
const char *v20; // rbx
size_t v21; // rax
void *v22; // rax
void *v23; // rcx
void *Block[2]; // [rsp+40h] [rbp-30h] BYREF
size_t v28; // [rsp+50h] [rbp-20h]
unsigned __int64 v29; // [rsp+58h] [rbp-18h]
v2 = (cocos2d::CCLabelBMFont *)a2;
v4 = 0;
cocos2d::CCNotificationObserver::getTarget(a2);
if ( !this->m_pComponents )
{
v5 = cocos2d::CCDictionary::create();
this->m_pComponents = v5;
cocos2d::CCObject::retain(v5);
}
String = cocos2d::CCLabelBMFont::getString(v2);
v7 = String;
*(_OWORD *)Block = 0;
v8 = nullptr;
v28 = 0;
v29 = 0;
v9 = -1;
v10 = -1;
do
++v10;
while ( String[v10] );
v11 = 0x7FFFFFFFFFFFFFFFLL;
if ( v10 > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
v29 = 15;
if ( v10 <= 0xF )
{
v28 = v10;
memcpy(Block, String, v10);
*((_BYTE *)Block + v10) = 0;
goto LABEL_21;
}
v12 = v10 | 0xF;
if ( (v10 | 0xF) > 0x7FFFFFFFFFFFFFFFLL )
{
v12 = 0x7FFFFFFFFFFFFFFFLL;
v13 = 0x8000000000000027uLL;
LABEL_10:
v14 = operator new(v13);
if ( !v14 )
goto LABEL_24;
v15 = (_QWORD *)(((unsigned __int64)v14 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*(v15 - 1) = v14;
goto LABEL_20;
}
if ( v12 < 0x16 )
v12 = 22;
if ( v12 + 1 >= 0x1000 )
{
v13 = v12 + 40;
if ( v12 + 40 < v12 + 1 )
Concurrency::cancel_current_task();
goto LABEL_10;
}
if ( v12 == -1 )
v15 = nullptr;
else
v15 = operator new(v12 + 1);
LABEL_20:
Block[0] = v15;
v28 = v10;
v29 = v12;
memcpy(v15, v7, v10);
*((_BYTE *)v15 + v10) = 0;
v2 = (cocos2d::CCLabelBMFont *)a2;
v4 = 0;
LABEL_21:
v16 = cocos2d::CCDictionary::objectForKey((__int64)this->m_pComponents, (unsigned __int8 *)Block);
v17 = _RTDynamicCast(
v16,
0,
&cocos2d::CCObject `RTTI Type Descriptor',
&cocos2d::CCComponent `RTTI Type Descriptor',
0);
if ( v29 > 0xF )
{
v18 = Block[0];
if ( v29 + 1 >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
LABEL_24:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v18);
}
if ( v17 )
return v4;
cocos2d::CCComponent::setOwner((cocos2d::CCComponent *)v2, this->m_pOwner);
v19 = cocos2d::CCLabelBMFont::getString(v2);
v20 = v19;
*(_OWORD *)Block = 0;
v28 = 0;
v29 = 0;
do
++v9;
while ( v19[v9] );
if ( v9 > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
v29 = 15;
if ( v9 > 0xF )
{
if ( (v9 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v11 = v9 | 0xF;
if ( (v9 | 0xF) < 0x16 )
v11 = 22;
if ( (unsigned __int64)(v11 + 1) < 0x1000 )
{
if ( v11 != -1 )
v8 = operator new(v11 + 1);
LABEL_43:
Block[0] = v8;
v28 = v9;
v29 = v11;
memcpy(v8, v20, v9);
*((_BYTE *)v8 + v9) = 0;
goto LABEL_44;
}
v21 = v11 + 40;
if ( v11 + 40 < (unsigned __int64)(v11 + 1) )
Concurrency::cancel_current_task();
}
else
{
v21 = 0x8000000000000027uLL;
}
v22 = operator new(v21);
if ( !v22 )
goto LABEL_47;
v8 = (void *)(((unsigned __int64)v22 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*((_QWORD *)v8 - 1) = v22;
goto LABEL_43;
}
v28 = v9;
memcpy(Block, v19, v9);
*((_BYTE *)Block + v9) = 0;
LABEL_44:
cocos2d::CCDictionary::setObject((__int64)this->m_pComponents, v2, (unsigned __int8 *)Block);
if ( v29 > 0xF )
{
v23 = Block[0];
if ( v29 + 1 >= 0x1000 )
{
v23 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v23 - 8) > 0x1F )
LABEL_47:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v23);
}
((void (__fastcall *)(cocos2d::CCLabelBMFont *))v2->setZOrder)(v2);
return 1;
}