//
// cocos2d::cc_utf8_to_utf16 from 0x180095260 to 0x1800953a6 (326 bytes)
//
// 3 xrefs:
// > cocos2d::CCLabelBMFont::setString @ 0x18004ca6e
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b67d4
//
// 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
//
// Hidden C++ exception states: #wind=1
unsigned __int16 *__fastcall cocos2d::cc_utf8_to_utf16(cocos2d *this, char *a2, int *a3)
{
int v5; // esi
_WORD *v6; // rbp
__int64 v7; // rdi
_WORD *v8; // rbx
void **v9; // rax
void *v10; // rcx
_WORD *v11; // [rsp+30h] [rbp-58h] BYREF
void **v12; // [rsp+38h] [rbp-50h] BYREF
void *Block[2]; // [rsp+40h] [rbp-48h] BYREF
__int64 v14; // [rsp+50h] [rbp-38h]
unsigned __int64 v15; // [rsp+58h] [rbp-30h]
if ( !this )
return nullptr;
v5 = 0;
v6 = nullptr;
sub_180005910(Block, this);
v7 = v14 + 1;
v8 = operator new(saturated_mul(v14 + 1, 2u));
memset(v8, 0, 2 * v7);
if ( !v14 )
goto LABEL_8;
v9 = Block;
if ( v15 > 0xF )
v9 = (void **)Block[0];
v12 = v9;
v11 = v8;
if ( (unsigned int)sub_180094B80(
(unsigned __int64 *)&v12,
(unsigned __int64)v9 + v14,
&v11,
(unsigned __int64)&v8[2 * v14],
0) )
{
j_j_free_0(v8);
}
else
{
LABEL_8:
v6 = v8;
if ( a2 )
{
for ( ; *v8; ++v5 )
++v8;
*(_DWORD *)a2 = v5;
}
}
if ( v15 > 0xF )
{
v10 = Block[0];
if ( v15 + 1 >= 0x1000 )
{
v10 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v10 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v10);
}
return v6;
}