//
// llvm::ConvertUTF8toWide from 0xd8d56c to 0xd8d740 (468 bytes)
//
// 2 xrefs:
// > cocos2d::cc_utf8_to_utf16 @ 0xd8dd78
// > ??> @ 0xe0bf0
//
// 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
//
__int64 __fastcall llvm::ConvertUTF8toWide(int a1, char *a2, void **a3, unsigned __int8 **a4)
{
bool v7; // zf
__int64 result; // x0
unsigned __int8 v9; // w0
unsigned __int8 *v10; // x4
__int64 v11; // x3
unsigned __int8 *v12; // x1
int v13; // w0
__int64 v14; // x3
unsigned __int8 *v15; // x4
unsigned __int8 *v16; // x1
__int64 v17; // x2
const void *v18; // x1
size_t v19; // x2
__int64 v20; // x1
unsigned __int8 *v21; // [xsp+38h] [xbp+38h] BYREF
unsigned __int8 *v22; // [xsp+40h] [xbp+40h] BYREF
if ( a1 != 1 )
{
if ( a1 == 2 )
{
if ( (*a2 & 1) != 0 )
{
v11 = *((_QWORD *)a2 + 1);
v10 = (unsigned __int8 *)*a3;
v21 = *((unsigned __int8 **)a2 + 2);
v12 = &v21[v11];
v22 = v10;
}
else
{
v10 = (unsigned __int8 *)*a3;
v11 = (unsigned __int8)*a2 >> 1;
v21 = (unsigned __int8 *)(a2 + 1);
v22 = v10;
v12 = (unsigned __int8 *)&a2[v11 + 1];
}
v13 = ConvertUTF8toUTF16(&v21, (unsigned __int64)v12, (_WORD **)&v22, (unsigned __int64)&v10[4 * v11], 0);
if ( !v13 )
{
LABEL_15:
*a3 = v22;
return v13 == 0;
}
}
else
{
v7 = a1 == 4;
result = 1;
if ( !v7 )
return result;
if ( (*a2 & 1) != 0 )
{
v14 = *((_QWORD *)a2 + 1);
v15 = (unsigned __int8 *)*a3;
v21 = *((unsigned __int8 **)a2 + 2);
v16 = &v21[v14];
v22 = v15;
}
else
{
v15 = (unsigned __int8 *)*a3;
v14 = (unsigned __int8)*a2 >> 1;
v21 = (unsigned __int8 *)(a2 + 1);
v22 = v15;
v16 = (unsigned __int8 *)&a2[v14 + 1];
}
v13 = ConvertUTF8toUTF32(
&v21,
(unsigned __int64)v16,
(unsigned __int64 *)&v22,
(unsigned __int64)&v15[16 * v14],
0);
if ( !v13 )
goto LABEL_15;
}
*a4 = v21;
return v13 == 0;
}
v9 = *a2;
if ( (*a2 & 1) != 0 )
{
v17 = *((_QWORD *)a2 + 1);
v22 = *((unsigned __int8 **)a2 + 2);
result = (unsigned __int8)isLegalUTF8String((const unsigned __int8 **)&v22, &v22[v17]);
if ( !(_BYTE)result )
goto LABEL_7;
}
else
{
v22 = (unsigned __int8 *)(a2 + 1);
result = (unsigned __int8)isLegalUTF8String(
(const unsigned __int8 **)&v22,
(const unsigned __int8 *)&a2[(v9 >> 1) + 1]);
if ( !(_BYTE)result )
{
LABEL_7:
*a4 = v22;
return result;
}
}
if ( (*a2 & 1) != 0 )
{
v18 = *((const void **)a2 + 2);
v19 = *((_QWORD *)a2 + 1);
}
else
{
v18 = a2 + 1;
v19 = (unsigned __int8)*a2 >> 1;
}
memcpy(*a3, v18, v19);
v20 = (unsigned __int8)*a2 >> 1;
if ( (*a2 & 1) != 0 )
v20 = *((_QWORD *)a2 + 1);
*a3 = (char *)*a3 + v20;
return 1;
}