//
// sub_80C8A4 from 0x80c8a4 to 0x80c9c6 (290 bytes)
//
// 4 xrefs:
// > DS_Dictionary::saveRootSubDictToFile @ 0x80e35c
// > DS_Dictionary::saveRootSubDictToFile @ 0x80e372
// > DS_Dictionary::saveRootSubDictToCompressedFile @ 0x80e672
// > DS_Dictionary::saveRootSubDictToCompressedFile @ 0x80e688
//
// 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:32 +0000
//
int *__fastcall sub_80C8A4(int *a1, char *a2, const char *a3)
{
unsigned __int8 *v3; // r4
int v7; // r3
size_t v8; // r0
size_t v9; // r0
int v10; // r2
int v11; // r10
unsigned int v12; // r2
unsigned __int8 *v13; // r3
unsigned int v14; // r1
unsigned __int8 *v15; // r11
unsigned int v16; // r2
char *v17; // r3
size_t v18; // r1
int v19; // r1
unsigned __int8 *v21; // [sp+14h] [bp-28h] BYREF
int v22; // [sp+1Ch] [bp-20h] BYREF
unsigned int v23; // [sp+20h] [bp-1Ch]
unsigned __int8 *v24; // [sp+24h] [bp-18h]
int v25; // [sp+28h] [bp-14h] BYREF
size_t v26; // [sp+2Ch] [bp-10h]
char *v27; // [sp+30h] [bp-Ch]
int v28; // [sp+34h] [bp-8h]
v3 = nullptr;
a1[1] = 0;
a1[2] = 0;
v7 = _stack_chk_guard;
*a1 = 0;
v28 = v7;
v8 = strlen(a2);
std::string::__init(a1, a2, v8);
v22 = 0;
v23 = 0;
v24 = nullptr;
std::string::__init(&v22, ".dat", 4u);
v25 = 0;
v26 = 0;
v27 = nullptr;
v9 = strlen(a3);
std::string::__init(&v25, a3, v9);
while ( 1 )
{
v10 = *(unsigned __int8 *)a1;
if ( (v10 & 1) != 0 )
{
v11 = a1[2];
v12 = a1[1];
}
else
{
v11 = (int)a1 + 1;
v12 = v10 >> 1;
}
if ( (v22 & 1) != 0 )
{
v13 = v24;
v14 = v23;
}
else
{
v14 = (int)(unsigned __int8)v22 >> 1;
v13 = (unsigned __int8 *)&v22 + 1;
}
if ( (unsigned int)v3 > v12 || v12 - (unsigned int)v3 < v14 )
break;
if ( v14 )
{
v15 = (unsigned __int8 *)(v11 + v12);
std::__search(
&v21,
&v3[v11],
(unsigned __int8 *)(v11 + v12),
v13,
&v13[v14],
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v21 == v15 )
break;
v3 = &v21[-v11];
}
if ( v3 == (unsigned __int8 *)-1 )
break;
if ( (v22 & 1) != 0 )
v16 = v23;
else
v16 = (int)(unsigned __int8)v22 >> 1;
if ( (v25 & 1) != 0 )
{
v17 = v27;
v18 = v26;
}
else
{
v18 = (int)(unsigned __int8)v25 >> 1;
v17 = (char *)&v25 + 1;
}
std::string::replace(a1, (size_t)v3, v16, v17, v18);
if ( (v25 & 1) != 0 )
v19 = v26;
else
v19 = (int)(unsigned __int8)v25 >> 1;
v3 += v19;
}
std::string::~string((int)&v25);
std::string::~string((int)&v22);
return a1;
}