//
// sub_7FE640 from 0x7fe640 to 0x7fe69c (92 bytes)
//
// 2 xrefs:
// > cocos2d::CCTextFieldTTF::insertText @ 0x7feb86
// > cocos2d::CCTextFieldTTF::deleteBackward @ 0x7fee82
//
// 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 12:01:17 +0000
//
int __fastcall sub_7FE640(unsigned __int8 *a1, int a2)
{
int v2; // r5
int v3; // r3
int v4; // r2
int v5; // r6
int v6; // r3
unsigned __int8 *v7; // r4
unsigned __int8 v8; // r4
int v9; // r4
v2 = 0;
v3 = *a1;
v4 = 0;
v5 = v3 & 1;
if ( (v3 & 1) != 0 )
v6 = *((_DWORD *)a1 + 1);
else
v6 = v3 >> 1;
while ( v2 < a2 )
{
if ( v4 >= v6 )
return v6;
if ( v5 )
v7 = *((unsigned __int8 **)a1 + 2);
else
v7 = a1 + 1;
v8 = v7[v4];
if ( (v8 & 0xE0) == 0xC0 )
{
v9 = 2;
}
else if ( (v8 & 0xF0) == 0xE0 )
{
v9 = 3;
}
else if ( (v8 & 0xF8) == 0xF0 )
{
v9 = 4;
}
else
{
v9 = 1;
}
v4 += v9;
++v2;
}
if ( v4 >= v6 )
return v6;
return v4;
}