//
// ConvertUTF32toUTF8 from 0xd8cdb0 to 0xd8cf5c (428 bytes)
//
// 2 xrefs:
// > llvm::ConvertCodePointToUTF8 @ 0xd8d788
// > ??> @ 0xb8588
//
// 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:16 +0000
//
__int64 __fastcall ConvertUTF32toUTF8(unsigned int **a1, unsigned __int64 a2, __int64 *a3, unsigned __int64 a4, int a5)
{
unsigned int *v5; // x10
__int64 v6; // x8
unsigned int v7; // w15
unsigned int v8; // w5
__int64 v9; // x7
__int64 v10; // x8
int v11; // w11
__int64 v12; // x12
char v13; // w9
unsigned int *v14; // x6
char v16; // w9
__int64 v17; // x8
v5 = *a1;
v6 = *a3;
if ( (unsigned __int64)*a1 >= a2 )
{
v14 = *a1;
v7 = 0;
LABEL_16:
*a1 = v14;
*a3 = v6;
return v7;
}
v7 = 0;
while ( 1 )
{
while ( 1 )
{
v14 = v5 + 1;
v8 = *v5;
if ( !a5 && v8 - 55296 <= 0x7FF )
{
*a1 = v5;
*a3 = v6;
return 3;
}
if ( v8 > 0x7F )
break;
v9 = v6 + 1;
if ( a4 < v6 + 1 )
{
v17 = -1;
goto LABEL_23;
}
++v6;
++v5;
*(_BYTE *)(v9 - 1) = v8;
if ( a2 <= (unsigned __int64)v14 )
goto LABEL_16;
}
if ( v8 > 0x7FF )
break;
v12 = v6 + 2;
if ( a4 < v6 + 2 )
{
v9 = v6 + 2;
v17 = -2;
goto LABEL_23;
}
v10 = 1;
v11 = 2;
LABEL_10:
*(_BYTE *)(v12 - 1) = v8 & 0x3F | 0x80;
v6 = v12 - 1 + v10;
++v5;
*(_BYTE *)(v12 - 2) = (v8 >> 6) | *((_BYTE *)&unk_11AC5B0 + v11);
if ( a2 <= (unsigned __int64)v14 )
goto LABEL_16;
}
if ( v8 <= 0xFFFF )
goto LABEL_7;
if ( v8 > 0x10FFFF )
{
v8 = 65533;
v7 = 3;
LABEL_7:
v9 = v6 + 3;
if ( a4 < v6 + 3 )
{
v17 = -3;
goto LABEL_23;
}
v10 = 2;
v11 = 3;
goto LABEL_9;
}
v9 = v6 + 4;
if ( a4 >= v6 + 4 )
{
v9 = v6 + 3;
v16 = v8 & 0x3F | 0x80;
v8 >>= 6;
*(_BYTE *)(v6 + 3) = v16;
v11 = 4;
v10 = 3;
LABEL_9:
v12 = v9 - 1;
v13 = v8 & 0x3F | 0x80;
v8 >>= 6;
*(_BYTE *)(v9 - 1) = v13;
goto LABEL_10;
}
v17 = -4;
LABEL_23:
*a1 = v5;
*a3 = v9 + v17;
return 2;
}