//
// KeybindingsLayer::goToPage from 0x1402c08f0 to 0x1402c0cf4 (1028 bytes)
//
// 5 xrefs:
// > KeybindingsLayer::init @ 0x1402c0270
// > KeybindingsLayer::onNextPage @ 0x1402c08d8
// > KeybindingsLayer::onPrevPage @ 0x1402c08e8
// > ParentalOptionsLayer::init @ 0x14037b9b6
// > ??> @ 0x1406d2960
//
// 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
//
// Merged with: KeybindingsLayer::goToPage, ParentalOptionsLayer::goToPage
__int64 __fastcall KeybindingsLayer::goToPage(__int64 a1, int a2)
{
int v2; // r15d
__int64 result; // rax
unsigned int v5; // esi
int v6; // edx
cocos2d::CCString *v7; // rax
const char *CString; // rax
size_t v9; // rbx
size_t v10; // r8
cocos2d::CCArray *v11; // r14
void *v12; // rcx
unsigned int i; // edi
struct cocos2d::CCObject *v14; // rax
cocos2d::CCString *v15; // rax
const char *v16; // rax
size_t v17; // r8
__int64 v18; // rdi
void *v19; // rcx
cocos2d::CCString *v20; // rax
const char *v21; // rax
size_t v22; // r8
cocos2d::CCArray *v23; // rdi
void *v24; // rcx
struct cocos2d::CCObject *v25; // rax
__int64 v26; // rdx
cocos2d::CCString *v27; // rax
const char *v28; // rax
__int64 v29; // rbx
__int64 v30; // rdx
void *v31; // rcx
__int64 v32; // rdx
void *Block[2]; // [rsp+20h] [rbp-30h] BYREF
__m128i si128; // [rsp+30h] [rbp-20h]
v2 = a2;
result = *(unsigned int *)(a1 + 640);
v5 = 0;
if ( a2 <= (int)result )
{
if ( a2 < 0 )
v2 = *(_DWORD *)(a1 + 640);
}
else
{
v2 = 0;
}
v6 = *(_DWORD *)(a1 + 632);
if ( v6 != v2 )
{
v7 = cocos2d::CCString::createWithFormat("object_%i", v6);
CString = cocos2d::CCString::getCString(v7);
*(_OWORD *)Block = 0;
si128 = 0;
v9 = -1;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003A930(Block, CString, v10);
v11 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 648), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v12 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v12 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v12 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v12);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Block[0]) = 0;
if ( v11 )
{
for ( i = 0; i < cocos2d::CCArray::count(v11); ++i )
{
v14 = cocos2d::CCArray::objectAtIndex(v11, i);
((void (__fastcall *)(struct cocos2d::CCObject *, _QWORD))v14->__vftable[4].update)(v14, 0);
}
}
v15 = cocos2d::CCString::createWithFormat("layer_%i", *(_DWORD *)(a1 + 632));
v16 = cocos2d::CCString::getCString(v15);
*(_OWORD *)Block = 0;
si128 = 0;
v17 = -1;
do
++v17;
while ( v16[v17] );
sub_14003A930(Block, v16, v17);
v18 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 648), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v19 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v19);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Block[0]) = 0;
if ( v18 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v18 + 320LL))(v18, 0);
v20 = cocos2d::CCString::createWithFormat("object_%i", v2);
v21 = cocos2d::CCString::getCString(v20);
*(_OWORD *)Block = 0;
si128 = 0;
v22 = -1;
do
++v22;
while ( v21[v22] );
sub_14003A930(Block, v21, v22);
v23 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 648), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v24 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v24 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v24 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v24);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Block[0]) = 0;
if ( v23 && cocos2d::CCArray::count(v23) )
{
do
{
v25 = cocos2d::CCArray::objectAtIndex(v23, v5);
LOBYTE(v26) = 1;
((void (__fastcall *)(struct cocos2d::CCObject *, __int64))v25->__vftable[4].update)(v25, v26);
++v5;
}
while ( v5 < cocos2d::CCArray::count(v23) );
}
v27 = cocos2d::CCString::createWithFormat("layer_%i", v2);
v28 = cocos2d::CCString::getCString(v27);
*(_OWORD *)Block = 0;
si128 = 0;
do
++v9;
while ( v28[v9] );
sub_14003A930(Block, v28, v9);
v29 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 648), Block);
v30 = si128.m128i_i64[1];
if ( si128.m128i_i64[1] > 0xFuLL )
{
v31 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v31 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v31 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v31);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Block[0]) = 0;
if ( v29 )
{
LOBYTE(v30) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v29 + 320LL))(v29, v30);
}
*(_DWORD *)(a1 + 632) = v2;
LOBYTE(v30) = v2 > 0;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 664) + 320LL))(*(_QWORD *)(a1 + 664), v30);
LOBYTE(v32) = *(_DWORD *)(a1 + 632) < *(_DWORD *)(a1 + 640);
return (*(__int64 (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 672) + 320LL))(*(_QWORD *)(a1 + 672), v32);
}
return result;
}