//
// sub_10040DA6C from 0x10040da6c to 0x10040dcf8 (652 bytes)
//
// 5 xrefs:
// > sub_1003FC928 @ 0x1003fdabc
// > sub_10040DE3C @ 0x10040de5c
// > LevelSettingsObject::objectFromDict @ 0x10040f204
// > sub_1004E0E28 @ 0x1004e0eec
// > sub_1004E2024 @ 0x1004e20f4
//
// This function is hookable on this platform (idp: arm, 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 11:04:47 +0000
//
void __usercall sub_10040DA6C(__int64 *a1@, std::string *a2@)
{
unsigned __int8 v4; // w8
std::string::size_type v5; // x1
unsigned __int64 v6; // x8
__int64 v7; // x9
unsigned __int64 v8; // x22
unsigned __int64 v9; // x8
__int64 *v10; // x8
__int64 *v11; // x8
unsigned __int64 v12; // x9
unsigned __int128 v13; // kr00_16
std::string::size_type v14; // x2
std::string::size_type v15; // x8
char v16; // w10
std::string::size_type size; // x9
std::string::size_type v18; // x11
bool v19; // nf
std::string *v20; // x10
char *v21; // x9
int v22; // w10
std::string::size_type v23; // x1
std::string::size_type v24; // x8
std::string *v25; // x9
int v26; // t1
std::string v27; // [xsp+8h] [xbp-38h] BYREF
v4 = atomic_load((unsigned __int8 *)&byte_1009F7270);
if ( (v4 & 1) == 0 && __cxa_guard_acquire((__guard *)&byte_1009F7270) )
{
sub_100009900(&stru_1009F7258, "0123456789 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.");
__cxa_atexit((void (__fastcall *)(void *))&std::string::~string, &stru_1009F7258, (void *)&_mh_execute_header);
__cxa_guard_release((__guard *)&byte_1009F7270);
}
memset(&v27, 0, sizeof(v27));
if ( *((char *)a1 + 23) >= 0 )
v5 = *((unsigned __int8 *)a1 + 23);
else
v5 = a1[1];
std::string::reserve(&v27, v5);
v6 = *((char *)a1 + 23);
v7 = a1[1];
if ( (v6 & 0x80000000) == 0LL )
v7 = *((char *)a1 + 23);
if ( v7 )
{
v8 = 0;
v9 = v6 >> 63;
do
{
if ( (v9 & 1) != 0 )
v10 = (__int64 *)*a1;
else
v10 = a1;
if ( std::string::find(&stru_1009F7258, *((_BYTE *)v10 + v8), 0) != -1 )
{
if ( *((char *)a1 + 23) >= 0 )
v11 = a1;
else
v11 = (__int64 *)*a1;
std::string::push_back(&v27, *((_BYTE *)v11 + v8));
}
++v8;
v12 = *((char *)a1 + 23);
v9 = v12 >> 63;
if ( (v12 & 0x80000000) != 0LL )
v12 = a1[1];
}
while ( v8 < v12 );
}
v13 = __PAIR128__(HIBYTE(v27.__r_.__value_.__r.__words[2]), &v27);
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v13 = *(_OWORD *)&v27.__r_.__value_.__l.__data_;
if ( !*((_QWORD *)&v13 + 1) )
goto LABEL_47;
v14 = 0;
while ( *(_BYTE *)(v13 + v14) == 32 )
{
if ( *((_QWORD *)&v13 + 1) == ++v14 )
goto LABEL_47;
}
if ( v14 == -1 )
goto LABEL_47;
std::string::erase(&v27, 0, v14);
v15 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
v16 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
size = v27.__r_.__value_.__l.__size_;
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v18 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
else
v18 = v27.__r_.__value_.__l.__size_;
if ( v18 >= 0x19 )
{
std::string::resize(&v27, 0x18u, 0);
v15 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
size = v27.__r_.__value_.__l.__size_;
v16 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
}
v19 = v16 < 0;
v20 = &v27;
if ( v19 )
{
v20 = (std::string *)v27.__r_.__value_.__r.__words[0];
v15 = size;
}
v21 = (char *)&v20[-1].__r_.__value_.__r.__words[2] + 7;
while ( v15 )
{
v22 = (unsigned __int8)v21[v15--];
if ( v22 != 32 )
{
v23 = v15 + 1;
goto LABEL_40;
}
}
v23 = 0;
LABEL_40:
std::string::erase(&v27, v23, 0xFFFFFFFFFFFFFFFFLL);
v24 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v24 = v27.__r_.__value_.__l.__size_;
if ( v24 )
{
v25 = &v27;
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v25 = (std::string *)v27.__r_.__value_.__r.__words[0];
while ( 1 )
{
v26 = (unsigned __int8)v25->__r_.__value_.__s.__data_[0];
v25 = (std::string *)((char *)v25 + 1);
if ( (v26 & 0xFFFFFFDF) - 65 <= 0x19 )
break;
if ( !--v24 )
goto LABEL_47;
}
*a2 = v27;
memset(&v27, 0, sizeof(v27));
}
else
{
LABEL_47:
sub_100009900(a2, "");
}
if ( SHIBYTE(v27.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v27.__r_.__value_.__l.__data_);
}