//
// LocalLevelManager::tryRecoverAutoSaves from 0x10025fb84 to 0x1002603a4 (2080 bytes)
//
// 1 xrefs:
// > AppDelegate::applicationDidFinishLaunching @ 0x100307010
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 11:01:38 +0000
//
__int64 __fastcall LocalLevelManager::tryRecoverAutoSaves(__int64 a1)
{
__int64 **v2; // x20
void **v3; // x24
_BOOL4 v4; // w0
_BOOL4 v5; // w23
std::error_code *v6; // x1
const std::__fs::filesystem::path *p_str; // x0
_BOOL4 v8; // w0
_BOOL4 v9; // w23
void **v10; // x20
void **v11; // x28
char v12; // w21
std::string::size_type v13; // x8
char *v14; // x9
char *v15; // x9
std::string::size_type v16; // x2
int v17; // w10
std::string::size_type size; // x8
void *v19; // x0
__int64 v20; // x0
std::error_code *v21; // x1
__int64 v22; // x24
char *CString; // x0
std::error_code *v24; // x1
char *v25; // x24
__int64 i; // x25
__int64 v27; // x26
bool v28; // w27
const std::__fs::filesystem::path *v29; // x0
_OWORD *v30; // x25
std::string::size_type v31; // x21
void *v32; // x0
int v33; // w8
__int128 v34; // q0
signed __int64 v35; // x8
std::string *v36; // x21
char *v37; // x24
std::string *v38; // x0
char *v39; // x0
unsigned __int64 v41; // x8
std::string *v42; // x0
__int128 v43; // q0
size_t v44; // x24
__int64 v45; // x0
std::string *v46; // x25
void **v47; // x1
int j; // w21
__int64 v49; // x0
std::error_code *v50; // x2
const char *v51; // x8
__int64 v52; // x0
const std::string::value_type *v53; // x0
const std::__fs::filesystem::path *v54; // x0
const std::__fs::filesystem::path *p_p; // x1
int v56; // w0
_BOOL4 v57; // w27
const std::__fs::filesystem::path *v58; // x0
std::string v60; // [xsp+10h] [xbp-1A0h] BYREF
std::string v61; // [xsp+28h] [xbp-188h] BYREF
std::string v62; // [xsp+40h] [xbp-170h] BYREF
std::string v63; // [xsp+58h] [xbp-158h] BYREF
void *__dst[2]; // [xsp+70h] [xbp-140h] BYREF
signed __int64 v65; // [xsp+80h] [xbp-130h]
std::string __p; // [xsp+90h] [xbp-120h] BYREF
void *v67[2]; // [xsp+A8h] [xbp-108h] BYREF
char v68; // [xsp+BFh] [xbp-F1h]
std::allocator v69[8]; // [xsp+C0h] [xbp-F0h] BYREF
char v70; // [xsp+D7h] [xbp-D9h]
std::string __a; // [xsp+D8h] [xbp-D8h] BYREF
std::string __str; // [xsp+F0h] [xbp-C0h] BYREF
void **v73; // [xsp+108h] [xbp-A8h] BYREF
void **v74; // [xsp+110h] [xbp-A0h]
__int64 v75; // [xsp+118h] [xbp-98h]
void **v76; // [xsp+120h] [xbp-90h] BYREF
void **v77; // [xsp+128h] [xbp-88h]
__int64 v78; // [xsp+130h] [xbp-80h]
const void *v79[2]; // [xsp+138h] [xbp-78h] BYREF
char v80; // [xsp+14Fh] [xbp-61h]
std::allocator v81; // [xsp+157h] [xbp-59h] BYREF
sub_10004EB10(a1);
v76 = nullptr;
v77 = nullptr;
v78 = 0;
sub_100009900(&v73, "autosave_");
sub_10004E838((__int64)v79, &v76, (const void **)&v73, 0);
if ( SHIBYTE(v75) < 0 )
operator delete(v73);
v73 = nullptr;
v74 = nullptr;
v75 = 0;
v2 = (__int64 **)v76;
v3 = v77;
if ( v76 == v77 )
goto LABEL_150;
do
{
sub_100009900(&__str, ".gdlvl.tmp");
v4 = sub_10004B4E0(v2, &__str);
v5 = v4;
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__str.__r_.__value_.__l.__data_);
if ( v5 )
{
LABEL_6:
sub_10011E060(v79, (const void **)v2, (__int64)&__str);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_str = (const std::__fs::filesystem::path *)&__str;
else
p_str = (const std::__fs::filesystem::path *)__str.__r_.__value_.__r.__words[0];
remove(p_str, v6);
goto LABEL_16;
}
}
else if ( v4 )
{
goto LABEL_6;
}
sub_100009900(&__str, ".gdlvl");
v8 = sub_10004B4E0(v2, &__str);
v9 = v8;
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__str.__r_.__value_.__l.__data_);
if ( !v9 )
goto LABEL_18;
}
else if ( !v8 )
{
goto LABEL_18;
}
sub_10011E060(v79, (const void **)v2, (__int64)&__str);
sub_10006D9F8((const void **)&v73, (__int128 *)&__str);
LABEL_16:
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
LABEL_18:
v2 += 3;
}
while ( v2 != (__int64 **)v3 );
v10 = v73;
v11 = v74;
if ( v73 != v74 )
{
v12 = 0;
while ( 1 )
{
v13 = *((char *)v10 + 23);
if ( (v13 & 0x8000000000000000LL) != 0 )
{
v14 = (char *)*v10;
v13 = (std::string::size_type)v10[1];
}
else
{
v14 = (char *)v10;
}
v15 = v14 - 1;
do
{
v16 = v13;
if ( !v13 )
break;
v17 = (unsigned __int8)v15[v13];
if ( v17 == 92 )
break;
--v13;
}
while ( v17 != 47 );
std::string::basic_string(
&__str,
(const std::string *)v10,
v16,
0xFFFFFFFFFFFFFFFFLL,
(std::allocator *)&__a);
size = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = __str.__r_.__value_.__l.__size_;
std::string::basic_string(&__a, &__str, 9u, size - 15, v69);
v19 = v10;
if ( *((char *)v10 + 23) < 0 )
v19 = *v10;
v20 = cocos2d::CCString::createWithContentsOfFile(v19);
v22 = v20;
if ( v20 && *(_BYTE *)cocos2d::CCString::getCString(v20) )
{
CString = (char *)cocos2d::CCString::getCString(v22);
sub_100009900(v69, CString);
cocos2d::ZipUtils::decompressString(v67, v69, 0, 11);
v25 = (char *)sub_1000D47B4((__int64)v67);
if ( v25 )
{
for ( i = 0; ; i = (unsigned int)(i + 1) )
{
if ( (unsigned int)i >= (unsigned int)sub_1002E757C(*(_QWORD *)(a1 + 360)) )
goto LABEL_47;
v27 = sub_1002E75A0(*(_QWORD *)(a1 + 360), i);
sub_1000A65B0(v27, (__int64)&__p);
v28 = sub_1000045BC(&__p, &__a);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
if ( v28 )
break;
}
if ( !v27 )
{
LABEL_47:
v30 = v25 + 344;
if ( v25[367] < 0 )
{
sub_1000097D0(&__p, *((void **)v25 + 43), *((_QWORD *)v25 + 44));
}
else
{
*(_OWORD *)&__p.__r_.__value_.__l.__data_ = *v30;
__p.__r_.__value_.__r.__words[2] = *((_QWORD *)v25 + 45);
}
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
{
v31 = __p.__r_.__value_.__l.__size_;
operator delete(__p.__r_.__value_.__l.__data_);
if ( !v31 )
goto LABEL_55;
LABEL_52:
if ( v25[367] < 0 )
{
sub_1000097D0(&__p, *((void **)v25 + 43), *((_QWORD *)v25 + 44));
}
else
{
*(_OWORD *)&__p.__r_.__value_.__l.__data_ = *v30;
__p.__r_.__value_.__r.__words[2] = *((_QWORD *)v25 + 45);
}
sub_10026053C((__int64 *)&v61, &__p);
std::string::operator=((std::string *)(v25 + 344), &v61);
if ( SHIBYTE(v61.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v61.__r_.__value_.__l.__data_);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
{
v32 = (void *)__p.__r_.__value_.__r.__words[0];
LABEL_62:
operator delete(v32);
}
}
else
{
if ( *((_BYTE *)&__p.__r_.__value_.__s + 23) )
goto LABEL_52;
LABEL_55:
sub_100009900(&v62, "Recovered Autosave");
std::string::operator=((std::string *)(v25 + 344), &v62);
if ( SHIBYTE(v62.__r_.__value_.__r.__words[2]) < 0 )
{
v32 = (void *)v62.__r_.__value_.__r.__words[0];
goto LABEL_62;
}
}
i = 0;
goto LABEL_64;
}
if ( *(char *)(v27 + 415) < 0 )
sub_1000097D0(&__p, *(void **)(v27 + 392), *(_QWORD *)(v27 + 400));
else
__p = *(std::string *)(v27 + 392);
if ( v25[415] < 0 )
{
sub_1000097D0(__dst, *((void **)v25 + 49), *((_QWORD *)v25 + 50));
}
else
{
*(_OWORD *)__dst = *(_OWORD *)(v25 + 392);
v65 = *((_QWORD *)v25 + 51);
}
v57 = sub_1000045BC(&__p, __dst);
if ( SHIBYTE(v65) < 0 )
operator delete(__dst[0]);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__p.__r_.__value_.__l.__data_);
if ( v57 )
goto LABEL_129;
}
else if ( v57 )
{
goto LABEL_129;
}
if ( *(char *)(v27 + 367) < 0 )
sub_1000097D0(&__p, *(void **)(v27 + 344), *(_QWORD *)(v27 + 352));
else
__p = *(std::string *)(v27 + 344);
sub_10026053C((__int64 *)&v63, &__p);
std::string::operator=((std::string *)(v25 + 344), &v63);
if ( SHIBYTE(v63.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v63.__r_.__value_.__l.__data_);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
LABEL_64:
sub_1002E7640(*(_QWORD *)(a1 + 360), v25, i);
*((_DWORD *)v25 + 285) = 2;
if ( v25[1463] < 0 )
{
**((_BYTE **)v25 + 180) = 0;
*((_QWORD *)v25 + 181) = 0;
}
else
{
v25[1440] = 0;
v25[1463] = 0;
}
v25[784] = 0;
v33 = (int)(float)(vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0);
*((_DWORD *)v25 + 195) = v33;
*((_DWORD *)v25 + 194) = v33;
sub_1000CEB6C(v25);
v25[786] = 1;
if ( *((char *)v10 + 23) < 0 )
{
sub_1000097D0(&__p, *v10, (unsigned __int64)v10[1]);
}
else
{
v34 = *(_OWORD *)v10;
__p.__r_.__value_.__r.__words[2] = (std::string::size_type)v10[2];
*(_OWORD *)&__p.__r_.__value_.__l.__data_ = v34;
}
v35 = SHIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v36 = &__str;
else
v36 = (std::string *)__str.__r_.__value_.__r.__words[0];
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v35 = __str.__r_.__value_.__l.__size_;
if ( v35 >= 10 )
{
v37 = (char *)v36 + v35;
v38 = v36;
do
{
v39 = (char *)memchr(v38, 95, v35 - 9);
if ( !v39 )
break;
if ( *(_QWORD *)v39 == 0x7265766F6365725FLL && *((_WORD *)v39 + 4) == 25701 )
{
if ( v39 != v37 && v39 - (char *)v36 != -1 )
goto LABEL_118;
break;
}
v38 = (std::string *)(v39 + 1);
v35 = v37 - (char *)v38;
}
while ( v37 - (char *)v38 >= 10 );
}
v41 = *((char *)v10 + 23);
if ( (v41 & 0x8000000000000000LL) != 0 )
v41 = (unsigned __int64)v10[1];
std::string::basic_string(&v60, (const std::string *)v10, 0, v41 - 6, &v81);
v42 = std::string::append(&v60, "_recovered");
v43 = *(_OWORD *)&v42->__r_.__value_.__l.__data_;
v65 = v42->__r_.__value_.__r.__words[2];
*(_OWORD *)__dst = v43;
v42->__r_.__value_.__l.__size_ = 0;
v42->__r_.__value_.__r.__words[2] = 0;
v42->__r_.__value_.__r.__words[0] = 0;
if ( SHIBYTE(v60.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v60.__r_.__value_.__l.__data_);
if ( v65 >= 0 )
v44 = HIBYTE(v65);
else
v44 = (size_t)__dst[1];
v45 = sub_100026068((__int64)&v60, v44 + 6);
if ( (v60.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v46 = &v60;
else
v46 = (std::string *)v60.__r_.__value_.__r.__words[0];
if ( v44 )
{
if ( v65 >= 0 )
v47 = __dst;
else
v47 = (void **)__dst[0];
v45 = (__int64)memmove(v46, v47, v44);
}
strcpy((char *)v46 + v44, ".gdlvl");
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
__p = v60;
for ( j = 2; j != 100; ++j )
{
v49 = cocos2d::CCFileUtils::sharedFileUtils(v45);
if ( ((*(__int64 (__fastcall **)(__int64, std::string *))(*(_QWORD *)v49 + 160LL))(v49, &__p) & 1) == 0 )
break;
v51 = v65 >= 0 ? (const char *)__dst : (const char *)__dst[0];
v52 = sub_1003065B0("%s%i.gdlvl", v51, j);
v53 = (const std::string::value_type *)cocos2d::CCString::getCString(v52);
v45 = (__int64)std::string::assign(&__p, v53);
}
v54 = (const std::__fs::filesystem::path *)v10;
if ( *((char *)v10 + 23) < 0 )
v54 = (const std::__fs::filesystem::path *)*v10;
if ( (__p.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_p = (const std::__fs::filesystem::path *)&__p;
else
p_p = (const std::__fs::filesystem::path *)__p.__r_.__value_.__r.__words[0];
rename(v54, p_p, v50);
if ( v56 )
std::string::operator=(&__p, (const std::string *)v10);
if ( SHIBYTE(v65) < 0 )
operator delete(__dst[0]);
LABEL_118:
sub_100017C70(a1 + 416);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
v12 = 1;
}
else
{
LABEL_129:
v58 = (const std::__fs::filesystem::path *)v10;
if ( *((char *)v10 + 23) < 0 )
v58 = (const std::__fs::filesystem::path *)*v10;
remove(v58, v24);
}
if ( v68 < 0 )
operator delete(v67[0]);
if ( v70 < 0 )
operator delete(*(void **)&v69[0].std::__non_trivial_if);
}
else
{
v29 = (const std::__fs::filesystem::path *)v10;
if ( *((char *)v10 + 23) < 0 )
v29 = (const std::__fs::filesystem::path *)*v10;
remove(v29, v21);
}
if ( SHIBYTE(__a.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__a.__r_.__value_.__l.__data_);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
v10 += 3;
if ( v10 == v11 )
goto LABEL_151;
}
}
LABEL_150:
v12 = 0;
LABEL_151:
__str.__r_.__value_.__r.__words[0] = (std::string::size_type)&v73;
sub_100018250((void ***)&__str);
v73 = (void **)&v76;
sub_100018250(&v73);
if ( v80 < 0 )
operator delete((void *)v79[0]);
return v12 & 1;
}