//
// ConvertUTF8toUTF16 from 0xd8d104 to 0xd8d33c (568 bytes)
//
// 2 xrefs:
// > llvm::ConvertUTF8toWide @ 0xd8d63c
// > ??> @ 0x910f0
//
// 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 ConvertUTF8toUTF16(
unsigned __int8 **a1,
unsigned __int64 a2,
_WORD **a3,
unsigned __int64 a4,
int a5)
{
unsigned __int8 *v6; // x27
_WORD *v8; // x26
int v9; // w24
int v10; // w23
__int64 v11; // x25
int v12; // w0
int v13; // w1
unsigned __int8 *v14; // x2
int v15; // w0
int v16; // w0
unsigned __int8 *v17; // x2
int v18; // w0
int v19; // w1
unsigned __int8 *v20; // x2
int v21; // w0
unsigned int v22; // w0
__int64 result; // x0
unsigned int v24; // w0
v6 = *a1;
v8 = *a3;
if ( (unsigned __int64)*a1 >= a2 )
{
LABEL_28:
result = 0;
}
else
{
v9 = *v6;
v10 = byte_11AC5C0[*v6];
v11 = (unsigned __int8)v10;
if ( (__int64)(a2 - (_QWORD)v6) > (unsigned __int8)v10 )
{
while ( 1 )
{
if ( !(unsigned __int8)sub_D8C8A4(v6, v10 + 1) )
{
result = 3;
goto LABEL_19;
}
v12 = 0;
switch ( v10 )
{
case 0:
v20 = v6;
v21 = 0;
goto LABEL_10;
case 1:
v17 = v6;
v18 = 0;
goto LABEL_9;
case 2:
v16 = 0;
goto LABEL_8;
case 3:
v14 = v6;
v15 = 0;
goto LABEL_7;
case 4:
v13 = 0;
goto LABEL_6;
case 5:
++v6;
v13 = v9 << 6;
LABEL_6:
v14 = v6 + 1;
v15 = (*v6 + v13) << 6;
LABEL_7:
v6 = v14 + 1;
v16 = (*v14 + v15) << 6;
LABEL_8:
v17 = v6 + 1;
v18 = (*v6 + v16) << 6;
LABEL_9:
v19 = *v17;
v20 = v17 + 1;
v21 = (v19 + v18) << 6;
LABEL_10:
v6 = v20 + 1;
v12 = *v20 + v21;
break;
default:
break;
}
v22 = v12 - dword_11AC6C0[v10];
if ( a4 <= (unsigned __int64)v8 )
{
LABEL_29:
result = 2;
v6 += ~v11;
goto LABEL_19;
}
if ( v22 <= 0xFFFF )
break;
if ( v22 > 0x10FFFF )
goto LABEL_14;
if ( a4 <= (unsigned __int64)(v8 + 1) )
goto LABEL_29;
v24 = v22 - 0x10000;
*v8 = (v24 >> 10) - 10240;
v8[1] = (v24 & 0x3FF) - 9216;
v8 += 2;
if ( (unsigned __int64)v6 >= a2 )
goto LABEL_28;
LABEL_17:
v9 = *v6;
v10 = byte_11AC5C0[*v6];
v11 = (unsigned __int8)v10;
if ( (unsigned __int8)v10 >= (__int64)(a2 - (_QWORD)v6) )
goto LABEL_18;
}
if ( v22 - 55296 <= 0x7FF )
{
LABEL_14:
if ( !a5 )
{
result = 3;
v6 += ~v11;
goto LABEL_19;
}
LOWORD(v22) = -3;
}
*v8++ = v22;
if ( (unsigned __int64)v6 >= a2 )
goto LABEL_28;
goto LABEL_17;
}
LABEL_18:
result = 1;
}
LABEL_19:
*a1 = v6;
*a3 = v8;
return result;
}