//
// TabbedPopupLayer::ensurePopupPage from 0xc393c0 to 0xc394e4 (292 bytes)
//
// 2 xrefs:
// > GameSettingsLayer::addToggle @ 0xc05640
// > ??> @ 0x8ea50
//
// 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 13:04:53 +0000
//
__int64 __fastcall TabbedPopupLayer::ensurePopupPage(TabbedPopupLayer *this, signed int a2, int a3)
{
__int64 v5; // x0
__int64 *v6; // x19
__int64 v7; // x1
_DWORD *v8; // x0
_DWORD *v9; // x0
unsigned int v11; // [xsp+44h] [xbp+44h] BYREF
if ( a2 < 0 )
return 0;
v5 = *((_QWORD *)this + 130);
if ( a2 >= (int)(-1431655765 * ((*((_QWORD *)this + 131) - v5) >> 3)) || a3 < 0 )
return 0;
v6 = (__int64 *)(v5 + 24LL * a2);
v7 = *v6;
if ( a3 >= (int)((v6[1] - *v6) >> 2) )
{
do
{
v11 = cocos2d::CCArray::count(*((cocos2d::CCArray **)this + 114));
SetupTriggerPopup::getPageContainer((cocos2d::CCArray **)this, v11);
v8 = (_DWORD *)v6[1];
if ( v8 == (_DWORD *)v6[2] )
{
std::vector::__push_back_slow_path((__int64)v6, &v11);
v9 = (_DWORD *)v6[1];
}
else
{
if ( v8 )
{
*v8 = v11;
v8 = (_DWORD *)v6[1];
}
v9 = v8 + 1;
v6[1] = (__int64)v9;
}
v7 = *v6;
}
while ( a3 >= (int)(((__int64)v9 - *v6) >> 2) );
}
return *(unsigned int *)(v7 + 4LL * a3);
}