//
// SecretLayer4::updateSearchLabel from 0x1003b1e00 to 0x1003b205a (602 bytes)
//
// 5 xrefs:
// > SecretLayer4::init @ 0x1003b144a
// > SecretLayer4::textInputClosed @ 0x1003b4258
// > sub_1003B4290 @ 0x1003b42bf
// > SecretLayer4::textChanged @ 0x1003b4328
// > sub_1003B4360 @ 0x1003b438f
//
// 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 SecretLayer4::updateSearchLabel(SecretLayer4 *a1, const char *a2)
{
double v2; // xmm0_8
size_t v3; // rax
size_t v4; // r12
char *v5; // r13
unsigned int v6; // ebx
size_t v7; // rax
size_t v8; // r12
char *v9; // r13
size_t v10; // r14
char v11; // r14
size_t v12; // r14
char v13; // bl
void *v14; // r15
size_t v15; // rax
char *v16; // rdi
size_t v17; // rdx
bool v18; // r12
bool v19; // r14
CCTextInputNode *m_searchInput; // rdi
cocos2d::CCLabelBMFont_vtbl **v21; // rbx
cocos2d::CCLabelBMFont_vtbl *v22; // rax
cocos2d::CCLabelBMFont *v23; // rdi
int __s2[5]; // [rsp+9h] [rbp-97h] BYREF
SecretLayer4 *v25; // [rsp+20h] [rbp-80h]
std::string v26; // [rsp+28h] [rbp-78h] BYREF
__int64 __s1; // [rsp+40h] [rbp-60h] BYREF
size_t __n; // [rsp+48h] [rbp-58h]
void *__p; // [rsp+50h] [rbp-50h]
cocos2d::CCLabelBMFont *m_textLabel; // [rsp+58h] [rbp-48h]
size_t __dst; // [rsp+60h] [rbp-40h] BYREF
size_t v32; // [rsp+68h] [rbp-38h]
void *v33; // [rsp+70h] [rbp-30h]
v3 = strlen(a2);
if ( v3 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v4 = v3;
m_textLabel = a1->m_searchInput->m_textLabel;
v25 = a1;
if ( v3 >= 0x17 )
{
v10 = 26;
if ( (v3 | 7) != 0x17 )
v10 = (v3 | 7) + 1;
v5 = (char *)operator new(v10);
v33 = v5;
__dst = v10 + 1;
v32 = v4;
}
else
{
LOBYTE(__dst) = 2 * v3;
v5 = (char *)&__dst + 1;
if ( !v3 )
{
BYTE1(__dst) = 0;
v6 = (unsigned __int8)__dst;
if ( (__dst & 1) != 0 )
goto LABEL_5;
goto LABEL_14;
}
}
memcpy(v5, a2, v4);
v5[v4] = 0;
v6 = (unsigned __int8)__dst;
if ( (__dst & 1) != 0 )
{
LABEL_5:
if ( v32 )
goto LABEL_6;
goto LABEL_15;
}
LABEL_14:
if ( v6 >> 1 )
{
LABEL_6:
v7 = strlen(a2);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v8 = v7;
if ( v7 >= 0x17 )
{
v12 = 26;
if ( (v7 | 7) != 0x17 )
v12 = (v7 | 7) + 1;
v9 = (char *)operator new(v12);
__p = v9;
__s1 = v12 | 1;
__n = v8;
}
else
{
LOBYTE(__s1) = 2 * v7;
v9 = (char *)&__s1 + 1;
if ( !v7 )
{
LABEL_21:
v9[v8] = 0;
__s2[0] = 3026478;
v13 = __s1;
v14 = __p;
if ( (__s1 & 1) != 0 )
{
v15 = __n;
v16 = (char *)__p;
}
else
{
v16 = (char *)&__s1 + 1;
v15 = (unsigned __int8)__s1 >> 1;
}
v17 = 3;
if ( v15 < 3 )
v17 = v15;
v18 = v15 == 3;
v19 = memcmp(v16, __s2, v17) == 0;
if ( (v13 & 1) != 0 )
operator delete(v14);
v11 = v18 && v19;
if ( (__dst & 1) != 0 )
goto LABEL_29;
goto LABEL_30;
}
}
memcpy(v9, a2, v8);
goto LABEL_21;
}
LABEL_15:
v11 = 1;
if ( (__dst & 1) != 0 )
LABEL_29:
operator delete(v33);
LABEL_30:
if ( v11 )
{
m_searchInput = v25->m_searchInput;
v26.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)6;
*(_DWORD *)((char *)&v26.__r_.__value_.__l.0 + 1) = 3026478;
CCTextInputNode::updateLabel(m_searchInput, &v26, v2);
v21 = (cocos2d::CCLabelBMFont_vtbl **)m_textLabel;
if ( (*(_BYTE *)&v26.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v26.__r_.__value_.__l.__data_);
BYTE2(__dst) = -40;
LOWORD(__dst) = -26260;
v22 = *v21;
v23 = (cocos2d::CCLabelBMFont *)v21;
}
else
{
BYTE2(__dst) = -1;
LOWORD(__dst) = -1;
v23 = m_textLabel;
v22 = m_textLabel->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
}
((void (__fastcall *)(cocos2d::CCLabelBMFont *, size_t *))v22->setColor)(v23, &__dst);
}