//
// tinyxml2::XMLUtil::ConvertUTF32ToUTF8 from 0x5ed67c to 0x5ed736 (186 bytes)
//
// 1 xrefs:
// > tinyxml2::XMLUtil::GetCharacterRef @ 0x5ed7f6
//
// 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 tinyxml2::XMLUtil::ConvertUTF32ToUTF8(tinyxml2::XMLUtil *this, unsigned int a2, char *a3, int *a4)
{
unsigned int v4; // r4
bool v6; // cc
int result; // r0
int v8; // r3
_BYTE *v9; // r3
char v10; // r2
char v11; // r2
char v12; // r2
_DWORD v13[7]; // [sp+0h] [bp-24h]
v4 = (unsigned int)this;
v6 = (unsigned int)this > 0x7F;
v13[0] = 0;
v13[1] = 0;
v13[2] = 192;
v13[3] = 224;
result = 240;
v13[4] = 240;
v13[5] = 248;
v13[6] = 252;
if ( v6 )
{
if ( v4 >= 0x800 )
{
if ( v4 >= 0x10000 )
{
if ( v4 >= 0x200000 )
{
*(_DWORD *)a3 = 0;
return result;
}
v8 = 4;
}
else
{
v8 = 3;
}
}
else
{
v8 = 2;
}
}
else
{
v8 = 1;
}
*(_DWORD *)a3 = v8;
v9 = (_BYTE *)(a2 + *(_DWORD *)a3);
switch ( *(_DWORD *)a3 )
{
case 1:
goto LABEL_14;
case 2:
goto LABEL_13;
case 3:
goto LABEL_12;
case 4:
--v9;
v10 = v4 & 0x3F | 0x80;
v4 >>= 6;
*v9 = v10;
LABEL_12:
--v9;
v11 = v4 & 0x3F | 0x80;
v4 >>= 6;
*v9 = v11;
LABEL_13:
--v9;
v12 = v4 & 0x3F | 0x80;
v4 >>= 6;
*v9 = v12;
LABEL_14:
*(v9 - 1) = v4 | LOBYTE(v13[*(_DWORD *)a3]);
break;
default:
return result;
}
return result;
}