//
// ConvertUTF8toUTF32 from 0x5ea194 to 0x5ea292 (254 bytes)
//
// 1 xrefs:
// > llvm::ConvertUTF8toWide @ 0x5ea332
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall ConvertUTF8toUTF32(unsigned __int8 **a1, unsigned int a2, unsigned int **a3, unsigned int a4, int a5)
{
unsigned int *v6; // r7
unsigned __int8 *v8; // r5
int v10; // r9
int v11; // r2
int v12; // r4
signed int v13; // r6
int v14; // r4
int v15; // r0
int v16; // r4
int v17; // r0
int v18; // r1
int v19; // r0
int v20; // r1
int v21; // r0
int v22; // r1
int v23; // r0
int v24; // r1
unsigned int v25; // r1
unsigned int v27; // [sp+8h] [bp-Ch]
int v28; // [sp+Ch] [bp-8h]
v6 = *a3;
v8 = *a1;
v10 = 0;
v11 = 65533;
while ( (unsigned int)v8 < a2 )
{
v27 = a4;
v12 = *v8;
v28 = v11;
v13 = *((unsigned __int8 *)&unk_9B0840 + v12 + 8);
if ( v13 >= (int)(a2 - (_DWORD)v8) )
{
v10 = 1;
break;
}
if ( !sub_5E9C70(v8, v13 + 1) )
goto LABEL_29;
a4 = v27;
v11 = v28;
switch ( v13 )
{
case 0:
v22 = 0;
goto LABEL_16;
case 1:
v20 = 0;
goto LABEL_14;
case 2:
v18 = 0;
goto LABEL_12;
case 3:
v16 = 0;
goto LABEL_10;
case 4:
v14 = 0;
goto LABEL_8;
case 5:
++v8;
v14 = v12 << 6;
LABEL_8:
v15 = *v8++;
v16 = (v14 + v15) << 6;
LABEL_10:
v17 = *v8++;
v18 = (v16 + v17) << 6;
LABEL_12:
v19 = *v8++;
v20 = (v18 + v19) << 6;
LABEL_14:
v21 = *v8++;
v22 = (v20 + v21) << 6;
LABEL_16:
v23 = *v8++;
v24 = v22 + v23;
break;
default:
v24 = 0;
break;
}
v25 = v24 - *((_DWORD *)&unk_9B0840 + v13 + 66);
if ( (unsigned int)v6 >= v27 )
{
v10 = 2;
v8 += ~v13;
break;
}
if ( v25 > 0x10FFFF )
{
v10 = 3;
*v6 = v28;
}
else if ( v25 - 55296 >= 0x800 )
{
*v6 = v25;
}
else
{
if ( !a5 )
{
v8 += ~v13;
LABEL_29:
v10 = 3;
break;
}
*v6 = v28;
}
++v6;
}
*a1 = v8;
*a3 = v6;
return v10;
}