//
// cocos2d::cc_utf8_strlen from 0x100660370 to 0x1006604ae (318 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall cocos2d::cc_utf8_strlen(const char *a1, int a2)
{
double v2; // xmm0_8
size_t v3; // rax
size_t v4; // r15
char *v5; // rbx
char *v6; // r12
__int64 v7; // r15
size_t v8; // r13
char v9; // r13
char *v10; // r14
size_t v11; // rax
char *v12; // r12
__int64 v13; // r13
int v14; // r14d
char *v16; // [rsp+0h] [rbp-50h]
_QWORD __dst[2]; // [rsp+8h] [rbp-48h] BYREF
char *__s; // [rsp+18h] [rbp-38h]
char v19; // [rsp+27h] [rbp-29h]
if ( !a1 )
return 0;
v3 = strlen(a1);
if ( v3 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v4 = v3;
v5 = (char *)__dst + 1;
if ( v3 >= 0x17 )
{
v8 = 26;
if ( (v3 | 7) != 0x17 )
v8 = (v3 | 7) + 1;
v6 = (char *)operator new(v8);
__s = v6;
__dst[0] = v8 + 1;
__dst[1] = v4;
}
else
{
LOBYTE(__dst[0]) = 2 * v3;
v6 = (char *)__dst + 1;
if ( !v3 )
goto LABEL_11;
}
memcpy(v6, a1, v4);
LABEL_11:
v6[v4] = 0;
v9 = __dst[0];
v10 = __s;
if ( (__dst[0] & 1) != 0 )
v5 = __s;
v11 = strlen(v5);
v7 = 0;
if ( v11 )
{
v19 = __dst[0];
v16 = __s;
v12 = &v5[v11];
do
{
v13 = byte_1008230B0[(unsigned __int8)*v5] + 1LL;
v14 = 0;
if ( v12 - v5 < v13 )
break;
if ( !sub_10065F320(v5, v13) )
break;
v5 += v13;
LODWORD(v7) = v7 + 1;
v14 = v7;
}
while ( v5 != v12 );
v7 = v14;
v10 = v16;
v9 = v19;
}
if ( (v9 & 1) != 0 )
operator delete(v10);
return v7;
}