//
// cocos2d::cc_utf8_to_utf16 from 0x180098b20 to 0x180098c71 (337 bytes)
//
// 3 xrefs:
// > cocos2d::CCLabelBMFont::setString @ 0x18004e568
// > ??> @ 0x18014cf68
// > ??> @ 0x1801c0a68
//
// This function is hookable on this platform (idp: pc, 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 11:22:10 +0000
//
// Hidden C++ exception states: #wind=1
unsigned __int16 *__fastcall cocos2d::cc_utf8_to_utf16(cocos2d *this, char *a2, int *a3)
{
_WORD *v5; // rbp
__int64 v6; // rdi
_WORD *v7; // rbx
void **v8; // rax
int i; // eax
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 = nullptr;
sub_180005A10(Block, (char *)this);
v6 = v14 + 1;
v7 = (_WORD *)sub_1800E4C6C(saturated_mul(v14 + 1, 2u));
memset(v7, 0, 2 * v6);
if ( !v14 )
goto LABEL_8;
v8 = Block;
if ( v15 > 0xF )
v8 = (void **)Block[0];
v12 = v8;
v11 = v7;
if ( (unsigned int)sub_180098140(
(unsigned __int64 *)&v12,
(unsigned __int64)v8 + v14,
&v11,
(unsigned __int64)&v7[2 * v14],
0) )
{
j_j_free_0(v7);
}
else
{
LABEL_8:
v5 = v7;
if ( a2 )
{
for ( i = 0; *v7; ++i )
++v7;
*(_DWORD *)a2 = i;
}
}
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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v10);
}
return v5;
}