//
// GameToolbox::stringSetupToMap from 0x1004ed450 to 0x1004ed74e (766 bytes)
//
// 5 xrefs:
// > GJBaseGameLayer::parseRecording @ 0x100135730
// > ColorAction::setupFromString @ 0x1002c648c
// > GJEffectManager::loadPersistentStateString @ 0x1002d6616
// > GJEffectManager::loadPersistentStateString @ 0x1002d6790
// > GJEffectManager::setupFromString @ 0x1002d94a5
//
// 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 12:31:22 +0000
//
void __fastcall GameToolbox::stringSetupToMap(unsigned __int8 *a1, const char *a2, __int64 a3)
{
unsigned __int64 v4; // r12
unsigned __int64 v5; // rbx
unsigned __int8 *v6; // r15
size_t v7; // rax
__int64 v8; // rcx
unsigned __int8 *v9; // rcx
unsigned __int8 *v10; // rdx
__int64 v11; // rdi
bool v12; // zf
unsigned __int64 v13; // r13
__int64 v14; // rdx
__int64 v15; // r13
std::string::size_type v16; // rbx
char *data; // r12
size_t v18; // r15
std::string *v19; // rax
unsigned __int64 v20; // r12
unsigned __int8 *v21; // r15
size_t v22; // rax
unsigned __int8 *v23; // rcx
unsigned __int8 *v24; // r12
__int64 v25; // rsi
std::string *v26; // [rsp+0h] [rbp-A0h] BYREF
__int64 v27; // [rsp+8h] [rbp-98h]
unsigned __int8 *v28; // [rsp+10h] [rbp-90h]
__int64 v29; // [rsp+18h] [rbp-88h]
unsigned __int8 *v30; // [rsp+20h] [rbp-80h]
std::string __dst; // [rsp+28h] [rbp-78h] BYREF
std::string v32; // [rsp+40h] [rbp-60h] BYREF
unsigned __int8 *v33; // [rsp+58h] [rbp-48h]
int v34; // [rsp+64h] [rbp-3Ch]
__int64 v35; // [rsp+68h] [rbp-38h]
char v36; // [rsp+76h] [rbp-2Ah] BYREF
char v37; // [rsp+77h] [rbp-29h]
v29 = a3;
v4 = *a1 >> 1;
v34 = *a1;
v5 = *((_QWORD *)a1 + 1);
v28 = a1;
v6 = *((unsigned __int8 **)a1 + 2);
v33 = v6;
v30 = a1 + 1;
if ( (v34 & 1) != 0 )
v4 = v5;
else
v6 = a1 + 1;
v7 = strlen(a2);
v8 = -1;
if ( v4 != 0 && v7 != 0 )
{
v9 = &v6[v4];
v10 = v6;
LABEL_6:
v11 = 0;
while ( *v10 != a2[v11] )
{
if ( v7 == ++v11 )
{
if ( ++v10 != v9 )
goto LABEL_6;
v10 = &v6[v4];
break;
}
}
v12 = v10 == v9;
v8 = -1;
if ( !v12 )
v8 = v10 - v6;
}
v35 = v8;
memset(&v32, 0, sizeof(v32));
v27 = (int)v4;
v37 = 1;
v13 = 0;
while ( v13 == v27 )
{
v15 = v35;
if ( v35 == -1 )
goto LABEL_54;
LABEL_44:
v13 = v15 + 1;
v20 = *v28 >> 1;
v34 = *v28;
v5 = *((_QWORD *)v28 + 1);
v21 = *((unsigned __int8 **)v28 + 2);
v33 = v21;
if ( (v34 & 1) != 0 )
v20 = v5;
else
v21 = v30;
v22 = strlen(a2);
v35 = -1;
if ( v20 > v13 && v22 != 0 )
{
v23 = &v21[v13];
v24 = &v21[v20];
LABEL_49:
v25 = 0;
while ( *v23 != a2[v25] )
{
if ( v22 == ++v25 )
{
if ( ++v23 != v24 )
goto LABEL_49;
v23 = v24;
break;
}
}
v14 = v23 - v21;
if ( v23 == v24 )
v14 = -1;
v35 = v14;
}
}
if ( (v34 & 1) != 0 )
{
if ( v5 < v13 )
LABEL_58:
sub_100056810();
}
else
{
v5 = (unsigned __int8)v34 >> 1;
v33 = v30;
if ( v13 > v5 )
goto LABEL_58;
}
v16 = v5 - v13;
if ( v16 >= v35 - v13 )
v16 = v35 - v13;
if ( v16 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( v16 >= 0x17 )
{
v18 = (v16 | 7) + 1;
if ( (v16 | 7) == 0x17 )
v18 = 26;
data = (char *)operator new(v18);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst.__r_.__value_.__r.__words[0] = v18 | 1;
__dst.__r_.__value_.__l.__size_ = v16;
goto LABEL_33;
}
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v16);
data = __dst.__r_.__value_.__s.__data_;
if ( v16 )
LABEL_33:
memmove(data, &v33[v13], v16);
data[v16] = 0;
v19 = &v32;
v15 = v35;
if ( (v37 & 1) != 0 )
{
LABEL_40:
std::string::operator=(v19, &__dst);
goto LABEL_41;
}
if ( (*(_BYTE *)&v32.__r_.__value_.__s.0 & 1) == 0 )
{
if ( !(*(_BYTE *)&v32.__r_.__value_.__l.0 >> 1) )
goto LABEL_41;
goto LABEL_39;
}
if ( v32.__r_.__value_.__l.__size_ )
{
LABEL_39:
v26 = &v32;
v19 = (std::string *)(sub_1004F6BB0(v29, &v32, &unk_100A0C46F, &v26, &v36) + 56);
goto LABEL_40;
}
LABEL_41:
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
v37 ^= 1u;
if ( v15 != -1 )
goto LABEL_44;
LABEL_54:
if ( (*(_BYTE *)&v32.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v32.__r_.__value_.__l.__data_);
}