//
// cocos2d::cc_utf8_to_utf16 from 0xd8dc1c to 0xd8ddac (400 bytes)
//
// 3 xrefs:
// > TextGameObject::updateTextObject @ 0x77e6bc
// > cocos2d::CCLabelBMFont::setString @ 0xd5602c
// > ??> @ 0xf68f8
//
// 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
//
void *__fastcall cocos2d::cc_utf8_to_utf16(cocos2d *this, char *a2, int *a3)
{
size_t v5; // x0
unsigned __int16 *v6; // x19
unsigned __int64 v7; // x0
char *v8; // x3
unsigned __int16 *v9; // x2
unsigned __int64 v10; // x2
__int64 v11; // x2
unsigned __int64 v12; // x0
void *v13; // x19
unsigned __int16 *v14; // x1
void *v16; // x0
size_t v17; // [xsp+48h] [xbp+48h]
void *v18; // [xsp+50h] [xbp+50h] BYREF
unsigned __int8 *v19; // [xsp+58h] [xbp+58h] BYREF
__int64 v20; // [xsp+60h] [xbp+60h] BYREF
unsigned __int16 *v21; // [xsp+68h] [xbp+68h]
void *v22; // [xsp+70h] [xbp+70h]
if ( !this )
return nullptr;
v20 = 0;
v21 = nullptr;
v22 = nullptr;
v5 = strlen((const char *)this);
v6 = (unsigned __int16 *)v5;
if ( v5 <= 0x16 )
{
LOBYTE(v20) = 2 * v5;
v8 = (char *)&v20 + 1;
if ( !v5 )
goto LABEL_5;
}
else
{
v7 = (v5 + 16) & 0xFFFFFFFFFFFFFFF0LL;
v20 = v7 | 1;
v8 = (char *)operator new(v7);
v22 = v8;
v21 = v6;
}
v8 = (char *)memcpy(v8, this, (size_t)v6);
LABEL_5:
*((_BYTE *)v6 + (_QWORD)v8) = 0;
v9 = (unsigned __int16 *)((unsigned __int8)v20 >> 1);
if ( (v20 & 1) != 0 )
v9 = v21;
v10 = (unsigned __int64)v9 + 1;
if ( v10 <= 0x3F80000000000000LL )
{
v12 = 2 * v10;
v11 = 2 * v10;
}
else
{
v11 = 2 * v10;
v12 = -1;
}
v17 = v11;
v13 = (void *)operator new[](v12);
memset(v13, 0, v17);
v18 = v13;
v19 = nullptr;
v14 = (unsigned __int16 *)((unsigned __int8)v20 >> 1);
if ( (v20 & 1) != 0 )
v14 = v21;
if ( !v14 || (unsigned __int8)llvm::ConvertUTF8toWide(2, (char *)&v20, &v18, &v19) )
{
if ( a2 )
*(_DWORD *)a2 = cocos2d::cc_wcslen((cocos2d *)v13, v14);
}
else
{
v16 = v13;
v13 = nullptr;
operator delete[](v16);
}
if ( (v20 & 1) != 0 )
operator delete(v22);
return v13;
}