//
// GJOptionsLayer::goToPage from 0x14039bd20 to 0x14039c169 (1097 bytes)
//
// 4 xrefs:
// > GJOptionsLayer::init @ 0x14039af5d
// > GJOptionsLayer::onNextPage @ 0x14039bd08
// > GJOptionsLayer::onPrevPage @ 0x14039bd18
// > ??> @ 0x140923360
//
// This function is hookable on this platform (idp: pc, 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:31:15 +0000
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall GJOptionsLayer::goToPage(__int64 a1, int a2)
{
int v2; // r14d
__int64 result; // rax
int v5; // edx
cocos2d::CCString *v6; // rax
const char *CString; // rax
size_t v8; // rbx
size_t v9; // r8
cocos2d::CCArray *v10; // rsi
void *v11; // rax
unsigned int i; // edi
struct cocos2d::CCObject *v13; // rax
cocos2d::CCString *v14; // rax
const char *v15; // rax
size_t v16; // r8
__int64 v17; // rdi
void *v18; // r8
cocos2d::CCString *v19; // rax
const char *v20; // rax
size_t v21; // r8
cocos2d::CCArray *v22; // rsi
void *v23; // rax
unsigned int j; // edi
struct cocos2d::CCObject *v25; // rax
__int64 v26; // rdx
cocos2d::CCString *v27; // rax
const char *v28; // rax
__int64 v29; // rbx
__int64 v30; // rdx
void *v31; // r8
__int64 v32; // rdx
void *Block[2]; // [rsp+30h] [rbp-30h] BYREF
__m128i si128; // [rsp+40h] [rbp-20h]
v2 = a2;
result = *(unsigned int *)(a1 + 1016);
if ( a2 <= (int)result )
{
if ( a2 < 0 )
v2 = *(_DWORD *)(a1 + 1016);
}
else
{
v2 = 0;
}
v5 = *(_DWORD *)(a1 + 1004);
if ( v5 != v2 )
{
v6 = cocos2d::CCString::createWithFormat("object_%i", v5);
CString = cocos2d::CCString::getCString(v6);
*(_OWORD *)Block = 0;
si128 = 0;
v8 = -1;
v9 = -1;
do
++v9;
while ( CString[v9] );
sub_14003D230(Block, CString, v9);
v10 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 1032), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v11 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v11 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v11);
}
si128 = _mm_load_si128((const __m128i *)&Size);
LOBYTE(Block[0]) = 0;
if ( v10 )
{
for ( i = 0; i < cocos2d::CCArray::count(v10); ++i )
{
v13 = cocos2d::CCArray::objectAtIndex(v10, i);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v13 + 336LL))(v13, 0);
}
}
v14 = cocos2d::CCString::createWithFormat("layer_%i", *(_DWORD *)(a1 + 1004));
v15 = cocos2d::CCString::getCString(v14);
*(_OWORD *)Block = 0;
si128 = 0;
v16 = -1;
do
++v16;
while ( v15[v16] );
sub_14003D230(Block, v15, v16);
v17 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 1032), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v18 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v18);
}
si128 = _mm_load_si128((const __m128i *)&Size);
LOBYTE(Block[0]) = 0;
if ( v17 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v17 + 336LL))(v17, 0);
v19 = cocos2d::CCString::createWithFormat("object_%i", v2);
v20 = cocos2d::CCString::getCString(v19);
*(_OWORD *)Block = 0;
si128 = 0;
v21 = -1;
do
++v21;
while ( v20[v21] );
sub_14003D230(Block, v20, v21);
v22 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 1032), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v23 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v23 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v23 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v23);
}
si128 = _mm_load_si128((const __m128i *)&Size);
LOBYTE(Block[0]) = 0;
if ( v22 )
{
for ( j = 0; j < cocos2d::CCArray::count(v22); ++j )
{
v25 = cocos2d::CCArray::objectAtIndex(v22, j);
LOBYTE(v26) = 1;
(*(void (__fastcall **)(struct cocos2d::CCObject *, __int64))(*(_QWORD *)v25 + 336LL))(v25, v26);
}
}
v27 = cocos2d::CCString::createWithFormat("layer_%i", v2);
v28 = cocos2d::CCString::getCString(v27);
*(_OWORD *)Block = 0;
si128 = 0;
do
++v8;
while ( v28[v8] );
sub_14003D230(Block, v28, v8);
v29 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 1032), 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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v31);
}
si128 = _mm_load_si128((const __m128i *)&Size);
LOBYTE(Block[0]) = 0;
if ( v29 )
{
LOBYTE(v30) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v29 + 336LL))(v29, v30);
}
*(_DWORD *)(a1 + 1004) = v2;
LOBYTE(v30) = v2 > 0;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 1048) + 336LL))(*(_QWORD *)(a1 + 1048), v30);
LOBYTE(v32) = *(_DWORD *)(a1 + 1004) < *(_DWORD *)(a1 + 1016);
return (*(__int64 (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 1056) + 336LL))(*(_QWORD *)(a1 + 1056), v32);
}
return result;
}