//
// GameLevelManager::onGetGauntletsCompleted from 0x70ddb0 to 0x70e4a8 (1784 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x731fc4
// > ??> @ 0x35fb8
//
// 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::onGetGauntletsCompleted(GameLevelManager *a1, const void **a2, const char **a3)
{
_DWORD *v5; // x22
unsigned __int64 v6; // x24
unsigned __int64 v7; // x21
size_t v8; // x2
int v9; // w19
__int64 v10; // x21
__int64 *v11; // x0
LevelManagerDelegate *v12; // x0
cocos2d::CCArray *v14; // x19
char *v15; // x0
cocos2d::CCString *v16; // x0
char *CString; // x0
cocos2d::CCString *v18; // x0
char *v19; // x0
cocos2d::CCArray *MapPacks; // x20
char *v21; // x0
unsigned int v22; // w19
__int64 v23; // x22
cocos2d::CCString *v24; // x0
size_t v25; // x0
void *v26; // x0
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x22
int v30; // w1
cocos2d::CCString *v31; // x0
size_t v32; // x0
char *v33; // x21
unsigned int v34; // w0
unsigned __int8 *v35; // x3
char *v36; // x2
unsigned int i; // w19
GJMapPack *v38; // x0
char *v39; // x0
LevelManagerDelegate *m_levelManagerDelegate; // x0
char *v41; // x0
void *v42; // x0
void *v43; // x0
unsigned int *v44; // x19
int v45; // w1
unsigned int *v46; // x1
int v47; // w2
unsigned int *v48; // x1
int v49; // w2
unsigned int *v50; // x1
int v51; // w2
unsigned int *v52; // x1
int v53; // w2
unsigned int *v54; // x1
int v55; // w2
char *v56; // [xsp+70h] [xbp+70h]
const char *v57; // [xsp+78h] [xbp+78h]
const char *v58; // [xsp+78h] [xbp+78h]
__int64 v59; // [xsp+90h] [xbp+90h] BYREF
__int64 v60; // [xsp+98h] [xbp+98h] BYREF
char *v61; // [xsp+A0h] [xbp+A0h] BYREF
char *v62; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v63; // [xsp+B0h] [xbp+B0h] BYREF
void *v64; // [xsp+B8h] [xbp+B8h] BYREF
unsigned __int8 v65[24]; // [xsp+C0h] [xbp+C0h] BYREF
unsigned __int8 v66[48]; // [xsp+D8h] [xbp+D8h] BYREF
v56 = (char *)*a3;
GameLevelManager::removeDLFromActive(a1, *a3);
sub_D153B8((int)&v64, "-1");
v5 = v64;
v6 = *((_QWORD *)v64 - 3);
v7 = *((_QWORD *)*a2 - 3);
if ( v6 > v7 )
v8 = *((_QWORD *)*a2 - 3);
else
v8 = *((_QWORD *)v64 - 3);
v9 = memcmp(*a2, v64, 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 )
{
v29 = v5 - 2;
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *(v5 - 2);
*(v5 - 2) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v11);
LABEL_7:
if ( !v9 )
goto LABEL_8;
sub_D153B8((int)&v64, (char *)*a2);
v14 = sub_6F004C(&v64, "#");
v15 = (char *)v64 - 24;
if ( (char *)v64 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v46 = (unsigned int *)((char *)v64 - 8);
do
v47 = __ldaxr(v46);
while ( __stlxr(v47 - 1, v46) );
}
else
{
v47 = *((_DWORD *)v64 - 2);
*((_DWORD *)v64 - 2) = v47 - 1;
}
if ( v47 <= 0 )
operator delete(v15);
}
if ( (unsigned int)cocos2d::CCArray::count(v14) > 1 )
{
v16 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v14, 0);
CString = (char *)cocos2d::CCString::getCString(v16);
sub_D153B8((int)&v59, CString);
v18 = cocos2d::CCArray::stringAtIndex(v14, 1u);
v19 = (char *)cocos2d::CCString::getCString(v18);
sub_D153B8((int)&v60, v19);
sub_D18D28(&v61, &v59);
MapPacks = GameLevelManager::createAndGetMapPacks((__int64)a1, &v61);
v21 = v61 - 24;
if ( v61 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v48 = (unsigned int *)(v61 - 8);
do
v49 = __ldaxr(v48);
while ( __stlxr(v49 - 1, v48) );
}
else
{
v49 = *((_DWORD *)v61 - 2);
*((_DWORD *)v61 - 2) = v49 - 1;
}
if ( v49 <= 0 )
operator delete(v21);
}
sub_D153B8((int)&v62, &byte_F288A0);
v22 = 0;
while ( v22 < (unsigned int)cocos2d::CCArray::count(MapPacks) )
{
v23 = cocos2d::CCArray::objectAtIndex(MapPacks, v22);
v24 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)*(unsigned int *)(v23 + 328));
v57 = cocos2d::CCString::getCString(v24);
v25 = strlen(v57);
sub_D15FD4(&v62, v57, v25);
sub_D18D28(&v63, v23 + 352);
sub_D15E14(&v62, &v63);
v26 = (void *)(v63 - 24);
if ( (__int64 *)(v63 - 24) == &qword_124B6B0 )
goto LABEL_22;
if ( &pthread_create )
{
v27 = (unsigned int *)(v63 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *(_DWORD *)(v63 - 8);
*(_DWORD *)(v63 - 8) = v28 - 1;
}
if ( v28 > 0 )
{
LABEL_22:
++v22;
}
else
{
++v22;
operator delete(v26);
}
}
v31 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_78,
"I25",
"fpAa",
112,
67,
"Qg");
v58 = cocos2d::CCString::getCString(v31);
v32 = strlen(v58);
sub_D15FD4(&v62, v58, v32);
v33 = v62;
v34 = strlen(v62);
rtsha1::calc((rtsha1 *)v33, (const void *)v34, (__int64)v65, v35);
rtsha1::toHexString((rtsha1 *)v65, v66, v36);
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(MapPacks); ++i )
{
v38 = (GJMapPack *)cocos2d::CCArray::objectAtIndex(MapPacks, i);
v38->m_isGauntlet = 1;
GameLevelManager::saveGauntlet(a1, v38);
}
sub_D153B8((int)&v64, &byte_F288A0);
GameLevelManager::storeSearchResult(a1, MapPacks, (char **)&v64, v56);
v39 = (char *)v64 - 24;
if ( (char *)v64 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v52 = (unsigned int *)((char *)v64 - 8);
do
v53 = __ldaxr(v52);
while ( __stlxr(v53 - 1, v52) );
}
else
{
v53 = *((_DWORD *)v64 - 2);
*((_DWORD *)v64 - 2) = v53 - 1;
}
if ( v53 <= 0 )
operator delete(v39);
}
m_levelManagerDelegate = a1->m_levelManagerDelegate;
if ( m_levelManagerDelegate )
m_levelManagerDelegate->loadLevelsFinished(m_levelManagerDelegate, MapPacks, (const unsigned __int8 *)v56);
v41 = v62 - 24;
if ( v62 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v54 = (unsigned int *)(v62 - 8);
do
v55 = __ldaxr(v54);
while ( __stlxr(v55 - 1, v54) );
}
else
{
v55 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v55 - 1;
}
if ( v55 <= 0 )
operator delete(v41);
}
v42 = (void *)(v60 - 24);
if ( (__int64 *)(v60 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v50 = (unsigned int *)(v60 - 8);
do
v51 = __ldaxr(v50);
while ( __stlxr(v51 - 1, v50) );
}
else
{
v51 = *(_DWORD *)(v60 - 8);
*(_DWORD *)(v60 - 8) = v51 - 1;
}
if ( v51 <= 0 )
operator delete(v42);
}
v43 = (void *)(v59 - 24);
if ( (__int64 *)(v59 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v44 = (unsigned int *)(v59 - 8);
do
v45 = __ldaxr(v44);
while ( __stlxr(v45 - 1, v44) );
}
else
{
v45 = *(_DWORD *)(v59 - 8);
*(_DWORD *)(v59 - 8) = v45 - 1;
}
if ( v45 <= 0 )
operator delete(v43);
}
}
else
{
LABEL_8:
v12 = a1->m_levelManagerDelegate;
if ( v12 )
v12->loadLevelsFailed(v12, (const unsigned __int8 *)v56);
}
return _stack_chk_guard;
}