//
// cocos2d::CCDirector::popToSceneStackLevel from 0x5c3820 to 0x5c389c (124 bytes)
//
// 2 xrefs:
// > cocos2d::CCDirector::popToRootScene @ 0x5c389e
// > cocos2d::CCDirector::popToSceneInStack @ 0x5c38b4
//
// 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 cocos2d::CCDirector::popToSceneStackLevel(cocos2d::CCDirector *a1, int a2)
{
signed int v4; // r0
signed int v5; // r6
unsigned int Object; // r5
int v7; // r2
bool v8; // r3
cocos2d::CCScene *v9; // r0
v4 = cocos2d::CCArray::count(a1->m_pobScenesStack);
v5 = v4;
if ( a2 )
{
if ( a2 < v4 )
{
do
{
Object = cocos2d::CCArray::lastObject(a1->m_pobScenesStack);
if ( (*(int (__fastcall **)(unsigned int))(*(_DWORD *)Object + 332))(Object) )
{
(*(void (__fastcall **)(unsigned int))(*(_DWORD *)Object + 356))(Object);
(*(void (__fastcall **)(unsigned int))(*(_DWORD *)Object + 352))(Object);
}
--v5;
(*(void (__fastcall **)(unsigned int))(*(_DWORD *)Object + 360))(Object);
cocos2d::CCDirector::checkSceneReference(a1);
cocos2d::CCArray::removeLastObject(a1->m_pobScenesStack, 1, v7, v8);
}
while ( v5 != a2 );
v9 = (cocos2d::CCScene *)cocos2d::CCArray::lastObject(a1->m_pobScenesStack);
a1->m_bSendCleanupToScene = 0;
a1->m_pNextScene = v9;
}
}
else
{
cocos2d::CCDirector::end(a1);
}
}