//
// cocos2d::cc_utf8_trim_ws from 0xd8d9a0 to 0xd8dac4 (292 bytes)
//
// 4 xrefs:
// > cocos2d::CCLabelBMFont::updateLabel @ 0xd575f8
// > cocos2d::CCLabelBMFont::updateLabel @ 0xd5765c
// > cocos2d::CCLabelBMFont::updateLabel @ 0xd5798c
// > ??> @ 0x4c0d8
//
// 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 13:08:17 +0000
//
unsigned __int64 __fastcall cocos2d::cc_utf8_trim_ws(unsigned __int64 result)
{
__int64 v1; // x19
int v2; // w22
__int64 *v3; // x21
int v4; // w19
__int64 v5; // x20
cocos2d *v6; // x0
__int64 v7; // x1
char *v8; // x2
char *v9; // x22
char *v10; // x1
__int64 v11; // x19
char *v12; // x22
v1 = (__int64)(*(_QWORD *)(result + 8) - *(_QWORD *)result) >> 1;
if ( (int)v1 > 0 )
{
v2 = v1 - 1;
v3 = (__int64 *)result;
result = (unsigned __int8)cocos2d::isspace_unicode((cocos2d *)*(unsigned __int16 *)(*(_QWORD *)result
+ 2LL * ((int)v1 - 1)));
if ( (_BYTE)result )
{
v4 = v1 - 2;
if ( v4 != -1 )
{
v5 = 2LL * v4;
while ( 1 )
{
v2 = v4 + 1;
v6 = (cocos2d *)*(unsigned __int16 *)(*v3 + v5);
v5 -= 2;
if ( !(unsigned __int8)cocos2d::isspace_unicode(v6) )
break;
if ( !v4 )
{
v7 = *v3;
v2 = 0;
v8 = (char *)v3[1];
result = (__int64)&v8[-*v3] >> 1;
if ( (int)result <= 0 )
return result;
goto LABEL_10;
}
--v4;
}
}
v7 = *v3;
v8 = (char *)v3[1];
result = (__int64)&v8[-*v3] >> 1;
if ( (int)result > v2 )
{
LABEL_10:
v9 = (char *)(v7 + 2LL * v2);
v10 = (char *)(v7 + 2LL * (int)result);
if ( v9 != v10 )
{
v11 = v8 - v10;
result = (v8 - v10) >> 1;
if ( result )
{
result = (unsigned __int64)memmove(v9, v10, v8 - v10);
v8 = (char *)v3[1];
}
v12 = &v9[v11];
if ( v8 != v12 )
{
result = ~((unsigned __int64)(v8 - 2 - v12) >> 1);
v3[1] = (__int64)&v8[2 * result];
}
}
}
}
}
return result;
}