//
// GJSmartTemplate::getSimplifiedKey from 0x53a168 to 0x53a56c (1028 bytes)
//
// 5 xrefs:
// > GJSmartTemplate::saveRemap @ 0x53a598
// > GJSmartTemplate::getPrefab @ 0x53a88c
// > GJSmartTemplate::getPrefab @ 0x53a9ae
// > GJSmartTemplate::getPrefab @ 0x53a9dc
// > GJSmartTemplate::getPrefab @ 0x53aa3c
//
// 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
//
int __fastcall GJSmartTemplate::getSimplifiedKey(int a1, int a2)
{
int v3; // r5
int v4; // r6
int v5; // r7
int v6; // r4
SmartBlockType v7; // r11
SmartBlockType v8; // r10
SmartBlockType v9; // r9
SmartBlockType v10; // lr
unsigned int v11; // r0
SmartBlockType v12; // r8
unsigned int v13; // r1
unsigned int v14; // r1
unsigned int v15; // r1
unsigned int v16; // r3
int v17; // r3
unsigned int v18; // r3
int v19; // r3
unsigned int v20; // r1
unsigned int v21; // r1
SmartBlockType v22; // r10
SmartBlockType v23; // r9
SmartBlockType v24; // r0
int v25; // r3
bool v26; // zf
int v28; // [sp+1Ch] [bp-30h]
SmartBlockType SimplifiedType; // [sp+1Ch] [bp-30h]
SmartBlockType v30; // [sp+20h] [bp-2Ch]
SmartBlockType v31; // [sp+24h] [bp-28h]
int v33; // [sp+2Ch] [bp-20h]
int v34; // [sp+30h] [bp-1Ch]
char v35; // [sp+43h] [bp-9h] BYREF
v33 = *(unsigned __int8 *)sub_7757BC(a2, 0);
v3 = *(unsigned __int8 *)sub_7757BC(a2, 1);
v34 = *(unsigned __int8 *)sub_7757BC(a2, 2);
v4 = v34;
v28 = *(unsigned __int8 *)sub_7757BC(a2, 3);
v5 = v28;
v6 = *(unsigned __int8 *)sub_7757BC(a2, 4);
v30 = *(unsigned __int8 *)sub_7757BC(a2, 5);
v7 = v30;
v8 = *(unsigned __int8 *)sub_7757BC(a2, 6);
v31 = *(unsigned __int8 *)sub_7757BC(a2, 7);
v9 = v31;
v10 = *(unsigned __int8 *)sub_7757BC(a2, 8);
v35 = 0;
v11 = (unsigned __int8)(v3 - 52);
v12 = v10;
if ( v11 <= 0x18 && ((1 << v11) & 0x1E1E003) != 0 )
{
v3 = 48;
v35 = 1;
}
v13 = (unsigned __int8)(v30 - 52);
if ( v13 <= 0x18 && (((1 << v13) & 0x1E003) != 0 || ((1 << v13) & 0x1E00000) != 0 && v30 != v28) )
{
v7 = 48;
v35 = 1;
}
v14 = (unsigned __int8)(v8 - 52);
if ( v14 <= 0x18 && (((1 << v14) & 0x1E003) != 0 || ((1 << v14) & 0x1E00000) != 0 && v8 != v6) )
{
v8 = 48;
v35 = 1;
}
v15 = (unsigned __int8)(v34 - 50);
if ( v15 <= 0x16 && ((1 << v15) & 0x7800F3) != 0 )
{
v4 = 48;
v35 = 1;
}
v16 = (unsigned __int8)(v31 - 50);
if ( v16 <= 0x16 )
{
v17 = 1 << v16;
if ( (v17 & 0xF3) != 0 || (v17 & 0x780000) != 0 && v31 != v28 )
{
v9 = 48;
v35 = 1;
}
}
v18 = (unsigned __int8)(v10 - 50);
if ( v18 <= 0x16 )
{
v19 = 1 << v18;
if ( (v19 & 0xF3) != 0 || (v19 & 0x780000) != 0 && v10 != v6 )
{
v12 = 48;
v35 = 1;
}
}
v20 = (unsigned __int8)(v28 - 51);
if ( v20 <= 0x18 && ((1 << v20) & 0x1110025) != 0 )
{
v5 = 48;
v35 = 1;
}
v21 = (unsigned __int8)(v6 - 50);
if ( v21 <= 0x17 && ((1 << v21) & 0x888015) != 0 )
{
v6 = 48;
v35 = 1;
}
switch ( v33 )
{
case '2':
case '6':
case 'E':
v7 = 48;
v5 = 48;
v35 = 1;
v3 = 48;
break;
case '3':
case '8':
case 'G':
v8 = 48;
v6 = 48;
v35 = 1;
v3 = 48;
break;
case '4':
case 'A':
case 'I':
v9 = 48;
v5 = 48;
v35 = 1;
v4 = 48;
break;
case '5':
case 'C':
case 'K':
v12 = 48;
v6 = 48;
v4 = 48;
v35 = 1;
break;
default:
break;
}
SimplifiedType = GJSmartTemplate::getSimplifiedType(v7, (bool *)&v35);
v22 = GJSmartTemplate::getSimplifiedType(v8, (bool *)&v35);
v23 = GJSmartTemplate::getSimplifiedType(v9, (bool *)&v35);
v24 = GJSmartTemplate::getSimplifiedType(v12, (bool *)&v35);
v25 = SimplifiedType;
if ( SimplifiedType != 48 )
{
if ( (v3 & 0xFFFFFFFD) != 0x30 && (v5 & 0xFFFFFFFD) != 0x30 )
{
if ( v22 == 48 )
goto LABEL_52;
goto LABEL_45;
}
v35 = 1;
}
if ( v22 == 48 )
{
v25 = 48;
goto LABEL_52;
}
if ( v3 == 48 )
{
v25 = 48;
LABEL_50:
v22 = 48;
v35 = 1;
goto LABEL_52;
}
v25 = 48;
LABEL_45:
if ( v6 == 48 || v3 == 51 || v6 == 51 )
goto LABEL_50;
LABEL_52:
if ( v23 != 48 )
{
if ( (v4 & 0xFFFFFFFB) != 0x30 && (v5 & 0xFFFFFFFB) != 0x30 )
{
if ( v24 == 48 )
goto LABEL_67;
goto LABEL_59;
}
v35 = 1;
}
if ( v24 == 48 )
{
v23 = 48;
goto LABEL_67;
}
if ( v4 == 48 )
{
v23 = 48;
LABEL_64:
v35 = 1;
if ( v25 != 48 )
{
LOBYTE(v24) = 48;
goto LABEL_80;
}
if ( v22 != 48 )
{
LOBYTE(v24) = 48;
goto LABEL_80;
}
v26 = v23 == 48;
LOBYTE(v24) = 48;
LABEL_72:
if ( !v26 )
goto LABEL_79;
if ( v3 == 48 )
{
if ( v4 == 48 )
{
if ( v5 != 48 )
{
v35 = 1;
if ( v6 == 48 )
{
LOBYTE(v24) = 48;
LOBYTE(v23) = 48;
LOBYTE(v5) = 49;
LOBYTE(v4) = 48;
LOBYTE(v3) = 48;
goto LABEL_79;
}
LOBYTE(v5) = 49;
goto LABEL_102;
}
LABEL_107:
if ( v6 == 48 )
goto LABEL_108;
goto LABEL_99;
}
if ( v5 != 48 )
goto LABEL_107;
if ( v6 != 48 )
goto LABEL_96;
goto LABEL_94;
}
if ( v5 != 48 )
{
LABEL_97:
if ( v6 == 48 )
{
LABEL_108:
LOBYTE(v24) = v6;
LOBYTE(v23) = v6;
goto LABEL_79;
}
if ( v3 != 48 )
{
LOBYTE(v24) = 48;
LOBYTE(v23) = 48;
goto LABEL_79;
}
LABEL_99:
if ( v4 != 48 )
{
LOBYTE(v24) = 48;
LOBYTE(v23) = 48;
goto LABEL_105;
}
LABEL_102:
LOBYTE(v24) = 48;
LOBYTE(v23) = 48;
v35 = 1;
LOBYTE(v6) = 49;
LOBYTE(v4) = 48;
LABEL_105:
LOBYTE(v3) = 48;
goto LABEL_79;
}
if ( v6 == 48 )
{
v3 = 49;
v35 = 1;
if ( v4 != 48 )
{
LABEL_94:
v4 = 49;
v35 = 1;
LABEL_96:
LOBYTE(v5) = 48;
goto LABEL_97;
}
}
else if ( v4 != 48 )
{
goto LABEL_96;
}
v4 = 48;
goto LABEL_97;
}
v23 = 48;
LABEL_59:
if ( v6 == 48 || v4 == 53 || v6 == 53 )
goto LABEL_64;
LABEL_67:
if ( v25 == 48 && v22 == 48 && v23 == 48 )
{
v26 = v24 == 48;
goto LABEL_72;
}
LABEL_79:
if ( !v35 )
{
sub_776584(a1, (char *)&unk_939830);
return a1;
}
LABEL_80:
GJSmartTemplate::keyFromNeighbors(a1, v33, v3, v4, v5, v6, v25, v22, v23, v24);
return a1;
}