//
// GameLevelManager::clearDeathDataInstances from 0x8135f4 to 0x8138f0 (764 bytes)
//
// 3 xrefs:
// > DeathMarkerSettingsPopup::FLAlert_Clicked @ 0xca5f6c
// > DeathTrackerOptionsPopup::FLAlert_Clicked @ 0xca93fc
// > ??> @ 0xb3f50
//
// 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 12:54:53 +0000
//
__int64 __fastcall GameLevelManager::clearDeathDataInstances(
GameLevelManager *this,
GJGameLevel *a2,
unsigned __int8 a3)
{
int v4; // w21
int v5; // w20
__int64 SavedLevel; // x0
__int64 *v7; // x1
__int64 v8; // x25
cocos2d::CCString *v9; // x0
size_t v10; // x0
__int64 v11; // x0
__int64 *v12; // x1
__int64 *v13; // x1
__int64 v14; // x0
__int64 v15; // x0
__int64 v16; // x19
__int64 *v17; // x3
GJGameLevel *v18; // x0
__int64 *v20; // x0
__int64 v21; // x20
unsigned __int64 v22; // x19
__int64 v23; // x0
char *CString; // [xsp+50h] [xbp+50h]
GJGameLevel *v25; // [xsp+58h] [xbp+58h] BYREF
__int64 v26; // [xsp+60h] [xbp+60h] BYREF
__int64 v27; // [xsp+68h] [xbp+68h] BYREF
GJGameLevel *v28; // [xsp+70h] [xbp+70h] BYREF
void *v29; // [xsp+78h] [xbp+78h] BYREF
__int64 *v30; // [xsp+80h] [xbp+80h]
__int64 *v31; // [xsp+88h] [xbp+88h]
__int64 v32[2]; // [xsp+90h] [xbp+90h] BYREF
void *v33; // [xsp+A0h] [xbp+A0h]
v25 = a2;
v4 = a3;
if ( !a2 )
return _stack_chk_guard;
v29 = nullptr;
v30 = nullptr;
v31 = nullptr;
std::vector::__push_back_slow_path((__int64)&v29, &v25);
v5 = *((_DWORD *)v25 + 82) - *((_DWORD *)v25 + 83);
if ( v5 > 0 )
{
SavedLevel = GameLevelManager::getSavedLevel(this, (const char *)(unsigned int)v5);
v26 = SavedLevel;
if ( SavedLevel && (GJGameLevel *)SavedLevel != v25 )
{
v7 = v30;
if ( v30 == v31 )
{
std::vector::__push_back_slow_path((__int64)&v29, &v26);
}
else
{
if ( v30 )
{
*v30 = SavedLevel;
v7 = v30;
}
v30 = v7 + 1;
}
}
v8 = *((_QWORD *)this + 117);
v9 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)v5);
CString = (char *)cocos2d::CCString::getCString(v9);
v32[0] = 0;
v32[1] = 0;
v33 = nullptr;
v10 = strlen(CString);
std::string::__init(v32, CString, v10);
v11 = cocos2d::CCDictionary::objectForKey(v8, v32);
v27 = v11;
if ( (v32[0] & 1) != 0 )
{
operator delete(v33);
v11 = v27;
}
if ( v11 && v25 != (GJGameLevel *)v11 )
{
v12 = v30;
if ( v30 != v31 )
{
if ( v30 )
{
*v30 = v11;
v12 = v30;
}
v13 = v12 + 1;
v30 = v13;
goto LABEL_17;
}
std::vector::__push_back_slow_path((__int64)&v29, &v27);
}
v13 = v30;
LABEL_17:
v14 = *((_QWORD *)this + 106);
if ( v14 )
{
v15 = *(_QWORD *)(v14 + 56);
if ( v15 )
{
v16 = *(_QWORD *)(v15 + 288);
v17 = v13;
while ( 1 )
{
v18 = *(GJGameLevel **)(v15 + 264);
v28 = v18;
if ( v18 && v18 != v25 && v5 == *((_DWORD *)v18 + 82) - *((_DWORD *)v18 + 83) )
{
if ( v31 == v13 )
{
std::vector::__push_back_slow_path((__int64)&v29, &v28);
v13 = v30;
}
else
{
if ( v13 )
{
*v13 = (__int64)v18;
v17 = v30;
}
v13 = v17 + 1;
v30 = v17 + 1;
}
}
if ( !v16 )
break;
v15 = v16;
v17 = v13;
v16 = *(_QWORD *)(v16 + 288);
}
}
}
goto LABEL_31;
}
v13 = v30;
LABEL_31:
v20 = (__int64 *)v29;
if ( ((char *)v13 - (_BYTE *)v29) >> 3 )
{
v21 = 0;
v22 = 0;
do
{
v23 = v20[v21];
if ( v4 )
GJGameLevel::clearDeathMarkerData(v23);
else
GJGameLevel::clearDeathTrackerData(v23);
v20 = (__int64 *)v29;
++v22;
++v21;
}
while ( v22 < ((char *)v30 - (_BYTE *)v29) >> 3 );
}
if ( v20 )
{
if ( v30 != v20 )
v30 += ~((unsigned __int64)((char *)(v30 - 1) - (char *)v20) >> 3);
operator delete(v20);
}
return _stack_chk_guard;
}