//
// GameLevelManager::onGetLevelSaveDataCompleted from 0x70b4dc to 0x70b880 (932 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x7320a4
// > ??> @ 0x8f880
//
// 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::onGetLevelSaveDataCompleted(
GameLevelManager *a1,
const void **a2,
const char **a3)
{
_DWORD *v5; // x27
unsigned __int64 v6; // x24
unsigned __int64 v7; // x20
size_t v8; // x2
int v9; // w19
__int64 v10; // x20
__int64 *v11; // x0
_QWORD *v12; // x19
unsigned __int64 v13; // x4
int v14; // w3
cocos2d::CCArray *v15; // x21
unsigned int v16; // w19
cocos2d::CCString *v17; // x0
int v18; // w27
cocos2d::CCString *v19; // x0
int v20; // w20
char *v21; // x0
void *v22; // x0
unsigned int *v23; // x20
int v24; // w1
__int64 SavedLevel; // x0
GJGameLevel *v27; // x27
int v28; // w0
_BOOL4 v29; // w28
int v30; // w0
int v31; // w20
unsigned int *v32; // x27
int v33; // w1
unsigned int *v34; // x1
int v35; // w2
__int64 v36; // [xsp+78h] [xbp+78h] BYREF
void *v37; // [xsp+80h] [xbp+80h] BYREF
GameLevelManager::removeDLFromActive(a1, *a3);
sub_D153B8((int)&v37, "-1");
v5 = v37;
v6 = *((_QWORD *)v37 - 3);
v7 = *((_QWORD *)*a2 - 3);
if ( v6 > v7 )
v8 = *((_QWORD *)*a2 - 3);
else
v8 = *((_QWORD *)v37 - 3);
v9 = memcmp(*a2, v37, v8);
if ( v9 || (v9 = 0x7FFFFFFF, v10 = v7 - v6, v10 > 0x7FFFFFFF) )
{
v11 = (__int64 *)(v5 - 6);
if ( v5 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v11 = (__int64 *)(v5 - 6);
if ( v10 >= (__int64)0xFFFFFFFF80000000LL )
v9 = v10;
else
v9 = 0x80000000;
if ( v11 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v32 = v5 - 2;
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *(v5 - 2);
*(v5 - 2) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v11);
LABEL_7:
if ( v9 )
{
v12 = *a2;
if ( strlen((const char *)*a2) > 0x28 )
{
v13 = *(v12 - 3);
if ( v13 <= 0x13 )
sub_D13C5C("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", 0x14u, *(v12 - 3));
sub_D14F84(&v36, a2, 20, v13 - 40);
cocos2d::ZipUtils::decompressString((cocos2d::ZipUtils *)&v36, nullptr, 11, v14);
v15 = sub_6F004C(&v37, &byte_F804F8);
v16 = 0;
while ( (unsigned int)cocos2d::CCArray::count(v15) > v16 + 1 )
{
v17 = cocos2d::CCArray::stringAtIndex(v15, v16);
v18 = cocos2d::CCString::intValue(v17);
v19 = cocos2d::CCArray::stringAtIndex(v15, v16 + 1);
v20 = cocos2d::CCString::intValue(v19);
if ( (unsigned int)(v20 - 1) <= 9
&& (SavedLevel = GameLevelManager::getSavedLevel(a1, v18), (v27 = (GJGameLevel *)SavedLevel) != nullptr) )
{
*(_DWORD *)(SavedLevel + 696) = v20;
v28 = rand();
v29 = v20 == 10;
v27->m_demon.value = v29;
v30 = (int)(float)((float)((float)v28 * 4.6566e-10) * 1000.0);
v27->m_stars.seed = v30;
v27->m_stars.random = v20 + v30;
v31 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v27->m_demon.seed = v31;
v27->m_demon.random = v29 + v31;
GameLevelManager::verifyLevelState(a1, v27);
GameLevelManager::updateLevelRewards(a1, v27);
v16 += 2;
}
else
{
v16 += 2;
}
}
v21 = (char *)v37 - 24;
if ( (char *)v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v34 = (unsigned int *)((char *)v37 - 8);
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
}
else
{
v35 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v35 - 1;
}
if ( v35 <= 0 )
operator delete(v21);
}
v22 = (void *)(v36 - 24);
if ( (__int64 *)(v36 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v36 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(_DWORD *)(v36 - 8);
*(_DWORD *)(v36 - 8) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v22);
}
}
}
return _stack_chk_guard;
}