//
// sub_1000676D0 from 0x1000676d0 to 0x100067b4e (1150 bytes)
//
// 2 xrefs:
// > CCTextInputNode::insertAtCursor @ 0x10006717a
// > CCTextInputNode::onTextFieldInsertText @ 0x10006a0ca
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:19:44 +0000
//
void __fastcall sub_1000676D0(std::string *a1, const std::string *a2, char a3, const std::string *a4, char a5)
{
unsigned int v8; // esi
std::string::size_type size; // rsi
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v10; // cl
unsigned int v11; // ebx
bool v12; // dl
std::string::size_type v13; // rbx
std::string::size_type v14; // rsi
std::string::size_type v15; // r13
std::string::size_type v16; // rbx
std::string::size_type v17; // rax
std::string::pointer v18; // rax
int v19; // r8d
char v20; // r9
unsigned int v21; // r10d
__int64 v22; // rdi
std::string::size_type v23; // r12
std::string::size_type v24; // rcx
signed int v25; // r15d
__m128i v26; // xmm0
__m128i v27; // xmm1
int v28; // eax
__int64 v29; // rax
__int64 v30; // rax
std::string::size_type v31; // rbx
std::string::pointer data; // r14
unsigned int v33; // eax
__int64 i; // r13
std::string::value_type v35; // r12
__int64 k; // r15
__int64 j; // r13
std::string::value_type v38; // r12
*(_OWORD *)&a1->__r_.__value_.__l.0 = 0;
a1->__r_.__value_.__r.__words[2] = 0;
v8 = (unsigned int)a2->__r_.__value_.__l.0;
if ( (v8 & 1) != 0 )
size = a2->__r_.__value_.__l.__size_;
else
size = v8 >> 1;
std::string::reserve(a1, size);
v10 = a2->__r_.__value_.__s.0;
v11 = (unsigned int)a2->__r_.__value_.__l.0;
v12 = (*(_BYTE *)&a2->__r_.__value_.__s.0 & 1) == 0;
if ( !a3 )
{
if ( (*(_BYTE *)&v10 & 1) != 0 )
{
v31 = a2->__r_.__value_.__l.__size_;
data = a2->__r_.__value_.__l.__data_;
if ( !v31 )
return;
}
else
{
data = a2->__r_.__value_.__s.__data_;
v31 = v11 >> 1;
if ( !v31 )
return;
}
v33 = (unsigned int)a4->__r_.__value_.__l.0;
if ( (v33 & 1) != 0 )
{
if ( a4->__r_.__value_.__l.__size_ )
goto LABEL_72;
}
else if ( v33 >> 1 )
{
LABEL_72:
if ( a5 )
{
for ( i = 0; i != v31; ++i )
{
v35 = data[i];
if ( v35 == 10 || std::string::find(a4, v35, 0) != -1 )
std::string::push_back(a1, v35);
}
}
else
{
for ( j = 0; j != v31; ++j )
{
v38 = data[j];
if ( std::string::find(a4, v38, 0) != -1 )
std::string::push_back(a1, v38);
}
}
return;
}
for ( k = 0; k != v31; ++k )
std::string::push_back(a1, data[k]);
return;
}
v13 = v11 >> 1;
v14 = a2->__r_.__value_.__l.__size_;
if ( (*(_BYTE *)&v10 & 1) != 0 )
v13 = a2->__r_.__value_.__l.__size_;
if ( v13 )
{
v15 = 0;
while ( 1 )
{
v18 = a2->__r_.__value_.__s.__data_;
if ( !v12 )
v18 = a2->__r_.__value_.__l.__data_;
v19 = (unsigned __int8)v18[v15];
v20 = 1;
if ( (v19 & 0x80u) == 0 )
break;
if ( (v19 & 0xFFFFFFE0) == 0xC0 )
{
v21 = 2;
goto LABEL_19;
}
v22 = v19 & 0xFFFFFFF0;
if ( (_DWORD)v22 != 224 )
{
if ( (v19 & 0xFFFFFFF8) != 0xF0 )
goto LABEL_9;
v21 = 4;
v20 = 0;
goto LABEL_19;
}
v21 = 3;
LOBYTE(v22) = 1;
v20 = 0;
LABEL_20:
v23 = v21;
v16 = v21 + v15;
v24 = *(unsigned __int8 *)&v10 >> 1;
if ( v12 )
v14 = v24;
if ( v16 > v14 )
{
LABEL_9:
v16 = v15 + 1;
goto LABEL_10;
}
v25 = (unsigned __int8)v18[v15];
if ( v21 == 4 )
{
v25 = v19 & 7;
if ( (v19 & 0x80u) == 0 )
goto LABEL_32;
goto LABEL_43;
}
if ( v21 == 3 )
{
v25 = v19 & 0xF;
LABEL_31:
if ( (v19 & 0x80u) == 0 )
goto LABEL_32;
goto LABEL_43;
}
if ( v21 != 2 )
goto LABEL_31;
v25 = v19 & 0x1F;
if ( (v19 & 0x80u) == 0 )
goto LABEL_32;
LABEL_43:
if ( (v18[v15 + 1] & 0xC0) != 0x80 )
goto LABEL_9;
v25 = (v25 << 6) | v18[v15 + 1] & 0x3F;
if ( !v20 )
{
if ( (v18[v15 + 2] & 0xC0) != 0x80 )
goto LABEL_9;
v25 = (v25 << 6) | v18[v15 + 2] & 0x3F;
if ( !(_BYTE)v22 )
{
v28 = (unsigned __int8)v18[v15 + 3];
if ( (v28 & 0xFFFFFFC0) != 0x80 )
goto LABEL_9;
v25 = (v25 << 6) | v28 & 0x3F;
}
}
LABEL_32:
if ( v25 == 10 )
{
if ( a5 )
goto LABEL_34;
}
else
{
v26 = _mm_cvtsi32_si128(v25);
v27 = _mm_add_epi32(_mm_shuffle_epi32(v26, 0), (__m128i)xmmword_100A04030);
if ( !_mm_movemask_ps((__m128)_mm_or_si128(
_mm_cmpeq_epi32(
_mm_shuffle_epi32(_mm_insert_epi32(v26, v25 & 0xFFFFFFE0, 1), 4),
(__m128i)xmmword_100A04050),
_mm_cmpeq_epi32(_mm_min_epu32(v27, (__m128i)xmmword_100A04040), v27)))
&& (unsigned int)v25 >= 0x20 )
{
if ( v25 > 8231 )
{
if ( v25 > 12643 )
{
if ( v25 != 12644 && v25 != 65440 )
{
LABEL_60:
if ( (v25 & 0xFFFFFFF0) == 0xFE00 )
goto LABEL_10;
if ( (unsigned int)v25 >= 0x80 )
{
v29 = qword_100BE1050;
if ( !qword_100BE1050 )
{
v30 = BitmapFontCache::sharedFontCache(v22);
v29 = BitmapFontCache::fontWithConfigFile(v30, "chatFont.fnt", 1.0);
qword_100BE1050 = v29;
if ( !v29 )
goto LABEL_10;
}
if ( !(unsigned __int8)sub_100204910(v29, (unsigned int)v25) )
goto LABEL_10;
}
LABEL_34:
std::string::append(a1, a2, v15, v23);
}
}
else if ( (unsigned int)(v25 - 8232) >= 2 && v25 != 10240 )
{
goto LABEL_60;
}
}
else if ( v25 <= 4446 )
{
if ( v25 != 847 && v25 != 1564 )
goto LABEL_60;
}
else if ( (unsigned int)(v25 - 4447) >= 2 && v25 != 6158 )
{
goto LABEL_60;
}
}
}
LABEL_10:
v10 = a2->__r_.__value_.__s.0;
v17 = *(_BYTE *)&a2->__r_.__value_.__l.0 >> 1;
v12 = (*(_BYTE *)&a2->__r_.__value_.__s.0 & 1) == 0;
v14 = a2->__r_.__value_.__l.__size_;
if ( (*(_BYTE *)&a2->__r_.__value_.__s.0 & 1) != 0 )
v17 = a2->__r_.__value_.__l.__size_;
v15 = v16;
if ( v16 >= v17 )
return;
}
v21 = 1;
LABEL_19:
v22 = 0;
goto LABEL_20;
}
}