//
// GauntletLayer::loadLevelsFailed from 0x91d680 to 0x91d8ac (556 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'GauntletLayer::loadLevelsFailed @ 0x91d8b0
// > ??> @ 0xc6b40
// > ??> @ 0x11ad1f8
//
// 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
//
void GauntletLayer::loadLevelsFailed(GauntletLayer *a1, const char *a2, int a3)
{
GameLevelManager *v5; // x0
_DWORD *v6; // x22
unsigned __int64 v7; // x20
unsigned __int64 v8; // x25
size_t v9; // x2
int v10; // w19
__int64 v11; // x20
__int64 *v12; // x0
_DWORD *v13; // x19
char *v14; // x0
unsigned int *v15; // x19
int v16; // w1
unsigned int *v17; // x22
int v18; // w1
unsigned int *v19; // x19
void *v20; // [xsp+68h] [xbp+68h] BYREF
void *v21; // [xsp+70h] [xbp+70h] BYREF
v5 = GameLevelManager::sharedState();
GameLevelManager::getGauntletSearchKey(v5, (const char *)(unsigned int)a1->m_gauntletType, (__int64)&v20);
sub_D153B8((int)&v21, (char *)a2);
v6 = v21;
v7 = *((_QWORD *)v20 - 3);
v8 = *((_QWORD *)v21 - 3);
if ( v8 > v7 )
v9 = *((_QWORD *)v20 - 3);
else
v9 = *((_QWORD *)v21 - 3);
v10 = memcmp(v20, v21, v9);
if ( v10 || (v10 = 0x7FFFFFFF, v11 = v7 - v8, v11 > 0x7FFFFFFF) )
{
v12 = (__int64 *)(v6 - 6);
if ( v6 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
goto LABEL_20;
}
v12 = (__int64 *)(v6 - 6);
if ( v11 >= (__int64)0xFFFFFFFF80000000LL )
v10 = v11;
else
v10 = 0x80000000;
if ( v12 != &qword_124B6B0 )
{
LABEL_20:
if ( &pthread_create )
{
v17 = v6 - 2;
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(v6 - 2);
*(v6 - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v12);
}
LABEL_7:
if ( v10 )
{
v13 = v20;
v14 = (char *)v20 - 24;
if ( (char *)v20 - 24 == (char *)&qword_124B6B0 )
return;
if ( &pthread_create )
{
v19 = (unsigned int *)((char *)v20 - 8);
do
v16 = __ldaxr(v19);
while ( __stlxr(v16 - 1, v19) );
goto LABEL_28;
}
}
else
{
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 0);
a1->m_tryAgainText->setVisible(a1->m_tryAgainText, 1);
v13 = v20;
v14 = (char *)v20 - 24;
if ( (char *)v20 - 24 == (char *)&qword_124B6B0 )
return;
if ( &pthread_create )
{
v15 = (unsigned int *)((char *)v20 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
goto LABEL_28;
}
}
v16 = *(v13 - 2);
*(v13 - 2) = v16 - 1;
LABEL_28:
if ( v16 <= 0 )
operator delete(v14);
}