//
// LevelListLayer::cloneList from 0xa77c30 to 0xa77e88 (600 bytes)
//
// 2 xrefs:
// > LevelListLayer::FLAlert_Clicked @ 0xa77fb4
// > ??> @ 0x65dc0
//
// 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 LevelListLayer::cloneList(LevelListLayer *a1)
{
GameLevelManager *v2; // x0
GJLevelList *NewLevelList; // x21
GameLevelManager *v4; // x0
GJLevelList *m_levelList; // x2
void *v6; // x0
GJLevelList *v7; // x1
int m_original; // w0
cocos2d::CCDirector *v9; // x20
cocos2d::CCScene *v10; // x0
cocos2d::CCTransitionFade *v11; // x0
void *v12; // x21
unsigned int *v13; // x20
int v14; // w0
unsigned int *v15; // x1
int v16; // w2
__int64 v17; // [xsp+48h] [xbp+48h] BYREF
__int64 v18; // [xsp+50h] [xbp+50h] BYREF
if ( !a1->m_exiting )
{
((void (__fastcall *)(LevelListLayer *))a1->setKeypadEnabled)(a1);
a1->m_exiting = 1;
GameManager::sharedState()->m_sceneEnum = 14;
v2 = GameLevelManager::sharedState();
NewLevelList = GameLevelManager::createNewLevelList(v2);
v4 = GameLevelManager::sharedState();
m_levelList = a1->m_levelList;
v4->m_returnToLocalLevels = 1;
NewLevelList->m_difficulty = m_levelList->m_difficulty;
sub_D18EA8(&NewLevelList->m_listDesc, &m_levelList->m_listDesc);
GJLevelList::duplicateListLevels(NewLevelList);
sub_D18D28(&v17);
if ( *(_QWORD *)(v17 - 24) <= 0x17u )
sub_D15FD4(&v17, " 2", 2);
sub_D18D28(&v18);
sub_D18EA8(&NewLevelList->m_listName, &v18);
v6 = (void *)(v18 - 24);
if ( (__int64 *)(v18 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v18 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *(_DWORD *)(v18 - 8);
*(_DWORD *)(v18 - 8) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v6);
}
v7 = a1->m_levelList;
m_original = v7->m_original;
if ( !m_original )
m_original = v7->m_listID;
NewLevelList->m_original = m_original;
v9 = cocos2d::CCDirector::sharedDirector();
v10 = LevelListLayer::scene(NewLevelList);
v11 = cocos2d::CCTransitionFade::create(0.5, v10);
cocos2d::CCDirector::replaceScene(v9, v11);
v12 = (void *)(v17 - 24);
if ( (__int64 *)(v17 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v17 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *(_DWORD *)(v17 - 8);
*(_DWORD *)(v17 - 8) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v12);
}
}
}