//
// sub_1006CE910 from 0x1006ce910 to 0x1006cedb2 (1186 bytes)
//
// 2 xrefs:
// > sub_1006CE060 @ 0x1006ce146
// > sub_1006CE060 @ 0x1006ce34a
//
// 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:35:37 +0000
//
void __fastcall sub_1006CE910(size_t *a1, std::string *a2)
{
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v3; // cl
unsigned __int64 v4; // rdx
std::string::size_type size; // rsi
std::string::size_type v6; // rax
std::string::pointer data; // rax
unsigned __int8 *v8; // rcx
unsigned __int64 v9; // rsi
__int64 v10; // rdi
int v11; // r8d
unsigned __int64 v12; // r9
std::string::pointer v13; // r13
std::string::size_type v14; // r12
__int64 v15; // r14
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v16; // al
__int64 v17; // rcx
std::string::size_type v18; // rax
unsigned __int8 *v19; // rax
__int64 v20; // rdx
int v21; // esi
unsigned __int64 v22; // rdi
int v23; // esi
unsigned __int64 v24; // rdi
int v25; // esi
unsigned __int64 v26; // rdi
int v27; // esi
unsigned __int64 v28; // rdi
std::string::value_type *v29; // rcx
char v30; // r13
size_t v31; // r15
unsigned __int64 v32; // r14
void *v33; // rbx
std::string::pointer v34; // rsi
size_t v35; // r12
void *v36; // rax
std::string v37; // [rsp+0h] [rbp-60h] BYREF
std::string v38; // [rsp+20h] [rbp-40h] BYREF
if ( (*(_BYTE *)&a2->__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v37, a2->__r_.__value_.__l.__data_, a2->__r_.__value_.__l.__size_);
else
v37 = *a2;
v3 = v37.__r_.__value_.__s.0;
v4 = *(_BYTE *)&v37.__r_.__value_.__l.0 >> 1;
size = v37.__r_.__value_.__l.__size_;
v6 = v37.__r_.__value_.__l.__size_;
if ( (*(_BYTE *)&v37.__r_.__value_.__s.0 & 1) == 0 )
v6 = *(_BYTE *)&v37.__r_.__value_.__l.0 >> 1;
if ( !v6 )
{
std::string::assign(&v37, "level");
v3 = v37.__r_.__value_.__s.0;
size = v37.__r_.__value_.__l.__size_;
v4 = *(_BYTE *)&v37.__r_.__value_.__l.0 >> 1;
data = v37.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v37.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_9;
goto LABEL_8;
}
data = v37.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v37.__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_8:
data = v37.__r_.__value_.__l.__data_;
v4 = size;
}
LABEL_9:
if ( v4 )
{
v8 = (unsigned __int8 *)data;
v9 = v4 & 3;
if ( (v4 & 3) != 0 )
{
v10 = 0x400000035002101LL;
v8 = (unsigned __int8 *)data;
do
{
v11 = *v8;
v12 = (unsigned int)(v11 - 34);
if ( (unsigned int)v12 <= 0x3A && _bittest64(&v10, v12) || v11 == 124 )
*v8 = 95;
++v8;
--v9;
}
while ( v9 );
}
if ( v4 >= 4 )
{
v19 = (unsigned __int8 *)&data[v4];
v20 = 0x400000035002101LL;
do
{
v21 = *v8;
v22 = (unsigned int)(v21 - 34);
if ( (unsigned int)v22 <= 0x3A && _bittest64(&v20, v22) || v21 == 124 )
*v8 = 95;
v23 = v8[1];
v24 = (unsigned int)(v23 - 34);
if ( (unsigned int)v24 <= 0x3A && _bittest64(&v20, v24) || v23 == 124 )
v8[1] = 95;
v25 = v8[2];
v26 = (unsigned int)(v25 - 34);
if ( (unsigned int)v26 <= 0x3A && _bittest64(&v20, v26) || v25 == 124 )
v8[2] = 95;
v27 = v8[3];
v28 = (unsigned int)(v27 - 34);
if ( (unsigned int)v28 <= 0x3A && _bittest64(&v20, v28) || v27 == 124 )
v8[3] = 95;
v8 += 4;
}
while ( v8 != v19 );
}
v3 = v37.__r_.__value_.__s.0;
}
if ( (*(_BYTE *)&v3 & 1) != 0 )
sub_10001AD30(&v38, v37.__r_.__value_.__l.__data_, v37.__r_.__value_.__l.__size_);
else
v38 = v37;
if ( (*(_BYTE *)&v38.__r_.__value_.__s.0 & 1) != 0 )
{
v13 = v38.__r_.__value_.__l.__data_;
v14 = v38.__r_.__value_.__l.__size_;
if ( !v38.__r_.__value_.__l.__size_ )
goto LABEL_31;
}
else
{
v14 = *(_BYTE *)&v38.__r_.__value_.__l.0 >> 1;
v13 = v38.__r_.__value_.__s.__data_;
if ( !(*(_BYTE *)&v38.__r_.__value_.__l.0 >> 1) )
goto LABEL_31;
}
v15 = 0;
do
{
v13[v15] = __toupper((unsigned __int8)v13[v15]);
++v15;
}
while ( v14 != v15 );
while ( 1 )
{
LABEL_31:
v16 = v38.__r_.__value_.__s.0;
if ( (*(_BYTE *)&v38.__r_.__value_.__s.0 & 1) == 0 )
{
while ( 1 )
{
if ( !*(_BYTE *)&v16 )
{
v16 = 0;
LABEL_73:
v18 = *(unsigned __int8 *)&v16 >> 1;
goto LABEL_74;
}
if ( *((_BYTE *)&v38.__r_.__value_.__s.0 + (*(unsigned __int8 *)&v16 >> 1)) != 32 )
break;
v17 = (*(unsigned __int8 *)&v16 >> 1) - 1LL;
v38.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v17);
*((_BYTE *)&v38.__r_.__value_.__l.0 + v17 + 1) = 0;
v16 = v38.__r_.__value_.__s.0;
if ( (*(_BYTE *)&v38.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_35;
}
if ( v16 != 6 )
goto LABEL_73;
if ( *(_WORD *)((char *)&v38.__r_.__value_.__l.0 + 1) ^ 0x4F43
| (unsigned __int8)v38.__r_.__value_.__s.__data_[2] ^ 0x4E )
{
if ( *(_WORD *)((char *)&v38.__r_.__value_.__l.0 + 1) ^ 0x5250
| (unsigned __int8)v38.__r_.__value_.__s.__data_[2] ^ 0x4E )
{
if ( *(_WORD *)((char *)&v38.__r_.__value_.__l.0 + 1) ^ 0x5541
| (unsigned __int8)v38.__r_.__value_.__s.__data_[2] ^ 0x58 )
{
v16 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)6;
if ( *(_WORD *)((char *)&v38.__r_.__value_.__l.0 + 1) ^ 0x554E
| (unsigned __int8)v38.__r_.__value_.__s.__data_[2] ^ 0x4C )
{
goto LABEL_73;
}
}
}
}
goto LABEL_80;
}
LABEL_35:
v18 = v38.__r_.__value_.__l.__size_;
if ( !v38.__r_.__value_.__l.__size_ )
goto LABEL_81;
if ( *(_BYTE *)(v38.__r_.__value_.__r.__words[2] + v38.__r_.__value_.__l.__size_ - 1) != 32 )
break;
--v38.__r_.__value_.__l.__size_;
*(_BYTE *)(v38.__r_.__value_.__r.__words[2] + v38.__r_.__value_.__l.__size_) = 0;
}
if ( v38.__r_.__value_.__l.__size_ == 3
&& (!(*(_WORD *)v38.__r_.__value_.__l.__data_ ^ 0x4F43
| *(unsigned __int8 *)(v38.__r_.__value_.__r.__words[2] + 2) ^ 0x4E)
|| !(*(_WORD *)v38.__r_.__value_.__l.__data_ ^ 0x5250
| *(unsigned __int8 *)(v38.__r_.__value_.__r.__words[2] + 2) ^ 0x4E)
|| !(*(_WORD *)v38.__r_.__value_.__l.__data_ ^ 0x5541
| *(unsigned __int8 *)(v38.__r_.__value_.__r.__words[2] + 2) ^ 0x58)
|| !(*(_WORD *)v38.__r_.__value_.__l.__data_ ^ 0x554E
| *(unsigned __int8 *)(v38.__r_.__value_.__r.__words[2] + 2) ^ 0x4C)) )
{
LABEL_80:
std::string::insert(&v37, 0, "_");
goto LABEL_81;
}
LABEL_74:
if ( v18 == 4 && (!std::string::compare(&v38, 0, 3u, "COM") || !std::string::compare(&v38, 0, 3u, "LPT")) )
{
v29 = &v38.__r_.__value_.__s.__data_[3];
if ( (*(_BYTE *)&v38.__r_.__value_.__s.0 & 1) != 0 )
v29 = (std::string::value_type *)(v38.__r_.__value_.__r.__words[2] + 3);
if ( (_DefaultRuneLocale.__runetype[(unsigned __int8)*v29] & 0x400) != 0 )
goto LABEL_80;
}
LABEL_81:
v30 = *(_BYTE *)&v37.__r_.__value_.__s.0 & 1;
if ( (*(_BYTE *)&v37.__r_.__value_.__s.0 & 1) != 0 )
v31 = v37.__r_.__value_.__l.__size_;
else
v31 = *(_BYTE *)&v37.__r_.__value_.__l.0 >> 1;
v32 = v31 + 6;
if ( v31 + 6 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( v32 >= 0x17 )
{
v35 = 26;
if ( (v32 | 7) != 0x17 )
v35 = (v32 | 7) + 1;
v36 = operator new(v35);
*a1 = v35 | 1;
a1[2] = (size_t)v36;
a1[1] = v32;
v33 = v36;
v34 = v37.__r_.__value_.__s.__data_;
if ( !v30 )
goto LABEL_89;
goto LABEL_88;
}
*(_OWORD *)a1 = 0;
a1[2] = 0;
*(_BYTE *)a1 = 2 * v32;
v33 = (char *)a1 + 1;
if ( !v31 )
goto LABEL_90;
v34 = v37.__r_.__value_.__s.__data_;
if ( v30 )
LABEL_88:
v34 = v37.__r_.__value_.__l.__data_;
LABEL_89:
memmove(v33, v34, v31);
LABEL_90:
strcpy((char *)v33 + v31, ".gdlvl");
if ( (*(_BYTE *)&v38.__r_.__value_.__s.0 & 1) != 0 )
{
operator delete(v38.__r_.__value_.__l.__data_);
v30 = *(_BYTE *)&v37.__r_.__value_.__s.0 & 1;
}
if ( v30 )
operator delete(v37.__r_.__value_.__l.__data_);
}