//
// AutoBackupPopup::onRestore from 0x1400cb880 to 0x1400cbe46 (1478 bytes)
//
// 2 xrefs:
// > AutoBackupPopup::buildRows @ 0x1400cb251
// > ??> @ 0x140914000
//
// This function is hookable on this platform (idp: pc, 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:26:23 +0000
//
// Hidden C++ exception states: #wind=11
void __fastcall AutoBackupPopup::onRestore(__int64 a1, __int64 a2)
{
int v3; // esi
int v4; // eax
__int64 v5; // r9
_QWORD *v6; // rdi
char *v7; // rbx
__int64 v8; // rcx
const char *v9; // r14
const char *v10; // r13
int v11; // r15d
const char *v12; // rcx
cocos2d::CCString *v13; // rax
cocos2d::CCString *v14; // rbx
const char *CString; // rax
__int64 v16; // rcx
const char *v17; // rax
size_t v18; // r8
void *v19; // rcx
__int64 v20; // rax
__int64 v21; // rbx
bool v22; // di
__int64 v23; // rbx
__int64 v24; // rax
cocos2d::CCObject *v25; // rbx
_QWORD *v26; // rax
__int64 v27; // rdx
void **v28; // rdx
int v29; // eax
float v30; // xmm0_4
struct cocos2d::CCObject *v31; // rdx
struct cocos2d::CCObject *v32; // rbx
cocos2d::CCNotificationCenter *v33; // rax
char *v34; // rbx
char *v35; // rdi
char *v36; // rax
int v37; // [rsp+50h] [rbp-B0h]
__int64 v38; // [rsp+58h] [rbp-A8h]
void *Block[2]; // [rsp+60h] [rbp-A0h] BYREF
char *v40; // [rsp+70h] [rbp-90h]
void **v41; // [rsp+78h] [rbp-88h]
__int128 *v42; // [rsp+80h] [rbp-80h]
void *Src[4]; // [rsp+88h] [rbp-78h] BYREF
__int128 v44; // [rsp+A8h] [rbp-58h] BYREF
__int64 v45; // [rsp+B8h] [rbp-48h]
unsigned __int64 v46; // [rsp+C0h] [rbp-40h]
_BYTE v47[16]; // [rsp+C8h] [rbp-38h] BYREF
__int64 v48; // [rsp+D8h] [rbp-28h]
_BYTE v49[32]; // [rsp+E8h] [rbp-18h] BYREF
_QWORD v50[4]; // [rsp+108h] [rbp+8h] BYREF
v3 = 0;
v4 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2);
if ( v4 < 0 )
return;
v5 = *(_QWORD *)(a1 + 856);
if ( v4 >= (int)((*(_QWORD *)(a1 + 864) - v5) / 168) )
return;
v6 = sub_140075860(v50, (_QWORD *)(a1 + 800), (_QWORD *)(v5 + 168LL * v4));
Block[0] = sub_14003D460(0x20u);
Block[1] = Block[0];
v7 = (char *)Block[0] + 32;
v40 = (char *)Block[0] + 32;
*(void **)&v44 = Block[0];
*((void **)&v44 + 1) = Block[0];
v45 = (__int64)Block;
sub_14003F4F0((__int64)Block[0], (__int64)v6);
Block[1] = v7;
sub_14003D310((__int64)v50);
v37 = *(_DWORD *)(a1 + 792);
v38 = LocalLevelManager::sharedState(v8);
v9 = (const char *)Block[0];
v10 = (const char *)Block[1];
v11 = 0;
if ( Block[0] == Block[1] )
goto LABEL_28;
do
{
v12 = v9;
if ( *((_QWORD *)v9 + 3) > 0xFu )
v12 = *(const char **)v9;
v13 = cocos2d::CCString::createWithContentsOfFile(v12);
v14 = v13;
if ( !v13 )
goto LABEL_24;
CString = cocos2d::CCString::getCString(v13);
v16 = -1;
do
++v16;
while ( CString[v16] );
if ( !v16 )
goto LABEL_24;
v17 = cocos2d::CCString::getCString(v14);
v44 = 0;
v45 = 0;
v46 = 0;
v18 = -1;
do
++v18;
while ( v17[v18] );
sub_14003D230(&v44, v17, v18);
cocos2d::ZipUtils::decompressString(v49, &v44, 0, 11);
if ( v46 > 0xF )
{
v19 = (void *)v44;
if ( v46 + 1 >= 0x1000 )
{
v19 = *(void **)(v44 - 8);
if ( (unsigned __int64)(v44 - (_QWORD)v19 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v19);
}
v45 = 0;
v46 = 15;
LOBYTE(v44) = 0;
v20 = GJGameLevel::createFromFullSaveString(v49);
v21 = v20;
v22 = true;
if ( v20 )
{
sub_14003F4F0((__int64)v47, v20 + 408);
v3 |= 3u;
if ( v48 )
v22 = false;
}
if ( (v3 & 1) != 0 )
{
v3 &= ~1u;
sub_14003D310((__int64)v47);
}
if ( v22 )
{
sub_14003D310((__int64)v49);
LABEL_24:
v23 = v38;
goto LABEL_25;
}
v26 = (_QWORD *)(v21 + 1592);
*(_QWORD *)(v21 + 1608) = 0;
if ( *(_QWORD *)(v21 + 1616) > 0xFu )
v26 = (_QWORD *)*v26;
*(_BYTE *)v26 = 0;
*(_DWORD *)(v21 + 1220) = 2;
v27 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v42 = (__int128 *)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v42);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v27 = qword_14090BFD0;
}
sub_14003F4F0((__int64)Src, v27 + 656);
v3 |= 4u;
v41 = Src;
if ( (void **)(v21 + 440) != Src )
{
v28 = Src;
if ( Src[3] > (void *)0xF )
v28 = (void **)Src[0];
sub_1400405A0((void **)(v21 + 440), v28, (size_t)Src[2]);
}
sub_14003D310((__int64)Src);
*(_DWORD *)(v21 + 336) = 0;
v29 = (int)(float)((float)((float)rand() / 32767.0) * 1000.0);
*(_DWORD *)(v21 + 332) = v29;
*(_DWORD *)(v21 + 328) = v29;
*(_WORD *)(v21 + 856) = 0;
*(_DWORD *)(v21 + 860) = 1;
v30 = (float)((float)rand() / 32767.0) * 1000.0;
*(_DWORD *)(v21 + 852) = (int)v30;
*(_DWORD *)(v21 + 848) = (int)v30;
GJGameLevel::unverifyCoins(v21);
*(_DWORD *)(v21 + 988) = v37;
v31 = (struct cocos2d::CCObject *)v21;
v23 = v38;
cocos2d::CCArray::insertObject(*(cocos2d::CCArray **)(v38 + 368), v31, 0);
++v11;
sub_14003D310((__int64)v49);
LABEL_25:
v9 += 32;
}
while ( v9 != v10 );
if ( v11 <= 0 )
goto LABEL_29;
LocalLevelManager::updateLevelOrder(v23);
LABEL_28:
if ( v11 > 0 )
{
v32 = cocos2d::CCInteger::create(v11);
v33 = (cocos2d::CCNotificationCenter *)cocos2d::CCNotificationCenter::sharedNotificationCenter();
cocos2d::CCNotificationCenter::postNotification(v33, "LevelsImportedNotification", v32);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 1096LL))(a1, 0);
}
else
{
LABEL_29:
v44 = 0;
v45 = 0;
v46 = 0;
*(_QWORD *)&v44 = sub_14003D460(0x20u);
v45 = 27;
v46 = 31;
strcpy((char *)v44, "Could not read this backup.");
v42 = &v44;
v24 = sub_14003F4F0((__int64)v47, (__int64)&v44);
v25 = FLAlertLayer::create(0, (int)"Error", v24, (__int64)"OK", 0, 1132068864, 0, 0, 1065353216);
sub_14003D310((__int64)&v44);
(*(void (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)v25 + 1064LL))(v25);
}
v34 = (char *)Block[0];
if ( Block[0] )
{
v35 = (char *)Block[1];
if ( Block[0] != Block[1] )
{
do
{
sub_14003D310((__int64)v34);
v34 += 32;
}
while ( v34 != v35 );
v34 = (char *)Block[0];
}
v36 = v34;
if ( ((v40 - v34) & 0xFFFFFFFFFFFFFFE0uLL) >= 0x1000 )
{
v34 = *((char **)v34 - 1);
if ( (unsigned __int64)(v36 - v34 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v34);
}
}