//
// GameStatsManager::trySelectActivePath from 0x7b9cbc to 0x7b9eb0 (500 bytes)
//
// 4 xrefs:
// > GameStatsManager::incrementActivePath @ 0x7b9ed8
// > GJPathsLayer::init @ 0xa6ef70
// > GJPathPage::init @ 0xa707d4
// > ??> @ 0x31f08
//
// 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 GameStatsManager::trySelectActivePath(GameStatsManager *a1)
{
StatKey m_activePath; // w1
StatKey v3; // w19
int v4; // w26
char *v5; // x0
int Stat; // w19
char *v7; // x0
unsigned int *v8; // x1
int v9; // w2
unsigned int *v10; // x2
int v11; // w1
char *v12; // [xsp+60h] [xbp+60h] BYREF
GameStatsManager::updateActivePath(a1, (StatKey)a1->m_activePath);
m_activePath = a1->m_activePath;
if ( m_activePath )
{
if ( !GameStatsManager::isPathUnlocked(a1, m_activePath) )
goto LABEL_10;
GameToolbox::intToString((__int64 *)&v12, (GameToolbox *)(unsigned int)a1->m_activePath);
Stat = GameStatsManager::getStat(a1, v12);
v7 = v12 - 24;
if ( v12 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v10 = (unsigned int *)(v12 - 8);
do
v11 = __ldaxr(v10);
while ( __stlxr(v11 - 1, v10) );
}
else
{
v11 = *((_DWORD *)v12 - 2);
*((_DWORD *)v12 - 2) = v11 - 1;
}
if ( v11 <= 0 )
operator delete(v7);
}
if ( Stat <= 999 )
{
if ( a1->m_activePath )
return;
}
else
{
LABEL_10:
a1->m_activePath = 0;
}
}
v3 = FirePath;
while ( 1 )
{
if ( GameStatsManager::isPathUnlocked(a1, v3) )
{
GameToolbox::intToString((__int64 *)&v12, (GameToolbox *)(unsigned int)v3);
v4 = GameStatsManager::getStat(a1, v12);
v5 = v12 - 24;
if ( v12 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(v12 - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *((_DWORD *)v12 - 2);
*((_DWORD *)v12 - 2) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v5);
}
if ( v4 <= 999 )
break;
}
if ( ++v3 == Gauntlets )
return;
}
a1->m_activePath = v3;
}