//
// GameLevelManager::onRestoreItemsCompleted from 0x6ff578 to 0x6ff8a4 (812 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732424
// > ??> @ 0x4eb88
//
// 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
//
__int64 __fastcall GameLevelManager::onRestoreItemsCompleted(GameLevelManager *a1, const void **a2)
{
_DWORD *v3; // x26
unsigned __int64 v4; // x27
unsigned __int64 v5; // x20
size_t v6; // x2
int v7; // w19
__int64 v8; // x20
__int64 *v9; // x0
FLAlertLayer *v10; // x19
char *v11; // x0
FLAlertLayer *v13; // x19
char *v14; // x0
char *v15; // x0
unsigned int *v16; // x19
int v17; // w1
unsigned int *v18; // x26
int v19; // w1
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x1
int v23; // w2
void *v24; // [xsp+70h] [xbp+70h] BYREF
GameLevelManager::removeDLFromActive(a1, "restoreKey");
sub_D153B8((int)&v24, "-1");
v3 = v24;
v4 = *((_QWORD *)v24 - 3);
v5 = *((_QWORD *)*a2 - 3);
if ( v4 > v5 )
v6 = *((_QWORD *)*a2 - 3);
else
v6 = *((_QWORD *)v24 - 3);
v7 = memcmp(*a2, v24, v6);
if ( v7 || (v7 = 0x7FFFFFFF, v8 = v5 - v4, v8 > 0x7FFFFFFF) )
{
v9 = (__int64 *)(v3 - 6);
if ( v3 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v9 = (__int64 *)(v3 - 6);
if ( v8 >= (__int64)0xFFFFFFFF80000000LL )
v7 = v8;
else
v7 = 0x80000000;
if ( v9 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v18 = v3 - 2;
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(v3 - 2);
*(v3 - 2) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v9);
LABEL_7:
if ( v7 )
{
sub_D153B8((int)&v24, "Your data has been restored.");
v13 = FLAlertLayer::create(0, (__int64)"Data restored", (__int64)&v24);
v14 = (char *)v24 - 24;
if ( (char *)v24 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)((char *)v24 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *((_DWORD *)v24 - 2);
*((_DWORD *)v24 - 2) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v14);
}
v13->show(v13);
sub_D18D28(&v24, a2);
GameLevelManager::parseRestoreData();
v15 = (char *)v24 - 24;
if ( (char *)v24 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v24 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v24 - 2);
*((_DWORD *)v24 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v15);
}
}
else
{
sub_D153B8((int)&v24, "No restore data found.");
v10 = FLAlertLayer::create(0, (__int64)"Error", (__int64)&v24);
v11 = (char *)v24 - 24;
if ( (char *)v24 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)((char *)v24 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v24 - 2);
*((_DWORD *)v24 - 2) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v11);
}
v10->show(v10);
}
return _stack_chk_guard;
}