//
// CCTextInputNode::rawToDisplayIndex from 0x140055460 to 0x140055624 (452 bytes)
//
// 5 xrefs:
// > CCTextInputNode::displayToRawIndex @ 0x14005573c
// > CCTextInputNode::updateBlinkLabelToChar @ 0x140056a92
// > ??> @ 0x140887094
// > ??> @ 0x1408870c8
// > ??> @ 0x14091034c
//
// 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
//
__int64 __fastcall CCTextInputNode::rawToDisplayIndex(_QWORD *a1, int a2)
{
_BYTE *v4; // rax
size_t v5; // r8
int *v6; // r11
unsigned __int64 v7; // rdi
__int64 v8; // rcx
void *v9; // rsi
unsigned int v10; // ebx
unsigned __int64 v11; // r14
void **v12; // r9
int v13; // ecx
int v14; // eax
__int64 v15; // r8
int v16; // edx
int v17; // edx
void *Block[2]; // [rsp+30h] [rbp-58h] BYREF
__int128 v20; // [rsp+40h] [rbp-48h]
v4 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(a1[74] + 600LL) + 8LL))(a1[74] + 600LL);
*(_OWORD *)Block = 0;
v5 = -1;
v20 = 0;
do
++v5;
while ( v4[v5] );
sub_14003D230(Block, v4, v5);
v6 = (int *)a1[66];
v7 = 0;
v8 = a1[67] - (_QWORD)v6;
v9 = Block[0];
v10 = a2;
v11 = v8 / 24;
if ( v8 / 24 )
{
while ( 1 )
{
v12 = Block;
v13 = v20;
if ( *((_QWORD *)&v20 + 1) > 0xFu )
v12 = (void **)Block[0];
v14 = 0;
v15 = 0;
if ( *v6 <= (int)v20 )
v13 = *v6;
if ( v13 > 0 )
{
do
{
v16 = v14 + 1;
if ( (*((_BYTE *)v12 + v15) & 0xC0) == 0x80 )
v16 = v14;
++v15;
v14 = v16;
}
while ( v15 < v13 );
}
v17 = v6[2];
if ( v17 + v14 > a2 )
break;
++v7;
v6 += 6;
v10 += 1 - v17;
if ( v7 >= v11 )
goto LABEL_17;
}
if ( a2 > v14 )
v10 += v14 - a2;
}
LABEL_17:
if ( *((_QWORD *)&v20 + 1) > 0xFu )
{
if ( (unsigned __int64)(*((_QWORD *)&v20 + 1) + 1LL) >= 0x1000 )
{
v9 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v9 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v9);
}
return v10;
}