//
// sub_14004ED00 from 0x14004ed00 to 0x14004f152 (1106 bytes)
//
// 2 xrefs:
// > CCTextInputNode::onTextFieldDetachWithIME @ 0x140050c89
// > ??> @ 0x1406c4c5c
//
// 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=2
__int64 __fastcall sub_14004ED00(__int64 a1, _BYTE *a2)
{
size_t v3; // r8
void **v4; // rdi
void **v5; // r8
unsigned __int64 v6; // rdx
void **v7; // rcx
void **v8; // rsi
void **v9; // rbx
signed __int64 v10; // rdi
void **v11; // rbx
void **v12; // rax
size_t v13; // r8
cocos2d::CCArray *v14; // rsi
cocos2d::CCArray *v15; // r13
unsigned int v16; // edi
cocos2d::CCArray *v17; // rax
cocos2d::CCString *v18; // rax
char *CString; // rax
char *v20; // rbx
size_t v21; // rdx
void **v22; // rcx
cocos2d::CCString *v23; // rax
char *v24; // rax
void **v25; // rdx
char *v26; // rbx
void *v27; // rcx
cocos2d::CCArray *v28; // rax
char v29; // r12
unsigned int v30; // edi
cocos2d::CCString *v31; // rax
char *v32; // rax
char *v33; // rbx
size_t v34; // rdx
void **v35; // rcx
bool v36; // r15
void **v37; // rsi
void **v38; // rdx
char *v39; // rbx
void *v40; // rcx
void *v41; // rcx
void *v43[2]; // [rsp+40h] [rbp-49h] BYREF
__int128 v44; // [rsp+50h] [rbp-39h]
void *Block[2]; // [rsp+60h] [rbp-29h] BYREF
__m128i si128; // [rsp+70h] [rbp-19h]
char v47[32]; // [rsp+80h] [rbp-9h] BYREF
*(_OWORD *)Block = 0;
si128 = 0;
v3 = -1;
do
++v3;
while ( a2[v3] );
sub_14003A930(Block, a2, v3);
v4 = Block;
v5 = (void **)Block[0];
v6 = si128.m128i_u64[1];
if ( si128.m128i_i64[1] > 0xFuLL )
v4 = (void **)Block[0];
v7 = Block;
if ( si128.m128i_i64[1] > 0xFuLL )
v7 = (void **)Block[0];
v8 = (void **)((char *)v7 + si128.m128i_i64[0]);
v9 = Block;
if ( si128.m128i_i64[1] > 0xFuLL )
v9 = (void **)Block[0];
if ( v9 != v8 )
{
v10 = (char *)v4 - (char *)v9;
do
{
*((_BYTE *)v9 + v10) = tolower(*(char *)v9);
v9 = (void **)((char *)v9 + 1);
}
while ( v9 != v8 );
v6 = si128.m128i_u64[1];
v5 = (void **)Block[0];
}
v11 = Block;
if ( v6 > 0xF )
{
v11 = v5;
v12 = v5;
if ( v6 + 1 >= 0x1000 )
{
v5 = (void **)*(v5 - 1);
if ( (unsigned __int64)((char *)v12 - (char *)v5 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v5);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Block[0]) = 0;
*(_OWORD *)v43 = 0;
v44 = 0u;
v13 = -1;
do
++v13;
while ( *((_BYTE *)v11 + v13) );
sub_14003A930(v43, v11, v13);
v14 = sub_14004DE50();
v15 = sub_1400494F0();
v16 = 0;
v17 = sub_14004DE50();
if ( cocos2d::CCArray::count(v17) )
{
do
{
v18 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v14, v16);
CString = (char *)cocos2d::CCString::getCString(v18);
v20 = CString;
v21 = -1;
do
++v21;
while ( CString[v21] );
v22 = v43;
if ( *((_QWORD *)&v44 + 1) > 0xFu )
v22 = (void **)v43[0];
if ( sub_14003BCE0((__int64)v22, v44, 0, CString, v21) != -1 )
{
v23 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v14, v16 + 1);
v24 = (char *)cocos2d::CCString::getCString(v23);
v25 = v43;
if ( *((_QWORD *)&v44 + 1) > 0xFu )
v25 = (void **)v43[0];
v26 = sub_140049190(v47, v25, v20, v24);
if ( v43 != (void **)v26 )
{
if ( *((_QWORD *)&v44 + 1) > 0xFu )
{
v27 = v43[0];
if ( (unsigned __int64)(*((_QWORD *)&v44 + 1) + 1LL) >= 0x1000 )
{
v27 = *((void **)v43[0] - 1);
if ( (unsigned __int64)((char *)v43[0] - (char *)v27 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v27);
}
*(_QWORD *)&v44 = 0;
*((_QWORD *)&v44 + 1) = 15;
LOBYTE(v43[0]) = 0;
*(_OWORD *)v43 = *(_OWORD *)v26;
v44 = *((_OWORD *)v26 + 1);
*((_QWORD *)v26 + 2) = 0;
*((_QWORD *)v26 + 3) = 15;
*v26 = 0;
}
sub_14003A830((__int64)v47);
}
v16 += 2;
v28 = sub_14004DE50();
}
while ( v16 < cocos2d::CCArray::count(v28) );
}
v29 = 0;
v30 = 0;
if ( !cocos2d::CCArray::count(v15) )
goto LABEL_56;
do
{
v31 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v15, v30);
v32 = (char *)cocos2d::CCString::getCString(v31);
v33 = v32;
v34 = -1;
do
++v34;
while ( v32[v34] );
v35 = v43;
v36 = *((_QWORD *)&v44 + 1) > 0xFu;
v37 = (void **)v43[0];
if ( *((_QWORD *)&v44 + 1) > 0xFu )
v35 = (void **)v43[0];
if ( sub_14003BCE0((__int64)v35, v44, 0, v32, v34) != -1 )
{
v38 = v43;
if ( v36 )
v38 = v37;
v39 = sub_140049190(v47, v38, v33, " ");
if ( v43 != (void **)v39 )
{
if ( *((_QWORD *)&v44 + 1) > 0xFu )
{
v40 = v43[0];
if ( (unsigned __int64)(*((_QWORD *)&v44 + 1) + 1LL) >= 0x1000 )
{
v40 = *((void **)v43[0] - 1);
if ( (unsigned __int64)((char *)v43[0] - (char *)v40 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v40);
}
*(_QWORD *)&v44 = 0;
*((_QWORD *)&v44 + 1) = 15;
LOBYTE(v43[0]) = 0;
*(_OWORD *)v43 = *(_OWORD *)v39;
v44 = *((_OWORD *)v39 + 1);
*((_QWORD *)v39 + 2) = 0;
*((_QWORD *)v39 + 3) = 15;
*v39 = 0;
}
sub_14003A830((__int64)v47);
v29 = 1;
}
++v30;
}
while ( v30 < cocos2d::CCArray::count(v15) );
if ( v29 )
{
*(_OWORD *)a1 = *(_OWORD *)v43;
*(_OWORD *)(a1 + 16) = v44;
}
else
{
LABEL_56:
*(_OWORD *)a1 = 0;
*(_QWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 24) = 15;
*(_BYTE *)a1 = 0;
if ( *((_QWORD *)&v44 + 1) > 0xFu )
{
v41 = v43[0];
if ( (unsigned __int64)(*((_QWORD *)&v44 + 1) + 1LL) >= 0x1000 )
{
v41 = *((void **)v43[0] - 1);
if ( (unsigned __int64)((char *)v43[0] - (char *)v41 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v41);
}
}
return a1;
}