//
// DS_Dictionary::saveRootSubDictToFile from 0xb41bb0 to 0xb4217c (1484 bytes)
//
// 1 xrefs:
// > ??> @ 0xb64a8
//
// 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
//
bool DS_Dictionary::saveRootSubDictToFile(DS_Dictionary *a1, const char *a2)
{
int v3; // w25
FileOperation *v4; // x0
size_t v5; // x0
size_t v6; // x0
char v7; // w24
const char *v8; // x1
char *v9; // x0
char *v10; // x0
char *v11; // x0
char *v12; // x0
const char *v14; // x25
unsigned int *v15; // x1
int v16; // w2
unsigned int *v17; // x1
int v18; // w2
unsigned int *v19; // x1
int v20; // w2
unsigned int *v21; // x1
int v22; // w2
char *v23; // [xsp+68h] [xbp+68h]
const char *v24; // [xsp+88h] [xbp+88h]
char *v25; // [xsp+A0h] [xbp+A0h] BYREF
const char *v26; // [xsp+A8h] [xbp+A8h] BYREF
const char *v27; // [xsp+B0h] [xbp+B0h] BYREF
const char *v28; // [xsp+B8h] [xbp+B8h] BYREF
__int64 (__fastcall **v29)(); // [xsp+C0h] [xbp+C0h] BYREF
_QWORD v30[7]; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v31; // [xsp+100h] [xbp+100h] BYREF
_BYTE v32[136]; // [xsp+130h] [xbp+130h] BYREF
_QWORD v33[28]; // [xsp+1B8h] [xbp+1B8h] BYREF
char v34; // [xsp+298h] [xbp+298h]
char v35; // [xsp+299h] [xbp+299h]
__int64 v36; // [xsp+2A0h] [xbp+2A0h]
__int64 v37; // [xsp+2A8h] [xbp+2A8h]
__int64 v38; // [xsp+2B0h] [xbp+2B0h]
__int64 v39; // [xsp+2B8h] [xbp+2B8h]
_QWORD v40[2]; // [xsp+2C0h] [xbp+2C0h] BYREF
_QWORD v41[7]; // [xsp+2D0h] [xbp+2D0h] BYREF
__int64 v42; // [xsp+308h] [xbp+308h] BYREF
_BYTE v43[136]; // [xsp+338h] [xbp+338h] BYREF
_QWORD v44[28]; // [xsp+3C0h] [xbp+3C0h] BYREF
char v45; // [xsp+4A0h] [xbp+4A0h]
char v46; // [xsp+4A1h] [xbp+4A1h]
__int64 v47; // [xsp+4A8h] [xbp+4A8h]
__int64 v48; // [xsp+4B0h] [xbp+4B0h]
__int64 v49; // [xsp+4B8h] [xbp+4B8h]
__int64 v50; // [xsp+4C0h] [xbp+4C0h]
v3 = (int)a1;
v4 = (FileOperation *)sub_D153B8((int)&v25, &byte_F288A0);
FileOperation::getFilePath(v4, (__int64)&v26);
v5 = strlen(a2);
sub_D15FD4(&v26, a2, v5);
v24 = v26;
v6 = strlen(v26);
sub_D1798C(&v25, v24, v6);
sub_B41824(v25, "2.dat", (__int64)&v27);
sub_B41824(v25, "3.dat", (__int64)&v28);
remove(v28);
rename(v27, v28);
if ( rename(v25, v27) )
rename(v28, v27);
else
remove(v28);
v7 = pugi::xml_document::save_file(v3, v25);
if ( v7 )
{
v8 = v28;
v9 = (char *)(v28 - 24);
if ( v28 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_5;
}
else
{
v14 = v27;
sub_CCFA58(v44);
v45 = 0;
v44[27] = 0;
v46 = 0;
v47 = 0;
v40[0] = &unk_121E508;
v48 = 0;
v49 = 0;
v50 = 0;
v44[0] = &unk_121E530;
v40[1] = 0;
sub_CCED04(v44, 0);
v40[0] = off_111EEE8;
v44[0] = off_111EF10;
sub_D0D394(v41);
sub_CCED04(v44, v41);
if ( sub_D0DE68(v41, v14, 8) )
sub_CCE830((char *)v40 + *(_QWORD *)(v40[0] - 24LL), 0);
else
sub_CCE830(
(char *)v40 + *(_QWORD *)(v40[0] - 24LL),
*(_DWORD *)((char *)&v41[2] + *(_QWORD *)(v40[0] - 24LL)) | 4u);
v23 = v25;
sub_CCFA58(v33);
v34 = 0;
v33[27] = 0;
v35 = 0;
v36 = 0;
v37 = 0;
v38 = 0;
v39 = 0;
v29 = (__int64 (__fastcall **)())&unk_121E558;
v33[0] = &unk_121E580;
sub_CCED04(v33, 0);
v33[0] = off_111EF80;
v29 = off_111EF58;
sub_D0D394(v30);
sub_CCED04(v33, v30);
if ( sub_D0DE68(v30, v23, 48) )
sub_CCE830((char *)&v30[-1] + (_QWORD)*(v29 - 3), 0);
else
sub_CCE830((char *)&v30[-1] + (_QWORD)*(v29 - 3), *(_DWORD *)((char *)&v30[3] + (_QWORD)*(v29 - 3)) | 4u);
sub_B417A4(
*(_QWORD *)&v43[*(_QWORD *)(v40[0] - 24LL) + 112],
*(_QWORD *)&v32[(_QWORD)*(v29 - 3) + 120],
*(_QWORD *)&v32[(_QWORD)*(v29 - 3) + 120] == 0);
v33[0] = off_111EF80;
v30[0] = off_121E480;
v29 = off_111EF58;
sub_D0D938(v30);
sub_CCE20C(v32);
v30[0] = off_111E930;
sub_CEA56C(&v31);
v29 = (__int64 (__fastcall **)())&unk_121E558;
v33[0] = off_111DB70;
sub_CCFDF8(v33);
v41[0] = off_121E480;
v40[0] = off_111EEE8;
v44[0] = off_111EF10;
sub_D0D938(v41);
sub_CCE20C(v43);
v41[0] = off_111E930;
sub_CEA56C(&v42);
v40[0] = &unk_121E508;
v44[0] = off_111DB70;
sub_CCFDF8(v44);
v8 = v28;
v9 = (char *)(v28 - 24);
if ( v28 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_5;
}
if ( &pthread_create )
{
v15 = (unsigned int *)(v8 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v8 - 2);
*((_DWORD *)v8 - 2) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v9);
LABEL_5:
v10 = (char *)(v27 - 24);
if ( v27 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v27 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v27 - 2);
*((_DWORD *)v27 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v10);
}
v11 = (char *)(v26 - 24);
if ( v26 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v26 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v26 - 2);
*((_DWORD *)v26 - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v11);
}
v12 = v25 - 24;
if ( v25 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v25 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v12);
}
return v7;
}