//
// sub_1800817F0 from 0x1800817f0 to 0x180081a2f (575 bytes)
//
// 6 xrefs:
// > pugi::xml_document::load_file @ 0x180081763
// > pugi::xml_document::load_file @ 0x1800817d3
// > ??> @ 0x18013c950
// > ??> @ 0x18013c9bc
// > ??> @ 0x1801b5340
// > ??> @ 0x1801b534c
//
// 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
//
__int64 __fastcall sub_1800817F0(__int64 a1, pugi::xml_document *a2, FILE *a3, int a4, unsigned int a5)
{
unsigned int v9; // edi
signed __int64 v10; // rsi
unsigned __int64 v11; // r12
char *v12; // rax
char *v13; // r15
size_t v14; // rbx
unsigned __int64 v15; // rax
char v16; // r9
char v17; // dl
char v18; // cl
char v19; // r8
bool v20; // 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_1801A2FA0(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_1801A2FA8(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:
v15 = v10;
LABEL_14:
v11 = v15;
LABEL_15:
pugi::xml_document::load_buffer_inplace_own(a2, a1, v13, v11, a4, v9);
return a1;
}
if ( a5 )
{
v9 = a5;
v15 = v10;
goto LABEL_45;
}
v15 = v10;
if ( (unsigned __int64)v10 < 4 )
{
v9 = 1;
v13[v10] = 0;
goto LABEL_15;
}
v16 = *v13;
v17 = v13[1];
v18 = v13[2];
v19 = v13[3];
if ( !*v13 )
{
if ( !v17 )
{
if ( v18 == -2 )
{
if ( v19 == -1 )
{
v9 = 6;
goto LABEL_45;
}
}
else if ( !v18 && v19 == 60 )
{
v9 = 6;
goto LABEL_45;
}
goto LABEL_44;
}
if ( v17 == 60 )
{
if ( !v18 && v19 == 63 )
{
v9 = 3;
goto LABEL_45;
}
goto LABEL_41;
}
goto LABEL_44;
}
switch ( v16 )
{
case -1:
v20 = v17 == -2;
break;
case -2:
if ( v17 == -1 )
{
LABEL_41:
v9 = 3;
goto LABEL_45;
}
LABEL_44:
v9 = 1;
goto LABEL_45;
case 60:
v20 = v17 == 0;
break;
default:
goto LABEL_44;
}
if ( v20 )
{
if ( !v18 && !v19 )
v9 = 5;
LABEL_45:
if ( v9 == 1 )
{
v13[v15] = 0;
goto LABEL_15;
}
goto LABEL_14;
}
goto LABEL_44;
}
fclose(a3);
*(_DWORD *)a1 = 2;
*(_DWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 8) = 0;
return a1;
}