//
// ConvertUTF8toUTF32 from 0xd8d33c to 0xd8d56c (560 bytes)
//
// 2 xrefs:
// > llvm::ConvertUTF8toWide @ 0xd8d680
// > ??> @ 0xcfa60
//
// 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 ConvertUTF8toUTF32(
_BYTE **a1,
unsigned __int64 a2,
unsigned __int64 *a3,
unsigned __int64 a4,
int a5)
{
_BYTE *v6; // x28
unsigned __int64 v8; // x26
int v9; // w24
int v10; // w23
__int64 v11; // x27
unsigned __int64 v12; // x25
int v13; // w1
int v14; // w7
int v15; // w0
int v16; // w1
int v17; // w0
int v18; // w1
int v19; // w0
int v20; // w1
int v21; // w0
int v22; // w1
int v23; // w0
unsigned int v24; // w0
unsigned int v29; // [xsp+7Ch] [xbp+7Ch]
v6 = *a1;
v8 = *a3;
if ( (unsigned __int64)*a1 >= a2 )
{
v29 = 0;
goto LABEL_20;
}
v9 = (unsigned __int8)*v6;
v10 = byte_11AC5C0[(unsigned __int8)*v6];
v11 = (unsigned __int8)v10;
if ( (__int64)(a2 - (_QWORD)v6) > (unsigned __int8)v10 )
{
v12 = v8 + 4;
v29 = 0;
do
{
v8 = v12 - 4;
if ( !(unsigned __int8)sub_D8C8A4(v6, v10 + 1) )
{
v29 = 3;
goto LABEL_20;
}
switch ( v10 )
{
case 0:
v21 = 0;
goto LABEL_11;
case 1:
v19 = 0;
goto LABEL_10;
case 2:
v17 = 0;
goto LABEL_9;
case 3:
v15 = 0;
goto LABEL_8;
case 4:
v13 = 0;
goto LABEL_7;
case 5:
++v6;
v13 = v9 << 6;
LABEL_7:
v14 = (unsigned __int8)*v6++;
v15 = (v14 + v13) << 6;
LABEL_8:
v16 = (unsigned __int8)*v6++;
v17 = (v16 + v15) << 6;
LABEL_9:
v18 = (unsigned __int8)*v6++;
v19 = (v18 + v17) << 6;
LABEL_10:
v20 = (unsigned __int8)*v6++;
v21 = (v20 + v19) << 6;
LABEL_11:
v22 = (unsigned __int8)*v6++;
v23 = v22 + v21;
break;
default:
v23 = 0;
break;
}
v24 = v23 - dword_11AC6C0[v10];
if ( a4 <= v8 )
{
v6 += ~v11;
v29 = 2;
goto LABEL_20;
}
if ( v24 > 0x10FFFF )
{
v8 = v12;
*(_DWORD *)(v12 - 4) = 65533;
v29 = 3;
}
else if ( v24 - 55296 > 0x7FF )
{
v8 = v12;
*(_DWORD *)(v12 - 4) = v24;
}
else
{
if ( !a5 )
{
v6 += ~v11;
v29 = 3;
goto LABEL_20;
}
v8 = v12;
*(_DWORD *)(v12 - 4) = 65533;
}
if ( (unsigned __int64)v6 >= a2 )
goto LABEL_20;
v9 = (unsigned __int8)*v6;
v12 += 4LL;
v10 = byte_11AC5C0[(unsigned __int8)*v6];
v11 = (unsigned __int8)v10;
}
while ( (unsigned __int8)v10 < (__int64)(a2 - (_QWORD)v6) );
}
v29 = 1;
LABEL_20:
*a1 = v6;
*a3 = v8;
return v29;
}