//
// cocos2d::CCDirector::popToSceneStackLevel from 0x7caad0 to 0x7cab4c (124 bytes)
//
// 2 xrefs:
// > cocos2d::CCDirector::popToRootScene @ 0x7cab4e
// > cocos2d::CCDirector::popToSceneInStack @ 0x7cab64
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:00:30 +0000
//
int __fastcall cocos2d::CCDirector::popToSceneStackLevel(cocos2d::CCArray **this, int a2)
{
int result; // r0
int v5; // r6
int Object; // r5
result = cocos2d::CCArray::count(*(this + 58));
v5 = result;
if ( !a2 )
return cocos2d::CCDirector::end((int)this);
if ( a2 < result )
{
do
{
Object = cocos2d::CCArray::lastObject(*(this + 58));
if ( (*(int (__fastcall **)(int))(*(_DWORD *)Object + 340))(Object) )
{
(*(void (__fastcall **)(int))(*(_DWORD *)Object + 364))(Object);
(*(void (__fastcall **)(int))(*(_DWORD *)Object + 360))(Object);
}
--v5;
(*(void (__fastcall **)(int))(*(_DWORD *)Object + 368))(Object);
cocos2d::CCDirector::checkSceneReference((int)this);
cocos2d::CCArray::removeLastObject(*(this + 58), 1);
}
while ( v5 != a2 );
result = cocos2d::CCArray::lastObject(*(this + 58));
*((_BYTE *)this + 228) = 0;
*(this + 56) = (cocos2d::CCArray *)result;
}
return result;
}