//
// CCTextInputNode::onTextFieldDetachWithIME from 0x10016ddf8 to 0x10016e254 (1116 bytes)
//
// 2 xrefs:
// > sub_10016E2DC @ 0x10016e2e8
// > ??> @ 0x10079fa90
//
// 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
//
bool __fastcall CCTextInputNode::onTextFieldDetachWithIME(CCTextInputNode *a1, cocos2d::CCTextFieldTTF *a2)
{
CCTextInputNode *v3; // x19
cocos2d::CCLabelBMFont *m_cursor; // x0
char *v5; // x0
void **v6; // x20
char v7; // w8
void **v8; // x19
char *v9; // x20
_QWORD *v10; // x0
__int64 v11; // x21
__int64 v12; // x0
__int64 v13; // x20
__int64 i; // x22
__int64 v15; // x0
cocos2d::CCString *v16; // x0
const char *CString; // x0
const char *v18; // x23
void **v19; // x19
__int64 v20; // x26
signed __int64 v21; // x24
char *v22; // x28
int v23; // w25
__int64 v24; // x26
cocos2d::CCString *v25; // x0
char *v26; // x0
char v27; // w19
__int64 j; // x21
cocos2d::CCString *v29; // x0
const char *v30; // x0
const char *v31; // x23
char *v32; // x24
signed __int64 v33; // x27
signed __int64 v34; // x0
signed __int64 v35; // x25
char *v36; // x22
int v37; // w26
char *v38; // x0
char *v39; // x0
char *v40; // x27
bool v41; // w0
bool v42; // w20
char *v43; // x1
char *v44; // x0
TextInputDelegate *m_delegate; // x0
TextInputDelegate *v46; // x0
CCTextInputNode *v48; // [xsp+8h] [xbp-D8h]
std::string v49; // [xsp+10h] [xbp-D0h] BYREF
void *v50[2]; // [xsp+28h] [xbp-B8h] BYREF
char v51; // [xsp+3Fh] [xbp-A1h]
void *v52[2]; // [xsp+40h] [xbp-A0h] BYREF
__int64 v53; // [xsp+50h] [xbp-90h]
__int128 v54; // [xsp+58h] [xbp-88h] BYREF
__int64 v55; // [xsp+68h] [xbp-78h]
void *__p[2]; // [xsp+70h] [xbp-70h] BYREF
__int64 v57; // [xsp+80h] [xbp-60h]
v3 = a1;
m_cursor = a1->m_cursor;
if ( m_cursor )
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))m_cursor->setVisible)(m_cursor, 0);
if ( v3->m_filterSwearWords )
{
v48 = v3;
v5 = (char *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *))a2->getString)(a2);
v6 = __p;
sub_100009900(__p, v5);
v7 = HIBYTE(v57);
if ( v57 >= 0 )
v8 = (void **)((char *)__p + HIBYTE(v57));
else
v8 = (void **)((char *)__p[0] + (unsigned __int64)__p[1]);
if ( v57 < 0 )
v6 = (void **)__p[0];
if ( v6 != v8 )
{
do
{
*(_BYTE *)v6 = __tolower(*(char *)v6);
v6 = (void **)((char *)v6 + 1);
}
while ( v6 != v8 );
v7 = HIBYTE(v57);
}
if ( v7 < 0 )
{
v9 = (char *)__p[0];
operator delete(__p[0]);
}
else
{
v9 = (char *)__p;
}
v10 = sub_100009900(__p, v9);
v11 = sub_10016EA2C(v10);
v12 = sub_10016F164();
v13 = v12;
for ( i = 0; ; i = (unsigned int)(i + 2) )
{
v15 = sub_10016EA2C(v12);
if ( (unsigned int)i >= (unsigned int)sub_10024A36C(v15) )
break;
v16 = (cocos2d::CCString *)sub_10024A388(v11, i);
CString = cocos2d::CCString::getCString(v16);
v18 = CString;
if ( v57 >= 0 )
v19 = __p;
else
v19 = (void **)__p[0];
if ( v57 >= 0 )
v20 = HIBYTE(v57);
else
v20 = (__int64)__p[1];
v12 = strlen(CString);
if ( v12 )
{
v21 = v12;
if ( v20 >= v12 )
{
v22 = (char *)v19 + v20;
v23 = *v18;
v12 = (__int64)v19;
do
{
if ( v20 - v21 == -1 )
break;
v12 = (__int64)memchr((void *)v12, v23, v20 - v21 + 1);
if ( !v12 )
break;
v24 = v12;
v12 = memcmp((const void *)v12, v18, v21);
if ( !(_DWORD)v12 )
{
if ( (char *)v24 == v22 || v24 - (_QWORD)v19 == -1 )
break;
goto LABEL_33;
}
v12 = v24 + 1;
v20 = (__int64)&v22[-v24 - 1];
}
while ( v20 >= v21 );
}
}
else
{
LABEL_33:
v25 = (cocos2d::CCString *)sub_10024A388(v11, (unsigned int)i | 1);
cocos2d::CCString::getCString(v25);
if ( v57 >= 0 )
v26 = (char *)__p;
else
v26 = (char *)__p[0];
v12 = (__int64)sub_100174C4C((__int64 *)&v54, v26);
if ( SHIBYTE(v57) < 0 )
operator delete(__p[0]);
*(_OWORD *)__p = v54;
v57 = v55;
}
}
v27 = 0;
for ( j = 0; (unsigned int)j < (unsigned int)sub_10024A36C(v13); j = (unsigned int)(j + 1) )
{
v29 = (cocos2d::CCString *)sub_10024A388(v13, j);
v30 = cocos2d::CCString::getCString(v29);
v31 = v30;
if ( v57 >= 0 )
v32 = (char *)__p;
else
v32 = (char *)__p[0];
if ( v57 >= 0 )
v33 = HIBYTE(v57);
else
v33 = (signed __int64)__p[1];
v34 = strlen(v30);
if ( v34 )
{
v35 = v34;
if ( v33 >= v34 )
{
v36 = &v32[v33];
v37 = *v31;
v38 = v32;
do
{
if ( v33 - v35 == -1 )
break;
v39 = (char *)memchr(v38, v37, v33 - v35 + 1);
if ( !v39 )
break;
v40 = v39;
if ( !memcmp(v39, v31, v35) )
{
if ( v40 == v36 || v40 - v32 == -1 )
break;
goto LABEL_58;
}
v38 = v40 + 1;
v33 = v36 - (v40 + 1);
}
while ( v33 >= v35 );
}
}
else
{
LABEL_58:
sub_100174C4C((__int64 *)&v54, v32);
if ( SHIBYTE(v57) < 0 )
operator delete(__p[0]);
*(_OWORD *)__p = v54;
v57 = v55;
v27 = 1;
}
}
if ( (v27 & 1) != 0 )
{
*(_OWORD *)v52 = *(_OWORD *)__p;
v53 = v57;
v3 = v48;
}
else
{
sub_100009900(v52, "");
v3 = v48;
if ( SHIBYTE(v57) < 0 )
operator delete(__p[0]);
}
sub_100009900(__p, "");
v41 = sub_1000045BC(v52, __p);
v42 = v41;
if ( SHIBYTE(v57) < 0 )
{
operator delete(__p[0]);
if ( v42 )
goto LABEL_75;
}
else if ( v41 )
{
LABEL_75:
if ( SHIBYTE(v53) < 0 )
operator delete(v52[0]);
goto LABEL_77;
}
if ( v53 >= 0 )
v43 = (char *)v52;
else
v43 = (char *)v52[0];
sub_100009900(v50, v43);
CCTextInputNode::setString(v3, (__int64 **)v50);
if ( v51 < 0 )
operator delete(v50[0]);
goto LABEL_75;
}
LABEL_77:
v44 = (char *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *))v3->m_textField->getString)(v3->m_textField);
sub_100009900(&v49, v44);
CCTextInputNode::updateLabel(v3, &v49);
if ( SHIBYTE(v49.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v49.__r_.__value_.__l.__data_);
v3->m_selected = 0;
PlatformToolbox::setKeyboardState(0);
m_delegate = v3->m_delegate;
if ( m_delegate )
((void (__fastcall *)(TextInputDelegate *, CCTextInputNode *))m_delegate->textInputClosed)(m_delegate, v3);
if ( v3->m_forceOffset )
{
v46 = v3->m_delegate;
if ( v46 )
((void (__fastcall *)(TextInputDelegate *, CCTextInputNode *))v46->textInputReturn)(v46, v3);
}
return 0;
}