//
// LevelSettingsObject::sanitizeIDName from 0x468c0c to 0x468e10 (516 bytes)
//
// 5 xrefs:
// > LevelSettingsObject::setIDName @ 0x46f7f2
// > LevelSettingsObject::getSaveString @ 0x471cc8
// > LevelSettingsObject::objectFromDict @ 0x47498c
// > IDNameBrowserPopup::updateConflictLabel @ 0x78fc42
// > IDNameBrowserPopup::onFormAdd @ 0x7934d0
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:48:58 +0000
//
int *__fastcall LevelSettingsObject::sanitizeIDName(int *a1, unsigned __int8 *a2, char *a3, int a4)
{
char v6; // r3
signed int v7; // r1
bool v8; // nf
unsigned int i; // r8
unsigned int v10; // r3
int v11; // r10
unsigned __int8 *v12; // r3
unsigned __int8 *v13; // r3
unsigned __int8 *v14; // r1
int v15; // r3
unsigned __int8 *v16; // r3
unsigned __int8 *v17; // r0
unsigned __int8 *v18; // r2
int v19; // r7
unsigned int v20; // r2
int *v21; // r0
char *v22; // r1
int v23; // r3
char *v24; // r3
int v25; // t1
int v26; // r1
unsigned int j; // r3
char *v28; // r2
int v30; // r0
unsigned int v31; // r1
char *v32; // r2
int v33; // [sp+0h] [bp-10h] BYREF
unsigned int v34; // [sp+4h] [bp-Ch]
char *v35; // [sp+8h] [bp-8h]
int v36; // [sp+Ch] [bp-4h]
char vars9; // [sp+19h] [bp+9h]
v33 = (int)a1;
v34 = (unsigned int)a2;
v35 = a3;
v36 = a4;
v6 = byte_D2B8E8;
__dmb(0xFu);
if ( (v6 & 1) == 0 && _cxa_guard_acquire((__guard *)&byte_D2B8E8) )
{
dword_D2B8EC = 0;
dword_D2B8F0 = 0;
dword_D2B8F4 = 0;
std::string::__init(&dword_D2B8EC, "0123456789 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.", 0x41u);
_cxa_guard_release((__guard *)&byte_D2B8E8);
_aeabi_atexit();
}
v7 = *a2;
v33 = 0;
v8 = (v7 & 1) != 0;
v34 = 0;
if ( (v7 & 1) == 0 )
v7 >>= 1;
v35 = nullptr;
if ( v8 )
v7 = *((_DWORD *)a2 + 1);
std::string::reserve(&v33, v7);
for ( i = 0; ; ++i )
{
v10 = *a2;
v11 = v10 & 1;
if ( (v10 & 1) == 0 )
break;
if ( i >= *((_DWORD *)a2 + 1) )
goto LABEL_20;
v12 = *((unsigned __int8 **)a2 + 2);
LABEL_14:
if ( std::string::find((unsigned __int8 *)&dword_D2B8EC, v12[i], 0) != -1 )
{
if ( v11 )
v13 = *((unsigned __int8 **)a2 + 2);
else
v13 = a2 + 1;
std::string::push_back(&v33, v13[i]);
}
}
if ( i < v10 >> 1 )
{
v12 = a2 + 1;
goto LABEL_14;
}
LABEL_20:
if ( (v33 & 1) != 0 )
{
v14 = (unsigned __int8 *)v35;
v15 = v34;
}
else
{
v15 = (int)(unsigned __int8)v33 >> 1;
v14 = (unsigned __int8 *)&v33 + 1;
}
if ( v15 )
{
v16 = &v14[v15];
v17 = v14;
while ( 1 )
{
v18 = v17;
if ( v17 == v16 )
break;
v19 = *v17++;
if ( v19 != 32 )
{
v20 = v18 - v14;
if ( v20 == -1 )
break;
std::string::erase((unsigned __int8 *)&v33, 0, v20);
if ( (v33 & 1) != 0 )
{
if ( v34 > 0x18 )
{
*((_BYTE *)&dword_18 + (_DWORD)v35) = 0;
v34 = 24;
}
}
else if ( (unsigned __int8)v33 > 0x31u )
{
vars9 = 0;
LOBYTE(v33) = 48;
}
if ( (v33 & 1) != 0 )
{
v22 = v35;
v23 = v34;
}
else
{
v23 = (int)(unsigned __int8)v33 >> 1;
v22 = (char *)&v33 + 1;
}
v24 = &v22[v23];
while ( v24 != v22 )
{
v25 = (unsigned __int8)*--v24;
if ( v25 != 32 )
{
v26 = v24 - v22;
goto LABEL_40;
}
}
v26 = -1;
LABEL_40:
std::string::erase((unsigned __int8 *)&v33, v26 + 1, 0xFFFFFFFF);
for ( j = 0; ; ++j )
{
if ( (v33 & 1) != 0 )
{
if ( j >= v34 )
goto LABEL_48;
v28 = v35;
}
else
{
if ( j >= (int)(unsigned __int8)v33 >> 1 )
{
LABEL_48:
v21 = a1;
*a1 = 0;
a1[1] = 0;
a1[2] = 0;
goto LABEL_49;
}
v28 = (char *)&v33 + 1;
}
if ( (v28[j] & 0xDFu) - 65 <= 0x19 )
break;
}
v30 = v33;
v31 = v34;
v32 = v35;
v33 = 0;
v34 = 0;
v35 = nullptr;
*a1 = v30;
a1[1] = v31;
a1[2] = (int)v32;
goto LABEL_50;
}
}
}
v21 = a1;
*a1 = 0;
a1[1] = 0;
a1[2] = 0;
LABEL_49:
std::string::__init(v21, &unk_B6B226, 0);
LABEL_50:
std::string::~string((int)&v33);
return a1;
}