//
// sub_1800847F0 from 0x1800847f0 to 0x180084a15 (549 bytes)
//
// 6 xrefs:
// > pugi::xml_document::load_file @ 0x180084763
// > pugi::xml_document::load_file @ 0x1800847d3
// > ??> @ 0x180145c00
// > ??> @ 0x180145c6c
// > ??> @ 0x1801bf5ec
// > ??> @ 0x1801bf5f8
//
// This function is hookable on this platform (idp: pc, 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 11:22:03 +0000
//
__int64 __fastcall sub_1800847F0(__int64 a1, char **a2, FILE *a3, int a4, unsigned int a5)
{
unsigned int v9; // edi
signed __int64 v10; // r15
unsigned __int64 v11; // r12
char *v12; // rax
char *v13; // r14
size_t v14; // rbx
char v15; // r8
char v16; // cl
char v17; // al
char v18; // dl
bool v19; // zf
if ( !a3 )
{
*(_DWORD *)a1 = 1;
*(_DWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 8) = 0;
return a1;
}
v9 = 2;
fseeki64(a3, 0, 2);
v10 = ftelli64(a3);
fseeki64(a3, 0, 0);
if ( v10 >= 0 )
{
v11 = v10 + 1;
v12 = (char *)off_1801ACF70(v10 + 1);
v13 = v12;
if ( !v12 )
{
fclose(a3);
*(_DWORD *)a1 = 3;
*(_DWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 8) = 0;
return a1;
}
v14 = fread(v12, 1u, v10, a3);
fclose(a3);
if ( v14 != v10 )
{
off_1801ACF78(v13);
*(_DWORD *)a1 = 2;
*(_DWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 8) = 0;
return a1;
}
if ( a5 == 8 || a5 == 4 )
goto LABEL_13;
if ( a5 == 7 )
{
v9 = 5;
LABEL_13:
v11 = v10;
LABEL_14:
pugi::xml_document::load_buffer_inplace_own(a2, a1, v13, v11, a4, v9);
return a1;
}
if ( a5 )
{
v9 = a5;
goto LABEL_44;
}
if ( (unsigned __int64)v10 < 4 )
{
v9 = 1;
v13[v10] = 0;
goto LABEL_14;
}
v15 = *v13;
v16 = v13[1];
v17 = v13[2];
v18 = v13[3];
if ( !*v13 )
{
if ( !v16 )
{
if ( v17 == -2 )
{
if ( v18 == -1 )
{
v9 = 6;
goto LABEL_44;
}
}
else if ( !v17 && v18 == 60 )
{
v9 = 6;
goto LABEL_44;
}
goto LABEL_43;
}
if ( v16 == 60 )
{
if ( !v17 && v18 == 63 )
{
v9 = 3;
goto LABEL_44;
}
goto LABEL_40;
}
goto LABEL_43;
}
switch ( v15 )
{
case -1:
v19 = v16 == -2;
break;
case -2:
if ( v16 == -1 )
{
LABEL_40:
v9 = 3;
goto LABEL_44;
}
LABEL_43:
v9 = 1;
goto LABEL_44;
case 60:
v19 = v16 == 0;
break;
default:
goto LABEL_43;
}
if ( v19 )
{
if ( !v17 && !v18 )
v9 = 5;
LABEL_44:
if ( v9 == 1 )
{
v13[v10] = 0;
goto LABEL_14;
}
goto LABEL_13;
}
goto LABEL_43;
}
fclose(a3);
*(_DWORD *)a1 = 2;
*(_DWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 8) = 0;
return a1;
}