//
// GJSmartTemplate::getSimplifiedKey from 0x100422e80 to 0x100423410 (1424 bytes)
//
// 5 xrefs:
// > GJSmartTemplate::saveRemap @ 0x10042239d
// > GJSmartTemplate::getPrefab_1 @ 0x1004253e1
// > GJSmartTemplate::getPrefab_1 @ 0x100425463
// > GJSmartTemplate::getPrefab_1 @ 0x1004254d8
// > GJSmartTemplate::getPrefab_1 @ 0x100425597
//
// 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
//
std::string *__fastcall GJSmartTemplate::getSimplifiedKey(std::string *a1, std::string *a2)
{
int v2; // r15d
int v3; // r13d
int v4; // r12d
int v5; // r14d
std::string::reference v6; // rax
unsigned int v7; // r15d
int v8; // ecx
char v9; // di
unsigned int v10; // ecx
int v11; // r11d
int v12; // edx
int v13; // r9d
int v14; // r8d
int v15; // ebx
unsigned int v16; // ecx
int v17; // edx
int v18; // ecx
int v19; // edx
int v20; // edx
int v21; // ecx
unsigned int v22; // ecx
int v23; // edx
int v24; // eax
unsigned int v25; // ecx
int v26; // edx
int v27; // edx
int v28; // ecx
unsigned int v29; // ecx
int v30; // edx
int v31; // edx
int v32; // ecx
unsigned int v33; // ecx
int v34; // edx
unsigned int v35; // ecx
int v36; // edx
char v37; // r10
int v38; // r12d
int v39; // esi
int v40; // esi
int v41; // esi
int v42; // esi
int v43; // ecx
bool v44; // si
bool v45; // dl
int v46; // r11d
bool v47; // si
bool v48; // di
int v49; // r15d
int v50; // ebx
bool v51; // al
bool v52; // dl
int v55; // [rsp+Ch] [rbp-44h]
int v56; // [rsp+10h] [rbp-40h]
std::string::value_type v57; // [rsp+18h] [rbp-38h]
int v58; // [rsp+1Ch] [rbp-34h]
int v59; // [rsp+20h] [rbp-30h]
v57 = *std::string::at(a2, 0);
v2 = (unsigned __int8)*std::string::at(a2, 1u);
v59 = (char)v2;
v56 = *std::string::at(a2, 2u);
v55 = *std::string::at(a2, 3u);
v58 = *std::string::at(a2, 4u);
v3 = *std::string::at(a2, 5u);
v4 = *std::string::at(a2, 6u);
v5 = *std::string::at(a2, 7u);
v6 = std::string::at(a2, 8u);
v7 = v2 - 52;
if ( v7 > 0x18 )
{
v9 = 0;
}
else
{
v8 = 31580163;
v9 = 0;
if ( _bittest(&v8, v7) )
{
v59 = 48;
v9 = 1;
}
}
v10 = (unsigned __int8)v3 - 52;
v11 = v4;
if ( v10 > 0x18 )
{
v13 = v56;
v14 = v55;
}
else
{
v12 = 122883;
v13 = v56;
v14 = v55;
if ( !_bittest(&v12, v10) )
{
v17 = 31457280;
v15 = v58;
if ( _bittest(&v17, v10) )
{
v18 = 48;
if ( (_BYTE)v3 == (_BYTE)v55 )
v18 = v3;
v9 |= (_BYTE)v3 != (unsigned __int8)v55;
v3 = v18;
}
v16 = (unsigned __int8)v4 - 52;
if ( v16 > 0x18 )
goto LABEL_20;
goto LABEL_14;
}
v3 = 48;
v9 = 1;
}
v15 = v58;
v16 = (unsigned __int8)v4 - 52;
if ( v16 <= 0x18 )
{
LABEL_14:
v19 = 122883;
if ( _bittest(&v19, v16) )
{
v11 = 48;
v9 = 1;
}
else
{
v20 = 31457280;
if ( _bittest(&v20, v16) )
{
v21 = 48;
if ( (_BYTE)v4 == (_BYTE)v15 )
v21 = v4;
v9 |= (_BYTE)v4 != (unsigned __int8)v15;
v11 = v21;
}
}
}
LABEL_20:
v22 = (unsigned __int8)v13 - 50;
if ( v22 <= 0x16 )
{
v23 = 7864563;
if ( _bittest(&v23, v22) )
{
v13 = 48;
v9 = 1;
}
}
v24 = *v6;
v25 = (unsigned __int8)v5 - 50;
if ( v25 <= 0x16 )
{
v26 = 243;
if ( _bittest(&v26, v25) )
{
v5 = 48;
v9 = 1;
}
else
{
v27 = 7864320;
if ( _bittest(&v27, v25) )
{
v28 = 48;
if ( (_BYTE)v5 == (_BYTE)v14 )
v28 = v5;
v9 |= (_BYTE)v5 != (unsigned __int8)v14;
v5 = v28;
}
}
}
v29 = (unsigned __int8)v24 - 50;
if ( v29 <= 0x16 )
{
v30 = 243;
if ( _bittest(&v30, v29) )
{
v24 = 48;
v9 = 1;
}
else
{
v31 = 7864320;
if ( _bittest(&v31, v29) )
{
v32 = 48;
if ( (_BYTE)v24 == (_BYTE)v15 )
v32 = v24;
v9 |= (_BYTE)v24 != (unsigned __int8)v15;
v24 = v32;
}
}
}
v33 = (unsigned __int8)v14 - 51;
if ( v33 <= 0x18 )
{
v34 = 17891365;
if ( _bittest(&v34, v33) )
{
v14 = 48;
v9 = 1;
}
}
v35 = (unsigned __int8)v15 - 50;
if ( v35 <= 0x17 )
{
v36 = 8945685;
if ( _bittest(&v36, v35) )
{
v15 = 48;
v9 = 1;
}
}
v37 = 1;
switch ( v57 )
{
case '2':
case '6':
case 'E':
v38 = 48;
v14 = 48;
v3 = 48;
goto LABEL_52;
case '3':
case '8':
case 'G':
v15 = 48;
v9 = 1;
v11 = 48;
v59 = 48;
goto LABEL_48;
case '4':
case 'A':
case 'I':
v13 = 48;
v9 = 1;
v14 = 48;
v5 = 48;
goto LABEL_48;
case '5':
case 'C':
case 'K':
v13 = 48;
v9 = 1;
v15 = 48;
v24 = 48;
goto LABEL_48;
default:
LABEL_48:
if ( (unsigned int)(v3 - 50) <= 0x1A && (v39 = 134185215, _bittest(&v39, v3 - 50)) )
v3 = 49;
else
v37 = v9;
v38 = v59;
LABEL_52:
if ( (unsigned int)(v11 - 50) <= 0x1A )
{
v40 = 134185215;
if ( _bittest(&v40, v11 - 50) )
{
v11 = 49;
v37 = 1;
}
}
if ( (unsigned int)(v5 - 50) <= 0x1A )
{
v41 = 134185215;
if ( _bittest(&v41, v5 - 50) )
{
v5 = 49;
v37 = 1;
}
}
if ( (unsigned int)(v24 - 50) <= 0x1A )
{
v42 = 134185215;
if ( _bittest(&v42, v24 - 50) )
{
v24 = 49;
v37 = 1;
}
}
v43 = 48;
if ( v3 == 48 )
{
v3 = 48;
if ( v11 == 48 )
goto LABEL_70;
goto LABEL_67;
}
v44 = (v38 & 0xFFFFFFFD) == 48 || (v14 & 0xFFFFFFFD) == 48;
v37 |= v44;
if ( v44 )
v3 = 48;
if ( v11 != 48 )
{
LABEL_67:
v45 = v15 == 48 || v38 == 48 || v38 == 51 || v15 == 51;
v37 |= v45;
if ( v45 )
v11 = 48;
v43 = v11;
}
LABEL_70:
v46 = 48;
if ( v5 == 48 )
{
v5 = 48;
if ( v24 == 48 )
goto LABEL_79;
goto LABEL_76;
}
v47 = (v13 & 0xFFFFFFFB) == 48 || (v14 & 0xFFFFFFFB) == 48;
v37 |= v47;
if ( v47 )
v5 = 48;
if ( v24 != 48 )
{
LABEL_76:
v48 = v13 == 48 || v15 == 48 || v13 == 53 || v15 == 53;
v37 |= v48;
if ( v48 )
v24 = 48;
v46 = v24;
}
LABEL_79:
if ( v3 != 48 )
goto LABEL_91;
if ( v43 != 48 )
{
if ( (v37 & 1) == 0 )
goto LABEL_97;
LABEL_95:
GJSmartTemplate::keyFromNeighbors_1(a1, v3, v43, v5, v46);
return a1;
}
if ( v5 != 48 || v46 != 48 )
{
LABEL_91:
if ( (v37 & 1) == 0 )
goto LABEL_97;
goto LABEL_95;
}
v49 = v15;
v50 = v13;
v51 = v49 == 48 && v14 == 48 && v38 != 48;
if ( v51 )
v38 = 49;
v52 = v49 == 48 && v14 == 48 && v13 != 48;
if ( v52 )
v50 = 49;
if ( v49 != 48 && v38 == 48 && v50 == 48
|| v14 != 48 && (v38 ^ 0x30 | v50 ^ 0x30) == 0
|| v52
|| v51
|| (v37 & 1) != 0 )
{
goto LABEL_95;
}
LABEL_97:
*(_WORD *)&a1->__r_.__value_.__l.0 = 0;
return a1;
}
}