//
// GameLevelManager::onGetUsersCompleted from 0x711a90 to 0x711fe4 (1364 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732d54
// > ??> @ 0xbf628
//
// 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::onGetUsersCompleted(GameLevelManager *a1, const void **a2, const char **a3)
{
char *v3; // x23
_DWORD *v6; // x27
unsigned __int64 v7; // x28
unsigned __int64 v8; // x20
size_t v9; // x2
int v10; // w19
__int64 v11; // x20
__int64 *v12; // x0
LevelManagerDelegate *v13; // x0
cocos2d::CCArray *v15; // x19
char *v16; // x0
cocos2d::CCString *v17; // x0
char *CString; // x0
cocos2d::CCString *v19; // x0
char *v20; // x0
LevelManagerDelegate *m_levelManagerDelegate; // x27
void (__fastcall *setupPageInfo)(LevelManagerDelegate *__hidden, std::string, const unsigned __int8 *); // x28
long double v23; // q0
void *v24; // x0
cocos2d::CCArray *Scores; // x26
char *v26; // x0
char *v27; // x0
LevelManagerDelegate *v28; // x0
void *v29; // x0
void *v30; // x19
unsigned int *v31; // x27
int v32; // w0
unsigned int *v33; // x27
int v34; // w1
unsigned int *v35; // x1
int v36; // w2
unsigned int *v37; // x1
int v38; // w2
unsigned int *v39; // x1
int v40; // w2
unsigned int *v41; // x1
int v42; // w2
unsigned int *v43; // x1
int v44; // w2
__int64 v45; // [xsp+70h] [xbp+70h] BYREF
__int64 v46; // [xsp+78h] [xbp+78h] BYREF
__int64 v47; // [xsp+80h] [xbp+80h] BYREF
char *v48; // [xsp+88h] [xbp+88h] BYREF
void *v49; // [xsp+90h] [xbp+90h] BYREF
v3 = (char *)*a3;
GameLevelManager::removeDLFromActive(a1, *a3);
sub_D153B8((int)&v49, "-1");
v6 = v49;
v7 = *((_QWORD *)v49 - 3);
v8 = *((_QWORD *)*a2 - 3);
if ( v7 > v8 )
v9 = *((_QWORD *)*a2 - 3);
else
v9 = *((_QWORD *)v49 - 3);
v10 = memcmp(*a2, v49, v9);
if ( v10 || (v10 = 0x7FFFFFFF, v11 = v8 - v7, v11 > 0x7FFFFFFF) )
{
v12 = (__int64 *)(v6 - 6);
if ( v6 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v12 = (__int64 *)(v6 - 6);
if ( v11 >= (__int64)0xFFFFFFFF80000000LL )
v10 = v11;
else
v10 = 0x80000000;
if ( v12 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v33 = v6 - 2;
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *(v6 - 2);
*(v6 - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v12);
LABEL_7:
if ( !v10 )
goto LABEL_8;
sub_D153B8((int)&v49, (char *)*a2);
v15 = sub_6F004C(&v49, "#");
v16 = (char *)v49 - 24;
if ( (char *)v49 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v35 = (unsigned int *)((char *)v49 - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *((_DWORD *)v49 - 2);
*((_DWORD *)v49 - 2) = v36 - 1;
}
if ( v36 <= 0 )
operator delete(v16);
}
if ( (unsigned int)cocos2d::CCArray::count(v15) > 1 )
{
v17 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v15, 0);
CString = (char *)cocos2d::CCString::getCString(v17);
sub_D153B8((int)&v45, CString);
v19 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v15, 1u);
v20 = (char *)cocos2d::CCString::getCString(v19);
sub_D153B8((int)&v46, v20);
m_levelManagerDelegate = a1->m_levelManagerDelegate;
if ( m_levelManagerDelegate )
{
setupPageInfo = m_levelManagerDelegate->setupPageInfo;
*(__n128 *)&v23 = sub_D18D28(&v47, &v46);
((void (__fastcall *)(LevelManagerDelegate *, __int64 *, char *, long double))setupPageInfo)(
m_levelManagerDelegate,
&v47,
v3,
v23);
v24 = (void *)(v47 - 24);
if ( (__int64 *)(v47 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v43 = (unsigned int *)(v47 - 8);
do
v44 = __ldaxr(v43);
while ( __stlxr(v44 - 1, v43) );
}
else
{
v44 = *(_DWORD *)(v47 - 8);
*(_DWORD *)(v47 - 8) = v44 - 1;
}
if ( v44 <= 0 )
operator delete(v24);
}
}
sub_D18D28(&v48, a2);
Scores = GameLevelManager::createAndGetScores(a1, &v48, 2);
v26 = v48 - 24;
if ( v48 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v39 = (unsigned int *)(v48 - 8);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *((_DWORD *)v48 - 2);
*((_DWORD *)v48 - 2) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v26);
}
sub_D18D28(&v49, &v46);
GameLevelManager::storeSearchResult(a1, Scores, (char **)&v49, v3);
v27 = (char *)v49 - 24;
if ( (char *)v49 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)((char *)v49 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *((_DWORD *)v49 - 2);
*((_DWORD *)v49 - 2) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v27);
}
v28 = a1->m_levelManagerDelegate;
if ( v28 )
v28->loadLevelsFinished(v28, Scores, (const unsigned __int8 *)v3);
v29 = (void *)(v46 - 24);
if ( (__int64 *)(v46 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v37 = (unsigned int *)(v46 - 8);
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = *(_DWORD *)(v46 - 8);
*(_DWORD *)(v46 - 8) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v29);
}
v30 = (void *)(v45 - 24);
if ( (__int64 *)(v45 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v31 = (unsigned int *)(v45 - 8);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *(_DWORD *)(v45 - 8);
*(_DWORD *)(v45 - 8) = v32 - 1;
}
if ( v32 <= 0 )
operator delete(v30);
}
}
else
{
LABEL_8:
v13 = a1->m_levelManagerDelegate;
if ( v13 )
v13->loadLevelsFailed(v13, (const unsigned __int8 *)v3);
}
return _stack_chk_guard;
}