//
// DS_Dictionary::saveRootSubDictToCompressedFile from 0x80e604 to 0x80e966 (866 bytes)
//
// 1 xrefs:
// > sub_3D4220 @ 0x3d4234
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:01:35 +0000
//
int __fastcall DS_Dictionary::saveRootSubDictToCompressedFile(DS_Dictionary *this, char *a2, int a3)
{
char *v6; // r1
char *v7; // r1
char *v8; // r1
const char *v9; // r0
const char *v10; // r0
const char *v11; // r1
const char *v12; // r0
const char *v13; // r1
const char *v14; // r0
const char *v15; // r0
const char *v16; // r1
const char *v17; // r0
FILE *v18; // r7
char *v19; // r0
size_t v20; // r2
size_t v21; // r11
int v22; // r0
int v23; // r3
int v24; // r7
char *v26; // r2
int v27; // r2
char *v28; // r2
int v29; // r2
_DWORD *v30; // r11
_DWORD *v31; // r10
unsigned __int8 *v32; // r2
unsigned __int8 v33; // r0
int v34; // r1
_BYTE *v35; // r0
int v36; // r2
char *filename; // [sp+14h] [bp-1C8h]
char *filenamea; // [sp+14h] [bp-1C8h]
int v39[2]; // [sp+18h] [bp-1C4h] BYREF
char *v40; // [sp+20h] [bp-1BCh]
_DWORD v41[3]; // [sp+24h] [bp-1B8h] BYREF
int v42[2]; // [sp+30h] [bp-1ACh] BYREF
const char *v43; // [sp+38h] [bp-1A4h]
int v44[2]; // [sp+3Ch] [bp-1A0h] BYREF
const char *v45; // [sp+44h] [bp-198h]
unsigned __int8 v46[4]; // [sp+48h] [bp-194h] BYREF
int v47; // [sp+4Ch] [bp-190h]
_BYTE *v48; // [sp+50h] [bp-18Ch]
int v49; // [sp+54h] [bp-188h] BYREF
size_t v50; // [sp+58h] [bp-184h]
char *v51; // [sp+5Ch] [bp-180h]
_UNKNOWN **v52; // [sp+60h] [bp-17Ch] BYREF
_BYTE v53[100]; // [sp+64h] [bp-178h] BYREF
_DWORD v54[20]; // [sp+C8h] [bp-114h] BYREF
_DWORD v55[2]; // [sp+118h] [bp-C4h] BYREF
_BYTE v56[100]; // [sp+120h] [bp-BCh] BYREF
_DWORD v57[22]; // [sp+184h] [bp-58h] BYREF
v39[0] = 0;
v39[1] = 0;
v40 = nullptr;
std::string::__init(v39, &unk_B6B226, 0);
FileOperation::getFilePath((FileOperation *)v41);
std::string::append(v41, a2);
if ( (v41[0] & 1) != 0 )
v6 = (char *)v41[2];
else
v6 = (char *)v41 + 1;
std::string::assign(v39, v6);
if ( (v39[0] & 1) != 0 )
v7 = v40;
else
v7 = (char *)v39 + 1;
sub_80C8A4(v42, v7, "2.dat");
if ( (v39[0] & 1) != 0 )
v8 = v40;
else
v8 = (char *)v39 + 1;
sub_80C8A4(v44, v8, "3.dat");
if ( (v44[0] & 1) != 0 )
v9 = v45;
else
v9 = (char *)v44 + 1;
remove(v9);
if ( (v42[0] & 1) != 0 )
v10 = v43;
else
v10 = (char *)v42 + 1;
if ( (v44[0] & 1) != 0 )
v11 = v45;
else
v11 = (char *)v44 + 1;
rename(v10, v11);
if ( (v39[0] & 1) != 0 )
v12 = v40;
else
v12 = (char *)v39 + 1;
if ( (v42[0] & 1) != 0 )
v13 = v43;
else
v13 = (char *)v42 + 1;
if ( rename(v12, v13) )
{
if ( (v44[0] & 1) != 0 )
v15 = v45;
else
v15 = (char *)v44 + 1;
if ( (v42[0] & 1) != 0 )
v16 = v43;
else
v16 = (char *)v42 + 1;
rename(v15, v16);
}
else
{
if ( (v44[0] & 1) != 0 )
v14 = v45;
else
v14 = (char *)v44 + 1;
remove(v14);
}
DS_Dictionary::saveRootSubDictToString((DS_Dictionary *)v46, this);
cocos2d::ZipUtils::compressString(&v49, v46, a3, (unsigned __int8 **)((char *)&dword_0 + 1), 11);
if ( (v46[0] & 1) != 0 )
{
*v48 = 0;
v47 = 0;
}
else
{
v46[1] = 0;
v46[0] = 0;
}
if ( (v39[0] & 1) != 0 )
v17 = v40;
else
v17 = (char *)v39 + 1;
v18 = fopen(v17, "wb");
if ( v18
&& ((v49 & 1) == 0 ? (v20 = (int)(unsigned __int8)v49 >> 1, v19 = (char *)&v49 + 1) : (char *)(v19 = v51, v20 = v50),
(v21 = fwrite(v19, 1u, v20, v18), v22 = fclose(v18), (v49 & 1) != 0)
? (v23 = v50)
: (v23 = (int)(unsigned __int8)v49 >> 1),
v21 == v23 && !v22) )
{
v24 = 1;
}
else
{
if ( (v42[0] & 1) != 0 )
v26 = (char *)v43;
else
v26 = (char *)v42 + 1;
filename = v26;
v55[0] = &unk_D12DDC;
v55[1] = 0;
v57[0] = &unk_D12DF0;
std::ios_base::init((std::ios_base *)v57, v56);
v57[19] = -1;
v57[18] = 0;
v55[0] = &off_D12E14;
v57[0] = &off_D12E28;
std::filebuf::basic_filebuf((int)v56, (int)&off_D12E14, v27);
if ( !std::filebuf::open((int)v56, filename, 8) )
std::ios_base::clear((std::ios_base *)v57, v57[4] | 4);
if ( (v39[0] & 1) != 0 )
v28 = v40;
else
v28 = (char *)v39 + 1;
v52 = (_UNKNOWN **)&unk_D12E3C;
v54[0] = &unk_D12E50;
filenamea = v28;
std::ios_base::init((std::ios_base *)v54, v53);
v54[18] = 0;
v54[19] = -1;
v54[0] = &off_D12E88;
v52 = &off_D12E74;
std::filebuf::basic_filebuf((int)v53, (int)&off_D12E74, v29);
if ( !std::filebuf::open((int)v53, filenamea, 16) )
std::ios_base::clear((std::ios_base *)v54, v54[4] | 4);
v30 = *(_DWORD **)((char *)&v57[-21] + *(_DWORD *)(v55[0] + 0xFFFFFFF4));
v31 = *(_DWORD **)&v53[(_DWORD)*(v52 - 3) + 20];
while ( v30 && (v30[3] != v30[4] || (*(int (__fastcall **)(_DWORD *))(*v30 + 36))(v30) != -1) )
{
v32 = (unsigned __int8 *)v30[3];
if ( v32 == (unsigned __int8 *)v30[4] )
v33 = (*(int (__fastcall **)(_DWORD *))(*v30 + 36))(v30);
else
v33 = *v32;
v34 = v33;
if ( v31 )
{
v35 = (_BYTE *)v31[6];
if ( v35 == (_BYTE *)v31[7] )
{
if ( (*(int (__fastcall **)(_DWORD *, int))(*v31 + 52))(v31, v34) == -1 )
v31 = nullptr;
}
else
{
v31[6] = v35 + 1;
*v35 = v34;
}
}
v36 = v30[3];
if ( v36 == v30[4] )
(*(void (__fastcall **)(_DWORD *))(*v30 + 40))(v30);
else
v30[3] = v36 + 1;
}
v24 = 0;
std::ofstream::~ofstream(&v52);
std::ifstream::~ifstream(v55);
}
std::string::~string((int)&v49);
std::string::~string((int)v46);
std::string::~string((int)v44);
std::string::~string((int)v42);
std::string::~string((int)v41);
std::string::~string((int)v39);
return v24;
}