//
// GJOptionsLayer::layerForPage from 0x14039bb30 to 0x14039bcf5 (453 bytes)
//
// 2 xrefs:
// > GJOptionsLayer::addToggleInternal @ 0x14039b240
// > ??> @ 0x140923354
//
// 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::layerForPage(__int64 a1, int a2)
{
cocos2d::CCString *v4; // rax
const char *CString; // rax
size_t v6; // rbx
size_t v7; // r8
__int64 v8; // rdi
void *v9; // r8
cocos2d::CCString *v10; // rax
const char *v11; // rax
void *v12; // rcx
void *Block[2]; // [rsp+30h] [rbp-48h] BYREF
__int128 v15; // [rsp+40h] [rbp-38h]
v4 = cocos2d::CCString::createWithFormat("layer_%i", a2);
CString = cocos2d::CCString::getCString(v4);
*(_OWORD *)Block = 0;
v15 = 0;
v6 = -1;
v7 = -1;
do
++v7;
while ( CString[v7] );
sub_14003D230(Block, CString, v7);
v8 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 1032), Block);
if ( *((_QWORD *)&v15 + 1) > 0xFu )
{
v9 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v15 + 1) + 1LL) >= 0x1000 )
{
v9 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v9 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v9);
}
if ( !v8 )
{
v8 = cocos2d::CCLayer::create();
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 584) + 464LL))(*(_QWORD *)(a1 + 584), v8);
v10 = cocos2d::CCString::createWithFormat("layer_%i", a2);
v11 = cocos2d::CCString::getCString(v10);
*(_OWORD *)Block = 0;
v15 = 0;
do
++v6;
while ( v11[v6] );
sub_14003D230(Block, v11, v6);
cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 1032), v8, Block);
if ( *((_QWORD *)&v15 + 1) > 0xFu )
{
v12 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v15 + 1) + 1LL) >= 0x1000 )
{
v12 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v12 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v12);
}
}
return v8;
}