//
// CCTextInputNode::insertAtCursor from 0x3e3f5c to 0x3e412e (466 bytes)
//
// 3 xrefs:
// > CCTextInputNode::pasteText @ 0x3e414e
// > CCTextInputNode::onTextFieldInsertText @ 0x3e44c6
// > EmotePickerPopup::onPickEmote @ 0x7795da
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:47:03 +0000
//
int __fastcall CCTextInputNode::insertAtCursor(int a1, int a2)
{
int v4; // r0
int v5; // r1
int v6; // r2
int v7; // r3
const char *v8; // r4
size_t v9; // r0
int v10; // r5
int v11; // r1
signed int v12; // r4
int v13; // r3
int v14; // r3
bool v15; // cc
int v17; // r3
char *v18; // r2
size_t v19; // r3
int v20; // r5
int v21; // r5
int v22; // r1
int v23; // r1
int v24; // r2
unsigned int v26; // r0
int v27; // [sp+8h] [bp-2Ch] BYREF
size_t v28; // [sp+Ch] [bp-28h]
char *v29; // [sp+10h] [bp-24h]
int v30; // [sp+14h] [bp-20h] BYREF
signed int v31; // [sp+18h] [bp-1Ch]
int v32; // [sp+1Ch] [bp-18h]
int v33; // [sp+20h] [bp-14h] BYREF
int v34; // [sp+24h] [bp-10h]
int v35; // [sp+28h] [bp-Ch]
if ( *(int *)(a1 + 372) > 0 )
{
EmoteSprite::translateUnicodeEmoji(&v33);
if ( (*(_BYTE *)a2 & 1) != 0 )
{
**(_BYTE **)(a2 + 8) = 0;
*(_DWORD *)(a2 + 4) = 0;
}
else
{
*(_BYTE *)(a2 + 1) = 0;
*(_BYTE *)a2 = 0;
}
std::string::reserve((int *)a2, 0);
v4 = v33;
v5 = v34;
v6 = v35;
v33 = 0;
v34 = 0;
v35 = 0;
*(_DWORD *)a2 = v4;
*(_DWORD *)(a2 + 4) = v5;
*(_DWORD *)(a2 + 8) = v6;
std::string::~string((int)&v33);
}
sub_3E3C78(
&v27,
(unsigned __int8 *)a2,
*(unsigned __int8 *)(a1 + 441),
(unsigned __int8 *)(a1 + 356),
*(_BYTE *)(a1 + 440));
if ( (v27 & 1) != 0 )
v7 = v28;
else
v7 = (int)(unsigned __int8)v27 >> 1;
if ( v7 )
{
v8 = (const char *)(*(int (__fastcall **)(_DWORD))(**(_DWORD **)(a1 + 416) + 624))(*(_DWORD *)(a1 + 416));
v30 = 0;
v31 = 0;
v32 = 0;
v9 = strlen(v8);
std::string::__init(&v30, v8, v9);
v10 = (unsigned __int8)v30;
v11 = *(_DWORD *)(*(_DWORD *)(a1 + 416) + 608);
if ( v11 >= 0 )
{
v12 = sub_3DC656((unsigned __int8 *)&v30, v11);
}
else if ( (v30 & 1) != 0 )
{
v12 = v31;
}
else
{
v12 = (int)(unsigned __int8)v30 >> 1;
}
if ( (v10 & 1) != 0 )
v13 = v31;
else
v13 = v10 >> 1;
if ( v12 <= v13 )
{
v15 = v12 <= 0;
}
else
{
if ( (v10 & 1) != 0 )
v14 = v31;
else
v14 = v10 >> 1;
v15 = v14 <= 0;
}
if ( !v15 )
{
if ( (v10 & 1) != 0 )
v17 = v31;
else
v17 = v10 >> 1;
if ( v12 > v17 )
{
if ( (v10 & 1) != 0 )
v12 = v31;
else
v12 = v10 >> 1;
}
}
else
{
v12 = 0;
}
if ( (v27 & 1) != 0 )
{
v18 = v29;
v19 = v28;
}
else
{
v19 = (int)(unsigned __int8)v27 >> 1;
v18 = (char *)&v27 + 1;
}
std::string::insert(&v30, v12, v18, v19);
v20 = *(_DWORD *)(a1 + 424);
if ( v20 > 0 && sub_3DC602((unsigned __int8 *)&v30) > v20 )
{
v26 = sub_3DC656((unsigned __int8 *)&v30, v20);
std::string::resize((unsigned __int8 *)&v30, v26, 0);
}
std::string::basic_string(&v33, (int)&v30);
CCTextInputNode::setString(a1, (int)&v33);
std::string::~string((int)&v33);
v21 = *(_DWORD *)(a1 + 416);
if ( *(int *)(v21 + 608) >= 0 )
{
if ( (v27 & 1) != 0 )
v22 = v28;
else
v22 = (int)(unsigned __int8)v27 >> 1;
*(_DWORD *)(v21 + 608) = sub_3DC19C((unsigned __int8 *)&v30, v22 + v12);
CCTextInputNode::updateBlinkLabel((CCTextInputNode *)a1, v23, v24);
}
std::string::~string((int)&v30);
}
return std::string::~string((int)&v27);
}