//
// LevelSettingsObject::sanitizeIDName from 0x7973e4 to 0x7977a8 (964 bytes)
//
// 6 xrefs:
// > LevelSettingsObject::setIDName @ 0x7a29a8
// > LevelSettingsObject::getSaveString @ 0x7a6348
// > LevelSettingsObject::objectFromDict @ 0x7ab064
// > IDNameBrowserPopup::updateConflictLabel @ 0xcde288
// > IDNameBrowserPopup::onFormAdd @ 0xce3c94
// > ??> @ 0xe4b50
//
// 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 12:53:34 +0000
//
__int64 *__usercall LevelSettingsObject::sanitizeIDName@(char *a1@, __int64 *a2@)
{
unsigned __int8 v4; // w1
unsigned __int8 v5; // w0
unsigned __int64 v6; // x1
unsigned __int8 v7; // w26
unsigned __int64 v8; // x19
unsigned __int8 v9; // w27
int v10; // w24
unsigned __int8 v11; // w2
int v12; // w1
size_t v13; // x2
char *v14; // x28
_BYTE *v15; // x0
char *v16; // x0
_BYTE *v17; // x2
unsigned __int64 v18; // x1
_BYTE *v19; // x1
_BYTE *v20; // x0
__int64 v22; // x0
char *v23; // x1
char *v24; // x0
int v25; // w2
char *v26; // x0
int v27; // t1
unsigned __int64 v28; // x1
unsigned __int64 v29; // x1
unsigned __int64 v30; // x1
unsigned __int64 v31; // x2
__int64 v32; // [xsp+60h] [xbp+60h] BYREF
unsigned __int64 v33; // [xsp+68h] [xbp+68h]
void *v34; // [xsp+70h] [xbp+70h]
__int64 v35; // [xsp+78h] [xbp+78h]
v4 = atomic_load((unsigned __int8 *)&byte_155C710);
if ( (v4 & 1) == 0 && _cxa_guard_acquire((__guard *)&byte_155C710) )
{
qword_155C6F8 = 0;
qword_155C700 = 0;
qword_155C708 = 0;
std::string::__init(&qword_155C6F8, "0123456789 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.", 0x41u);
_cxa_guard_release((__guard *)&byte_155C710);
__cxa_atexit((void (*)(void *))std::string::~string, &qword_155C6F8, &unk_1548000);
}
v5 = *a1;
v32 = 0;
v33 = 0;
v6 = v5 >> 1;
v34 = nullptr;
if ( (v5 & 1) != 0 )
v6 = *((_QWORD *)a1 + 1);
std::string::reserve(&v32, v6);
v7 = *a1;
v8 = 0;
v9 = *a1 & 1;
v10 = v9;
if ( !v9 )
goto LABEL_10;
LABEL_5:
if ( v8 < *((_QWORD *)a1 + 1) )
{
v11 = qword_155C6F8;
v12 = *(unsigned __int8 *)(*((_QWORD *)a1 + 2) + v8);
if ( (qword_155C6F8 & 1) != 0 )
{
LABEL_7:
v13 = qword_155C700;
v14 = (char *)qword_155C708;
if ( qword_155C700 )
goto LABEL_13;
}
else
{
while ( 1 )
{
v13 = v11 >> 1;
v14 = (char *)&qword_155C6F8 + 1;
if ( !v13 )
break;
LABEL_13:
v15 = memchr(v14, v12, v13);
if ( !v15 || v15 - v14 == -1 )
break;
v16 = a1 + 1;
if ( v10 )
v16 = *((char **)a1 + 2);
std::string::push_back(&v32, v16[v8]);
v7 = *a1;
++v8;
v9 = *a1 & 1;
LABEL_9:
v10 = v9;
if ( v9 )
goto LABEL_5;
LABEL_10:
if ( v8 >= v7 >> 1 )
goto LABEL_18;
v11 = qword_155C6F8;
v12 = (unsigned __int8)a1[v8 + 1];
if ( (qword_155C6F8 & 1) != 0 )
goto LABEL_7;
}
}
++v8;
goto LABEL_9;
}
LABEL_18:
if ( (v32 & 1) != 0 )
{
v17 = v34;
v18 = v33;
}
else
{
v18 = (unsigned __int8)v32 >> 1;
v17 = (char *)&v32 + 1;
}
if ( v18 )
{
v19 = &v17[v18];
if ( v19 != v17 )
{
v20 = v17;
if ( *v17 != 32 )
{
v31 = 0;
LABEL_34:
std::string::erase((char *)&v32, 0, v31);
if ( (v32 & 1) != 0 )
{
v22 = v33;
if ( v33 > 0x18 )
{
v22 = 24;
v33 = 24;
*((_BYTE *)v34 + 24) = 0;
}
v23 = (char *)v34;
}
else
{
LODWORD(v22) = (int)(unsigned __int8)v32 >> 1;
if ( (int)v22 > 24 )
{
BYTE1(v35) = 0;
LOBYTE(v32) = 48;
v23 = (char *)&v32 + 1;
v22 = 24;
}
else
{
v22 = (int)v22;
v23 = (char *)&v32 + 1;
}
}
v24 = &v23[v22];
if ( v24 != v23 )
{
v25 = (unsigned __int8)*(v24 - 1);
v26 = v24 - 1;
if ( v25 != 32 )
{
LABEL_53:
v28 = v26 - v23 + 1;
goto LABEL_44;
}
while ( v26 != v23 )
{
v27 = (unsigned __int8)*--v26;
if ( v27 != 32 )
goto LABEL_53;
}
}
v28 = 0;
LABEL_44:
std::string::erase((char *)&v32, v28, 0xFFFFFFFFFFFFFFFFLL);
v29 = 0;
if ( (v32 & 1) == 0 )
goto LABEL_48;
while ( v29 < v33 )
{
if ( (unsigned __int8)((*((_BYTE *)v34 + v29) & 0xDF) - 65) <= 0x19u )
{
LABEL_50:
a2[2] = (__int64)v34;
v30 = v33;
*a2 = v32;
a2[1] = v30;
v32 = 0;
v33 = 0;
v34 = nullptr;
goto LABEL_27;
}
while ( 1 )
{
++v29;
if ( (v32 & 1) != 0 )
break;
LABEL_48:
if ( v29 >= (unsigned __int8)v32 >> 1 )
goto LABEL_26;
if ( (unsigned __int8)((*((_BYTE *)&v32 + v29 + 1) & 0xDF) - 65) <= 0x19u )
goto LABEL_50;
}
}
goto LABEL_26;
}
while ( v19 != ++v20 )
{
if ( *v20 != 32 )
{
v31 = v20 - v17;
if ( v31 == -1 )
break;
goto LABEL_34;
}
}
}
}
LABEL_26:
*a2 = 0;
a2[1] = 0;
a2[2] = 0;
std::string::__init(a2, &byte_11B8890, 0);
LABEL_27:
if ( (v32 & 1) != 0 )
operator delete(v34);
return a2;
}