//
// tinyxml2::XMLUtil::GetCharacterRef from 0x5ed740 to 0x5ed816 (214 bytes)
//
// 1 xrefs:
// > tinyxml2::StrPair::GetStr @ 0x5ed8a4
//
// 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
//
char *__fastcall tinyxml2::XMLUtil::GetCharacterRef(tinyxml2::XMLUtil *this, const char *a2, char *a3, int *a4)
{
char *result; // r0
int v8; // r3
int v9; // r4
int v10; // r1
tinyxml2::XMLUtil *v11; // r2
int *v12; // r3
int *v13; // t1
char *v14; // r3
char *v15; // r4
int i; // r1
int *v17; // t1
int *v18; // r3
*(_DWORD *)a3 = 0;
if ( *((_BYTE *)this + 1) != 35 || !*((_BYTE *)this + 2) )
return (char *)this + 1;
if ( *((_BYTE *)this + 2) == 120 )
{
result = (char *)*((unsigned __int8 *)this + 3);
if ( !result )
return result;
result = strchr((const char *)this + 3, 59);
if ( !result )
return result;
v8 = (unsigned __int8)*result;
if ( *result )
{
v9 = result - (char *)this;
v10 = 1;
v11 = nullptr;
while ( 1 )
{
v13 = (int *)(unsigned __int8)*--result;
v12 = v13;
if ( v13 == &dword_78 )
break;
if ( (unsigned __int8)((_BYTE)v12 - 48) > 9u )
{
if ( (unsigned int)v12 - 97 > 5 )
{
if ( (unsigned int)v12 - 65 > 5 )
return nullptr;
v14 = (char *)v12 - 55;
}
else
{
v14 = (char *)v12 - 87;
}
v11 = (tinyxml2::XMLUtil *)((char *)v11 + (_DWORD)v14 * v10);
}
else
{
v11 = (tinyxml2::XMLUtil *)((char *)v11 + (_DWORD)(v12 - 12) * v10);
}
v10 *= 16;
}
LABEL_24:
tinyxml2::XMLUtil::ConvertUTF32ToUTF8(v11, (unsigned int)a2, a3, v12);
return (char *)this + v9 + 1;
}
return (char *)v8;
}
result = strchr((const char *)this + 2, 59);
if ( !result )
return result;
v8 = (unsigned __int8)*result;
if ( !*result )
return (char *)v8;
v11 = nullptr;
v15 = result;
for ( i = 1; ; i *= 10 )
{
v17 = (int *)(unsigned __int8)*--v15;
v12 = v17;
if ( v17 == (int *)((char *)&dword_20 + 3) )
{
v9 = result - (char *)this;
goto LABEL_24;
}
v18 = v12 - 12;
if ( (unsigned __int8)v18 > 9u )
break;
v11 = (tinyxml2::XMLUtil *)((char *)v11 + (_DWORD)v18 * i);
}
return nullptr;
}