//
// GJOptionsLayer::addGVToggle from 0x14039b040 to 0x14039b193 (339 bytes)
//
// 3 xrefs:
// > FindObjectOptionsLayer::setupOptions @ 0x140180c75
// > SFXSettingsPopup::setupOptions @ 0x14061f6d5
// > ??> @ 0x14092330c
//
// 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:14 +0000
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall GJOptionsLayer::addGVToggle(__int64 a1, int a2, char *a3, __int64 a4)
{
__int64 v8; // rbp
__int64 v9; // rcx
bool GameVariable; // al
__int64 v11; // rsi
size_t v12; // r8
cocos2d::CCDictionary *v13; // rdi
struct cocos2d::CCObject *v14; // rax
void *v15; // rcx
void *v17; // [rsp+30h] [rbp-58h]
void *Block[2]; // [rsp+38h] [rbp-50h] BYREF
__int64 v19; // [rsp+48h] [rbp-40h]
unsigned __int64 v20; // [rsp+50h] [rbp-38h]
v8 = atoi(a3);
v9 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v17 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v17);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v9 = qword_14090BFD0;
}
GameVariable = GameManager::getGameVariable(v9, a3);
v11 = GJOptionsLayer::addToggleInternal(a1, a2, v8, GameVariable, a4);
*(_OWORD *)Block = 0;
v19 = 0;
v20 = 0;
v12 = -1;
do
++v12;
while ( a3[v12] );
sub_14003D230(Block, a3, v12);
v13 = *(cocos2d::CCDictionary **)(a1 + 1040);
v14 = (struct cocos2d::CCObject *)cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(v13, v14, v8);
if ( v20 > 0xF )
{
v15 = Block[0];
if ( v20 + 1 >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v15);
}
return v11;
}