//
// GameToolbox::stringSetupToMap from 0x1400658c0 to 0x140065c58 (920 bytes)
//
// 2 xrefs:
// > ColorAction::setupFromString @ 0x140259ad5
// > ??> @ 0x1406c5dcc
//
// 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=4
void GameToolbox::stringSetupToMap(
std::string *const m_bigStorage,
const char *a2,
std::map *a3)
{
std::string *v4; // r15
unsigned __int64 v5; // rbx
std::size_t m_capacity; // rsi
unsigned __int64 m_size; // rdi
__int64 v8; // rcx
__int64 v9; // r13
__int64 v10; // rax
size_t v11; // r8
size_t v12; // rdi
std::string *v13; // rax
bool v14; // bl
void **v15; // rdx
size_t v16; // rsi
__int64 Myhead; // r14
std::_Tree_node, void *>::_Nodeptr Parent; // rbx
void **v19; // rdx
std::_Tree_node, void *>::value_type *p_Myval; // rcx
std::size_t v21; // rdi
size_t v22; // r8
__int64 v23; // rax
const void *v24; // rdx
void **v25; // rcx
size_t v26; // rbx
size_t v27; // r8
__int64 v28; // rax
std::_Tree_val>>::_Nodeptr v29; // rdi
_OWORD *v30; // rsi
void **v31; // rdx
void *v32; // rcx
__int64 v33; // rcx
void *v34; // rcx
bool v35; // [rsp+30h] [rbp-69h]
__int64 i; // [rsp+38h] [rbp-61h]
std::_Tree_node, void *>::_Nodeptr v37; // [rsp+40h] [rbp-59h] BYREF
int v38; // [rsp+48h] [rbp-51h]
std::map *v39; // [rsp+60h] [rbp-39h]
_OWORD *v40; // [rsp+68h] [rbp-31h]
void *Src[2]; // [rsp+70h] [rbp-29h] BYREF
size_t v42; // [rsp+80h] [rbp-19h]
unsigned __int64 v43; // [rsp+88h] [rbp-11h]
void *Buf2[2]; // [rsp+90h] [rbp-9h] BYREF
size_t Size; // [rsp+A0h] [rbp+7h]
unsigned __int64 v46; // [rsp+A8h] [rbp+Fh]
v4 = m_bigStorage;
v5 = 0;
m_capacity = m_bigStorage->m_data.m_capacity;
if ( m_capacity > 0xF )
m_bigStorage = (std::string *const)m_bigStorage->m_data.m_bigStorage;
m_size = v4->m_data.m_size;
v9 = sub_140042190((__int64)m_bigStorage, m_size, 0, "_", 1);
*(_OWORD *)Buf2 = 0;
Size = 0;
v46 = 15;
LOBYTE(Buf2[0]) = 0;
v35 = 1;
v10 = (int)m_size;
for ( i = (int)m_size; ; v10 = i )
{
if ( v5 != v10 )
{
*(_OWORD *)Src = 0;
v42 = 0;
v43 = 0;
if ( m_size < v5 )
sub_14003BCC0(v8);
v11 = v9 - v5;
v12 = m_size - v5;
if ( v12 < v9 - v5 )
v11 = v12;
v13 = v4;
if ( m_capacity > 0xF )
v13 = (std::string *)v4->m_data.m_bigStorage;
sub_14003A930(Src, &v13->m_data.m_smallStorage._Elems[v5], v11);
v14 = v35;
if ( v35 )
{
v15 = Src;
if ( v43 > 0xF )
v15 = (void **)Src[0];
sub_14003CCE0(Buf2, v15, v42);
}
else
{
v16 = Size;
if ( Size )
{
Myhead = (__int64)a3->_Mypair._Myval2._Myval2._Myhead;
Parent = a3->_Mypair._Myval2._Myval2._Myhead->_Parent;
v37 = Parent;
v38 = 0;
while ( !Parent->_Isnil )
{
v37 = Parent;
v19 = Buf2;
if ( v46 > 0xF )
v19 = (void **)Buf2[0];
p_Myval = &Parent->_Myval;
if ( Parent->_Myval.first.m_data.m_capacity > 0xF )
p_Myval = (std::_Tree_node, void *>::value_type *)Parent->_Myval.first.m_data.m_bigStorage;
v21 = Parent->_Myval.first.m_data.m_size;
v22 = v21;
if ( v16 < v21 )
v22 = v16;
LODWORD(v23) = memcmp(p_Myval, v19, v22);
if ( !(_DWORD)v23 )
{
if ( v21 >= v16 )
v23 = v21 > v16;
else
LODWORD(v23) = -1;
}
if ( (int)v23 >= 0 )
{
v38 = 1;
Myhead = (__int64)Parent;
Parent = Parent->_Left;
}
else
{
v38 = 0;
Parent = Parent->_Right;
}
}
if ( *(_BYTE *)(Myhead + 25) )
goto LABEL_42;
v24 = (const void *)(Myhead + 32);
if ( *(_QWORD *)(Myhead + 56) > 0xFu )
v24 = *(const void **)(Myhead + 32);
v25 = Buf2;
if ( v46 > 0xF )
v25 = (void **)Buf2[0];
v26 = *(_QWORD *)(Myhead + 48);
v27 = v16;
if ( v26 < v16 )
v27 = *(_QWORD *)(Myhead + 48);
LODWORD(v28) = memcmp(v25, v24, v27);
if ( !(_DWORD)v28 )
{
if ( v16 >= v26 )
v28 = v16 > v26;
else
LODWORD(v28) = -1;
}
if ( (int)v28 < 0 )
{
LABEL_42:
if ( a3->_Mypair._Myval2._Myval2._Mysize == 0x2AAAAAAAAAAAAAALL )
sub_140052E40();
v29 = a3->_Mypair._Myval2._Myval2._Myhead;
v39 = a3;
v40 = nullptr;
v30 = operator new(0x60u);
v40 = v30;
sub_14003BDB0((__int64)(v30 + 2), (__int64)Buf2);
v30[4] = 0;
*((_QWORD *)v30 + 10) = 0;
*((_QWORD *)v30 + 11) = 15;
*((_BYTE *)v30 + 64) = 0;
*(_QWORD *)v30 = v29;
*((_QWORD *)v30 + 1) = v29;
*((_QWORD *)v30 + 2) = v29;
*((_WORD *)v30 + 12) = 0;
v40 = nullptr;
Myhead = sub_1400636D0(a3, (__int64)&v37, (__int64)v30);
}
if ( (void **)(Myhead + 64) != Src )
{
v31 = Src;
if ( v43 > 0xF )
v31 = (void **)Src[0];
sub_14003CCE0((void **)(Myhead + 64), v31, v42);
}
v14 = 0;
}
}
v35 = !v14;
if ( v43 > 0xF )
{
v32 = Src[0];
if ( v43 + 1 >= 0x1000 )
{
v32 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v32 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v32);
}
}
if ( v9 == -1 )
break;
v5 = v9 + 1;
v33 = (__int64)v4;
m_capacity = v4->m_data.m_capacity;
if ( m_capacity > 0xF )
v33 = (__int64)v4->m_data.m_bigStorage;
m_size = v4->m_data.m_size;
v9 = sub_140042190(v33, m_size, v9 + 1, "_", 1);
}
if ( v46 > 0xF )
{
v34 = Buf2[0];
if ( v46 + 1 >= 0x1000 )
{
v34 = *((void **)Buf2[0] - 1);
if ( (unsigned __int64)((char *)Buf2[0] - (char *)v34 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v34);
}
}