//
// DS_Dictionary::setRectArrayForKey from 0x18001f500 to 0x18001f9fb (1275 bytes)
//
// 3 xrefs:
// > DS_Dictionary::setRectArrayForKey @ 0x18001f4f3
// > ??> @ 0x1801438a8
// > ??> @ 0x1801aecf8
//
// 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=5
__int64 __fastcall DS_Dictionary::setRectArrayForKey(DS_Dictionary *a1, char *a2, _QWORD *a3, char a4)
{
unsigned int v8; // r14d
const char *v9; // rdi
const char *v10; // r8
char *v11; // rax
const char *v12; // r8
__int64 *v13; // rax
__int64 v14; // rax
const char *v15; // r8
int v16; // r15d
__int64 result; // rax
__int64 v18; // r13
int v19; // r14d
int v20; // r14d
char v21; // cl
void *v22; // rdi
unsigned __int64 v23; // rbx
size_t v24; // rbx
__int128 *v25; // rbx
const char *v26; // r8
__int64 v27; // rax
__int64 v28; // rax
void *v29; // rcx
__int64 v30; // [rsp+20h] [rbp-E0h] BYREF
_BYTE v31[8]; // [rsp+28h] [rbp-D8h] BYREF
__int64 v32; // [rsp+30h] [rbp-D0h] BYREF
__int64 v33; // [rsp+38h] [rbp-C8h] BYREF
__int128 v34; // [rsp+40h] [rbp-C0h]
int v35; // [rsp+5Ch] [rbp-A4h]
_QWORD v36[2]; // [rsp+60h] [rbp-A0h] BYREF
void *v37; // [rsp+70h] [rbp-90h] BYREF
void **v38; // [rsp+78h] [rbp-88h] BYREF
_BYTE v39[96]; // [rsp+80h] [rbp-80h] BYREF
unsigned __int64 v40; // [rsp+E0h] [rbp-20h]
int v41; // [rsp+E8h] [rbp-18h]
_BYTE v42[104]; // [rsp+F8h] [rbp-8h] BYREF
_BYTE v43[8]; // [rsp+160h] [rbp+60h] BYREF
_BYTE v44[8]; // [rsp+168h] [rbp+68h] BYREF
__int128 v45; // [rsp+170h] [rbp+70h] BYREF
__int64 v46; // [rsp+180h] [rbp+80h]
unsigned __int64 v47; // [rsp+188h] [rbp+88h]
v8 = 0;
LODWORD(v30) = 0;
DS_Dictionary::removeKey(a1, a2);
pugi::xml_node::xml_node((cocos2d::CCThread *)&v32);
pugi::xml_node::xml_node((cocos2d::CCThread *)&v33);
v9 = "k";
if ( !a4 )
goto LABEL_9;
v10 = "k";
if ( a1->compatible )
v10 = "key";
sub_18007FB10(&a1->dictTree._Mypair._Myval2._Mylast[-1], &v30, v10);
if ( sub_18007F4E0(&v30) )
{
while ( 1 )
{
v11 = (char *)sub_18007FB70(&v30);
if ( !sub_1800190E0(v11, a2) )
break;
v12 = "k";
if ( a1->compatible )
v12 = "key";
v30 = *(_QWORD *)sub_180081A50(&v30, v31, v12);
if ( !sub_18007F4E0(&v30) )
goto LABEL_9;
}
if ( a1->compatible )
v9 = "key";
v13 = (__int64 *)sub_180081070(&a1->dictTree._Mypair._Myval2._Mylast[-1], v31, v9, &v30);
}
else
{
LABEL_9:
if ( a1->compatible )
v9 = "key";
v13 = (__int64 *)sub_18007F870(&a1->dictTree._Mypair._Myval2._Mylast[-1], v31, v9);
}
v32 = *v13;
v14 = sub_18007F910(&v32, v31, 3);
sub_180085410(v14, a2);
v15 = "a";
if ( a1->compatible )
v15 = "array";
v33 = *(_QWORD *)sub_180080EE0(&a1->dictTree._Mypair._Myval2._Mylast[-1], v31, v15, &v32);
v16 = 0;
result = (__int64)(a3[1] - *a3) >> 4;
if ( result )
{
v18 = 0;
do
{
v36[0] = &unk_1800E6C00;
v37 = &unk_1800E6C08;
std::ios::ios(v42);
v19 = v8 | 1;
LODWORD(v30) = v19;
std::iostream::iostream(v36, &v38, 0);
*(_QWORD *)((char *)v36 + *(int *)(v36[0] + 4LL)) = &std::basic_stringstream,std::allocator>::`vftable';
*(int *)((char *)&v35 + *(int *)(v36[0] + 4LL)) = *(_DWORD *)(v36[0] + 4LL) - 152;
std::streambuf::streambuf(&v38);
v38 = &std::stringbuf::`vftable';
v40 = 0;
v41 = 0;
sub_180015680((__int64)&v37, (__int64)"{{");
std::ostream::operator<<(&v37);
sub_180015680((__int64)&v37, (__int64)",");
std::ostream::operator<<(&v37);
sub_180015680((__int64)&v37, (__int64)"},{");
std::ostream::operator<<(&v37);
sub_180015680((__int64)&v37, (__int64)",");
std::ostream::operator<<(&v37);
sub_180015680((__int64)&v37, (__int64)"}}");
v45 = 0;
v46 = 0;
v47 = 15;
LOBYTE(v45) = 0;
v20 = v19 | 4;
LODWORD(v30) = v20;
v34 = 0;
v21 = v41;
if ( (v41 & 0x22) != 2 )
{
if ( std::streambuf::pptr(&v38) )
{
v22 = (void *)std::streambuf::pbase(&v38);
v23 = std::streambuf::pptr(&v38);
if ( v23 < v40 )
v23 = v40;
v24 = v23 - (_QWORD)v22;
std::streambuf::epptr(&v38);
goto LABEL_29;
}
v21 = v41;
}
if ( (v21 & 4) != 0 || !std::streambuf::gptr(&v38) )
{
v24 = *((_QWORD *)&v34 + 1);
v22 = (void *)v34;
}
else
{
v22 = (void *)std::streambuf::eback(&v38);
v24 = std::streambuf::egptr(&v38) - (_QWORD)v22;
}
LABEL_29:
if ( v22 )
sub_180010050((void **)&v45, v22, v24);
v8 = v20 & 0xFFFFFFF9 | 2;
v25 = &v45;
if ( v47 > 0xF )
v25 = (__int128 *)v45;
v26 = "s";
if ( a1->compatible )
v26 = "string";
v27 = sub_18007F870(&v33, v43, v26);
v28 = sub_18007F910(v27, v44, 3);
sub_180085410(v28, v25);
if ( v47 > 0xF )
{
v29 = (void *)v45;
if ( v47 + 1 >= 0x1000 )
{
v29 = *(void **)(v45 - 8);
if ( (unsigned __int64)(v45 - (_QWORD)v29 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v29);
}
*(_QWORD *)((char *)v36 + *(int *)(v36[0] + 4LL)) = &std::basic_stringstream,std::allocator>::`vftable';
*(int *)((char *)&v35 + *(int *)(v36[0] + 4LL)) = *(_DWORD *)(v36[0] + 4LL) - 152;
sub_1800179A0((__int64)&v38);
std::iostream::~iostream>(v39);
std::ios::~ios>(v42);
++v16;
v18 += 16;
result = v16;
}
while ( v16 < (unsigned __int64)((__int64)(a3[1] - *a3) >> 4) );
}
return result;
}