//
// cocos2d::CCUserDefault::setBoolForKey from 0x18009f210 to 0x18009f3f2 (482 bytes)
//
// 2 xrefs:
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b7650
//
// 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
//
// Hidden C++ exception states: #wind=1
void __fastcall cocos2d::CCUserDefault::setBoolForKey(cocos2d::CCUserDefault *this, const char *a2, char a3)
{
void *v5; // rcx
unsigned __int64 v6; // rcx
const struct tinyxml2::XMLElement *v7; // rax
struct tinyxml2::XMLElement *v8; // rbx
tinyxml2::XMLDocument *v9; // rdi
void **v10; // rcx
struct tinyxml2::XMLNode *v11; // rax
const char *v12; // rdx
unsigned __int64 v13; // rdx
tinyxml2::XMLNode *v14; // [rsp+20h] [rbp-48h] BYREF
tinyxml2::XMLDocument *v15; // [rsp+28h] [rbp-40h] BYREF
void *Block[2]; // [rsp+30h] [rbp-38h] BYREF
__int64 v17; // [rsp+40h] [rbp-28h]
unsigned __int64 v18; // [rsp+48h] [rbp-20h]
if ( a3 == 1 )
{
sub_180005910(Block, "true");
cocos2d::CCUserDefault::setStringForKey(this, a2, Block);
if ( v18 <= 0xF )
return;
v5 = Block[0];
if ( v18 + 1 >= 0x1000 )
{
v5 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v5 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
goto LABEL_22;
}
*(_OWORD *)Block = 0;
v17 = 5;
v6 = 15;
v18 = 15;
LODWORD(Block[0]) = *(_DWORD *)"false";
WORD2(Block[0]) = (unsigned __int8)aFalse[4];
if ( a2 )
{
v7 = sub_18009EE00((__int64)a2, &v14, &v15);
v8 = v7;
v9 = v15;
if ( v7 )
{
v10 = *((void ***)v7 + 6);
if ( v10 )
{
tinyxml2::XMLNode::SetValue(v10, (const char *)Block, 0);
LABEL_13:
if ( v9 )
{
cocos2d::CCUserDefault::sharedUserDefault();
v12 = (const char *)&cocos2d::CCUserDefault::m_sFilePath;
if ( *((_QWORD *)&xmmword_1801A8A40 + 1) > 0xFu )
v12 = cocos2d::CCUserDefault::m_sFilePath;
tinyxml2::XMLDocument::SaveFile((__int64)v9, v12, 0);
(*(void (__fastcall **)(tinyxml2::XMLDocument *, __int64))(*(_QWORD *)v9 + 128LL))(v9, 1);
}
v6 = v18;
goto LABEL_18;
}
}
else
{
if ( !v14 )
goto LABEL_13;
v8 = tinyxml2::XMLDocument::NewElement(v15, a2);
tinyxml2::XMLNode::InsertEndChild(v14, v8);
}
v11 = tinyxml2::XMLDocument::NewText(v9, (const char *)Block);
tinyxml2::XMLNode::InsertEndChild(v8, v11);
goto LABEL_13;
}
LABEL_18:
if ( v6 <= 0xF )
return;
v13 = v6 + 1;
v5 = Block[0];
if ( v13 >= 0x1000 )
{
v5 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v5 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
LABEL_22:
j_j_free_0(v5);
}