//
// DS_Dictionary::getIndexOfKeyWithClosestAlphaNumericalMatch from 0x18001a5e0 to 0x18001a78e (430 bytes)
//
// 2 xrefs:
// > ??> @ 0x1801438a8
// > ??> @ 0x1801ae9ec
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall DS_Dictionary::getIndexOfKeyWithClosestAlphaNumericalMatch(DS_Dictionary *this, const char *a2)
{
DS_Dictionary *v2; // rsi
const char *v4; // r8
unsigned int v5; // r13d
bool v6; // zf
std::_Vector_val>::pointer Mylast; // rcx
const char *v8; // rbx
const char *v9; // rdi
int v10; // r15d
int v11; // eax
int v12; // r14d
int v13; // eax
int v14; // ebp
int v15; // esi
int v16; // ecx
int v17; // ecx
int v18; // ecx
const char *v19; // r8
__int64 v22; // [rsp+70h] [rbp+18h] BYREF
char v23; // [rsp+78h] [rbp+20h] BYREF
v2 = this;
v4 = "k";
v5 = 0;
v6 = !this->compatible;
Mylast = this->dictTree._Mypair._Myval2._Mylast;
if ( !v6 )
v4 = "key";
sub_18007FB10(&Mylast[-1], &v22, v4);
if ( !sub_18007F4E0(&v22) )
return 0;
while ( 1 )
{
v8 = (const char *)sub_18007FB70(&v22);
v9 = a2;
v10 = sub_18001C1A0(a2);
v11 = sub_18001C1A0(v8);
v12 = v11;
if ( !v10 )
{
if ( v11 )
return v5;
v13 = stricmp(a2, v8);
goto LABEL_21;
}
if ( !v11 )
return v5;
v14 = 0;
v15 = 0;
if ( v10 > 0 )
{
while ( v15 < v12 )
{
if ( !isdigit(*v9) )
{
do
v16 = *++v9;
while ( !isdigit(v16) );
}
if ( !isdigit(*v8) )
{
do
v17 = *++v8;
while ( !isdigit(v17) );
}
if ( *v9 != *v8 )
{
v2 = this;
v18 = *v9 - *v8;
goto LABEL_22;
}
++v9;
++v8;
++v14;
++v15;
if ( v14 >= v10 )
goto LABEL_19;
}
if ( v14 < v10 )
return v5;
}
LABEL_19:
if ( v15 < v12 )
return v5;
v13 = stricmp(v9, v8);
v2 = this;
LABEL_21:
v18 = v13;
LABEL_22:
if ( v18 )
return v5;
++v5;
v19 = "k";
if ( v2->compatible )
v19 = "key";
v22 = *(_QWORD *)sub_180081A50(&v22, &v23, v19);
if ( !sub_18007F4E0(&v22) )
return 0;
}
}