//
// CCTextInputNode::onTextFieldDetachWithIME from 0x5a3d04 to 0x5a4490 (1932 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'CCTextInputNode::onTextFieldDetachWithIME @ 0x5a4494
// > ??> @ 0x83088
// > ??> @ 0x1141350
//
// 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 CCTextInputNode::onTextFieldDetachWithIME(CCTextInputNode *a1, cocos2d::CCTextFieldTTF *a2)
{
cocos2d::CCLabelBMFont *m_cursor; // x0
char *v5; // x0
char *v6; // x20
TextInputDelegate *m_delegate; // x0
TextInputDelegate *v8; // x0
char *v10; // x0
char *v11; // x20
char *v12; // x21
char *v13; // x22
signed __int64 v14; // x22
__int64 v15; // x19
cocos2d::CCArray *v16; // x26
cocos2d::CCArray *v17; // x22
unsigned int v18; // w20
cocos2d::CCArray *v19; // x0
cocos2d::CCString *v20; // x0
char *CString; // x21
cocos2d::CCString *v22; // x0
char *v23; // x0
char *v24; // x0
unsigned int *v25; // x1
int v26; // w2
unsigned int v27; // w20
int v28; // w27
cocos2d::CCString *v29; // x0
char *v30; // x21
char *v31; // x0
unsigned int *v32; // x1
int v33; // w2
char *v34; // x1
char *v35; // x0
_DWORD *v36; // x22
char *v37; // x21
size_t v38; // x26
size_t v39; // x27
size_t v40; // x2
signed __int64 v41; // x20
void *v42; // x3
unsigned int v43; // w0
char *v44; // x0
char *v45; // x0
unsigned int *v46; // x21
int v47; // w1
unsigned int *v48; // x22
int v49; // w0
unsigned int *v50; // x19
int v51; // w0
unsigned int *v52; // x1
int v53; // w2
unsigned int *v54; // x2
int v55; // w1
unsigned int *v56; // x1
int v57; // w2
void *v58[2]; // [xsp+0h] [xbp+0h] BYREF
void *p; // [xsp+68h] [xbp+68h]
void *v60; // [xsp+78h] [xbp+78h] BYREF
char *v61; // [xsp+80h] [xbp+80h] BYREF
void *v62; // [xsp+88h] [xbp+88h] BYREF
char *v63; // [xsp+90h] [xbp+90h] BYREF
m_cursor = a1->m_cursor;
if ( m_cursor )
m_cursor->setVisible(m_cursor, 0);
if ( a1->m_filterSwearWords )
{
v10 = (char *)a2->getString(a2);
sub_D153B8((unsigned int)v58 + 144, v10);
v11 = v63;
if ( (*((_DWORD *)v63 - 2) & 0x80000000) != 0
|| (sub_D176A8(&v63), v11 = v63, (*((_DWORD *)v63 - 2) & 0x80000000) != 0) )
{
v12 = v11;
v13 = &v11[*((_QWORD *)v11 - 3)];
}
else
{
sub_D176A8(&v63);
v12 = v63;
v13 = &v12[*((_QWORD *)v12 - 3)];
if ( (*((_DWORD *)v63 - 2) & 0x80000000) == 0 )
{
sub_D176A8(&v63);
v12 = v63;
}
}
if ( v11 != v13 )
{
v14 = v13 - v11;
v15 = 0;
do
{
v12[v15] = tolower((unsigned __int8)v11[v15]);
++v15;
}
while ( v15 != v14 );
v12 = v63;
}
if ( v12 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v54 = (unsigned int *)(v12 - 8);
do
v55 = __ldaxr(v54);
while ( __stlxr(v55 - 1, v54) );
}
else
{
v55 = *((_DWORD *)v12 - 2);
*((_DWORD *)v12 - 2) = v55 - 1;
}
if ( v55 <= 0 )
operator delete(v12 - 24);
}
sub_D153B8((int)&v61, v12);
v16 = (cocos2d::CCArray *)sub_595870();
v17 = sub_5968D0();
v18 = 0;
while ( 1 )
{
v19 = (cocos2d::CCArray *)sub_595870();
if ( v18 >= (unsigned int)cocos2d::CCArray::count(v19) )
break;
v20 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v16, v18);
CString = (char *)cocos2d::CCString::getCString(v20);
strlen(CString);
if ( sub_D1641C((unsigned int)v58 + 128, CString) == -1 )
goto LABEL_23;
v22 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v16, v18 + 1);
v23 = (char *)cocos2d::CCString::getCString(v22);
sub_595654(v61, CString, v23, (__int64)&v63);
sub_D163D4(&v61, &v63);
v24 = v63 - 24;
if ( v63 - 24 == (char *)&qword_124B6B0 )
goto LABEL_23;
if ( &pthread_create )
{
v25 = (unsigned int *)(v63 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v63 - 2);
*((_DWORD *)v63 - 2) = v26 - 1;
}
if ( v26 > 0 )
{
LABEL_23:
v18 += 2;
}
else
{
v18 += 2;
operator delete(v24);
}
}
v27 = 0;
v28 = 0;
while ( v27 < (unsigned int)cocos2d::CCArray::count(v17) )
{
v29 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v17, v27);
v30 = (char *)cocos2d::CCString::getCString(v29);
strlen(v30);
if ( sub_D1641C((unsigned int)v58 + 128, v30) != -1 )
{
sub_595654(v61, v30, " ", (__int64)&v62);
sub_D163D4(&v61, &v62);
v31 = (char *)v62 - 24;
if ( (char *)v62 - 24 == (char *)&qword_124B6B0 )
goto LABEL_34;
if ( &pthread_create )
{
v32 = (unsigned int *)((char *)v62 - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v33 - 1;
}
if ( v33 > 0 )
{
LABEL_34:
v28 = 1;
}
else
{
v28 = 1;
operator delete(v31);
}
}
++v27;
}
if ( v28 )
{
v34 = &byte_124B6C8;
v60 = v61;
v61 = &byte_124B6C8;
}
else
{
sub_D153B8((int)&v60, &byte_F288A0);
v34 = v61;
}
v35 = v34 - 24;
if ( v34 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v52 = (unsigned int *)(v34 - 8);
do
v53 = __ldaxr(v52);
while ( __stlxr(v53 - 1, v52) );
}
else
{
v53 = *((_DWORD *)v34 - 2);
*((_DWORD *)v34 - 2) = v53 - 1;
}
if ( v53 <= 0 )
operator delete(v35);
}
sub_D153B8((unsigned int)v58 + 136, &byte_F288A0);
v36 = v62;
v37 = (char *)v60;
v38 = *((_QWORD *)v62 - 3);
v39 = *((_QWORD *)v60 - 3);
p = (char *)v62 - 24;
if ( v38 > v39 )
v40 = v39;
else
v40 = v38;
LODWORD(v41) = memcmp(v60, v62, v40);
v42 = p;
if ( !(_DWORD)v41 )
{
v41 = v39 - v38;
v43 = 0x7FFFFFFF;
if ( (__int64)(v39 - v38) <= 0x7FFFFFFF )
{
v43 = 0x80000000;
if ( v41 >= (__int64)0xFFFFFFFF80000000LL )
{
if ( p == &qword_124B6B0 )
goto LABEL_57;
goto LABEL_64;
}
}
LODWORD(v41) = v43;
}
if ( p == &qword_124B6B0 )
{
LABEL_51:
sub_D153B8((unsigned int)v58 + 144, v37);
CCTextInputNode::setString(a1, (const unsigned __int8 **)&v63);
v44 = v63 - 24;
if ( v63 - 24 == (char *)&qword_124B6B0 )
goto LABEL_52;
if ( &pthread_create )
{
v56 = (unsigned int *)(v63 - 8);
do
v57 = __ldaxr(v56);
while ( __stlxr(v57 - 1, v56) );
}
else
{
v57 = *((_DWORD *)v63 - 2);
*((_DWORD *)v63 - 2) = v57 - 1;
}
if ( v57 > 0 )
{
LABEL_52:
v37 = (char *)v60;
}
else
{
operator delete(v44);
v37 = (char *)v60;
}
LABEL_58:
v45 = v37 - 24;
if ( v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v46 = (unsigned int *)(v37 - 8);
do
v47 = __ldaxr(v46);
while ( __stlxr(v47 - 1, v46) );
}
else
{
v47 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v47 - 1;
}
if ( v47 <= 0 )
operator delete(v45);
}
goto LABEL_4;
}
LABEL_64:
if ( &pthread_create )
{
v48 = v36 - 2;
do
v49 = __ldaxr(v48);
while ( __stlxr(v49 - 1, v48) );
}
else
{
v49 = *(v36 - 2);
*(v36 - 2) = v49 - 1;
}
if ( v49 <= 0 )
operator delete(v42);
v37 = (char *)v60;
LABEL_57:
if ( !(_DWORD)v41 )
goto LABEL_58;
goto LABEL_51;
}
LABEL_4:
v5 = (char *)a1->m_textField->getString(a1->m_textField);
sub_D153B8((int)&v63, v5);
CCTextInputNode::updateLabel(a1, (const void **)&v63);
v6 = v63 - 24;
if ( v63 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v50 = (unsigned int *)(v63 - 8);
do
v51 = __ldaxr(v50);
while ( __stlxr(v51 - 1, v50) );
}
else
{
v51 = *((_DWORD *)v63 - 2);
*((_DWORD *)v63 - 2) = v51 - 1;
}
if ( v51 <= 0 )
operator delete(v6);
}
a1->m_selected = 0;
PlatformToolbox::setKeyboardState(0);
m_delegate = a1->m_delegate;
if ( m_delegate )
{
m_delegate->textInputClosed(m_delegate, a1);
if ( a1->m_forceOffset )
{
v8 = a1->m_delegate;
if ( v8 )
v8->textInputReturn(v8, a1);
}
}
return 0;
}