//
// DS_Dictionary::rectFromString from 0x10017a390 to 0x10017a91b (1419 bytes)
//
// 2 xrefs:
// > DS_Dictionary::getRectForKey @ 0x10017e14e
// > DS_Dictionary::getRectArrayForKey @ 0x10017e620
//
// 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
//
__int64 __fastcall DS_Dictionary::rectFromString(double a1, __int64 a2, __int64 a3, __int64 a4)
{
unsigned int v5; // r14d
std::string::size_type v6; // r13
int v7; // eax
std::string::size_type v9; // rax
bool v10; // cl
std::string::size_type v11; // r15
std::string::size_type size; // r14
std::string::pointer data; // r12
std::size_t v14; // rax
std::size_t v15; // r14
char *elems; // rbx
double v17; // xmm0_8
int v18; // eax
std::string *v19; // rdi
std::string::size_type v20; // r14
size_t v21; // r13
std::string::pointer v22; // rsi
std::size_t v23; // r12
char *v24; // r13
size_t v25; // r15
std::string::size_type v26; // r14
std::string::size_type v27; // r12
__int64 v28; // rbx
std::size_t v29; // rax
std::size_t v30; // r12
char *v31; // r13
double v32; // rsi
size_t v33; // r15
__int64 v34; // rbx
unsigned int v35; // eax
std::__vector_base::pointer begin; // r15
std::array *longStorage; // rdi
const char *v38; // r15
double v39; // xmm0_8
std::__vector_base::pointer v40; // r15
std::array *p_shortStorage; // rdi
float v42; // xmm1_4
float v43; // xmm0_4
float v44; // xmm0_4
const char *v45; // r15
float v46; // xmm3_4
std::string *v47; // rbx
std::__vector_base::pointer end; // r15
std::__vector_base::pointer v49; // rdi
std::string *v50; // rbx
std::__vector_base::pointer v51; // r15
std::__vector_base::pointer v52; // rdi
_BYTE v53[16]; // [rsp+8h] [rbp-D8h] BYREF
__int64 v54; // [rsp+18h] [rbp-C8h]
std::vector v55; // [rsp+20h] [rbp-C0h] BYREF
std::vector __p; // [rsp+40h] [rbp-A0h] BYREF
std::string v57; // [rsp+58h] [rbp-88h] BYREF
float v58; // [rsp+74h] [rbp-6Ch]
__int64 v59; // [rsp+78h] [rbp-68h]
std::string __dst; // [rsp+80h] [rbp-60h] BYREF
double v61; // [rsp+98h] [rbp-48h]
std::string v62; // [rsp+A0h] [rbp-40h] BYREF
DS_Dictionary::cleanStringWhiteSpace(&v62, a1, a3, a3);
v5 = 0;
v6 = std::string::find(&v62, 123, 0);
v7 = std::string::find(&v62, 125, 0);
if ( v7 != -1 )
{
v9 = std::string::find(&v62, 125, v7 + 1);
v10 = (_DWORD)v9 == -1;
if ( (_DWORD)v9 != -1 )
{
LODWORD(v9) = std::string::find(&v62, 125, (__int64)((__int64)&_mh_execute_header + (v9 << 32)) >> 32);
v10 = (_DWORD)v9 == -1;
}
v5 = 0;
if ( (_DWORD)v6 != -1 && !v10 )
{
v11 = (__int64)((__int64)&_mh_execute_header + (v6 << 32)) >> 32;
if ( (*(_BYTE *)&v62.__r_.__value_.__s.0 & 1) != 0 )
{
size = v62.__r_.__value_.__l.__size_;
if ( v62.__r_.__value_.__l.__size_ >= v11 )
{
data = v62.__r_.__value_.__l.__data_;
LABEL_14:
v14 = ~(_DWORD)v6 + (int)v9;
v15 = size - v11;
if ( v15 >= v14 )
v15 = v14;
if ( v15 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a1);
v54 = a4;
if ( v15 >= 0x17 )
{
v21 = 26;
if ( (v15 | 7) != 0x17 )
v21 = (v15 | 7) + 1;
elems = (char *)operator new(v21);
__dst.m_data.m_long.longStorage = elems;
__dst.m_data.m_long.capacitym1 = v21 | 1;
__dst.m_data.m_long.size = v15;
}
else
{
__dst.m_data.m_short.sizex2 = 2 * v15;
elems = __dst.m_data.m_short.shortStorage.__elems_;
if ( !v15 )
{
__dst.m_data.m_short.shortStorage.__elems_[0] = 0;
if ( (*(_BYTE *)&v62.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_21;
goto LABEL_20;
}
}
memmove(elems, &data[v11], v15);
elems[v15] = 0;
if ( (*(_BYTE *)&v62.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_21:
*(std::string *)&v62.__r_.__value_.__l.0 = __dst;
v17 = *(double *)&__dst.m_data.m_long.capacitym1;
v5 = 0;
v18 = std::string::find(&v62, 125, 0);
if ( v18 == -1 )
goto LABEL_2;
v19 = &v62;
v20 = std::string::find(&v62, 44, v18);
if ( (_DWORD)v20 == -1 )
{
v5 = 0;
goto LABEL_2;
}
if ( (*(_BYTE *)&v62.__r_.__value_.__s.0 & 1) != 0 )
{
v22 = v62.__r_.__value_.__l.__data_;
v23 = v62.__r_.__value_.__l.__size_;
}
else
{
v23 = *(_BYTE *)&v62.__r_.__value_.__l.0 >> 1;
v22 = v62.__r_.__value_.__s.__data_;
}
if ( v23 >= (int)v20 )
v23 = (int)v20;
if ( v23 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v17);
v59 = (int)v20;
v61 = COERCE_DOUBLE((std::string *)((char *)&v62.__r_.__value_.__l.0 + 1));
if ( v23 >= 0x17 )
{
v25 = 26;
if ( (v23 | 7) != 0x17 )
v25 = (v23 | 7) + 1;
v24 = (char *)operator new(v25);
__dst.m_data.m_long.longStorage = v24;
__dst.m_data.m_long.capacitym1 = v25 | 1;
__dst.m_data.m_long.size = v23;
}
else
{
__dst.m_data.m_short.sizex2 = 2 * v23;
v24 = __dst.m_data.m_short.shortStorage.__elems_;
if ( !v23 )
{
LABEL_42:
v24[v23] = 0;
v26 = (__int64)((__int64)&_mh_execute_header + (v20 << 32)) >> 32;
if ( (*(_BYTE *)&v62.__r_.__value_.__s.0 & 1) != 0 )
{
v27 = v62.__r_.__value_.__l.__size_;
v28 = v59;
if ( v62.__r_.__value_.__l.__size_ < v26 )
goto LABEL_96;
v61 = *(double *)&v62.__r_.__value_.__l.__data_;
}
else
{
v27 = *(_BYTE *)&v62.__r_.__value_.__l.0 >> 1;
v28 = v59;
if ( v26 > v27 )
LABEL_96:
sub_1000547C0();
}
v29 = v27 - v28;
v30 = v27 - v26;
if ( v30 >= v29 )
v30 = v29;
if ( v30 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v17);
if ( v30 >= 0x17 )
{
v33 = 26;
if ( (v30 | 7) != 0x17 )
v33 = (v30 | 7) + 1;
v31 = (char *)operator new(v33);
v57.m_data.m_long.longStorage = v31;
v57.m_data.m_long.capacitym1 = v33 | 1;
v57.m_data.m_long.size = v30;
v32 = v61;
}
else
{
v57.m_data.m_short.sizex2 = 2 * v30;
v31 = v57.m_data.m_short.shortStorage.__elems_;
v32 = v61;
if ( !v30 )
goto LABEL_57;
}
v19 = (std::string *)v31;
memmove(v31, (const void *)(v26 + *(_QWORD *)&v32), v30);
LABEL_57:
v31[v30] = 0;
memset(&v55, 0, sizeof(v55));
v34 = v54;
if ( DS_Dictionary::splitWithForm((DS_Dictionary *)v19, &__dst, &v55) )
{
memset(&__p, 0, sizeof(__p));
LOBYTE(v35) = DS_Dictionary::splitWithForm((DS_Dictionary *)v19, &v57, &__p);
v5 = v35;
if ( (_BYTE)v35 )
{
begin = v55.__begin_;
if ( (v55.__begin_->m_data.m_short.sizex2 & 1) != 0 )
longStorage = (std::array *)v55.__begin_->m_data.m_long.longStorage;
else
longStorage = &v55.__begin_->m_data.m_short.shortStorage;
v61 = atof(longStorage->__elems_);
if ( (begin[1].m_data.m_short.sizex2 & 1) != 0 )
v38 = begin[1].m_data.m_long.longStorage;
else
v38 = begin[1].m_data.m_short.shortStorage.__elems_;
v39 = atof(v38);
v40 = __p.__begin_;
if ( (__p.__begin_->m_data.m_short.sizex2 & 1) != 0 )
p_shortStorage = (std::array *)__p.__begin_->m_data.m_long.longStorage;
else
p_shortStorage = &__p.__begin_->m_data.m_short.shortStorage;
v42 = v61;
*(float *)&v61 = v42;
v43 = v39;
*(float *)&v59 = v43;
v44 = atof(p_shortStorage->__elems_);
v58 = v44;
if ( (v40[1].m_data.m_short.sizex2 & 1) != 0 )
v45 = v40[1].m_data.m_long.longStorage;
else
v45 = v40[1].m_data.m_short.shortStorage.__elems_;
v46 = atof(v45);
sub_10028CC00(
v53,
COERCE_DOUBLE((unsigned __int64)LODWORD(v61)),
COERCE_DOUBLE((unsigned __int64)(unsigned int)v59),
v58,
v46);
sub_10028D1A0(v34, v53);
}
v47 = __p.__begin_;
if ( __p.__begin_ )
{
end = __p.__end_;
v49 = __p.__begin_;
if ( __p.__end_ != __p.__begin_ )
{
do
{
if ( (end[-1].m_data.m_short.sizex2 & 1) != 0 )
operator delete(end[-1].m_data.m_long.longStorage);
--end;
}
while ( end != v47 );
v49 = __p.__begin_;
}
__p.__end_ = v47;
operator delete(v49);
}
}
else
{
v5 = 0;
}
v50 = v55.__begin_;
if ( v55.__begin_ )
{
v51 = v55.__end_;
v52 = v55.__begin_;
if ( v55.__end_ != v55.__begin_ )
{
do
{
if ( (v51[-1].m_data.m_short.sizex2 & 1) != 0 )
operator delete(v51[-1].m_data.m_long.longStorage);
--v51;
}
while ( v51 != v50 );
v52 = v55.__begin_;
}
v55.__end_ = v50;
operator delete(v52);
}
if ( (v57.m_data.m_short.sizex2 & 1) != 0 )
operator delete(v57.m_data.m_long.longStorage);
if ( (__dst.m_data.m_short.sizex2 & 1) != 0 )
operator delete(__dst.m_data.m_long.longStorage);
goto LABEL_2;
}
}
v19 = (std::string *)v24;
memmove(v24, v22, v23);
goto LABEL_42;
}
LABEL_20:
operator delete(v62.__r_.__value_.__l.__data_);
goto LABEL_21;
}
}
else
{
size = *(_BYTE *)&v62.__r_.__value_.__l.0 >> 1;
if ( v11 <= size )
{
data = v62.__r_.__value_.__s.__data_;
goto LABEL_14;
}
}
sub_1000547C0();
}
}
LABEL_2:
if ( (*(_BYTE *)&v62.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v62.__r_.__value_.__l.__data_);
return v5;
}