//
// cocos2d::cc_utf16_to_utf8 from 0xd8e4a0 to 0xd8e638 (408 bytes)
//
// 2 xrefs:
// > cocos2d::JniHelper::jstring2string @ 0xd81484
// > ??> @ 0xdced0
//
// 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
//
_BYTE *__fastcall cocos2d::cc_utf16_to_utf8(cocos2d *this, unsigned __int16 *a2, int *a3)
{
__int64 v5; // x19
int v6; // w0
int v7; // w20
__int16 v8; // w1
size_t v9; // x0
_BYTE *v10; // x19
size_t v11; // x1
size_t v12; // x2
char *v13; // x1
int v14; // w0
int v15; // w2
__int64 v17[2]; // [xsp+48h] [xbp+48h] BYREF
void *v18; // [xsp+58h] [xbp+58h]
__int64 v19; // [xsp+60h] [xbp+60h] BYREF
size_t v20; // [xsp+68h] [xbp+68h]
void *v21; // [xsp+70h] [xbp+70h]
if ( !this )
return nullptr;
v17[0] = 0;
v5 = 0;
v17[1] = 0;
v18 = nullptr;
v6 = cocos2d::cc_wcslen(this, _stack_chk_guard);
v7 = v6;
if ( v6 <= 0 )
{
v19 = 0;
v20 = 0;
v21 = nullptr;
if ( !v6 )
goto LABEL_6;
}
else
{
do
{
v8 = *((_WORD *)this + v5++);
std::wstring::push_back(v17, v8);
}
while ( v7 > (int)v5 );
v19 = 0;
v20 = 0;
v21 = nullptr;
}
if ( (unsigned __int8)llvm::convertUTF16ToUTF8String((unsigned __int8 *)v17, (__int64)&v19) )
{
LABEL_6:
if ( (v19 & 1) != 0 )
v9 = v20;
else
v9 = (unsigned __int8)v19 >> 1;
v10 = (_BYTE *)operator new[](v9 + 1);
v11 = (unsigned __int8)v19 >> 1;
if ( (v19 & 1) != 0 )
v11 = v20;
v10[v11] = 0;
if ( v7 > 0 )
{
if ( (v19 & 1) != 0 )
{
v13 = (char *)v21;
v12 = v20;
}
else
{
v12 = (unsigned __int8)v19 >> 1;
v13 = (char *)&v19 + 1;
}
memcpy(v10, v13, v12);
}
if ( a2 )
{
v14 = v19 & 1;
v15 = (unsigned __int8)v19 >> 1;
if ( v14 )
v15 = v20;
*(_DWORD *)a2 = v15;
}
else
{
v14 = v19 & 1;
}
goto LABEL_18;
}
v10 = nullptr;
v14 = v19 & 1;
LABEL_18:
if ( v14 )
operator delete(v21);
if ( (v17[0] & 1) != 0 )
operator delete(v18);
return v10;
}