//
// GJSmartTemplate::flipKey from 0x1402b4680 to 0x1402b49ac (812 bytes)
//
// 5 xrefs:
// > GJSmartTemplate::scanForPrefab @ 0x1402b2074
// > GJSmartTemplate::scanForPrefab @ 0x1402b22b5
// > GJSmartTemplate::scanForPrefab @ 0x1402b24c5
// > GJSmartTemplate::scanForPrefab @ 0x1402b24da
// > ??> @ 0x1406d23fc
//
// 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
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall GJSmartTemplate::flipKey(__int64 a1, char *a2, bool a3, bool a4)
{
unsigned __int64 v7; // rcx
unsigned __int64 v9; // rdx
char *v10; // r8
char *v11; // r8
SmartBlockType v12; // r14d
char *v13; // r8
SmartBlockType v14; // r8d
char *v15; // r9
SmartBlockType v16; // edi
char *v17; // r9
SmartBlockType v18; // ebp
char *v19; // r9
SmartBlockType v20; // r15d
char *v21; // r9
SmartBlockType v22; // r10d
char *v23; // r9
SmartBlockType v24; // r9d
char *v25; // rdx
SmartBlockType v26; // ebx
SmartBlockType v27; // ebp
SmartBlockType v28; // r14d
char v29; // r13
bool v30; // dl
bool v31; // r8
char v32; // r12
bool v33; // dl
bool v34; // r8
char v35; // r15
bool v36; // dl
bool v37; // r8
char v38; // r14
bool v39; // dl
bool v40; // r8
char v41; // bp
bool v42; // dl
bool v43; // r8
char v44; // si
bool v45; // dl
bool v46; // r8
char v47; // di
bool v48; // dl
bool v49; // r8
char v50; // bl
bool v51; // dl
bool v52; // r8
char v53; // al
__int64 v54; // r11
SmartBlockType v55; // [rsp+20h] [rbp-78h]
SmartBlockType v57; // [rsp+28h] [rbp-70h]
SmartBlockType v58; // [rsp+2Ch] [rbp-6Ch]
SmartBlockType v59; // [rsp+30h] [rbp-68h]
v7 = 0;
if ( a3 || a4 )
{
v9 = *((_QWORD *)a2 + 2);
if ( !v9 )
goto LABEL_37;
v10 = a2;
v7 = *((_QWORD *)a2 + 3);
if ( v7 > 0xF )
v10 = *(char **)a2;
v55 = *v10;
if ( v9 <= 1 )
goto LABEL_37;
v11 = a2;
if ( v7 > 0xF )
v11 = *(char **)a2;
v12 = v11[1];
if ( v9 <= 2 )
goto LABEL_37;
v13 = a2;
if ( v7 > 0xF )
v13 = *(char **)a2;
v14 = v13[2];
v58 = v14;
if ( v9 <= 3 )
goto LABEL_37;
v15 = a2;
if ( v7 > 0xF )
v15 = *(char **)a2;
v16 = v15[3];
if ( v9 <= 4 )
goto LABEL_37;
v17 = a2;
if ( v7 > 0xF )
v17 = *(char **)a2;
v18 = v17[4];
if ( v9 <= 5 )
goto LABEL_37;
v19 = a2;
if ( v7 > 0xF )
v19 = *(char **)a2;
v20 = v19[5];
if ( v9 <= 6 )
goto LABEL_37;
v21 = a2;
if ( v7 > 0xF )
v21 = *(char **)a2;
v22 = v21[6];
if ( v9 <= 7 )
goto LABEL_37;
v23 = a2;
if ( v7 > 0xF )
v23 = *(char **)a2;
v24 = v23[7];
if ( v9 <= 8 )
LABEL_37:
sub_14003BCC0(v7);
v25 = a2;
if ( v7 > 0xF )
v25 = *(char **)a2;
v26 = v25[8];
if ( a3 )
{
v59 = v12;
v57 = v18;
v27 = v22;
v28 = v20;
}
else if ( a4 )
{
v59 = v14;
v58 = v12;
v57 = v16;
v16 = v18;
v27 = v24;
v28 = v25[8];
v26 = v20;
v24 = v22;
}
else
{
v59 = v55;
v58 = v55;
v57 = v55;
v16 = v55;
v27 = v55;
v28 = v55;
v26 = v55;
v24 = v55;
}
v29 = GJSmartTemplate::flipBlockType(v24, a3, a4);
v32 = GJSmartTemplate::flipBlockType(v26, v30, v31);
v35 = GJSmartTemplate::flipBlockType(v28, v33, v34);
v38 = GJSmartTemplate::flipBlockType(v27, v36, v37);
v41 = GJSmartTemplate::flipBlockType(v16, v39, v40);
v44 = GJSmartTemplate::flipBlockType(v57, v42, v43);
v47 = GJSmartTemplate::flipBlockType(v58, v45, v46);
v50 = GJSmartTemplate::flipBlockType(v59, v48, v49);
v53 = GJSmartTemplate::flipBlockType(v55, v51, v52);
*(_OWORD *)v54 = 0;
*(_QWORD *)(v54 + 16) = 0;
*(_QWORD *)(v54 + 24) = 15;
*(_BYTE *)v54 = 0;
sub_14003B190((void **)v54, v53);
sub_14003B190((void **)a1, v50);
sub_14003B190((void **)a1, v47);
sub_14003B190((void **)a1, v44);
sub_14003B190((void **)a1, v41);
sub_14003B190((void **)a1, v38);
sub_14003B190((void **)a1, v35);
sub_14003B190((void **)a1, v32);
sub_14003B190((void **)a1, v29);
sub_14003A830((__int64)a2);
return a1;
}
else
{
*(_OWORD *)a1 = 0;
*(_QWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 24) = 0;
*(_OWORD *)a1 = *(_OWORD *)a2;
*(_OWORD *)(a1 + 16) = *((_OWORD *)a2 + 1);
*((_QWORD *)a2 + 2) = 0;
*((_QWORD *)a2 + 3) = 15;
*a2 = 0;
sub_14003A830((__int64)a2);
return a1;
}
}