//
// CCTextInputNode::onTextFieldDeleteBackward from 0x1001fc7e8 to 0x1001fca3c (596 bytes)
//
// 2 xrefs:
// > sub_1001FCA70 @ 0x1001fca74
// > ??> @ 0x1008f55a0
//
// This function is hookable on this platform (idp: arm, 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:00:43 +0000
//
__int64 __fastcall CCTextInputNode::onTextFieldDeleteBackward(__int64 a1, _DWORD *a2)
{
char *v4; // x0
int v5; // w21
int v6; // w0
int v7; // w23
int v8; // w0
__int64 v9; // x22
__int64 v10; // x25
__int64 v11; // x24
unsigned __int64 v12; // x8
std::string::size_type *v13; // x9
std::string::size_type v14; // x2
std::string::size_type v15; // x22
int v16; // w0
unsigned __int64 v17; // x9
std::string::size_type *v18; // x8
std::string *v19; // x8
__int64 v20; // x9
int v21; // w10
std::string::value_type v22; // t1
std::string __p; // [xsp+0h] [xbp-70h] BYREF
std::string v25; // [xsp+18h] [xbp-58h] BYREF
*(_DWORD *)(a1 + 648) = -1082130432;
if ( *(int *)(a1 + 504) < 1 || *(_QWORD *)(a1 + 512) == *(_QWORD *)(a1 + 520) )
return 0;
v4 = (char *)(*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 1248LL))(a2);
sub_100009900(&v25, v4);
v5 = a2[188];
v6 = sub_1001FC380((__int64 *)&v25);
v7 = v6;
if ( v5 < 0 || v5 > v6 )
{
if ( (v25.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v8 = HIBYTE(v25.__r_.__value_.__r.__words[2]);
else
v8 = v25.__r_.__value_.__r.__words[1];
}
else
{
v8 = sub_1001FC2D0((__int64 *)&v25, v5);
}
v10 = *(_QWORD *)(a1 + 520);
v11 = *(_QWORD *)(a1 + 512);
if ( v10 != v11 )
{
v12 = 0xAAAAAAAAAAAAAAABLL * ((v10 - v11) >> 3);
if ( v12 <= 1 )
v12 = 1;
v13 = (std::string::size_type *)(v11 + 8);
do
{
v15 = *(v13 - 1);
v14 = *v13;
if ( v8 == (unsigned int)*v13 + (_DWORD)v15 )
goto LABEL_27;
v13 += 3;
}
while ( --v12 );
}
v9 = 0;
if ( v5 >= 1 && v5 <= v7 )
{
v16 = sub_1001FC2D0((__int64 *)&v25, v5 - 1);
if ( v10 == v11 )
{
LABEL_25:
v9 = 0;
goto LABEL_49;
}
if ( 0xAAAAAAAAAAAAAAABLL * ((v10 - v11) >> 3) <= 1 )
v17 = 1;
else
v17 = 0xAAAAAAAAAAAAAAABLL * ((v10 - v11) >> 3);
v18 = (std::string::size_type *)(v11 + 8);
while ( 1 )
{
v15 = *(v18 - 1);
if ( v16 == (_DWORD)v15 )
break;
v18 += 3;
if ( !--v17 )
goto LABEL_25;
}
v14 = *v18;
LABEL_27:
std::string::erase(&v25, v15, v14);
if ( SHIBYTE(v25.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, v25.__r_.__value_.__l.__data_, v25.__r_.__value_.__l.__size_);
else
__p = v25;
CCTextInputNode::setString((_QWORD *)a1, (__int64 *)&__p);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__p.__r_.__value_.__l.__data_);
if ( (v5 & 0x80000000) == 0 )
goto LABEL_32;
}
else if ( (v5 & 0x80000000) == 0 )
{
LABEL_32:
v19 = (std::string *)v25.__r_.__value_.__r.__words[0];
if ( (v25.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v19 = &v25;
LODWORD(v20) = HIBYTE(v25.__r_.__value_.__r.__words[2]);
if ( (v25.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
LODWORD(v20) = v25.__r_.__value_.__r.__words[1];
if ( (int)v20 >= (int)v15 )
v20 = (unsigned int)v15;
else
v20 = (unsigned int)v20;
if ( (int)v20 < 1 )
{
v21 = 0;
}
else
{
v21 = 0;
do
{
v22 = v19->__r_.__value_.__s.__data_[0];
v19 = (std::string *)((char *)v19 + 1);
if ( (v22 & 0xC0) != 0x80 )
++v21;
--v20;
}
while ( v20 );
}
goto LABEL_48;
}
v21 = -1;
LABEL_48:
a2[188] = v21;
sub_1001FCD10(a1, *(unsigned int *)(*(_QWORD *)(a1 + 576) + 752LL));
v9 = 1;
}
LABEL_49:
if ( SHIBYTE(v25.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v25.__r_.__value_.__l.__data_);
return v9;
}