//
// llvm::convertUTF16ToUTF8String from 0x7f545c to 0x7f559c (320 bytes)
//
// 1 xrefs:
// > cocos2d::cc_utf16_to_utf8 @ 0x7f56c8
//
// 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
//
int __fastcall llvm::convertUTF16ToUTF8String(unsigned __int8 *a1, unsigned __int8 *a2)
{
int v3; // r5
unsigned __int16 *v5; // r2
unsigned __int8 *v6; // r6
int v7; // r5
char *v8; // r6
int v9; // r5
int v10; // r3
int v11; // r1
int v12; // r1
int v13; // r2
unsigned __int8 *v14; // lr
int v15; // r3
int v16; // r5
int v17; // r0
int v18; // r3
bool v19; // zf
_BYTE *v20; // r3
bool v21; // nf
int v22; // r3
unsigned __int16 *v24; // [sp+8h] [bp-18h] BYREF
unsigned __int8 *v25; // [sp+Ch] [bp-14h] BYREF
void *v26; // [sp+10h] [bp-10h] BYREF
int v27; // [sp+14h] [bp-Ch]
int v28; // [sp+18h] [bp-8h]
v3 = *a1;
if ( (v3 & 1) == 0 )
{
if ( (unsigned int)v3 >> 1 )
{
v5 = (unsigned __int16 *)(a1 + 2);
goto LABEL_6;
}
return 1;
}
if ( !*((_DWORD *)a1 + 1) )
return 1;
v5 = *((unsigned __int16 **)a1 + 2);
LABEL_6:
v24 = v5;
if ( (v3 & 1) != 0 )
{
v6 = *((unsigned __int8 **)a1 + 2);
v7 = *((_DWORD *)a1 + 1);
}
else
{
v6 = a1 + 2;
v7 = v3 >> 1;
}
v8 = (char *)&v6[2 * v7];
v9 = 0;
v26 = nullptr;
v27 = 0;
v28 = 0;
if ( *v5 == 65534 )
{
std::vector::insert(&v26, nullptr, (__int16 *)v5, v8);
v10 = (v27 - (int)v26) >> 1;
while ( v9 != v10 )
{
*((_WORD *)v26 + v9) = __rev16(*((unsigned __int16 *)v26 + v9));
++v9;
}
v24 = (unsigned __int16 *)v26;
v8 = (char *)v26 + ((v27 - (_DWORD)v26) & 0xFFFFFFFE);
}
v11 = *a1;
if ( *v24 == 65279 )
++v24;
if ( (v11 & 1) != 0 )
v12 = *((_DWORD *)a1 + 1);
else
v12 = v11 >> 1;
std::string::resize(a2, 4 * v12 + 1, 0);
v13 = *a2;
if ( (v13 & 1) != 0 )
v14 = *((unsigned __int8 **)a2 + 2);
else
v14 = a2 + 1;
v25 = v14;
if ( (v13 & 1) != 0 )
v15 = *((_DWORD *)a2 + 1);
else
v15 = v13 >> 1;
v16 = 0;
v17 = ConvertUTF16toUTF8(&v24, (unsigned int)v8, &v25, (unsigned int)&v14[v15], 0);
v18 = *a2;
if ( v17 )
{
v20 = (_BYTE *)(v18 & 1);
v19 = v20 == nullptr;
if ( v20 )
{
v20 = *((_BYTE **)a2 + 2);
}
else
{
a2[1] = 0;
*a2 = 0;
}
if ( v19 )
{
v16 = (int)v20;
}
else
{
*v20 = 0;
*((_DWORD *)a2 + 1) = 0;
}
}
else
{
v22 = v18 << 31;
v21 = v22 < 0;
if ( v22 >= 0 )
v22 = (int)(a2 + 1);
if ( v21 )
v22 = *((_DWORD *)a2 + 2);
v16 = 1;
std::string::resize(a2, (unsigned int)&v25[-v22], 0);
}
if ( v26 )
{
v27 -= 2 * ((unsigned int)(v27 - (_DWORD)v26) >> 1);
operator delete(v26);
}
return v16;
}