//
// sub_1000D8E20 from 0x1000d8e20 to 0x1000d90c2 (674 bytes)
//
// 5 xrefs:
// > LevelSettingsObject::getSaveString @ 0x1000b93d3
// > SFXFolderObject::init @ 0x1000d94c3
// > LevelSettingsObject::objectFromDict @ 0x1000db641
// > IDNameBrowserPopup::onFormAdd @ 0x10090b057
// > sub_10090C4C0 @ 0x10090c62a
//
// 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:20:57 +0000
//
std::string *__fastcall sub_1000D8E20(std::string *a1, unsigned __int8 *a2)
{
unsigned int v3; // esi
std::string::size_type v4; // rsi
unsigned int v5; // ecx
bool v6; // al
unsigned __int64 v7; // rbx
unsigned __int8 *v8; // rcx
unsigned __int8 *v9; // rax
unsigned int v10; // ecx
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v11; // al
std::string::pointer data; // r14
std::string::pointer v13; // rsi
std::string::size_type size; // rcx
std::string *v15; // rbx
std::string::size_type v16; // rdx
std::string::size_type v17; // rax
char v18; // dl
std::string::size_type v19; // rcx
std::string::size_type v20; // rsi
std::string::pointer v21; // rdi
std::string::size_type v22; // rax
std::string::size_type v23; // rsi
std::string::size_type v25; // rcx
__int64 v26; // rdx
std::string v28; // [rsp+10h] [rbp-40h] BYREF
if ( !(_BYTE)byte_100BE11E0 && __cxa_guard_acquire(&byte_100BE11E0) )
{
sub_10000E4E0(&obj, "0123456789 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.");
__cxa_atexit((void (__fastcall *)(void *))&std::string::~string, &obj, (void *)&_mh_execute_header);
__cxa_guard_release(&byte_100BE11E0);
}
memset(&v28, 0, sizeof(v28));
v3 = *a2;
if ( (v3 & 1) != 0 )
v4 = *((_QWORD *)a2 + 1);
else
v4 = v3 >> 1;
std::string::reserve(&v28, v4);
v5 = *a2;
v6 = (v5 & 1) == 0;
if ( (v5 & 1) != 0 )
{
if ( !*((_QWORD *)a2 + 1) )
goto LABEL_19;
}
else if ( !(v5 >> 1) )
{
goto LABEL_19;
}
v7 = 0;
do
{
while ( 1 )
{
v8 = a2 + 1;
if ( !v6 )
v8 = *((unsigned __int8 **)a2 + 2);
if ( std::string::find(&obj, v8[v7], 0) != -1 )
{
v9 = a2 + 1;
if ( (*a2 & 1) != 0 )
v9 = *((unsigned __int8 **)a2 + 2);
std::string::push_back(&v28, v9[v7]);
}
v10 = *a2;
v6 = (v10 & 1) == 0;
if ( (v10 & 1) == 0 )
break;
if ( ++v7 >= *((_QWORD *)a2 + 1) )
goto LABEL_19;
}
++v7;
}
while ( v7 < v10 >> 1 );
LABEL_19:
v11 = v28.__r_.__value_.__s.0;
data = v28.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
{
v13 = v28.__r_.__value_.__l.__data_;
size = v28.__r_.__value_.__l.__size_;
v15 = a1;
if ( !v28.__r_.__value_.__l.__size_ )
goto LABEL_48;
}
else
{
size = *(_BYTE *)&v28.__r_.__value_.__l.0 >> 1;
v13 = v28.__r_.__value_.__s.__data_;
v15 = a1;
if ( !(*(_BYTE *)&v28.__r_.__value_.__l.0 >> 1) )
goto LABEL_48;
}
v16 = 0;
while ( v13[v16] == 32 )
{
if ( size == ++v16 )
goto LABEL_48;
}
if ( v16 == -1 )
goto LABEL_48;
std::string::erase(&v28, 0, v16);
v17 = *(_BYTE *)&v28.__r_.__value_.__l.0 >> 1;
v18 = *(_BYTE *)&v28.__r_.__value_.__s.0 & 1;
v19 = v28.__r_.__value_.__l.__size_;
v20 = v28.__r_.__value_.__l.__size_;
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) == 0 )
v20 = *(_BYTE *)&v28.__r_.__value_.__l.0 >> 1;
if ( v20 >= 0x19 )
{
std::string::resize(&v28, 0x18u, 0);
v19 = v28.__r_.__value_.__l.__size_;
v18 = *(_BYTE *)&v28.__r_.__value_.__s.0 & 1;
v17 = *(_BYTE *)&v28.__r_.__value_.__l.0 >> 1;
}
v21 = v28.__r_.__value_.__s.__data_;
if ( v18 )
{
v21 = v28.__r_.__value_.__l.__data_;
v17 = v19;
}
v22 = v17 + 1;
while ( v22 != 1 )
{
v23 = v22 - 1;
if ( v21[v22-- - 2] != 32 )
goto LABEL_39;
}
v23 = 0;
LABEL_39:
std::string::erase(&v28, v23, 0xFFFFFFFFFFFFFFFFLL);
v11 = v28.__r_.__value_.__s.0;
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
{
v25 = v28.__r_.__value_.__l.__size_;
if ( !v28.__r_.__value_.__l.__size_ )
{
LABEL_48:
*(_WORD *)&v15->__r_.__value_.__l.0 = 0;
if ( (*(_BYTE *)&v11 & 1) != 0 )
operator delete(v28.__r_.__value_.__l.__data_);
return v15;
}
}
else
{
v25 = *(_BYTE *)&v28.__r_.__value_.__l.0 >> 1;
if ( !(*(_BYTE *)&v28.__r_.__value_.__l.0 >> 1) )
goto LABEL_48;
}
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
data = v28.__r_.__value_.__l.__data_;
v26 = 0;
while ( (unsigned __int8)((data[v26] & 0xDF) - 65) > 0x19u )
{
if ( v25 == ++v26 )
goto LABEL_48;
}
*v15 = v28;
return v15;
}