//
// cocos2d::cc_utf16_to_utf8 from 0x7f55a0 to 0x7f576e (462 bytes)
//
// 1 xrefs:
// > cocos2d::JniHelper::jstring2string @ 0x7eddf6
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:01:08 +0000
//
cocos2d *__fastcall cocos2d::cc_utf16_to_utf8(cocos2d *this, unsigned __int16 *a2, int *a3)
{
cocos2d *v4; // r6
int v5; // r7
int v6; // r8
__int16 v7; // r11
unsigned int v8; // r4
unsigned int v9; // r3
unsigned int v10; // r5
unsigned int v11; // r5
unsigned int v12; // r5
const char *v13; // r0
_WORD *v14; // r0
void *v15; // r3
void *v16; // r1
char *v17; // lr
unsigned int v18; // r2
__int16 v19; // t1
char *v20; // r2
size_t v21; // r0
cocos2d *v22; // r0
size_t v23; // r3
size_t v24; // r3
char *v26; // r1
size_t v27; // r2
char *v28; // r3
char *v29; // [sp+4h] [bp-30h]
void *v30; // [sp+4h] [bp-30h]
_DWORD v31[2]; // [sp+Ch] [bp-28h] BYREF
int v32; // [sp+14h] [bp-20h] BYREF
unsigned int v33; // [sp+18h] [bp-1Ch]
void *v34; // [sp+1Ch] [bp-18h]
int v35; // [sp+20h] [bp-14h] BYREF
size_t v36; // [sp+24h] [bp-10h]
void *v37; // [sp+28h] [bp-Ch]
v4 = this;
v5 = 0;
if ( !this )
return v4;
v32 = 0;
v33 = 0;
v34 = nullptr;
v6 = cocos2d::cc_wcslen(this, a2);
while ( v5 < v6 )
{
v7 = *((_WORD *)v4 + v5);
if ( (v32 & 1) == 0 )
{
v8 = (int)(unsigned __int8)v32 >> 1;
if ( v8 != 4 )
{
v20 = (char *)&v32 + 2 * v8 + 2;
LOBYTE(v32) = 2 * (v8 + 1);
goto LABEL_24;
}
v28 = (char *)&v32 + 2;
LABEL_9:
v10 = 2 * v8;
if ( 2 * v8 < v8 + 1 )
v10 = v8 + 1;
if ( v10 <= 4 )
v11 = 4;
else
v11 = ((v10 + 8) & 0xFFFFFFF8) - 1;
goto LABEL_14;
}
v9 = v33;
v8 = (v32 & 0xFFFFFFFE) - 1;
if ( v33 == v8 )
{
v28 = (char *)v34;
if ( v8 <= 0x3FFFFFE6 )
goto LABEL_9;
v11 = 2147483630;
LABEL_14:
v12 = v11 + 1;
if ( v12 >= 0x80000000 )
{
std::logic_error::logic_error(
(std::logic_error *)v31,
"allocator::allocate(size_t n) 'n' exceeds maximum supported size");
v31[0] = &off_D1546C;
v13 = (const char *)std::logic_error::what((std::logic_error *)v31);
fprintf((FILE *)((char *)&_sF + 168), "%s\n", v13);
abort();
}
v29 = v28;
v14 = (_WORD *)operator new(2 * v12);
v15 = v29;
v16 = v14;
if ( !v8 )
goto LABEL_17;
v17 = v29 - 2;
v18 = v8;
do
{
v19 = *((_WORD *)v17 + 1);
v17 += 2;
--v18;
*v14++ = v19;
}
while ( v18 );
if ( v8 != 4 )
{
LABEL_17:
v30 = v16;
operator delete(v15);
v16 = v30;
}
v34 = v16;
v32 = v12 | 1;
v9 = v8;
}
v20 = (char *)v34 + 2 * v9;
v33 = v9 + 1;
LABEL_24:
*(_WORD *)v20 = v7;
*((_WORD *)v20 + 1) = 0;
++v5;
}
v35 = 0;
v36 = 0;
v37 = nullptr;
if ( !v6 || llvm::convertUTF16ToUTF8String((unsigned __int8 *)&v32, (unsigned __int8 *)&v35) )
{
if ( (v35 & 1) != 0 )
v21 = v36;
else
v21 = (int)(unsigned __int8)v35 >> 1;
v22 = (cocos2d *)operator new[](v21 + 1);
if ( (v35 & 1) != 0 )
v23 = v36;
else
v23 = (int)(unsigned __int8)v35 >> 1;
v4 = v22;
*((_BYTE *)v22 + v23) = 0;
if ( v6 > 0 )
{
if ( (v35 & 1) != 0 )
{
v26 = (char *)v37;
v27 = v36;
}
else
{
v27 = (int)(unsigned __int8)v35 >> 1;
v26 = (char *)&v35 + 1;
}
memcpy(v22, v26, v27);
}
if ( a2 )
{
if ( (v35 & 1) != 0 )
v24 = v36;
else
v24 = (int)(unsigned __int8)v35 >> 1;
*(_DWORD *)a2 = v24;
}
}
else
{
v4 = nullptr;
}
if ( (v35 & 1) != 0 )
operator delete(v37);
if ( (v32 & 1) != 0 )
operator delete(v34);
return v4;
}