//
// GManager::loadDataFromFile from 0x5889dc to 0x588c34 (600 bytes)
//
// 2 xrefs:
// > GManager::load @ 0x588c38
// > ??> @ 0x768f0
//
// 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 GManager::loadDataFromFile(__int64 a1, const char **a2)
{
DS_Dictionary *v4; // x19
pugi::xml_node *m_start; // x0
bool Data; // w0
_BOOL4 v8; // w23
char *v9; // x0
pugi::xml_node **p_m_finish; // x0
unsigned int *p_compatible; // x2
int v12; // w1
unsigned int *v13; // x1
int v14; // w2
DS_Dictionary *v15; // [xsp+58h] [xbp+58h] BYREF
const char *v16; // [xsp+60h] [xbp+60h] BYREF
v4 = (DS_Dictionary *)operator new(0xF0u);
DS_Dictionary::DS_Dictionary(v4);
if ( GManager::tryLoadData(a1, v4, a2) )
goto LABEL_2;
sub_58820C((char *)*a2, "2.dat", (__int64)&v15);
Data = GManager::tryLoadData(a1, v4, (const char **)&v15);
v8 = Data;
if ( Data )
{
DS_Dictionary::copyFile((const char *)v15, *a2);
}
else
{
sub_58820C((char *)*a2, ".dat.bak", (__int64)&v16);
v8 = GManager::tryLoadData(a1, v4, &v16);
v9 = (char *)(v16 - 24);
if ( v16 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v16 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v16 - 2);
*((_DWORD *)v16 - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v9);
}
}
p_m_finish = &v15[-1].dictTree.m_finish;
if ( &v15[-1].dictTree.m_finish != (pugi::xml_node **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_compatible = (unsigned int *)&v15[-1].compatible;
do
v12 = __ldaxr(p_compatible);
while ( __stlxr(v12 - 1, p_compatible) );
}
else
{
v12 = *(_DWORD *)&v15[-1].compatible;
*(_DWORD *)&v15[-1].compatible = v12 - 1;
}
if ( v12 <= 0 )
operator delete(p_m_finish);
}
if ( v8 )
LABEL_2:
(*(void (__fastcall **)(__int64, DS_Dictionary *))(*(_QWORD *)a1 + 896LL))(a1, v4);
else
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 904LL))(a1);
m_start = v4->dictTree.m_start;
if ( m_start )
operator delete(m_start);
pugi::xml_document::~xml_document(&v4->doc);
operator delete(v4);
return _stack_chk_guard;
}