//
// CCTextInputNode::displayToRawIndex from 0x140055630 to 0x14005580b (475 bytes)
//
// 4 xrefs:
// > CCTextInputNode::updateCursorPosition @ 0x140058830
// > CCTextInputNode::updateCursorPosition @ 0x140058960
// > CCTextInputNode::updateCursorPosition @ 0x140058a5e
// > ??> @ 0x140910388
//
// 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 11:25:40 +0000
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall CCTextInputNode::displayToRawIndex(_QWORD *a1, int a2)
{
_BYTE *v4; // rax
size_t v5; // r8
unsigned int v6; // r14d
unsigned __int64 v7; // rbp
__int64 v8; // r8
unsigned __int64 v9; // r13
void **v10; // rdi
__int64 v11; // rsi
int v12; // r10d
int *v13; // r15
void **v14; // r9
int v15; // edx
__int64 v16; // r8
int v17; // eax
int v18; // ecx
void **v19; // rax
void *Block[2]; // [rsp+30h] [rbp-58h] BYREF
__int128 v22; // [rsp+40h] [rbp-48h]
v4 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(a1[74] + 600LL) + 8LL))(a1[74] + 600LL);
*(_OWORD *)Block = 0;
v22 = 0;
v5 = -1;
do
++v5;
while ( v4[v5] );
sub_14003D230(Block, v4, v5);
v6 = a2;
v7 = 0;
v8 = a1[66];
v9 = *((_QWORD *)&v22 + 1);
v10 = (void **)Block[0];
if ( (a1[67] - v8) / 24 )
{
v11 = 0;
v12 = v22;
do
{
v13 = (int *)(v11 + v8);
v14 = Block;
if ( v9 > 0xF )
v14 = v10;
v15 = 0;
v16 = 0;
v17 = v12;
if ( *v13 <= v12 )
v17 = *v13;
if ( v17 > 0 )
{
do
{
v18 = v15 + 1;
if ( (*((_BYTE *)v14 + v16) & 0xC0) == 0x80 )
v18 = v15;
v15 = v18;
++v16;
}
while ( v16 < v17 );
}
if ( (int)CCTextInputNode::rawToDisplayIndex(a1, v15) >= a2 )
break;
v6 += v13[2] - 1;
++v7;
v11 += 24;
v8 = a1[66];
v12 = v22;
}
while ( v7 < (a1[67] - v8) / 24 );
}
if ( v9 > 0xF )
{
v19 = v10;
if ( v9 + 1 >= 0x1000 )
{
v10 = (void **)*(v10 - 1);
if ( (unsigned __int64)((char *)v19 - (char *)v10 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v10);
}
return v6;
}