//
// cocos2d::CCDirector::popToSceneStackLevel from 0x1002077c4 to 0x1002078ac (232 bytes)
//
// 2 xrefs:
// > cocos2d::CCDirector::popToRootScene @ 0x1002077c0
// > cocos2d::CCDirector::popToSceneInStack @ 0x100207900
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 11:00:57 +0000
//
__int64 __fastcall cocos2d::CCDirector::popToSceneStackLevel(_QWORD *a1, int a2)
{
__int64 result; // x0
int v5; // w21
__int64 v6; // x22
char v7; // w8
__int64 v8; // x9
result = sub_1002E757C(a1[37]);
if ( a2 )
{
v5 = result;
if ( (int)result <= a2 )
return result;
do
{
v6 = sub_1002E75B0(a1[37]);
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v6 + 680LL))(v6) )
{
(*(void (__fastcall **)(__int64))(*(_QWORD *)v6 + 728LL))(v6);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v6 + 720LL))(v6);
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)v6 + 736LL))(v6);
if ( a1[12] )
{
if ( a1[12] == sub_1002E75B0(a1[37]) )
a1[12] = 0;
}
sub_1002E7648(a1[37], 1);
--v5;
}
while ( v5 > a2 );
result = sub_1002E75B0(a1[37]);
v7 = 0;
a1[35] = result;
v8 = 36;
}
else
{
v7 = 1;
v8 = 23;
}
LOBYTE(a1[v8]) = v7;
return result;
}