decompiled_code:
__int64 thiefd_()
{
int v0; // er14
unsigned int v1; // er12
unsigned int v2; // er9
unsigned int v3; // edx
unsigned int v4; // ebx
int v5; // eax
int v6; // edx
int v7; // ecx
int v8; // er15
__int64 v9; // rbp
int v10; // er13
__int64 result; // rax
int v12; // er12
unsigned int v13; // er13
__int64 v14; // rbp
__int64 v15; // rsi
__int64 v16; // rdi
int v17; // eax
int v18; // er9
__int64 v19; // rsi
unsigned int v20; // er13
unsigned int v21; // er13
int v22; // er13
__int64 v23; // rbp
__int64 v24; // rdi
int v25; // er13
int v26; // esi
int v27; // er13
unsigned int v28; // ebp
unsigned int v29; // ebp
__int64 v30; // rdi
int v31; // er13
__int64 v32; // [rsp+0h] [rbp-48h]
__int64 v33; // [rsp+8h] [rbp-40h]

v0 = 2;
v1 = oindex_[39];
v32 = (int)(v1 - 1);
v33 = (int)(oindex_[40] - 1) + 2420LL;
while ( 1 )
{
v2 = hack_;
v3 = *((_DWORD *)&objcts_ + v32 + 2201);
if ( v3 )
{
hack_ = *((_DWORD *)&objcts_ + v32 + 2201);
v2 = v3;
}
if ( *((_DWORD *)&play_ + 1) != v2 )
{
if ( v2 == *((_DWORD *)&rindex_ + 26) )
{
v19 = *((unsigned int *)&rindex_ + 26);
v4 = -v1;
if ( v3 )
{
newsta_(v1, 0LL, 0LL, 0LL, 0LL);
v21 = oindex_[40];
if ( (unsigned int)qhere_(v21, *((unsigned int *)&rindex_ + 26))
|| *((_DWORD *)&objcts_ + (int)(v21 - 1) + 2421) == v4 )
{
newsta_(v21, 0LL, 0LL, v1, 0LL);
}
v19 = hack_;
}
robadv_(v4, v19, 0LL, 0LL);
v20 = oindex_[90];
if ( (unsigned int)qhere_(v20, hack_) )
{
v2 = hack_;
*((_DWORD *)&objcts_ + (int)(v20 - 1) + 1101) |= 8u;
goto LABEL_19;
}
goto LABEL_43;
}
goto LABEL_6;
}
if ( v2 == *((_DWORD *)&rindex_ + 26) )
goto LABEL_70;
if ( (*((_BYTE *)&rooms_ + 4 * (int)(v2 - 1) + 4005) & 0x40) == 0 )
{
if ( *((_DWORD *)&hack_ + 1) )
{
if ( !v3 )
goto LABEL_70;
}
else
{
if ( !v3 )
{
if ( !(unsigned int)prob_(70LL, 70LL) )
{
v2 = hack_;
if ( *((_DWORD *)&objcts_ + (int)(oindex_[40] - 1) + 2641) == v1 )
{
result = newsta_(v1, 583LL, hack_, 0LL, 0LL);
*((_DWORD *)&hack_ + 1) = 1;
return result;
}
LABEL_70:
v4 = -v1;
goto LABEL_19;
}
result = prob_(70LL, 70LL);
if ( (_DWORD)result )
return result;
v30 = hack_;
v4 = -v1;
*((_DWORD *)&hack_ + 1) = 1;
v31 = robrm_(v30, 100LL, 0LL, 0LL, -v1);
v26 = 586;
v27 = robadv_(play_, 0LL, 0LL, -v1) + v31;
goto LABEL_65;
}
if ( (*((_BYTE *)&objcts_ + 4 * v32 + 4405) & 1) != 0 )
{
if ( !(unsigned int)winnin_(v1, play_) )
{
newsta_(v1, 584LL, 0LL, 0LL, 0LL);
*((_DWORD *)&objcts_ + v32 + 1101) &= 0xFFFFFEFF;
goto LABEL_75;
}
if ( (unsigned int)prob_(90LL, 90LL) )
{
v2 = hack_;
v4 = -v1;
goto LABEL_19;
}
}
if ( !(unsigned int)prob_(70LL, 70LL) )
{
newsta_(v1, 585LL, 0LL, 0LL, 0LL);
LABEL_75:
v29 = oindex_[40];
if ( (unsigned int)qhere_(v29, hack_)
|| (result = (int)(v29 - 1), !(*((_DWORD *)&objcts_ + result + 2421) + v1)) )
{
result = newsta_(v29, 0LL, 0LL, v1, 0LL);
}
return result;
}
}
result = prob_(70LL, 70LL);
if ( (_DWORD)result )
return result;
v24 = hack_;
v4 = -v1;
*((_DWORD *)&hack_ + 1) = 1;
v25 = robrm_(v24, 100LL, 0LL, 0LL, -v1);
v26 = 588;
v27 = robadv_(play_, 0LL, 0LL, -v1) + v25;
LABEL_65:
newsta_(v1, v26 - ((unsigned int)(v27 == 0) - 1), 0LL, 0LL, 0LL);
v28 = oindex_[40];
if ( (unsigned int)qhere_(v28, hack_) || *((_DWORD *)&objcts_ + (int)(v28 - 1) + 2421) == v4 )
newsta_(v28, 0LL, 0LL, v1, 0LL);
v2 = hack_;
if ( v27 )
{
if ( (unsigned int)lit_(hack_) )
goto LABEL_43;
rspeak_(406LL);
v2 = hack_;
}
goto LABEL_19;
}
LABEL_6:
newsta_(v1, 0LL, 0LL, 0LL, 0LL);
v4 = -v1;
if ( (unsigned int)qhere_(oindex_[40], hack_) || *((_DWORD *)&objcts_ + v33 + 1) == v4 )
newsta_(oindex_[40], 0LL, 0LL, v1, 0LL);
v2 = hack_;
if ( *((char *)&rooms_ + 4 * hack_ + 4001) >= 0 )
goto LABEL_19;
robrm_(hack_, 75LL, 0LL, 0LL, v4);
v2 = hack_;
v5 = *((_DWORD *)&rindex_ + 4);
if ( hack_ < v5
|| (v6 = *((_DWORD *)&rindex_ + 6), hack_ > v6)
|| (v7 = *((_DWORD *)&play_ + 1), v6 < v7)
|| v5 > v7 )
{
v22 = objcts_;
v23 = 1LL;
if ( objcts_ <= 0 )
goto LABEL_19;
while ( !(unsigned int)qhere_((unsigned int)v23, v2)
|| *((_DWORD *)&objcts_ + v23 + 1540)
|| (unsigned int)prob_(80LL, 60LL)
|| (*((_DWORD *)&objcts_ + v23 + 880) & 0xA000) != 40960 )
{
++v23;
v2 = hack_;
if ( v22 < (int)v23 )
goto LABEL_19;
}
newsta_((unsigned int)v23, 0LL, 0LL, 0LL, v4);
*((_DWORD *)&objcts_ + (int)v23 + 1100) |= 4u;
LABEL_43:
v2 = hack_;
goto LABEL_19;
}
v8 = objcts_;
if ( objcts_ <= 0 )
goto LABEL_19;
v9 = 1LL;
while ( 1 )
{
if ( (unsigned int)qhere_((unsigned int)v9, v2) )
{
if ( !(unsigned int)prob_(60LL, 60LL) )
{
v10 = v9 - 1;
if ( (*((_DWORD *)&objcts_ + v9 + 880) & 0xA000) == 40960 )
break;
}
}
++v9;
v2 = hack_;
if ( v8 < (int)v9 )
goto LABEL_19;
}
rspsub_(590LL, *((unsigned int *)&objcts_ + v10 + 221));
if ( (unsigned int)prob_(40LL, 20LL) )
goto LABEL_43;
newsta_((unsigned int)v9, 0LL, 0LL, 0LL, v4);
v2 = hack_;
*((_DWORD *)&objcts_ + v10 + 1101) |= 4u;
LABEL_19:
result = (int)(oindex_[9] - 1);
if ( *((_DWORD *)&objcts_ + result + 2421) == v4 )
findex_[6] = 0;
if ( v0 == 1 )
break;
v17 = v2 - 1;
do
{
if ( v17 <= 0 )
v17 = rooms_;
v18 = v17--;
}
while ( (*((_DWORD *)&rooms_ + v17 + 1001) & 0x2410) != 0x2000 );
hack_ = v18;
v0 = 1;
*((_DWORD *)&hack_ + 1) = 0;
}
if ( v2 != *((_DWORD *)&rindex_ + 26) )
{
v12 = objcts_;
v13 = 591;
result = 0LL;
if ( *((_DWORD *)&play_ + 1) != v2 )
v13 = 0;
if ( objcts_ > 0 )
{
v14 = 1LL;
do
{
while ( 1 )
{
if ( *((_DWORD *)&objcts_ + v14 + 2420) == v4 )
{
result = prob_(70LL, 70LL);
if ( !(_DWORD)result )
{
result = *((unsigned int *)&objcts_ + v14 + 1540);
if ( (int)result <= 0 )
break;
}
}
if ( v12 < (int)++v14 )
return result;
}
v15 = v13;
v16 = (unsigned int)v14++;
v13 = 0;
result = newsta_(v16, v15, hack_, 0LL, 0LL);
}
while ( v12 >= (int)v14 );
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // er14
unsigned int v1; // er12
unsigned int v2; // er9
unsigned int v3; // edx
unsigned int v4; // ebx
int v5; // eax
int v6; // edx
int v7; // ecx
int v8; // er15
__int64 v9; // rbp
int v10; // er13
__int64 result; // rax
int v12; // er12
unsigned int v13; // er13
__int64 v14; // rbp
__int64 v15; // rsi
__int64 v16; // rdi
int v17; // eax
int v18; // er9
__int64 v19; // rsi
unsigned int v20; // er13
unsigned int v21; // er13
int v22; // er13
__int64 v23; // rbp
__int64 v24; // rdi
int v25; // er13
int v26; // esi
int v27; // er13
unsigned int v28; // ebp
unsigned int v29; // ebp
__int64 v30; // rdi
int v31; // er13
__int64 v32; // [rsp+0h] [rbp-48h]
__int64 v33; // [rsp+8h] [rbp-40h]

v0 = 2;
v1 = oindex_[39];
v32 = (int)(v1 - 1);
v33 = (int)(oindex_[40] - 1) + 2420LL;
while ( 1 )
{
v2 = hack_;
v3 = *((_DWORD *)&objcts_ + v32 + 2201);
if ( v3 )
{
hack_ = *((_DWORD *)&objcts_ + v32 + 2201);
v2 = v3;
}
if ( *((_DWORD *)&play_ + 1) != v2 )
{
if ( v2 == *((_DWORD *)&rindex_ + 26) )
{
v19 = *((unsigned int *)&rindex_ + 26);
v4 = -v1;
if ( v3 )
{
newsta_(v1, 0LL, 0LL, 0LL, 0LL);
v21 = oindex_[40];
if ( (unsigned int)qhere_(v21, *((unsigned int *)&rindex_ + 26))
|| *((_DWORD *)&objcts_ + (int)(v21 - 1) + 2421) == v4 )
{
newsta_(v21, 0LL, 0LL, v1, 0LL);
}
v19 = hack_;
}
robadv_(v4, v19, 0LL, 0LL);
v20 = oindex_[90];
if ( (unsigned int)qhere_(v20, hack_) )
{
v2 = hack_;
*((_DWORD *)&objcts_ + (int)(v20 - 1) + 1101) |= 8u;
goto LABEL_19;
}
goto LABEL_43;
}
goto LABEL_6;
}
if ( v2 == *((_DWORD *)&rindex_ + 26) )
goto LABEL_70;
if ( (*((_BYTE *)&rooms_ + 4 * (int)(v2 - 1) + 4005) & 0x40) == 0 )
{
if ( *((_DWORD *)&hack_ + 1) )
{
if ( !v3 )
goto LABEL_70;
}
else
{
if ( !v3 )
{
if ( !(unsigned int)prob_(70LL, 70LL) )
{
v2 = hack_;
if ( *((_DWORD *)&objcts_ + (int)(oindex_[40] - 1) + 2641) == v1 )
{
result = newsta_(v1, 583LL, hack_, 0LL, 0LL);
*((_DWORD *)&hack_ + 1) = 1;
return result;
}
LABEL_70:
v4 = -v1;
goto LABEL_19;
}
result = prob_(70LL, 70LL);
if ( (_DWORD)result )
return result;
v30 = hack_;
v4 = -v1;
*((_DWORD *)&hack_ + 1) = 1;
v31 = robrm_(v30, 100LL, 0LL, 0LL, -v1);
v26 = 586;
v27 = robadv_(play_, 0LL, 0LL, -v1) + v31;
goto LABEL_65;
}
if ( (*((_BYTE *)&objcts_ + 4 * v32 + 4405) & 1) != 0 )
{
if ( !(unsigned int)winnin_(v1, play_) )
{
newsta_(v1, 584LL, 0LL, 0LL, 0LL);
*((_DWORD *)&objcts_ + v32 + 1101) &= 0xFFFFFEFF;
goto LABEL_75;
}
if ( (unsigned int)prob_(90LL, 90LL) )
{
v2 = hack_;
v4 = -v1;
goto LABEL_19;
}
}
if ( !(unsigned int)prob_(70LL, 70LL) )
{
newsta_(v1, 585LL, 0LL, 0LL, 0LL);
LABEL_75:
v29 = oindex_[40];
if ( (unsigned int)qhere_(v29, hack_)
|| (result = (int)(v29 - 1), !(*((_DWORD *)&objcts_ + result + 2421) + v1)) )
{
result = newsta_(v29, 0LL, 0LL, v1, 0LL);
}
return result;
}
}
result = prob_(70LL, 70LL);
if ( (_DWORD)result )
return result;
v24 = hack_;
v4 = -v1;
*((_DWORD *)&hack_ + 1) = 1;
v25 = robrm_(v24, 100LL, 0LL, 0LL, -v1);
v26 = 588;
v27 = robadv_(play_, 0LL, 0LL, -v1) + v25;
LABEL_65:
newsta_(v1, v26 - ((unsigned int)(v27 == 0) - 1), 0LL, 0LL, 0LL);
v28 = oindex_[40];
if ( (unsigned int)qhere_(v28, hack_) || *((_DWORD *)&objcts_ + (int)(v28 - 1) + 2421) == v4 )
newsta_(v28, 0LL, 0LL, v1, 0LL);
v2 = hack_;
if ( v27 )
{
if ( (unsigned int)lit_(hack_) )
goto LABEL_43;
rspeak_(406LL);
v2 = hack_;
}
goto LABEL_19;
}
LABEL_6:
newsta_(v1, 0LL, 0LL, 0LL, 0LL);
v4 = -v1;
if ( (unsigned int)qhere_(oindex_[40], hack_) || *((_DWORD *)&objcts_ + v33 + 1) == v4 )
newsta_(oindex_[40], 0LL, 0LL, v1, 0LL);
v2 = hack_;
if ( *((char *)&rooms_ + 4 * hack_ + 4001) >= 0 )
goto LABEL_19;
robrm_(hack_, 75LL, 0LL, 0LL, v4);
v2 = hack_;
v5 = *((_DWORD *)&rindex_ + 4);
if ( hack_ < v5
|| (v6 = *((_DWORD *)&rindex_ + 6), hack_ > v6)
|| (v7 = *((_DWORD *)&play_ + 1), v6 < v7)
|| v5 > v7 )
{
v22 = objcts_;
v23 = 1LL;
if ( objcts_ <= 0 )
goto LABEL_19;
while ( !(unsigned int)qhere_((unsigned int)v23, v2)
|| *((_DWORD *)&objcts_ + v23 + 1540)
|| (unsigned int)prob_(80LL, 60LL)
|| (*((_DWORD *)&objcts_ + v23 + 880) & 0xA000) != 40960 )
{
++v23;
v2 = hack_;
if ( v22 < (int)v23 )
goto LABEL_19;
}
newsta_((unsigned int)v23, 0LL, 0LL, 0LL, v4);
*((_DWORD *)&objcts_ + (int)v23 + 1100) |= 4u;
LABEL_43:
v2 = hack_;
goto LABEL_19;
}
v8 = objcts_;
if ( objcts_ <= 0 )
goto LABEL_19;
v9 = 1LL;
while ( 1 )
{
if ( (unsigned int)qhere_((unsigned int)v9, v2) )
{
if ( !(unsigned int)prob_(60LL, 60LL) )
{
v10 = v9 - 1;
if ( (*((_DWORD *)&objcts_ + v9 + 880) & 0xA000) == 40960 )
break;
}
}
++v9;
v2 = hack_;
if ( v8 < (int)v9 )
goto LABEL_19;
}
rspsub_(590LL, *((unsigned int *)&objcts_ + v10 + 221));
if ( (unsigned int)prob_(40LL, 20LL) )
goto LABEL_43;
newsta_((unsigned int)v9, 0LL, 0LL, 0LL, v4);
v2 = hack_;
*((_DWORD *)&objcts_ + v10 + 1101) |= 4u;
LABEL_19:
result = (int)(oindex_[9] - 1);
if ( *((_DWORD *)&objcts_ + result + 2421) == v4 )
findex_[6] = 0;
if ( v0 == 1 )
break;
v17 = v2 - 1;
do
{
if ( v17 <= 0 )
v17 = rooms_;
v18 = v17--;
}
while ( (*((_DWORD *)&rooms_ + v17 + 1001) & 0x2410) != 0x2000 );
hack_ = v18;
v0 = 1;
*((_DWORD *)&hack_ + 1) = 0;
}
if ( v2 != *((_DWORD *)&rindex_ + 26) )
{
v12 = objcts_;
v13 = 591;
result = 0LL;
if ( *((_DWORD *)&play_ + 1) != v2 )
v13 = 0;
if ( objcts_ > 0 )
{
v14 = 1LL;
do
{
while ( 1 )
{
if ( *((_DWORD *)&objcts_ + v14 + 2420) == v4 )
{
result = prob_(70LL, 70LL);
if ( !(_DWORD)result )
{
result = *((unsigned int *)&objcts_ + v14 + 1540);
if ( (int)result <= 0 )
break;
}
}
if ( v12 < (int)++v14 )
return result;
}
v15 = v13;
v16 = (unsigned int)v14++;
v13 = 0;
result = newsta_(v16, v15, hack_, 0LL, 0LL);
}
while ( v12 >= (int)v14 );
}
}
return result;
}

original_code:
void thiefd_()
{
   integer i__1, i__2;
   integer i, j, nr;
   logical once;
   integer rhere;
   once = (0);
L1025:
   rhere = objcts_.oroom[oindex_.thief - 1];
   if (rhere != 0) {
      hack_.thfpos = rhere;
   }
   if (hack_.thfpos == play_.here) {
      goto L1100;
   }
   if (hack_.thfpos != rindex_.treas) {
      goto L1400;
   }
   if (rhere == 0) {
      goto L1050;
   }
   newsta_(oindex_.thief, 0, 0, 0, 0);
   rhere = 0;
   if (qhere_(oindex_.still, rindex_.treas) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
L1050:
   i__1 = -oindex_.thief;
   i = robadv_(i__1, hack_.thfpos, 0, 0);
   if (qhere_(oindex_.egg, hack_.thfpos)) {
      objcts_.oflag2[oindex_.egg - 1] |= (8);
   }
   goto L1700;
L1100:
   if (hack_.thfpos == rindex_.treas) {
      goto L1700;
   }
   if ((rooms_.rflag[hack_.thfpos - 1] & (16384)) != 0) {
      goto L1400;
   }
   if (hack_.thfflg) {
      goto L1300;
   }
   if (rhere != 0 || prob_(70, 70)) {
      goto L1150;
   }
   if (objcts_.ocan[oindex_.still - 1] != oindex_.thief) {
      goto L1700;
   }
   newsta_(oindex_.thief, 583, hack_.thfpos, 0, 0);
   hack_.thfflg = (1);
   return;
L1150:
   if (rhere == 0 || (objcts_.oflag2[oindex_.thief - 1] & (256))
         == 0) {
      goto L1200;
   }
   if (winnin_(oindex_.thief, play_.winner)) {
      goto L1175;
   }
   newsta_(oindex_.thief, 584, 0, 0, 0);
   objcts_.oflag2[oindex_.thief - 1] &= ~ (256);
   if (qhere_(oindex_.still, hack_.thfpos) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
   return;
L1175:
   if (prob_(90, 90)) {
      goto L1700;
   }
L1200:
   if (rhere == 0 || prob_(70, 70)) {
      goto L1250;
   }
   newsta_(oindex_.thief, 585, 0, 0, 0);
   if (qhere_(oindex_.still, hack_.thfpos) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
   return;
L1300:
   if (rhere == 0) {
      goto L1700;
   }
L1250:
   if (prob_(70, 70)) {
      return;
   }
   hack_.thfflg = (1);
   i__1 = -oindex_.thief;
   i__2 = -oindex_.thief;
   nr = robrm_(hack_.thfpos, 100, 0, 0, i__1) + robadv_(
         play_.winner, 0, 0, i__2);
   i = 586;
   if (rhere != 0) {
      i = 588;
   }
   if (nr != 0) {
      ++i;
   }
   newsta_(oindex_.thief, i, 0, 0, 0);
   if (qhere_(oindex_.still, hack_.thfpos) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
   if (nr != 0 && ! lit_(hack_.thfpos)) {
      rspeak_(406);
   }
   rhere = 0;
   goto L1700;
L1400:
   newsta_(oindex_.thief, 0, 0, 0, 0);
   rhere = 0;
   if (qhere_(oindex_.still, hack_.thfpos) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
   if ((rooms_.rflag[hack_.thfpos - 1] & (32768)) == 0) {
      goto L1700;
   }
   i__1 = -oindex_.thief;
   i = robrm_(hack_.thfpos, 75, 0, 0, i__1);
   if (hack_.thfpos < rindex_.maze1 || hack_.thfpos > rindex_.maz15 ||
         play_.here < rindex_.maze1 || play_.here > rindex_.maz15) {
      goto L1500;
   }
   i__1 = objcts_.olnt;
   for (i = 1; i <= i__1; ++i) {
      if (! qhere_(i, hack_.thfpos) || prob_(60, 60) || (
               objcts_.oflag1[i - 1] & (32768) + (8192)) !=
            (32768) + (8192)) {
         goto L1450;
      }
      rspsub_(590, objcts_.odesc2[i - 1]);
      if (prob_(40, 20)) {
         goto L1700;
      }
      i__2 = -oindex_.thief;
      newsta_(i, 0, 0, 0, i__2);
      objcts_.oflag2[i - 1] |= (4);
      goto L1700;
L1450:
      ;
   }
   goto L1700;
L1500:
   i__1 = objcts_.olnt;
   for (i = 1; i <= i__1; ++i) {
      if (! qhere_(i, hack_.thfpos) || objcts_.otval[i - 1] != 0 ||
            prob_(80, 60) || (objcts_.oflag1[i - 1] &
               (32768) + (8192)) != (32768) +
            (8192)) {
         goto L1550;
      }
      i__2 = -oindex_.thief;
      newsta_(i, 0, 0, 0, i__2);
      objcts_.oflag2[i - 1] |= (4);
      goto L1700;
L1550:
      ;
   }
L1700:
   if (objcts_.oadv[oindex_.rope - 1] == -oindex_.thief) {
      findex_.domef = (0);
   }
   if (once) {
      goto L1800;
   }
   once = ! once;
L1750:
   --hack_.thfpos;
   if (hack_.thfpos <= 0) {
      hack_.thfpos = rooms_.rlnt;
   }
   if ((rooms_.rflag[hack_.thfpos - 1] & (8192) + (1024) +
            (16)) != (8192)) {
      goto L1750;
   }
   hack_.thfflg = (0);
   goto L1025;
L1800:
   if (hack_.thfpos == rindex_.treas) {
      return;
   }
   j = 591;
   if (hack_.thfpos != play_.here) {
      j = 0;
   }
   i__1 = objcts_.olnt;
   for (i = 1; i <= i__1; ++i) {
      if (objcts_.oadv[i - 1] != -oindex_.thief || prob_(70, 70)
            || objcts_.otval[i - 1] > 0) {
         goto L1850;
      }
      newsta_(i, j, hack_.thfpos, 0, 0);
      j = 0;
L1850:
      ;
   }
   return;
}

canonical_original_code:
void thiefd_()
{
   int i__1; int i__2;
   int i; int j; int nr;
   int once;
   int rhere;
   once = (0);
L1025:
   rhere = objcts_.oroom[oindex_.thief - 1];
   if (rhere != 0) {
      hack_.thfpos = rhere;
   }
   if (hack_.thfpos == play_.here) {
      goto L1100;
   }
   if (hack_.thfpos != rindex_.treas) {
      goto L1400;
   }
   if (rhere == 0) {
      goto L1050;
   }
   newsta_(oindex_.thief, 0, 0, 0, 0);
   rhere = 0;
   if (qhere_(oindex_.still, rindex_.treas) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
L1050:
   i__1 = -oindex_.thief;
   i = robadv_(i__1, hack_.thfpos, 0, 0);
   if (qhere_(oindex_.egg, hack_.thfpos)) {
      objcts_.oflag2[oindex_.egg - 1] |= (8);
   }
   goto L1700;
L1100:
   if (hack_.thfpos == rindex_.treas) {
      goto L1700;
   }
   if ((rooms_.rflag[hack_.thfpos - 1] & (16384)) != 0) {
      goto L1400;
   }
   if (hack_.thfflg) {
      goto L1300;
   }
   if (rhere != 0 || prob_(70, 70)) {
      goto L1150;
   }
   if (objcts_.ocan[oindex_.still - 1] != oindex_.thief) {
      goto L1700;
   }
   newsta_(oindex_.thief, 583, hack_.thfpos, 0, 0);
   hack_.thfflg = (1);
   return;
L1150:
   if (rhere == 0 || (objcts_.oflag2[oindex_.thief - 1] & (256))
         == 0) {
      goto L1200;
   }
   if (winnin_(oindex_.thief, play_.winner)) {
      goto L1175;
   }
   newsta_(oindex_.thief, 584, 0, 0, 0);
   objcts_.oflag2[oindex_.thief - 1] &= ~ (256);
   if (qhere_(oindex_.still, hack_.thfpos) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
   return;
L1175:
   if (prob_(90, 90)) {
      goto L1700;
   }
L1200:
   if (rhere == 0 || prob_(70, 70)) {
      goto L1250;
   }
   newsta_(oindex_.thief, 585, 0, 0, 0);
   if (qhere_(oindex_.still, hack_.thfpos) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
   return;
L1300:
   if (rhere == 0) {
      goto L1700;
   }
L1250:
   if (prob_(70, 70)) {
      return;
   }
   hack_.thfflg = (1);
   i__1 = -oindex_.thief;
   i__2 = -oindex_.thief;
   nr = robrm_(hack_.thfpos, 100, 0, 0, i__1) + robadv_(
         play_.winner, 0, 0, i__2);
   i = 586;
   if (rhere != 0) {
      i = 588;
   }
   if (nr != 0) {
      ++i;
   }
   newsta_(oindex_.thief, i, 0, 0, 0);
   if (qhere_(oindex_.still, hack_.thfpos) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
   if (nr != 0 && ! lit_(hack_.thfpos)) {
      rspeak_(406);
   }
   rhere = 0;
   goto L1700;
L1400:
   newsta_(oindex_.thief, 0, 0, 0, 0);
   rhere = 0;
   if (qhere_(oindex_.still, hack_.thfpos) || objcts_.oadv[
         oindex_.still - 1] == -oindex_.thief) {
      newsta_(oindex_.still, 0, 0, oindex_.thief, 0);
   }
   if ((rooms_.rflag[hack_.thfpos - 1] & (32768)) == 0) {
      goto L1700;
   }
   i__1 = -oindex_.thief;
   i = robrm_(hack_.thfpos, 75, 0, 0, i__1);
   if (hack_.thfpos < rindex_.maze1 || hack_.thfpos > rindex_.maz15 ||
         play_.here < rindex_.maze1 || play_.here > rindex_.maz15) {
      goto L1500;
   }
   i__1 = objcts_.olnt;
   for (i = 1; i <= i__1; ++i) {
      if (! qhere_(i, hack_.thfpos) || prob_(60, 60) || (
               objcts_.oflag1[i - 1] & (32768) + (8192)) !=
            (32768) + (8192)) {
         goto L1450;
      }
      rspsub_(590, objcts_.odesc2[i - 1]);
      if (prob_(40, 20)) {
         goto L1700;
      }
      i__2 = -oindex_.thief;
      newsta_(i, 0, 0, 0, i__2);
      objcts_.oflag2[i - 1] |= (4);
      goto L1700;
L1450:
      ;
   }
   goto L1700;
L1500:
   i__1 = objcts_.olnt;
   for (i = 1; i <= i__1; ++i) {
      if (! qhere_(i, hack_.thfpos) || objcts_.otval[i - 1] != 0 ||
            prob_(80, 60) || (objcts_.oflag1[i - 1] &
               (32768) + (8192)) != (32768) +
            (8192)) {
         goto L1550;
      }
      i__2 = -oindex_.thief;
      newsta_(i, 0, 0, 0, i__2);
      objcts_.oflag2[i - 1] |= (4);
      goto L1700;
L1550:
      ;
   }
L1700:
   if (objcts_.oadv[oindex_.rope - 1] == -oindex_.thief) {
      findex_.domef = (0);
   }
   if (once) {
      goto L1800;
   }
   once = ! once;
L1750:
   --hack_.thfpos;
   if (hack_.thfpos <= 0) {
      hack_.thfpos = rooms_.rlnt;
   }
   if ((rooms_.rflag[hack_.thfpos - 1] & (8192) + (1024) +
            (16)) != (8192)) {
      goto L1750;
   }
   hack_.thfflg = (0);
   goto L1025;
L1800:
   if (hack_.thfpos == rindex_.treas) {
      return;
   }
   j = 591;
   if (hack_.thfpos != play_.here) {
      j = 0;
   }
   i__1 = objcts_.olnt;
   for (i = 1; i <= i__1; ++i) {
      if (objcts_.oadv[i - 1] != -oindex_.thief || prob_(70, 70)
            || objcts_.otval[i - 1] > 0) {
         goto L1850;
      }
      newsta_(i, j, hack_.thfpos, 0, 0);
      j = 0;
L1850:
      ;
   }
   return;
}

variable_types: j int

variable_types: nr int

variable_types: once int

variable_types: rhere int


repo: mgius/zork

decompiled_code:
__int64 __fastcall score_(int a1)
{
unsigned int v2; // ebp
int v3; // ecx
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // rsi
__int64 v7; // rdx
int v8; // eax
int v9; // edi

v2 = advs_[play_ + 4];
if ( findex_[32] )
{
more_output(0LL);
printf("Your score in the endgame ");
if ( a1 )
printf("would be");
else
printf("is");
v6 = state_[9];
printf(" %d [total of %d points], in %d moves.\n", v6, state_[10], state_[0]);
v7 = (unsigned int)((int)(20 * state_[9]) >> 31);
v8 = (int)(20 * state_[9]) / (int)state_[10];
if ( v8 > 19 )
{
v9 = 1;
}
else if ( v8 > 14 )
{
v9 = 2;
}
else if ( v8 > 9 )
{
v9 = 3;
}
else if ( v8 > 4 )
{
v9 = 4;
}
else
{
v9 = 5;
if ( v8 < 0 )
goto LABEL_2;
}
LODWORD(v7) = (int)(20 * state_[9]) % (int)state_[10];
rspeak_((unsigned int)(v9 + 786), v6, v7);
}
LABEL_2:
more_output(0LL);
printf("Your score ");
if ( a1 )
printf("would be");
else
printf("is");
printf(" %d [total of %d points], in %d move", v2, state_[3], state_[0]);
if ( state_[0] != 1 )
putchar(115);
puts(".");
v3 = 20;
result = (unsigned int)((int)(20 * v2) / (int)state_[3]);
v5 = 1LL;
while ( (int)result < v3 )
{
if ( v5 == 10 )
return result;
v3 = rank_0[v5++];
}
return rspeak_((unsigned int)(v5 + 484), v2, v5);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
unsigned int v2; // ebp
int v3; // ecx
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // rsi
__int64 v7; // rdx
int v8; // eax
int v9; // edi

v2 = advs_[play_ + 4];
if ( findex_[32] )
{
more_output(0LL);
printf("Your score in the endgame ");
if ( a1 )
printf("would be");
else
printf("is");
v6 = state_[9];
printf(" %d [total of %d points], in %d moves.\n", v6, state_[10], state_[0]);
v7 = (unsigned int)((int)(20 * state_[9]) >> 31);
v8 = (int)(20 * state_[9]) / (int)state_[10];
if ( v8 > 19 )
{
v9 = 1;
}
else if ( v8 > 14 )
{
v9 = 2;
}
else if ( v8 > 9 )
{
v9 = 3;
}
else if ( v8 > 4 )
{
v9 = 4;
}
else
{
v9 = 5;
if ( v8 < 0 )
goto LABEL_2;
}
LODWORD(v7) = (int)(20 * state_[9]) % (int)state_[10];
rspeak_((unsigned int)(v9 + 786), v6, v7);
}
LABEL_2:
more_output(0LL);
printf("Your score ");
if ( a1 )
printf("would be");
else
printf("is");
printf(" %d [total of %d points], in %d move", v2, state_[3], state_[0]);
if ( state_[0] != 1 )
putchar(115);
puts(".");
v3 = 20;
result = (unsigned int)((int)(20 * v2) / (int)state_[3]);
v5 = 1LL;
while ( (int)result < v3 )
{
if ( v5 == 10 )
return result;
v3 = rank_0[v5++];
}
return rspeak_((unsigned int)(v5 + 484), v2, v5);
}

original_code:
void score_(logical flg)
{
   static const integer rank[10] = { 20,19,18,16,12,8,4,2,1,0 };
   static const integer erank[5] = { 20,15,10,5,0 };
   integer i, as;
   as = advs_.ascore[play_.winner - 1];
   if (findex_.endgmf) {
      more_output(((void *)0));
      printf("Your score in the endgame ");
      if (flg)
         printf("would be");
      else
         printf("is");
      printf(" %d [total of %d points], in %d moves.\n", state_.egscor,
            state_.egmxsc, state_.moves);
      for (i = 1; i <= 5; ++i) {
         if (state_.egscor * 20 / state_.egmxsc >= erank[i - 1]) {
            rspeak_(i + 786);
            break;
         }
      }
   }
   more_output(((void *)0));
   printf("Your score ");
   if (flg)
      printf("would be");
   else
      printf("is");
   printf(" %d [total of %d points], in %d move", as, state_.mxscor,
         state_.moves);
   if (state_.moves != 1)
      printf("s");
   printf(".\n");
   for (i = 1; i <= 10; ++i) {
      if (as * 20 / state_.mxscor >= rank[i - 1]) {
         rspeak_(i + 484);
         return;
      }
   }
}

canonical_original_code:
void score_(int flg)
{
   static int rank[10] = { 20,19,18,16,12,8,4,2,1,0 };
   static int erank[5] = { 20,15,10,5,0 };
   int i; int as;
   as = advs_.ascore[play_.winner - 1];
   if (findex_.endgmf) {
      more_output(((void *)0));
      printf("Your score in the endgame ");
      if (flg)
         printf("would be");
      else
         printf("is");
      printf(" %d [total of %d points], in %d moves.\n", state_.egscor,
            state_.egmxsc, state_.moves);
      for (i = 1; i <= 5; ++i) {
         if (state_.egscor * 20 / state_.egmxsc >= erank[i - 1]) {
            rspeak_(i + 786);
            break;
         }
      }
   }
   more_output(((void *)0));
   printf("Your score ");
   if (flg)
      printf("would be");
   else
      printf("is");
   printf(" %d [total of %d points], in %d move", as, state_.mxscor,
         state_.moves);
   if (state_.moves != 1)
      printf("s");
   printf(".\n");
   for (i = 1; i <= 10; ++i) {
      if (as * 20 / state_.mxscor >= rank[i - 1]) {
         rspeak_(i + 484);
         return;
      }
   }
}

variable_types: flg int

variable_types:
rank
int [10]

variable_types:
erank
int [5]

variable_types: i int

variable_types: as int

return_type: void


decompiled_code:
__int64 __fastcall scrupd_(int a1)
{
__int64 result; // rax
int v2; // eax
__int64 v3; // rax
int v4; // edx

result = (unsigned int)findex_[32];
if ( (_DWORD)result )
{
state_[9] += a1;
}
else
{
v2 = play_;
state_[2] += a1;
v3 = v2 - 1;
v4 = a1 + advs_[v3 + 5];
advs_[v3 + 5] = v4;
result = state_[3] - 10 * state_[1];
if ( v4 >= (int)result )
{
result = cindex_[14] - 1;
cevent_[(int)result + 51] = 1;
cevent_[(int)result + 1] = 15;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 result; // rax
int v2; // eax
__int64 v3; // rax
int v4; // edx

result = (unsigned int)findex_[32];
if ( (_DWORD)result )
{
state_[9] += a1;
}
else
{
v2 = play_;
state_[2] += a1;
v3 = v2 - 1;
v4 = a1 + advs_[v3 + 5];
advs_[v3 + 5] = v4;
result = state_[3] - 10 * state_[1];
if ( v4 >= (int)result )
{
result = cindex_[14] - 1;
cevent_[(int)result + 51] = 1;
cevent_[(int)result + 1] = 15;
}
}
return result;
}

original_code:
void scrupd_(integer n)
{
   if (findex_.endgmf) {
      state_.egscor += n;
      return;
   }
   advs_.ascore[play_.winner - 1] += n;
   state_.rwscor += n;
   if (advs_.ascore[play_.winner - 1] < state_.mxscor - state_.deaths *10) {
      return;
   }
   cevent_.cflag[cindex_.cevegh - 1] = (1);
   cevent_.ctick[cindex_.cevegh - 1] = 15;
   return;
}

canonical_original_code:
void scrupd_(int n)
{
   if (findex_.endgmf) {
      state_.egscor += n;
      return;
   }
   advs_.ascore[play_.winner - 1] += n;
   state_.rwscor += n;
   if (advs_.ascore[play_.winner - 1] < state_.mxscor - state_.deaths *10) {
      return;
   }
   cevent_.cflag[cindex_.cevegh - 1] = (1);
   cevent_.ctick[cindex_.cevegh - 1] = 15;
   return;
}

variable_types: n int


decompiled_code:
__int64 __fastcall moveto_(unsigned int a1, __int64 a2)
{
__int64 v3; // r12
__int64 v4; // rbx
__int64 v5; // rdx
int v6; // eax
__int64 v7; // rbx
int v8; // edi
__int64 result; // rax

v3 = (int)a2 - 1;
v4 = (int)(a1 - 1);
v5 = rooms_[v4 + 1001];
v6 = advs_[v3 + 9];
if ( v6 )
{
rspsub_(428LL, objcts_[v6 + 220]);
result = 0LL;
}
else if ( (rooms_[v4 + 1001] & 0x2000) != 0 )
{
BYTE1(v5) &= 1u;
if ( BYTE1(v5) )
{
rspeak_(rooms_[a1 + 600], a2, v5);
result = 1LL;
}
else
{
if ( aindex_ != (_DWORD)a2 )
newsta_((unsigned int)advs_[v3 + 13], 0LL, a1, 0LL, 0LL);
v7 = v4 + 800;
advs_[v3 + 1] = a1;
v8 = rooms_[v7 + 1];
*((_DWORD *)&play_ + 1) = a1;
scrupd_(v8);
result = 1LL;
rooms_[v7 + 1] = 0;
}
}
else
{
rspeak_(427LL, a2, v5);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, __int64 a2)
{
__int64 v3; // r12
__int64 v4; // rbx
__int64 v5; // rdx
int v6; // eax
__int64 v7; // rbx
int v8; // edi
__int64 result; // rax

v3 = (int)a2 - 1;
v4 = (int)(a1 - 1);
v5 = rooms_[v4 + 1001];
v6 = advs_[v3 + 9];
if ( v6 )
{
rspsub_(428LL, objcts_[v6 + 220]);
result = 0LL;
}
else if ( (rooms_[v4 + 1001] & 0x2000) != 0 )
{
BYTE1(v5) &= 1u;
if ( BYTE1(v5) )
{
rspeak_(rooms_[a1 + 600], a2, v5);
result = 1LL;
}
else
{
if ( aindex_ != (_DWORD)a2 )
newsta_((unsigned int)advs_[v3 + 13], 0LL, a1, 0LL, 0LL);
v7 = v4 + 800;
advs_[v3 + 1] = a1;
v8 = rooms_[v7 + 1];
*((_DWORD *)&play_ + 1) = a1;
func1(v8);
result = 1LL;
rooms_[v7 + 1] = 0;
}
}
else
{
rspeak_(427LL, a2, v5);
result = 0LL;
}
return result;
}

original_code:
logical moveto_(integer nr, integer who)
{
   logical ret_val;
   integer j;
   logical lhr;
   logical lnr, nlv;
   integer bits;
   ret_val = (0);
   lhr = (rooms_.rflag[play_.here - 1] & (8192)) != 0;
   lnr = (rooms_.rflag[nr - 1] & (8192)) != 0;
   j = advs_.avehic[who - 1];
   if (j != 0) {
      goto L100;
   }
   if (lnr) {
   ret_val = (1);
   if ((rooms_.rflag[nr - 1] & (256)) == 0) {
      if (who != aindex_.player) {
         newsta_(advs_.aobj[who - 1], 0, nr, 0, 0);
      }
      if (j != 0) {
         newsta_(j, 0, nr, 0, 0);
      }
      play_.here = nr;
      advs_.aroom[who - 1] = play_.here;
      scrupd_(rooms_.rval[nr - 1]);
      rooms_.rval[nr - 1] = 0;
      return ret_val;
   }
   rspeak_(((integer *)&rooms_ + 601)[nr - 1]);
   return ret_val;
   }
   rspeak_(427);
   return ret_val;
L100:
   bits = 0;
   if (j == oindex_.rboat) {
      bits = (4096);
   }
   if (j == oindex_.ballo) {
      bits = (2048);
   }
   if (j == oindex_.bucke) {
      bits = (128);
   }
   nlv = (rooms_.rflag[nr - 1] & bits) == 0;
   if (! lnr && nlv || lnr && lhr && nlv && bits != (8192)) {
      goto L800;
   }
L800:
   rspsub_(428, objcts_.odesc2[j - 1]);
   return ret_val;
}

canonical_original_code:
int moveto_(int nr, int who)
{
   int ret_val;
   int j;
   int lhr;
   int lnr; int nlv;
   int bits;
   ret_val = (0);
   lhr = (rooms_.rflag[play_.here - 1] & (8192)) != 0;
   lnr = (rooms_.rflag[nr - 1] & (8192)) != 0;
   j = advs_.avehic[who - 1];
   if (j != 0) {
      goto L100;
   }
   if (lnr) {
   ret_val = (1);
   if ((rooms_.rflag[nr - 1] & (256)) == 0) {
      if (who != aindex_.player) {
         newsta_(advs_.aobj[who - 1], 0, nr, 0, 0);
      }
      if (j != 0) {
         newsta_(j, 0, nr, 0, 0);
      }
      play_.here = nr;
      advs_.aroom[who - 1] = play_.here;
      scrupd_(rooms_.rval[nr - 1]);
      rooms_.rval[nr - 1] = 0;
      return ret_val;
   }
   rspeak_(((int *)&rooms_ + 601)[nr - 1]);
   return ret_val;
   }
   rspeak_(427);
   return ret_val;
L100:
   bits = 0;
   if (j == oindex_.rboat) {
      bits = (4096);
   }
   if (j == oindex_.ballo) {
      bits = (2048);
   }
   if (j == oindex_.bucke) {
      bits = (128);
   }
   nlv = (rooms_.rflag[nr - 1] & bits) == 0;
   if (! lnr && nlv || lnr && lhr && nlv && bits != (8192)) {
      goto L800;
   }
L800:
   rspsub_(428, objcts_.odesc2[j - 1]);
   return ret_val;
}

variable_types: who int

variable_types: lhr int

variable_types: lnr int

variable_types: nlv int

variable_types: bits int

return_type: int


decompiled_code:
void __noreturn game_()
{
unsigned int v0; // ebx
int v1; // eax
unsigned int v2; // er14
int v3; // ebp
__int64 v4; // r12
int v5; // eax
int v6; // eax
unsigned int v7; // eax
int v8; // eax
bool v9; // cc
unsigned int v10; // eax
int v11; // eax

rspeak_(1LL);
rmdesc_(3LL);
v0 = aindex_;
v1 = prsvec_[4];
v2 = oindex_[116];
v3 = aindex_ - 1;
v4 = oindex_[21] - 1 + 1100LL;
while ( 1 )
{
play_[0] = v0;
play_[2] = 0;
if ( v1 <= 1 )
rdline_((unsigned int)((_DWORD)&input_ + 4), 1LL);
++state_;
v5 = parse_((unsigned int)((_DWORD)&input_ + 4), 1LL);
prsvec_[3] = v5;
if ( !v5 || (unsigned int)xvehic_(1u) )
goto LABEL_5;
if ( prsvec_[0] == vindex_[51] )
{
if ( (objcts_[prsvec_[2] + 1100] & 0x400) == 0 )
{
rspeak_(602LL);
goto LABEL_15;
}
play_[0] = oactor_();
v9 = prsvec_[4] <= 1;
play_[1] = advs_[play_[0]];
if ( v9 || !(unsigned int)parse_((unsigned int)((_DWORD)&input_ + 4), 1LL) )
{
rspeak_(play_[2] == 0 ? 341 : 604);
goto LABEL_28;
}
if ( (unsigned int)aappli_((unsigned int)advs_[play_[0] + 16]) || (unsigned int)xvehic_(1u) )
goto LABEL_36;
v11 = prsvec_[2];
if ( v11 != v2 && v11 != oindex_[115] )
{
if ( (unsigned int)vappli_(prsvec_[0]) )
rappli_(rooms_[play_[1] - 1 + 601]);
LABEL_36:
xendmv_(play_[2]);
LABEL_28:
v10 = advs_[v3 + 1];
play_[0] = v0;
play_[1] = v10;
goto LABEL_15;
}
}
else
{
LABEL_10:
v6 = prsvec_[2];
if ( v6 != v2 && v6 != oindex_[115] )
{
if ( !(unsigned int)vappli_(prsvec_[0]) )
goto LABEL_5;
goto LABEL_15;
}
}
valuac_(v2);
LABEL_15:
v7 = play_[1];
if ( !findex_[8] && *((_DWORD *)&rindex_ + 13) == v7 )
{
while ( 1 )
{
rdline_((unsigned int)((_DWORD)&input_ + 4), 0LL);
++state_;
if ( !strcmp((const char *)(unsigned int)((_DWORD)&input_ + 4), "ECHO") )
break;
v8 = parse_((unsigned int)((_DWORD)&input_ + 4), 0LL);
prsvec_[3] = v8;
if ( v8 && prsvec_[0] == vindex_[50] && (unsigned int)findxt_((unsigned int)prsvec_[2], play_[1]) )
goto LABEL_10;
more_output((unsigned int)((_DWORD)&input_ + 4));
play_[2] = 1;
}
rspeak_(571LL);
objcts_[v4 + 1] &= 0xFFFFDFFF;
findex_[8] = 1;
*(_QWORD *)&prsvec_[3] = 0x100000001LL;
}
else
{
rappli_(rooms_[v7 - 1 + 601]);
}
LABEL_5:
xendmv_(play_[2]);
if ( (unsigned int)lit_(play_[1]) )
{
v1 = prsvec_[4];
}
else
{
prsvec_[4] = 1;
v1 = 1;
}
}
}

canonical_decompiled_code:
void __noreturn func2()
{
unsigned int v0; // ebx
int v1; // eax
unsigned int v2; // er14
int v3; // ebp
__int64 v4; // r12
int v5; // eax
int v6; // eax
unsigned int v7; // eax
int v8; // eax
bool v9; // cc
unsigned int v10; // eax
int v11; // eax

rspeak_(1LL);
rmdesc_(3LL);
v0 = aindex_;
v1 = prsvec_[4];
v2 = oindex_[116];
v3 = aindex_ - 1;
v4 = oindex_[21] - 1 + 1100LL;
while ( 1 )
{
play_[0] = v0;
play_[2] = 0;
if ( v1 <= 1 )
rdline_((unsigned int)((_DWORD)&input_ + 4), 1LL);
++state_;
v5 = parse_((unsigned int)((_DWORD)&input_ + 4), 1LL);
prsvec_[3] = v5;
if ( !v5 || (unsigned int)func0(1u) )
goto LABEL_5;
if ( prsvec_[0] == vindex_[51] )
{
if ( (objcts_[prsvec_[2] + 1100] & 0x400) == 0 )
{
rspeak_(602LL);
goto LABEL_15;
}
play_[0] = oactor_();
v9 = prsvec_[4] <= 1;
play_[1] = advs_[play_[0]];
if ( v9 || !(unsigned int)parse_((unsigned int)((_DWORD)&input_ + 4), 1LL) )
{
rspeak_(play_[2] == 0 ? 341 : 604);
goto LABEL_28;
}
if ( (unsigned int)aappli_((unsigned int)advs_[play_[0] + 16]) || (unsigned int)func0(1u) )
goto LABEL_36;
v11 = prsvec_[2];
if ( v11 != v2 && v11 != oindex_[115] )
{
if ( (unsigned int)vappli_(prsvec_[0]) )
rappli_(rooms_[play_[1] - 1 + 601]);
LABEL_36:
func1(play_[2]);
LABEL_28:
v10 = advs_[v3 + 1];
play_[0] = v0;
play_[1] = v10;
goto LABEL_15;
}
}
else
{
LABEL_10:
v6 = prsvec_[2];
if ( v6 != v2 && v6 != oindex_[115] )
{
if ( !(unsigned int)vappli_(prsvec_[0]) )
goto LABEL_5;
goto LABEL_15;
}
}
valuac_(v2);
LABEL_15:
v7 = play_[1];
if ( !findex_[8] && *((_DWORD *)&rindex_ + 13) == v7 )
{
while ( 1 )
{
rdline_((unsigned int)((_DWORD)&input_ + 4), 0LL);
++state_;
if ( !strcmp((const char *)(unsigned int)((_DWORD)&input_ + 4), "ECHO") )
break;
v8 = parse_((unsigned int)((_DWORD)&input_ + 4), 0LL);
prsvec_[3] = v8;
if ( v8 && prsvec_[0] == vindex_[50] && (unsigned int)findxt_((unsigned int)prsvec_[2], play_[1]) )
goto LABEL_10;
more_output((unsigned int)((_DWORD)&input_ + 4));
play_[2] = 1;
}
rspeak_(571LL);
objcts_[v4 + 1] &= 0xFFFFDFFF;
findex_[8] = 1;
*(_QWORD *)&prsvec_[3] = 0x100000001LL;
}
else
{
rappli_(rooms_[v7 - 1 + 601]);
}
LABEL_5:
func1(play_[2]);
if ( (unsigned int)lit_(play_[1]) )
{
v1 = prsvec_[4];
}
else
{
prsvec_[4] = 1;
v1 = 1;
}
}
}

original_code:
void game_()
{
    logical f;
    integer i;
    rspeak_(1);
    f = rmdesc_(3);
L100:
    play_.winner = aindex_.player;
    play_.telflg = (0);
    if (prsvec_.prscon <= 1) {
 rdline_(input_.inbuf, 1);
    }
    ++state_.moves;
    prsvec_.prswon = parse_(input_.inbuf, 1);
    if (! prsvec_.prswon) {
 goto L400;
    }
    if (xvehic_(1)) {
 goto L400;
    }
    if (prsvec_.prsa == vindex_.tellw) {
 goto L2000;
    }
L300:
    if (prsvec_.prso == oindex_.valua || prsvec_.prso == oindex_.every) {
 goto L900;
    }
    if (! vappli_(prsvec_.prsa)) {
 goto L400;
    }
L350:
    if (! findex_.echof && play_.here == rindex_.echor) {
 goto L1000;
    }
    f = rappli_(rooms_.ractio[play_.here - 1]);
L400:
    xendmv_(play_.telflg);
    if (! lit_(play_.here)) {
 prsvec_.prscon = 1;
    }
    goto L100;
L900:
    valuac_(oindex_.valua);
    goto L350;
L1000:
    rdline_(input_.inbuf, 0);
    ++state_.moves;
    if (strcmp(input_.inbuf, "ECHO") != 0)
 goto L1300;
    rspeak_(571);
    findex_.echof = (1);
    objcts_.oflag2[oindex_.bar - 1] &= ~ (8192);
    prsvec_.prswon = (1);
    prsvec_.prscon = 1;
    goto L400;
L1300:
    prsvec_.prswon = parse_(input_.inbuf, 0);
    if (! prsvec_.prswon || prsvec_.prsa != vindex_.walkw) {
 goto L1400;
    }
    if (findxt_(prsvec_.prso, play_.here)) {
 goto L300;
    }
L1400:
    more_output(input_.inbuf);
    play_.telflg = (1);
    goto L1000;
L2000:
    if ((objcts_.oflag2[prsvec_.prso - 1] & (1024)) != 0) {
 goto L2100;
    }
    rspeak_(602);
    goto L350;
L2100:
    play_.winner = oactor_(prsvec_.prso);
    play_.here = advs_.aroom[play_.winner - 1];
    if (prsvec_.prscon <= 1) {
 goto L2700;
    }
    if (parse_(input_.inbuf, 1)) {
 goto L2150;
    }
L2700:
    i = 341;
    if (play_.telflg) {
 i = 604;
    }
    rspeak_(i);
L2600:
    play_.winner = aindex_.player;
    play_.here = advs_.aroom[play_.winner - 1];
    goto L350;
L2150:
    if (aappli_(advs_.aactio[play_.winner - 1])) {
 goto L2400;
    }
    if (xvehic_(1)) {
 goto L2400;
    }
    if (prsvec_.prso == oindex_.valua || prsvec_.prso == oindex_.every) {
 goto L2900;
    }
    if (! vappli_(prsvec_.prsa)) {
 goto L2400;
    }
    f = rappli_(rooms_.ractio[play_.here - 1]);
L2400:
    xendmv_(play_.telflg);
    goto L2600;
L2900:
    valuac_(oindex_.valua);
    goto L350;
}

canonical_original_code:
void game_()
{
    int f;
    int i;
    rspeak_(1);
    f = rmdesc_(3);
L100:
    play_.winner = aindex_.player;
    play_.telflg = (0);
    if (prsvec_.prscon <= 1) {
 rdline_(input_.inbuf, 1);
    }
    ++state_.moves;
    prsvec_.prswon = parse_(input_.inbuf, 1);
    if (! prsvec_.prswon) {
 goto L400;
    }
    if (xvehic_(1)) {
 goto L400;
    }
    if (prsvec_.prsa == vindex_.tellw) {
 goto L2000;
    }
L300:
    if (prsvec_.prso == oindex_.valua || prsvec_.prso == oindex_.every) {
 goto L900;
    }
    if (! vappli_(prsvec_.prsa)) {
 goto L400;
    }
L350:
    if (! findex_.echof && play_.here == rindex_.echor) {
 goto L1000;
    }
    f = rappli_(rooms_.ractio[play_.here - 1]);
L400:
    xendmv_(play_.telflg);
    if (! lit_(play_.here)) {
 prsvec_.prscon = 1;
    }
    goto L100;
L900:
    valuac_(oindex_.valua);
    goto L350;
L1000:
    rdline_(input_.inbuf, 0);
    ++state_.moves;
    if (strcmp(input_.inbuf, "ECHO") != 0)
 goto L1300;
    rspeak_(571);
    findex_.echof = (1);
    objcts_.oflag2[oindex_.bar - 1] &= ~ (8192);
    prsvec_.prswon = (1);
    prsvec_.prscon = 1;
    goto L400;
L1300:
    prsvec_.prswon = parse_(input_.inbuf, 0);
    if (! prsvec_.prswon || prsvec_.prsa != vindex_.walkw) {
 goto L1400;
    }
    if (findxt_(prsvec_.prso, play_.here)) {
 goto L300;
    }
L1400:
    more_output(input_.inbuf);
    play_.telflg = (1);
    goto L1000;
L2000:
    if ((objcts_.oflag2[prsvec_.prso - 1] & (1024)) != 0) {
 goto L2100;
    }
    rspeak_(602);
    goto L350;
L2100:
    play_.winner = oactor_(prsvec_.prso);
    play_.here = advs_.aroom[play_.winner - 1];
    if (prsvec_.prscon <= 1) {
 goto L2700;
    }
    if (parse_(input_.inbuf, 1)) {
 goto L2150;
    }
L2700:
    i = 341;
    if (play_.telflg) {
 i = 604;
    }
    rspeak_(i);
L2600:
    play_.winner = aindex_.player;
    play_.here = advs_.aroom[play_.winner - 1];
    goto L350;
L2150:
    if (aappli_(advs_.aactio[play_.winner - 1])) {
 goto L2400;
    }
    if (xvehic_(1)) {
 goto L2400;
    }
    if (prsvec_.prso == oindex_.valua || prsvec_.prso == oindex_.every) {
 goto L2900;
    }
    if (! vappli_(prsvec_.prsa)) {
 goto L2400;
    }
    f = rappli_(rooms_.ractio[play_.here - 1]);
L2400:
    xendmv_(play_.telflg);
    goto L2600;
L2900:
    valuac_(oindex_.valua);
    goto L350;
}

variable_types: f int


protected

decompiled_code:
__int64 protected()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 1LL;
}

original_code:
logical protected()
{
    return (1);
}

canonical_original_code:
int protected()
{
    return (1);
}


original_code:
void encryp_(const char *inw, char *outw)
{
   const char *keyw = "ECORMS";
   integer i, j, uinw[6], usum;
   char ukeyw[1*6];
   integer uinws, ukeyws;
   --outw;
   --inw;
   uinws = 0;
   ukeyws = 0;
   j = 1;
   for (i = 1; i <= 6; ++i) {
      ukeyw[i - 1] = (keyw[i - 1] - 64);
      if (inw[j] <= '@') {
         j = 1;
      }
      uinw[i - 1] = inw[j] - 64;
      ukeyws += ukeyw[i - 1];
      uinws += uinw[i - 1];
      ++j;
   }
   usum = uinws % 8 + (ukeyws % 8 << 3);
   for (i = 1; i <= 6; ++i) {
      j = (uinw[i - 1] ^ ukeyw[i - 1] ^ usum) & 31;
      usum = (usum + 1) % 32;
      if (j > 26) {
         j %= 26;
      }
      outw[i] = (((1) >= (j) ? (1) : (j)) + 64);
   }
}

canonical_original_code:
void encryp_(char *inw, char *outw)
{
   char *keyw = "ECORMS";
   int i; int j; int uinw[6]; int usum;
   char ukeyw[-1];
   int uinws; int ukeyws;
   --outw;
   --inw;
   uinws = 0;
   ukeyws = 0;
   j = 1;
   for (i = 1; i <= 6; ++i) {
      ukeyw[i - 1] = (keyw[i - 1] - 64);
      if (inw[j] <= '@') {
         j = 1;
      }
      uinw[i - 1] = inw[j] - 64;
      ukeyws += ukeyw[i - 1];
      uinws += uinw[i - 1];
      ++j;
   }
   usum = uinws % 8 + (ukeyws % 8 << 3);
   for (i = 1; i <= 6; ++i) {
      j = (uinw[i - 1] ^ ukeyw[i - 1] ^ usum) & 31;
      usum = (usum + 1) % 32;
      if (j > 26) {
         j %= 26;
      }
      outw[i] = (((1) >= (j) ? (1) : (j)) + 64);
   }
}

variable_types:
inw
char *

variable_types:
outw
char *

variable_types:
keyw
char *

variable_types:
uinw
int [6]

variable_types: usum int

variable_types:
ukeyw
char [-1]

variable_types: uinws int

variable_types: ukeyws int


decompiled_code:
__int64 __fastcall cpgoto_(int a1)
{
unsigned int v2; // ebp
__int64 result; // rax
int v4; // er14
__int64 v5; // rbx
int v6; // er15
__int64 v7; // rdi

v2 = *((_DWORD *)&rindex_ + 85);
rooms_[v2 - 1 + 1001] &= 0xFFFF7FFF;
result = objcts_[0];
if ( (int)objcts_[0] > 0 )
{
v4 = hyper_;
v5 = 1LL;
v6 = hyper_ * a1;
while ( 1 )
{
result = objcts_[v5 + 2200];
if ( v2 != (_DWORD)result || (objcts_[v5 + 1100] & 0x480) != 0 )
{
if ( v6 != (_DWORD)result )
goto LABEL_4;
LABEL_8:
v7 = (unsigned int)v5++;
result = newsta_(v7, 0LL, v2, 0LL, 0LL);
if ( (int)objcts_[0] < (int)v5 )
break;
}
else
{
newsta_((unsigned int)v5, 0LL, (unsigned int)(v4 * findex_[67]), 0LL, 0LL);
result = objcts_[v5 + 2200];
if ( v6 == (_DWORD)result )
goto LABEL_8;
LABEL_4:
if ( (int)objcts_[0] < (int)++v5 )
break;
}
}
}
findex_[67] = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
unsigned int v2; // ebp
__int64 result; // rax
int v4; // er14
__int64 v5; // rbx
int v6; // er15
__int64 v7; // rdi

v2 = *((_DWORD *)&rindex_ + 85);
rooms_[v2 - 1 + 1001] &= 0xFFFF7FFF;
result = objcts_[0];
if ( (int)objcts_[0] > 0 )
{
v4 = hyper_;
v5 = 1LL;
v6 = hyper_ * a1;
while ( 1 )
{
result = objcts_[v5 + 2200];
if ( v2 != (_DWORD)result || (objcts_[v5 + 1100] & 0x480) != 0 )
{
if ( v6 != (_DWORD)result )
goto LABEL_4;
LABEL_8:
v7 = (unsigned int)v5++;
result = newsta_(v7, 0LL, v2, 0LL, 0LL);
if ( (int)objcts_[0] < (int)v5 )
break;
}
else
{
newsta_((unsigned int)v5, 0LL, (unsigned int)(v4 * findex_[67]), 0LL, 0LL);
result = objcts_[v5 + 2200];
if ( v6 == (_DWORD)result )
goto LABEL_8;
LABEL_4:
if ( (int)objcts_[0] < (int)++v5 )
break;
}
}
}
findex_[67] = a1;
return result;
}

original_code:
void cpgoto_(integer st)
{
   integer i__2;
   integer i;
   rooms_.rflag[rindex_.cpuzz - 1] &= ~ (32768);
   for (i = 1; i <= objcts_.olnt; ++i) {
      if (objcts_.oroom[i - 1] == rindex_.cpuzz && (objcts_.oflag2[i - 1]
               & (1024) + (128)) == 0) {
         i__2 = findex_.cphere * hyper_.hfactr;
         newsta_(i, 0, i__2, 0, 0);
      }
      if (objcts_.oroom[i - 1] == st * hyper_.hfactr) {
         newsta_(i, 0, rindex_.cpuzz, 0, 0);
      }
   }
   findex_.cphere = st;
}

canonical_original_code:
void cpgoto_(int st)
{
   int i__2;
   int i;
   rooms_.rflag[rindex_.cpuzz - 1] &= ~ (32768);
   for (i = 1; i <= objcts_.olnt; ++i) {
      if (objcts_.oroom[i - 1] == rindex_.cpuzz && (objcts_.oflag2[i - 1]
               & (1024) + (128)) == 0) {
         i__2 = findex_.cphere * hyper_.hfactr;
         newsta_(i, 0, i__2, 0, 0);
      }
      if (objcts_.oroom[i - 1] == st * hyper_.hfactr) {
         newsta_(i, 0, rindex_.cpuzz, 0, 0);
      }
   }
   findex_.cphere = st;
}

variable_types: st int

variable_types: i int


decompiled_code:
__int64 __fastcall cpinfo_(__int64 a1, int a2)
{
__int64 v3; // rdx
int i; // ecx
unsigned int v5; // esi
unsigned int v6; // eax
__int64 v7; // rdi
__int64 result; // rax
__int64 v9; // [rsp+0h] [rbp-28h]
char v10; // [rsp+18h] [rbp-10h]
char v11; // [rsp+19h] [rbp-Fh]
char v12; // [rsp+1Ah] [rbp-Eh]
char v13; // [rsp+1Bh] [rbp-Dh]
char v14; // [rsp+1Ch] [rbp-Ch]
char v15; // [rsp+1Dh] [rbp-Bh]
char v16; // [rsp+1Eh] [rbp-Ah]
char v17; // [rsp+1Fh] [rbp-9h]

rspeak_(a1);
v3 = 0LL;
for ( i = -9; ; i = dgmoft_0[v3] )
{
*(&v10 + v3) = byte_388[puzzle_[i + 23 + a2]];
v5 = abs32(i);
if ( v5 != 1 && v5 != 8 )
{
v6 = ((i >> 31) & 0xFFFFFFF0) + 8;
if ( puzzle_[v6 + a2 - 1 + 24] )
{
if ( puzzle_[a2 + i - v6 - 1 + 24] )
*(&v10 + v3) = 63;
}
}
if ( ++v3 == 8 )
break;
}
more_output(0LL);
printf(
" |%c%c %c%c %c%c|\n",
(unsigned int)v10,
(unsigned int)v10,
(unsigned int)v11,
(unsigned int)v11,
(unsigned int)v12,
(unsigned int)v12);
more_output(0LL);
printf(" West |%c%c .. %c%c| East\n", (unsigned int)v13, (unsigned int)v13, (unsigned int)v14, (unsigned int)v14);
more_output(0LL);
LODWORD(v9) = v17;
printf(
" |%c%c %c%c %c%c|\n",
(unsigned int)v15,
(unsigned int)v15,
(unsigned int)v16,
(unsigned int)v16,
(unsigned int)v17,
v9);
if ( a2 == 10 )
{
rspeak_(870LL);
goto LABEL_17;
}
if ( a2 == 37 )
{
rspeak_(871LL);
LABEL_17:
if ( findex_[44] )
goto LABEL_13;
goto LABEL_18;
}
v7 = 873LL;
if ( !findex_[44] )
{
LABEL_18:
v7 = 872LL;
if ( a2 == 52 )
goto LABEL_19;
LABEL_13:
result = a2;
if ( puzzle_[a2 + 24] != -2 )
goto LABEL_14;
goto LABEL_20;
}
if ( a2 != 52 )
goto LABEL_13;
LABEL_19:
rspeak_(v7);
result = a2;
if ( puzzle_[a2 + 24] != -2 )
{
LABEL_14:
if ( puzzle_[a2 + 22] != -3 )
return result;
return rspeak_(875LL);
}
LABEL_20:
result = rspeak_(874LL);
if ( puzzle_[a2 + 22] == -3 )
return rspeak_(875LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
__int64 v3; // rdx
int i; // ecx
unsigned int v5; // esi
unsigned int v6; // eax
__int64 v7; // rdi
__int64 result; // rax
__int64 v9; // [rsp+0h] [rbp-28h]
char v10; // [rsp+18h] [rbp-10h]
char v11; // [rsp+19h] [rbp-Fh]
char v12; // [rsp+1Ah] [rbp-Eh]
char v13; // [rsp+1Bh] [rbp-Dh]
char v14; // [rsp+1Ch] [rbp-Ch]
char v15; // [rsp+1Dh] [rbp-Bh]
char v16; // [rsp+1Eh] [rbp-Ah]
char v17; // [rsp+1Fh] [rbp-9h]

rspeak_(a1);
v3 = 0LL;
for ( i = -9; ; i = dgmoft_0[v3] )
{
*(&v10 + v3) = byte_388[puzzle_[i + 23 + a2]];
v5 = abs32(i);
if ( v5 != 1 && v5 != 8 )
{
v6 = ((i >> 31) & 0xFFFFFFF0) + 8;
if ( puzzle_[v6 + a2 - 1 + 24] )
{
if ( puzzle_[a2 + i - v6 - 1 + 24] )
*(&v10 + v3) = 63;
}
}
if ( ++v3 == 8 )
break;
}
more_output(0LL);
printf(
" |%c%c %c%c %c%c|\n",
(unsigned int)v10,
(unsigned int)v10,
(unsigned int)v11,
(unsigned int)v11,
(unsigned int)v12,
(unsigned int)v12);
more_output(0LL);
printf(" West |%c%c .. %c%c| East\n", (unsigned int)v13, (unsigned int)v13, (unsigned int)v14, (unsigned int)v14);
more_output(0LL);
LODWORD(v9) = v17;
printf(
" |%c%c %c%c %c%c|\n",
(unsigned int)v15,
(unsigned int)v15,
(unsigned int)v16,
(unsigned int)v16,
(unsigned int)v17,
v9);
if ( a2 == 10 )
{
rspeak_(870LL);
goto LABEL_17;
}
if ( a2 == 37 )
{
rspeak_(871LL);
LABEL_17:
if ( findex_[44] )
goto LABEL_13;
goto LABEL_18;
}
v7 = 873LL;
if ( !findex_[44] )
{
LABEL_18:
v7 = 872LL;
if ( a2 == 52 )
goto LABEL_19;
LABEL_13:
result = a2;
if ( puzzle_[a2 + 24] != -2 )
goto LABEL_14;
goto LABEL_20;
}
if ( a2 != 52 )
goto LABEL_13;
LABEL_19:
rspeak_(v7);
result = a2;
if ( puzzle_[a2 + 24] != -2 )
{
LABEL_14:
if ( puzzle_[a2 + 22] != -3 )
return result;
return rspeak_(875LL);
}
LABEL_20:
result = rspeak_(874LL);
if ( puzzle_[a2 + 22] == -3 )
return rspeak_(875LL);
return result;
}

original_code:
void cpinfo_(integer rmk, integer st)
{
   static const integer dgmoft[8] = { -9,-8,-7,-1,1,7,8,9 };
   const char *pict = "SSS M";
   integer i, j, k, l;
   char dgm[1*8];
   rspeak_(rmk);
   for (i = 1; i <= 8; ++i) {
      j = dgmoft[i - 1];
      dgm[i - 1] = pict[puzzle_.cpvec[st + j - 1] + 3];
      if (((j) >= 0 ? (j) : -(j)) == 1 || ((j) >= 0 ? (j) : -(j)) == 8) {
         continue;
      }
      k = 8;
      if (j < 0) {
         k = -8;
      }
      l = j - k;
      if (puzzle_.cpvec[st + k - 1] != 0 && puzzle_.cpvec[st + l - 1] !=
            0) {
         dgm[i - 1] = '?';
      }
   }
   more_output(((void *)0));
   printf("       |%c%c %c%c %c%c|\n", dgm[0], dgm[0], dgm[1], dgm[1],
         dgm[2], dgm[2]);
   more_output(((void *)0));
   printf(" West  |%c%c .. %c%c| East\n", dgm[3], dgm[3], dgm[4], dgm[4]);
   more_output(((void *)0));
   printf("       |%c%c %c%c %c%c|\n", dgm[5], dgm[5], dgm[6], dgm[6],
         dgm[7], dgm[7]);
   if (st == 10) {
      rspeak_(870);
   }
   if (st == 37) {
      rspeak_(871);
   }
   i = 872;
   if (findex_.cpoutf) {
      i = 873;
   }
   if (st == 52) {
      rspeak_(i);
   }
   if (puzzle_.cpvec[st] == -2) {
      rspeak_(874);
   }
   if (puzzle_.cpvec[st - 2] == -3) {
      rspeak_(875);
   }
}

variable_types: rmk int

variable_types:
dgmoft
int [8]

variable_types:
pict
char *

variable_types: j int

variable_types: k int

variable_types: l int

variable_types:
dgm
char [-1]


original_code:
logical findxt_(integer dir, integer rm)
{
   logical ret_val;
   integer i, xi;
   integer xxxflg;
   ret_val = (1);
   xi = rooms_.rexit[rm - 1];
   if (xi == 0) {
      return (0);
   }
   do {
      i = exits_.travel[xi - 1];
      curxt_.xroom1 = i & xpars_.xrmask;
      xxxflg = ~ xpars_.xlflag & 65535;
      curxt_.xtype = ((i & xxxflg) / xpars_.xfshft & xpars_.xfmask) + 1;
      switch (curxt_.xtype) {
      case 4:
      case 3:
         curxt_.xobj = exits_.travel[xi + 1] & xpars_.xrmask;
         curxt_.xactio = exits_.travel[xi + 1] / xpars_.xashft;
      case 2:
         curxt_.xstrng = exits_.travel[xi];
      case 1:
         xi += xpars_.xelnt[curxt_.xtype - 1];
         if ((i & xpars_.xdmask) == dir) {
            return ret_val;
         }
  break;
      default:
   bug_(10, curxt_.xtype);
      }
   } while ((i & xpars_.xlflag) == 0);
}

canonical_original_code:
int findxt_(int dir, int rm)
{
   int ret_val;
   int i; int xi;
   int xxxflg;
   ret_val = (1);
   xi = rooms_.rexit[rm - 1];
   if (xi == 0) {
      return (0);
   }
   do {
      i = exits_.travel[xi - 1];
      curxt_.xroom1 = i & xpars_.xrmask;
      xxxflg = ~ xpars_.xlflag & 65535;
      curxt_.xtype = ((i & xxxflg) / xpars_.xfshft & xpars_.xfmask) + 1;
      switch (curxt_.xtype) {
      case 4:
      case 3:
         curxt_.xobj = exits_.travel[xi + 1] & xpars_.xrmask;
         curxt_.xactio = exits_.travel[xi + 1] / xpars_.xashft;
      case 2:
         curxt_.xstrng = exits_.travel[xi];
      case 1:
         xi += xpars_.xelnt[curxt_.xtype - 1];
         if ((i & xpars_.xdmask) == dir) {
            return ret_val;
         }
  break;
      default:
   bug_(10, curxt_.xtype);
      }
   } while ((i & xpars_.xlflag) == 0);
}

variable_types: dir int

variable_types: rm int

variable_types: xi int

variable_types: xxxflg int


decompiled_code:
__int64 __fastcall yesno_(unsigned int a1, unsigned int a2, unsigned int a3)
{
char v5[136]; // [rsp+0h] [rbp-88h] BYREF

while ( 1 )
{
rspeak_(a1);
fflush(stdout);
fgets(v5, 100, stdin);
more_input();
if ( (v5[0] & 0xDF) == 89 )
{
rspeak_(a2);
return 1LL;
}
if ( (v5[0] & 0xDF) == 78 )
break;
rspeak_(6LL);
}
rspeak_(a3);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, unsigned int a2, unsigned int a3)
{
char v5[136]; // [rsp+0h] [rbp-88h] BYREF

while ( 1 )
{
rspeak_(a1);
fflush(stdout);
fgets(v5, 100, stdin);
more_input();
if ( (v5[0] & 0xDF) == 89 )
{
rspeak_(a2);
return 1LL;
}
if ( (v5[0] & 0xDF) == 78 )
break;
rspeak_(6LL);
}
rspeak_(a3);
return 0LL;
}

original_code:
logical yesno_(integer q, integer y, integer n)
{
   char ans[100];
L100:
   rspeak_(q);
   (void) fflush(stdout);
   (void) fgets(ans, sizeof ans, stdin);
   more_input();
   if (*ans == 'Y' || *ans == 'y') {
      rspeak_(y);
      return (1);
   }
   if (*ans == 'N' || *ans == 'n') {
      rspeak_(n);
      return (0);
   }
   rspeak_(6);
   goto L100;
}

canonical_original_code:
int yesno_(int q, int y, int n)
{
   char ans[100];
L100:
   rspeak_(q);
   (void) fflush(stdout);
   (void) fgets(ans, sizeof ans, stdin);
   more_input();
   if (*ans == 'Y' || *ans == 'y') {
      rspeak_(y);
      return (1);
   }
   if (*ans == 'N' || *ans == 'n') {
      rspeak_(n);
      return (0);
   }
   rspeak_(6);
   goto L100;
}

variable_types: q int

variable_types: y int

variable_types: n int

variable_types:
ans
char [100]


decompiled_code:
__int64 __fastcall princo_(int a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // rbx
__int64 v4; // rsi

rspsub_(a2, objcts_[a1 + 220]);
result = objcts_[0];
if ( (int)objcts_[0] > 0 )
{
v3 = 1LL;
do
{
while ( objcts_[v3 + 2640] != a1 )
{
if ( (int)objcts_[0] < (int)++v3 )
return result;
}
v4 = objcts_[v3++ + 220];
result = rspsub_(502LL, v4);
}
while ( (int)objcts_[0] >= (int)v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // rbx
__int64 v4; // rsi

rspsub_(a2, objcts_[a1 + 220]);
result = objcts_[0];
if ( (int)objcts_[0] > 0 )
{
v3 = 1LL;
do
{
while ( objcts_[v3 + 2640] != a1 )
{
if ( (int)objcts_[0] < (int)++v3 )
return result;
}
v4 = objcts_[v3++ + 220];
result = rspsub_(502LL, v4);
}
while ( (int)objcts_[0] >= (int)v3 );
}
return result;
}

original_code:
void princo_(integer obj, integer desc)
{
   integer i;
   rspsub_(desc, objcts_.odesc2[obj - 1]);
   for (i = 1; i <= objcts_.olnt; ++i) {
      if (objcts_.ocan[i - 1] == obj) {
         rspsub_(502, objcts_.odesc2[i - 1]);
      }
   }
}

canonical_original_code:
void princo_(int obj, int desc)
{
   int i;
   rspsub_(desc, objcts_.odesc2[obj - 1]);
   for (i = 1; i <= objcts_.olnt; ++i) {
      if (objcts_.ocan[i - 1] == obj) {
         rspsub_(502, objcts_.odesc2[i - 1]);
      }
   }
}

variable_types: obj int

variable_types: desc int


listRemoveNode

repo: mgmillani/fcg-bomberman

original_code:
void listRemoveNode(t_list *list, t_listNode *node)
{
 if(node->prev == ((void *)0))
  list->first = node->next;
 else
  node->prev->next = node->next;
 if(node->next == ((void *)0))
  list->last = node->prev;
 else
  node->next->prev = node->prev;
 list->length--;
 free(node);
}

canonical_original_code:
void listRemoveNode(struct s_list *list, struct s_listNode *node)
{
 if(node->prev == ((void *)0))
  list->first = node->next;
 else
  node->prev->next = node->next;
 if(node->next == ((void *)0))
  list->last = node->prev;
 else
  node->next->prev = node->prev;
 list->length--;
 free(node);
}

variable_types: struct s_list { int length; struct s_listNode { void *key; void *data; struct s_listNode *next; struct s_listNode *prev; } *first; struct s_listNode *last; } *

variable_types:
node
struct s_listNode *

user_defined_types: struct s_list { int length; struct s_listNode *first; struct s_listNode *last; }


listDestroyData

decompiled_code:
void __fastcall listDestroyData(__int64 a1, void (__fastcall *a2)(_QWORD), void (__fastcall *a3)(_QWORD))
{
_QWORD *v4; // rbp
_QWORD *v5; // rbx

v4 = *(_QWORD **)(a1 + 8);
if ( v4 )
{
while ( 1 )
{
if ( a3 )
a3(v4[1]);
if ( a2 )
a2(*v4);
v5 = (_QWORD *)v4[2];
free(v4);
if ( !v5 )
break;
v4 = v5;
}
}
*(_DWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
}

original_code:
void listDestroyData(t_list *list,void (*keyDestructor)(void *key), void (*dataDestructor)(void *data))
{
 t_listNode *node,*aux;
 for(node = list->first;node!=((void *)0);node=aux)
 {
  if(dataDestructor!=((void *)0))
   dataDestructor(node->data);
  if(keyDestructor!=((void *)0))
   keyDestructor(node->key);
  aux = node->next;
  free(node);
 }
 list->length = 0;
 list->first = ((void *)0);
 list->last = ((void *)0);
}

canonical_original_code:
void listDestroyData(struct s_list *list, void (*keyDestructor)(void *key), void (*dataDestructor)(void *data))
{
 struct s_listNode *node; struct s_listNode *aux;
 for(node = list->first;node!=((void *)0);node=aux)
 {
  if(dataDestructor!=((void *)0))
   dataDestructor(node->data);
  if(keyDestructor!=((void *)0))
   keyDestructor(node->key);
  aux = node->next;
  free(node);
 }
 list->length = 0;
 list->first = ((void *)0);
 list->last = ((void *)0);
}

variable_types:
keyDestructor
void (*)(void *key)

variable_types:
dataDestructor
void (*)(void *data)

variable_types: struct s_listNode { void *key; void *data; struct s_listNode *next; struct s_listNode *prev; } *


listDestroy

original_code:
void listDestroy(t_list *list)
{
  t_listNode *node,*aux;
 for(node = list->first;node!=((void *)0);node=aux)
 {
  aux = node->next;
  free(node);
 }
 list->length = 0;
 list->first = ((void *)0);
 list->last = ((void *)0);
}

canonical_original_code:
void listDestroy(struct s_list *list)
{
  struct s_listNode *node; struct s_listNode *aux;
 for(node = list->first;node!=((void *)0);node=aux)
 {
  aux = node->next;
  free(node);
 }
 list->length = 0;
 list->first = ((void *)0);
 list->last = ((void *)0);
}

user_defined_types: struct s_listNode { void *key; void *data; struct s_listNode *next; struct s_listNode *prev; }


listSort

original_code:
void listSort(t_list *list, int (*compare)(void *,void *))
{
 if(list->length < 2)
  return;
 t_listNode *cur,*dest,*aux;
 for(cur = list->first->next;cur!=list->last;cur=aux)
 {
  aux = cur->next;
  dest = cur->prev;
  while(compare(cur->key,dest->key) < 0)
  {
   dest = dest->prev;
   if(dest == ((void *)0))
   {
    cur->prev->next = cur->next;
    cur->next->prev = cur->prev;
    cur->prev = ((void *)0);
    cur->next = list->first;
    list->first->prev = cur;
    list->first = cur;
    break;
   }
  }
  if(dest!=cur->prev)
  {
   cur->prev->next = cur->next;
   cur->next->prev = cur->prev;
   cur->prev = dest;
   cur->next = dest->next;
   dest->next->prev = cur;
   dest->next = cur;
  }
 }
 dest = cur->prev;
 while(compare(cur->key,dest->key) < 0)
 {
  dest = dest->prev;
  if(dest == ((void *)0))
  {
   list->last = cur->prev;
   cur->prev->next = ((void *)0);
   cur->prev = ((void *)0);
   cur->next = list->first;
   list->first->prev = cur;
   list->first = cur;
   break;
  }
 }
 if(dest!=((void *)0) && dest != cur->prev)
 {
  list->last = cur->prev;
  cur->prev->next = ((void *)0);
  cur->prev = dest;
  cur->next = dest->next;
  dest->next->prev = cur;
  dest->next = cur;
 }
}

canonical_original_code:
void listSort(struct s_list *list, int (*compare)(void *, void *))
{
 if(list->length < 2)
  return;
 struct s_listNode *cur; struct s_listNode *dest; struct s_listNode *aux;
 for(cur = list->first->next;cur!=list->last;cur=aux)
 {
  aux = cur->next;
  dest = cur->prev;
  while(compare(cur->key,dest->key) < 0)
  {
   dest = dest->prev;
   if(dest == ((void *)0))
   {
    cur->prev->next = cur->next;
    cur->next->prev = cur->prev;
    cur->prev = ((void *)0);
    cur->next = list->first;
    list->first->prev = cur;
    list->first = cur;
    break;
   }
  }
  if(dest!=cur->prev)
  {
   cur->prev->next = cur->next;
   cur->next->prev = cur->prev;
   cur->prev = dest;
   cur->next = dest->next;
   dest->next->prev = cur;
   dest->next = cur;
  }
 }
 dest = cur->prev;
 while(compare(cur->key,dest->key) < 0)
 {
  dest = dest->prev;
  if(dest == ((void *)0))
  {
   list->last = cur->prev;
   cur->prev->next = ((void *)0);
   cur->prev = ((void *)0);
   cur->next = list->first;
   list->first->prev = cur;
   list->first = cur;
   break;
  }
 }
 if(dest!=((void *)0) && dest != cur->prev)
 {
  list->last = cur->prev;
  cur->prev->next = ((void *)0);
  cur->prev = dest;
  cur->next = dest->next;
  dest->next->prev = cur;
  dest->next = cur;
 }
}

variable_types:
compare
int (*)(void *, void *)


drawPowerup

decompiled_code:
__int64 __fastcall drawPowerup(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // r12
__int64 v3; // rbx
float v4; // xmm0_4
double v5; // xmm1_8
__int64 v6; // rdi
__int64 v7; // rsi
__int64 v8; // rbp
double v9; // xmm1_8
__int64 v10; // rdi
__int64 result; // rax

v1 = a1;
v2 = a1 + 432;
v3 = a1;
glEnable(3553LL);
glBindTexture(3553LL, *(unsigned int *)(a1 + 880));
v4 = *(double *)(a1 + 872);
glRotatef(v4, 0.0, 1.0);
v5 = *(double *)&LC5;
do
{
v6 = v3;
v3 += 72LL;
drawRectangle(v6, v5);
v5 = *(double *)&LC5;
}
while ( v3 != v2 );
v7 = *(unsigned int *)(v1 + 864);
v8 = v1 + 864;
glBindTexture(3553LL, v7);
v9 = *(double *)&LC5;
do
{
v10 = v3;
v3 += 72LL;
drawRectangle(v10, v9);
result = LC5;
v9 = *(double *)&LC5;
}
while ( v8 != v3 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // r12
__int64 v3; // rbx
float v4; // xmm0_4
double v5; // xmm1_8
__int64 v6; // rdi
__int64 v7; // rsi
__int64 v8; // rbp
double v9; // xmm1_8
__int64 v10; // rdi
__int64 result; // rax

v1 = a1;
v2 = a1 + 432;
v3 = a1;
glEnable(3553LL);
glBindTexture(3553LL, *(unsigned int *)(a1 + 880));
v4 = *(double *)(a1 + 872);
glRotatef(v4, 0.0, 1.0);
v5 = *(double *)&LC5;
do
{
v6 = v3;
v3 += 72LL;
drawRectangle(v6, v5);
v5 = *(double *)&LC5;
}
while ( v3 != v2 );
v7 = *(unsigned int *)(v1 + 864);
v8 = v1 + 864;
glBindTexture(3553LL, v7);
v9 = *(double *)&LC5;
do
{
v10 = v3;
v3 += 72LL;
drawRectangle(v10, v9);
result = LC5;
v9 = *(double *)&LC5;
}
while ( v8 != v3 );
return result;
}

original_code:
void drawPowerup(t_powerup *pwup)
{
 glEnable(0x0DE1);
 glBindTexture(0x0DE1,pwup->border);
 glRotatef(pwup->angle,0,1,0);
 unsigned int i;
 for(i=0 ; i<6 ; i++)
  drawRectangle(pwup->frameBox+i,1.0,1.0);
 glBindTexture(0x0DE1,pwup->image);
 for(i=0 ; i<6 ; i++)
  drawRectangle(pwup->imageBox+i,1.0,1.0);
}

canonical_original_code:
void drawPowerup(struct s_powerup *pwup)
{
 glEnable(0x0DE1);
 glBindTexture(0x0DE1,pwup->border);
 glRotatef(pwup->angle,0,1,0);
 unsigned int i;
 for(i=0 ; i<6 ; i++)
  drawRectangle(pwup->frameBox+i,1.0,1.0);
 glBindTexture(0x0DE1,pwup->image);
 for(i=0 ; i<6 ; i++)
  drawRectangle(pwup->imageBox+i,1.0,1.0);
}

variable_types: struct s_powerup { struct s_rect3 { double pos[3]; double v[3]; double w[3]; } frameBox[6]; struct s_rect3 imageBox[6]; unsigned int image; double angle; unsigned int border; } *

variable_types:
i
unsigned int

user_defined_types: struct s_powerup { struct s_rect3 frameBox[6]; struct s_rect3 imageBox[6]; unsigned int image; double angle; unsigned int border; }


addCategory

decompiled_code:
__int64 __fastcall addCategory(__int64 a1, const char *a2)
{
__int64 result; // rax
size_t v3; // r12
void *v4; // rax
void *v5; // rax

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
result = listSearch(a1, a2, &strcmp);
if ( !result )
{
v3 = strlen(a2) + 1;
v4 = malloc(v3);
v5 = memcpy(v4, a2, v3);
listAppend(a1, v5, 0LL);
result = *(_QWORD *)(a1 + 16);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const char *a2)
{
__int64 result; // rax
size_t v3; // r12
void *v4; // rax
void *v5; // rax

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
result = listSearch(a1, a2, &strcmp);
if ( !result )
{
v3 = strlen(a2) + 1;
v4 = malloc(v3);
v5 = memcpy(v4, a2, v3);
listAppend(a1, v5, 0LL);
result = *(_QWORD *)(a1 + 16);
}
return result;
}

original_code:
t_listNode *addCategory(t_list *cats,const char *name)
{
 if(cats == ((void *)0) || name == ((void *)0))
  return ((void *)0);
 t_listNode *node;
 node = listSearch(cats,name,(int (*)(const void*,const void*))strcmp);
 if(node == ((void *)0))
 {
  char *catName = malloc(strlen(name)+1);
  strcpy(catName,name);
  t_abp *cat = ((void *)0);
  listAppend(cats,catName,cat);
  return cats->last;
 }
 else
 {
  return node;
 }
}

canonical_original_code:
struct s_listNode *addCategory(struct s_list *cats, char *name)
{
 if(cats == ((void *)0) || name == ((void *)0))
  return ((void *)0);
 struct s_listNode *node;
 node = listSearch(cats,name,(int (*)(void *, void *))strcmp);
 if(node == ((void *)0))
 {
  char *catName = malloc(strlen(name)+1);
  strcpy(catName,name);
  struct s_abp *cat = ((void *)0);
  listAppend(cats,catName,cat);
  return cats->last;
 }
 else
 {
  return node;
 }
}

variable_types: struct s_list { int length; struct s_listNode *first; struct s_listNode *last; } *

variable_types:
name
char *

variable_types:
catName
char *

variable_types: struct s_abp { void *key; void *data; struct s_abp *left; struct s_abp *right; } *

return_type: struct s_listNode { void *key; void *data; struct s_listNode *next; struct s_listNode *prev; } *


addError

decompiled_code:
void __fastcall addError(__int64 a1, int a2, unsigned int a3)
{
int v5; // edi
char *v6; // r13

if ( a1 )
{
v5 = (int)(log10((double)(int)a3) + 1.0);
if ( a2 == 2 )
{
v6 = (char *)malloc(v5 + 33);
sprintf(v6, "Error: Nameless variable (line %d)%c", a3, 0LL);
goto LABEL_7;
}
if ( a2 > 2 )
{
if ( a2 == 3 )
{
v6 = (char *)malloc(v5 + 27);
sprintf(v6, "Error: Missing ']' (line %d)%c", a3, 0LL);
goto LABEL_7;
}
}
else
{
if ( !a2 )
{
v6 = (char *)malloc(v5 + 34);
sprintf(v6, "Error: Redefined variable (line %d)%c", a3, 0LL);
goto LABEL_7;
}
if ( a2 == 1 )
{
v6 = (char *)malloc(v5 + 33);
sprintf(v6, "Error: Empty attribution (line %d)%c", a3, 0LL);
LABEL_7:
listAppend(a1, v6, 0LL);
return;
}
}
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, int a2, unsigned int a3)
{
int v5; // edi
char *v6; // r13

if ( a1 )
{
v5 = (int)(log10((double)(int)a3) + 1.0);
if ( a2 == 2 )
{
v6 = (char *)malloc(v5 + 33);
sprintf(v6, "Error: Nameless variable (line %d)%c", a3, 0LL);
goto LABEL_7;
}
if ( a2 > 2 )
{
if ( a2 == 3 )
{
v6 = (char *)malloc(v5 + 27);
sprintf(v6, "Error: Missing ']' (line %d)%c", a3, 0LL);
goto LABEL_7;
}
}
else
{
if ( !a2 )
{
v6 = (char *)malloc(v5 + 34);
sprintf(v6, "Error: Redefined variable (line %d)%c", a3, 0LL);
goto LABEL_7;
}
if ( a2 == 1 )
{
v6 = (char *)malloc(v5 + 33);
sprintf(v6, "Error: Empty attribution (line %d)%c", a3, 0LL);
LABEL_7:
listAppend(a1, v6, 0LL);
return;
}
}
}
}

original_code:
void addError(t_list *errors,int errorCode,int line)
{
 if(errors == ((void *)0))
  return;
 char *phrase;
 int len = (1+log10(line));
 switch(errorCode)
 {
  case ErrorEmptyDefinition:
   len += 32;
   phrase = malloc(len+1);
   sprintf(phrase,"Error: Empty attribution (line %d)%c",line,'\0');
   listAppend(errors,phrase,((void *)0));
   break;
  case ErrorNoVarName:
   len += 32;
   phrase = malloc(len+1);
   sprintf(phrase,"Error: Nameless variable (line %d)%c",line,'\0');
   listAppend(errors,phrase,((void *)0));
   break;
  case ErrorOpenCategory:
   len += 26;
   phrase = malloc(len+1);
   sprintf(phrase,"Error: Missing ']' (line %d)%c",line,'\0');
   listAppend(errors,phrase,((void *)0));
   break;
  case ErrorRedefinedVariable:
   len += 33;
   phrase = malloc(len+1);
   sprintf(phrase,"Error: Redefined variable (line %d)%c",line,'\0');
   listAppend(errors,phrase,((void *)0));
   break;
 }
}

canonical_original_code:
void addError(struct s_list *errors, int errorCode, int line)
{
 if(errors == ((void *)0))
  return;
 char *phrase;
 int len = (1+log10(line));
 switch(errorCode)
 {
  case ErrorEmptyDefinition:
   len += 32;
   phrase = malloc(len+1);
   sprintf(phrase,"Error: Empty attribution (line %d)%c",line,'\0');
   listAppend(errors,phrase,((void *)0));
   break;
  case ErrorNoVarName:
   len += 32;
   phrase = malloc(len+1);
   sprintf(phrase,"Error: Nameless variable (line %d)%c",line,'\0');
   listAppend(errors,phrase,((void *)0));
   break;
  case ErrorOpenCategory:
   len += 26;
   phrase = malloc(len+1);
   sprintf(phrase,"Error: Missing ']' (line %d)%c",line,'\0');
   listAppend(errors,phrase,((void *)0));
   break;
  case ErrorRedefinedVariable:
   len += 33;
   phrase = malloc(len+1);
   sprintf(phrase,"Error: Redefined variable (line %d)%c",line,'\0');
   listAppend(errors,phrase,((void *)0));
   break;
 }
}

variable_types: errorCode int

variable_types: line int

variable_types:
phrase
char *

variable_types: len int


configDestroy

decompiled_code:
void __fastcall configDestroy(void *ptr, __int64 a2)
{
__int64 i; // rbx

if ( ptr )
{
for ( i = *((_QWORD *)ptr + 1); i; i = *(_QWORD *)(i + 16) )
{
free(*(void **)i);
abpDestroy(*(_QWORD *)(i + 8), &free);
free(*(void **)(i + 8));
}
free(ptr);
}
if ( a2 )
listDestroyData(a2, &free, 0LL);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr, __int64 a2)
{
__int64 i; // rbx

if ( ptr )
{
for ( i = *((_QWORD *)ptr + 1); i; i = *(_QWORD *)(i + 16) )
{
free(*(void **)i);
abpDestroy(*(_QWORD *)(i + 8), &free);
free(*(void **)(i + 8));
}
free(ptr);
}
if ( a2 )
listDestroyData(a2, &free, 0LL);
}

original_code:
void configDestroy(t_list *config, t_list *errors)
{
 if(config != ((void *)0))
 {
  t_listNode *node;
  for(node=config->first ; node!=((void *)0) ; node=node->next)
  {
   free(node->key);
   abpDestroy(node->data,free,free);
   free(node->data);
  }
  free(config);
 }
 if(errors != ((void *)0))
 {
  listDestroyData(errors,free,((void *)0));
 }
}

canonical_original_code:
void configDestroy(struct s_list *config, struct s_list *errors)
{
 if(config != ((void *)0))
 {
  struct s_listNode *node;
  for(node=config->first ; node!=((void *)0) ; node=node->next)
  {
   free(node->key);
   abpDestroy(node->data,free,free);
   free(node->data);
  }
  free(config);
 }
 if(errors != ((void *)0))
 {
  listDestroyData(errors,free,((void *)0));
 }
}

variable_types:
errors
struct s_list *


cleanFire

decompiled_code:
void __fastcall cleanFire(__int64 *a1)
{
unsigned int v1; // edx
unsigned int i; // er8
__int64 v3; // rsi
unsigned int v4; // eax
_DWORD *v5; // rcx

v1 = 0;
for ( i = 0; *((_DWORD *)a1 + 3) > i; ++i )
{
if ( *((_DWORD *)a1 + 2) )
{
v3 = *a1;
v4 = 0;
do
{
v5 = (_DWORD *)(v3 + 4LL * v1);
if ( *v5 == 2 )
*v5 = 0;
++v4;
++v1;
}
while ( *((_DWORD *)a1 + 2) > v4 );
}
}
}

original_code:
void cleanFire(t_gameGrid *grid)
{
 unsigned int x,y;
 unsigned int pos;
 for(pos=0,y=0 ; y<grid->h ; y++)
  for(x=0 ; x<grid->w ; x++,pos++)
   if(grid->grid[pos] == Fire)
    grid->grid[pos] = Empty;
}

canonical_original_code:
void cleanFire(struct s_gameGrid *grid)
{
 unsigned int x; unsigned int y;
 unsigned int pos;
 for(pos=0,y=0 ; y<grid->h ; y++)
  for(x=0 ; x<grid->w ; x++,pos++)
   if(grid->grid[pos] == Fire)
    grid->grid[pos] = Empty;
}

variable_types: struct s_gameGrid { enum e_gridElements { Empty=0, Bomb=1, Fire=2, EnemySpawn=3, Spawn=4, PowerupBomb=5, PowerupPower=6, PowerupSpeed=7, BreakableWall=8, UnbreakableWall=9, NumElements=10 } *grid; unsigned int w; double cellSize; unsigned int spawnPoints; unsigned int enemySpawnPoints; } *

variable_types:
x
unsigned int

variable_types:
y
unsigned int

variable_types:
pos
unsigned int

user_defined_types: struct s_gameGrid { enum e_gridElements *grid; unsigned int w; double cellSize; unsigned int spawnPoints; unsigned int enemySpawnPoints; }


gameGridPrint

decompiled_code:
int __fastcall gameGridPrint(__int64 a1)
{
unsigned int v1; // er13
unsigned int v2; // ebp
unsigned int i; // ebx
__int64 v4; // rdx
int result; // eax

if ( *(_DWORD *)(a1 + 12) )
{
v1 = 0;
v2 = 0;
do
{
for ( i = 0; *(_DWORD *)(a1 + 8) > i; ++i )
{
v4 = v2++;
printf("(%02d)", *(unsigned int *)(*(_QWORD *)a1 + 4 * v4));
}
++v1;
result = putchar(10);
}
while ( *(_DWORD *)(a1 + 12) > v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
unsigned int v1; // er13
unsigned int v2; // ebp
unsigned int i; // ebx
__int64 v4; // rdx
int result; // eax

if ( *(_DWORD *)(a1 + 12) )
{
v1 = 0;
v2 = 0;
do
{
for ( i = 0; *(_DWORD *)(a1 + 8) > i; ++i )
{
v4 = v2++;
printf("(%02d)", *(unsigned int *)(*(_QWORD *)a1 + 4 * v4));
}
++v1;
result = putchar(10);
}
while ( *(_DWORD *)(a1 + 12) > v1 );
}
return result;
}

original_code:
void gameGridPrint(t_gameGrid *grid)
{
 unsigned int x,y,pos;
 for(pos=0,y=0 ; y<grid->h; y++)
 {
  for(x=0 ; x<grid->w ; x++,pos++)
  {
   printf("(%02d)",grid->grid[pos]);
  }
  printf("\n");
 }
}

canonical_original_code:
void gameGridPrint(struct s_gameGrid *grid)
{
 unsigned int x; unsigned int y; unsigned int pos;
 for(pos=0,y=0 ; y<grid->h; y++)
 {
  for(x=0 ; x<grid->w ; x++,pos++)
  {
   printf("(%02d)",grid->grid[pos]);
  }
  printf("\n");
 }
}

user_defined_types: enum e_gridElements { Empty=0, Bomb=1, Fire=2, EnemySpawn=3, Spawn=4, PowerupBomb=5, PowerupPower=6, PowerupSpeed=7, BreakableWall=8, UnbreakableWall=9, NumElements=10 }


randrange

decompiled_code:
__int64 __fastcall randrange(int a1)
{
return (unsigned int)(int)((double)(a1 + 1) * (double)rand() * 4.656612873077393e-10);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)(int)((double)(a1 + 1) * (double)rand() * 4.656612873077393e-10);
}

original_code:
unsigned int randrange(unsigned int max)
{
    return ((max+1) * ((double) rand())/((unsigned int)2147483647 +1));
}

variable_types:
max
unsigned int

return_type: unsigned int


abpPrint

decompiled_code:
__int64 __fastcall abpPrint(_QWORD *a1, void (__fastcall *a2)(_QWORD), void (__fastcall *a3)(_QWORD), int a4)
{
_QWORD *v5; // r12
int v7; // ebx
__int64 result; // rax

if ( a1 )
{
v5 = a1;
do
{
v7 = 0;
if ( a4 > 0 )
{
do
{
++v7;
putchar(124);
}
while ( v7 != a4 );
}
++a4;
a2(*v5);
putchar(58);
a3(v5[1]);
putchar(10);
result = abpPrint(v5[2], a2, a3, (unsigned int)a4);
v5 = (_QWORD *)v5[3];
}
while ( v5 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, void (__fastcall *a2)(_QWORD), void (__fastcall *a3)(_QWORD), int a4)
{
_QWORD *v5; // r12
int v7; // ebx
__int64 result; // rax

if ( a1 )
{
v5 = a1;
do
{
v7 = 0;
if ( a4 > 0 )
{
do
{
++v7;
putchar(124);
}
while ( v7 != a4 );
}
++a4;
a2(*v5);
putchar(58);
a3(v5[1]);
putchar(10);
result = func0(v5[2], a2, a3, (unsigned int)a4);
v5 = (_QWORD *)v5[3];
}
while ( v5 );
}
return result;
}

original_code:
void abpPrint(t_abp *tree,void (*printKey)(void *),void (*printData)(void *),int depth)
{
 if(tree == ((void *)0))
  return;
 int i;
 for(i=0;i<depth;i++)
  printf("|");
 printKey(tree->key);
 printf(":");
 printData(tree->data);
 printf("\n");
 abpPrint(tree->left,printKey,printData,depth+1);
 abpPrint(tree->right,printKey,printData,depth+1);
}

canonical_original_code:
void abpPrint(struct s_abp *tree, void (*printKey)(void *), void (*printData)(void *), int depth)
{
 if(tree == ((void *)0))
  return;
 int i;
 for(i=0;i<depth;i++)
  printf("|");
 printKey(tree->key);
 printf(":");
 printData(tree->data);
 printf("\n");
 abpPrint(tree->left,printKey,printData,depth+1);
 abpPrint(tree->right,printKey,printData,depth+1);
}

variable_types:
printKey
void (*)(void *)

variable_types:
printData
void (*)(void *)

variable_types: depth int

variable_types: i int

user_defined_types: struct s_abp { void *key; void *data; struct s_abp *left; struct s_abp *right; }


abpStringPrint

decompiled_code:
// attributes: thunk
int abpStringPrint(const char *s)
{
return puts(s);
}

canonical_decompiled_code:
int func1(const char *s)
{
return puts(s);
}

original_code:
void abpStringPrint(void *data)
{
 printf("%s\n",(char *)data);
}

variable_types:
data
void *


abpDestroy

decompiled_code:
void __fastcall abpDestroy(void *ptr, void (__fastcall *a2)(_QWORD), void (__fastcall *a3)(_QWORD))
{
if ( ptr )
{
if ( a2 )
a2(*(_QWORD *)ptr);
if ( a3 )
a3(*((_QWORD *)ptr + 1));
abpDestroy(*((void **)ptr + 2));
abpDestroy(*((void **)ptr + 3));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr, void (__fastcall *a2)(_QWORD), void (__fastcall *a3)(_QWORD))
{
if ( ptr )
{
if ( a2 )
a2(*(_QWORD *)ptr);
if ( a3 )
a3(*((_QWORD *)ptr + 1));
func2(*((void **)ptr + 2));
func2(*((void **)ptr + 3));
free(ptr);
}
}

original_code:
void abpDestroy(t_abp *tree, void (*keyDestructor)(void *),void (*dataDestructor)(void *))
{
 if(tree == ((void *)0))
  return;
 if(keyDestructor != ((void *)0))
  keyDestructor(tree->key);
 if(dataDestructor != ((void *)0))
  dataDestructor(tree->data);
 abpDestroy(tree->left,keyDestructor,dataDestructor);
 abpDestroy(tree->right,keyDestructor,dataDestructor);
 free(tree);
}

canonical_original_code:
void abpDestroy(struct s_abp *tree, void (*keyDestructor)(void *), void (*dataDestructor)(void *))
{
 if(tree == ((void *)0))
  return;
 if(keyDestructor != ((void *)0))
  keyDestructor(tree->key);
 if(dataDestructor != ((void *)0))
  dataDestructor(tree->data);
 abpDestroy(tree->left,keyDestructor,dataDestructor);
 abpDestroy(tree->right,keyDestructor,dataDestructor);
 free(tree);
}

variable_types:
keyDestructor
void (*)(void *)

variable_types:
dataDestructor
void (*)(void *)


moveParticle

decompiled_code:
double *__fastcall moveParticle(double *a1)
{
double *result; // rax
double v2; // xmm0_8
double v3; // xmm1_8
double v4; // xmm1_8
double v5; // xmm0_8

result = a1 + 3;
do
{
v2 = a1[9];
v3 = *a1++;
v4 = v3 + v2;
v5 = v2 + a1[11];
a1[11] = 0.0;
*(a1 - 1) = v4;
a1[8] = v5;
}
while ( a1 != result );
return result;
}

canonical_decompiled_code:
double *__fastcall func3(double *a1)
{
double *result; // rax
double v2; // xmm0_8
double v3; // xmm1_8
double v4; // xmm1_8
double v5; // xmm0_8

result = a1 + 3;
do
{
v2 = a1[9];
v3 = *a1++;
v4 = v3 + v2;
v5 = v2 + a1[11];
a1[11] = 0.0;
*(a1 - 1) = v4;
a1[8] = v5;
}
while ( a1 != result );
return result;
}

original_code:
void moveParticle(t_particle *part)
{
 unsigned int i;
 for(i=0 ; i<3 ; i++)
 {
  part->pos.pos[i] += part->vel[i];
  part->vel[i] += part->acc[i];
  part->acc[i] = 0;
 }
}

canonical_original_code:
void moveParticle(struct s_particle *part)
{
 unsigned int i;
 for(i=0 ; i<3 ; i++)
 {
  part->pos.pos[i] += part->vel[i];
  part->vel[i] += part->acc[i];
  part->acc[i] = 0;
 }
}

variable_types: struct s_particle { struct s_rect3 { double pos[3]; double v[3]; double w[3]; } pos; double vel[3]; double acc[3]; } *

variable_types:
i
unsigned int

user_defined_types: struct s_particle { struct s_rect3 pos; double vel[3]; double acc[3]; }


generateRandomParticle

original_code:
void generateRandomParticle(t_particle *particle,double cellSize,int direction[2])
{
 particle->pos.v[0] = 0;
 particle->pos.v[1] = 0.1;
 particle->pos.v[2] = 0;
 double r = (double)rand()/2147483647;
 particle->pos.w[0] = r*0.1;
 particle->pos.w[1] = 0;
 particle->pos.w[2] = 0.1*sqrt(1 - r*r);
 unsigned int i;
 for(i=0 ; i<3 ; i++)
 {
  particle->pos.pos[i] = cellSize*(double)rand()/2147483647;
  particle->acc[i] = 0;
 }
 particle->vel[0] = direction[0]*(0.01*((double)rand()/2147483647)+0.01);
 particle->vel[1] = 0;
 particle->vel[2] = direction[1]*(0.01*((double)rand()/2147483647)+0.01);
}

canonical_original_code:
void generateRandomParticle(struct s_particle *particle, double cellSize, int direction[2])
{
 particle->pos.v[0] = 0;
 particle->pos.v[1] = 0.1;
 particle->pos.v[2] = 0;
 double r = (double)rand()/2147483647;
 particle->pos.w[0] = r*0.1;
 particle->pos.w[1] = 0;
 particle->pos.w[2] = 0.1*sqrt(1 - r*r);
 unsigned int i;
 for(i=0 ; i<3 ; i++)
 {
  particle->pos.pos[i] = cellSize*(double)rand()/2147483647;
  particle->acc[i] = 0;
 }
 particle->vel[0] = direction[0]*(0.01*((double)rand()/2147483647)+0.01);
 particle->vel[1] = 0;
 particle->vel[2] = direction[1]*(0.01*((double)rand()/2147483647)+0.01);
}

variable_types: cellSize double

variable_types:
direction
int [2]

variable_types: r double

user_defined_types: struct s_rect3 { double pos[3]; double v[3]; double w[3]; }


init

decompiled_code:
__int64 __fastcall init(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
__int64 result; // rax
__int64 v7[7]; // [rsp+0h] [rbp-38h] BYREF

putenv("SDL_VIDEO_CENTERED=center");
result = SDL_Init(32LL);
if ( (_DWORD)result != -1 )
{
SDL_WM_SetCaption("Bombot", 0LL);
SDL_GL_SetAttribute(5LL, 1LL);
SDL_SetVideoMode(a1, a2, a3, a4);
SDL_ShowCursor(0LL);
glEnable(2884LL);
v7[0] = 0x3E19999A3E4CCCCDLL;
v7[1] = 0x3F8000003DCCCCCDLL;
glEnable(2912LL);
glFogf(2915LL, 5.0);
glFogf(2916LL, 15.1);
glFogi(2917LL, 9729LL);
glFogfv(2918LL, v7);
glFogf(2914LL, 0.30000001);
glClearColor(0.2, 0.15000001, 0.1, 0.0);
glViewport(0LL, 0LL, a1, a2);
glClear(0x4000LL);
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(60.0, (double)(int)a1 / (double)(int)a2, 0.1, 1024.0);
glMatrixMode(5888LL);
glLoadIdentity();
result = (unsigned int)-((unsigned int)IMG_Init(2LL) == 0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
__int64 result; // rax
__int64 v7[7]; // [rsp+0h] [rbp-38h] BYREF

putenv("SDL_VIDEO_CENTERED=center");
result = SDL_Init(32LL);
if ( (_DWORD)result != -1 )
{
SDL_WM_SetCaption("Bombot", 0LL);
SDL_GL_SetAttribute(5LL, 1LL);
SDL_SetVideoMode(a1, a2, a3, a4);
SDL_ShowCursor(0LL);
glEnable(2884LL);
v7[0] = 0x3E19999A3E4CCCCDLL;
v7[1] = 0x3F8000003DCCCCCDLL;
glEnable(2912LL);
glFogf(2915LL, 5.0);
glFogf(2916LL, 15.1);
glFogi(2917LL, 9729LL);
glFogfv(2918LL, v7);
glFogf(2914LL, 0.30000001);
glClearColor(0.2, 0.15000001, 0.1, 0.0);
glViewport(0LL, 0LL, a1, a2);
glClear(0x4000LL);
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(60.0, (double)(int)a1 / (double)(int)a2, 0.1, 1024.0);
glMatrixMode(5888LL);
glLoadIdentity();
result = (unsigned int)-((unsigned int)IMG_Init(2LL) == 0);
}
return result;
}

original_code:
int init(int width,int height,int bpp,int options)
{
 putenv("SDL_VIDEO_CENTERED=center");
 if(SDL_Init(0x00000020) == -1)
  return -1;
 SDL_WM_SetCaption(gProgName,((void *)0));
 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
 SDL_SetVideoMode(width,height,bpp,options);
 SDL_ShowCursor(0);
 glEnable(0x0B44);
 GLfloat density = 0.3;
 GLfloat fogColor[4] = {0.2,0.15,0.1,1};
 glEnable(0x0B60);
 glFogf (0x0B63, 5);
 glFogf (0x0B64, 15.1);
 glFogi(0x0B65,0x2601);
 glFogfv(0x0B66,fogColor);
 glFogf(0x0B62,density);
 glClearColor(0.2f,0.15f,0.1f,0.0f);
 glViewport(0,0,width,height);
 glClear(0x00004000);
 glMatrixMode(0x1701);
 glLoadIdentity();
 double ratio = (double)width/height;
 gluPerspective( 60.0, ratio, 0.1, 1024.0 );
 glMatrixMode(0x1700);
 glLoadIdentity();
 if(IMG_Init(IMG_INIT_PNG)==0)
  return -1;
 return 0;
}

canonical_original_code:
int init(int width, int height, int bpp, int options)
{
 putenv("SDL_VIDEO_CENTERED=center");
 if(SDL_Init(0x00000020) == -1)
  return -1;
 SDL_WM_SetCaption(gProgName,((void *)0));
 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
 SDL_SetVideoMode(width,height,bpp,options);
 SDL_ShowCursor(0);
 glEnable(0x0B44);
 float density = 0.3;
 float fogColor[4] = {0.2,0.15,0.1,1};
 glEnable(0x0B60);
 glFogf (0x0B63, 5);
 glFogf (0x0B64, 15.1);
 glFogi(0x0B65,0x2601);
 glFogfv(0x0B66,fogColor);
 glFogf(0x0B62,density);
 glClearColor(0.2f,0.15f,0.1f,0.0f);
 glViewport(0,0,width,height);
 glClear(0x00004000);
 glMatrixMode(0x1701);
 glLoadIdentity();
 double ratio = (double)width/height;
 gluPerspective( 60.0, ratio, 0.1, 1024.0 );
 glMatrixMode(0x1700);
 glLoadIdentity();
 if(IMG_Init(IMG_INIT_PNG)==0)
  return -1;
 return 0;
}

variable_types: width int

variable_types: height int

variable_types: bpp int

variable_types: options int

variable_types: density float

variable_types:
fogColor
float [4]

variable_types: ratio double


gameOver

decompiled_code:
__int64 __fastcall gameOver(unsigned int a1)
{
glMatrixMode(5889LL);
glLoadIdentity();
glMatrixMode(5888LL);
glLoadIdentity();
glDisable(2929LL);
glDisable(2896LL);
glDisable(2884LL);
gluOrtho2D(1.0, -1.0, -1.0, 1.0);
glColor3f(1.0, 1.0);
glDisable(2884LL);
glEnable(3553LL);
glBindTexture(3553LL, a1);
glBegin(7LL);
glTexCoord2f(0.0);
glVertex2f(1.0);
glTexCoord2f(0.0);
glVertex2f(1.0);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC13));
glVertex2f(-1.0);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC13));
glVertex2f(-1.0);
glEnd(-1.0, 1.0);
SDL_GL_SwapBuffers();
return SDL_Delay(3000LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
glMatrixMode(5889LL);
glLoadIdentity();
glMatrixMode(5888LL);
glLoadIdentity();
glDisable(2929LL);
glDisable(2896LL);
glDisable(2884LL);
gluOrtho2D(1.0, -1.0, -1.0, 1.0);
glColor3f(1.0, 1.0);
glDisable(2884LL);
glEnable(3553LL);
glBindTexture(3553LL, a1);
glBegin(7LL);
glTexCoord2f(0.0);
glVertex2f(1.0);
glTexCoord2f(0.0);
glVertex2f(1.0);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC13));
glVertex2f(-1.0);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC13));
glVertex2f(-1.0);
glEnd(-1.0, 1.0);
SDL_GL_SwapBuffers();
return SDL_Delay(3000LL);
}

original_code:
void gameOver(GLuint screen)
{
 glMatrixMode(0x1701);
 glLoadIdentity();
 glMatrixMode(0x1700);
 glLoadIdentity();
 glDisable(0x0B71);
 glDisable(0x0B50);
 glDisable(0x0B44);
 gluOrtho2D(1,-1,-1,1);
 glColor3f(1,1,1);
 glDisable(0x0B44);
 glEnable(0x0DE1);
 glBindTexture(0x0DE1,screen);
 glBegin(0x0007);
 glTexCoord2f(0, 0.0f);
 glVertex2f(1,1);
 glTexCoord2f(0, 1.0);
 glVertex2f(1,-1);
 glTexCoord2f(1.0, 1.0);
 glVertex2f(-1,-1);
 glTexCoord2f(1.0, 0);
 glVertex2f(-1,1);
 glEnd();
 SDL_GL_SwapBuffers();
 SDL_Delay(3000);
}

canonical_original_code:
void gameOver(unsigned int screen)
{
 glMatrixMode(0x1701);
 glLoadIdentity();
 glMatrixMode(0x1700);
 glLoadIdentity();
 glDisable(0x0B71);
 glDisable(0x0B50);
 glDisable(0x0B44);
 gluOrtho2D(1,-1,-1,1);
 glColor3f(1,1,1);
 glDisable(0x0B44);
 glEnable(0x0DE1);
 glBindTexture(0x0DE1,screen);
 glBegin(0x0007);
 glTexCoord2f(0, 0.0f);
 glVertex2f(1,1);
 glTexCoord2f(0, 1.0);
 glVertex2f(1,-1);
 glTexCoord2f(1.0, 1.0);
 glVertex2f(-1,-1);
 glTexCoord2f(1.0, 0);
 glVertex2f(-1,1);
 glEnd();
 SDL_GL_SwapBuffers();
 SDL_Delay(3000);
}

variable_types:
screen
unsigned int


colorCompare

decompiled_code:
__int64 __fastcall colorCompare(__int64 a1, __int64 a2, int a3)
{
__int64 v6; // rax
int v7; // ecx
bool v8; // si
unsigned int v9; // edx

if ( a3 <= 0 )
return 0LL;
v6 = 1LL;
do
{
v7 = *(unsigned __int8 *)(a2 + v6 - 1);
v8 = a3 > (int)v6;
v9 = *(unsigned __int8 *)(a1 + v6 - 1) - v7;
LOBYTE(v7) = *(unsigned __int8 *)(a1 + v6++ - 1) == v7;
}
while ( ((unsigned __int8)v7 & v8) != 0 );
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
__int64 v6; // rax
int v7; // ecx
bool v8; // si
unsigned int v9; // edx

if ( a3 <= 0 )
return 0LL;
v6 = 1LL;
do
{
v7 = *(unsigned __int8 *)(a2 + v6 - 1);
v8 = a3 > (int)v6;
v9 = *(unsigned __int8 *)(a1 + v6 - 1) - v7;
LOBYTE(v7) = *(unsigned __int8 *)(a1 + v6++ - 1) == v7;
}
while ( ((unsigned __int8)v7 & v8) != 0 );
return v9;
}

original_code:
int colorCompare(const unsigned char *a,const unsigned char *b,int depth)
{
 int i;
 int diff=0;
 for(i=0 ; i< depth && diff==0 ; i++)
 {
  diff = a[i] - b[i];
 }
 return diff;
}

canonical_original_code:
int colorCompare(unsigned char *a, unsigned char *b, int depth)
{
 int i;
 int diff = 0;
 for(i=0 ; i< depth && diff==0 ; i++)
 {
  diff = a[i] - b[i];
 }
 return diff;
}

variable_types:
a
unsigned char *

variable_types:
b
unsigned char *

variable_types: depth int

variable_types: i int

variable_types: diff int


loadGrid

decompiled_code:
void *__fastcall loadGrid(__int64 a1, void *a2)
{
void *v2; // r12
__int64 v4; // [rsp+1h] [rbp-27h] BYREF
int v5; // [rsp+9h] [rbp-1Fh]
__int16 v6; // [rsp+Dh] [rbp-1Bh]
char v7; // [rsp+Fh] [rbp-19h]

v2 = a2;
if ( !a2 )
v2 = malloc(0x20uLL);
v7 = 0;
v5 = 0xFFFF;
v4 = 0xFF00FF0000000000LL;
v6 = -256;
gameGridLoad(v2, a1, &v4);
return v2;
}

canonical_decompiled_code:
void *__fastcall func0(__int64 a1, void *a2)
{
void *v2; // r12
__int64 v4; // [rsp+1h] [rbp-27h] BYREF
int v5; // [rsp+9h] [rbp-1Fh]
__int16 v6; // [rsp+Dh] [rbp-1Bh]
char v7; // [rsp+Fh] [rbp-19h]

v2 = a2;
if ( !a2 )
v2 = malloc(0x20uLL);
v7 = 0;
v5 = 0xFFFF;
v4 = 0xFF00FF0000000000LL;
v6 = -256;
gameGridLoad(v2, a1, &v4);
return v2;
}

original_code:
t_gameGrid *loadGrid(const char *fname,t_gameGrid *grid)
{
 if(grid == ((void *)0))
  grid = malloc(sizeof(*grid));
 t_colorMap colorMap;
 colorMap.emptyColor[0] = 0;
 colorMap.emptyColor[1] = 0;
 colorMap.emptyColor[2] = 0;
 colorMap.breakableColor[0] = 255;
 colorMap.breakableColor[1] = 0;
 colorMap.breakableColor[2] = 0;
 colorMap.unbreakableColor[0] = 0;
 colorMap.unbreakableColor[1] = 255;
 colorMap.unbreakableColor[2] = 0;
 colorMap.spawnColor[0] = 0;
 colorMap.spawnColor[1] = 0;
 colorMap.spawnColor[2] = 255;
 colorMap.enemySpawnColor[0] = 0;
 colorMap.enemySpawnColor[1] = 255;
 colorMap.enemySpawnColor[2] = 255;
 gameGridLoad(grid,fname,&colorMap);
 return grid;
}

canonical_original_code:
struct s_gameGrid *loadGrid(char *fname, struct s_gameGrid *grid)
{
 if(grid == ((void *)0))
  grid = malloc(sizeof(*grid));
 struct s_colorMap colorMap;
 colorMap.emptyColor[0] = 0;
 colorMap.emptyColor[1] = 0;
 colorMap.emptyColor[2] = 0;
 colorMap.breakableColor[0] = 255;
 colorMap.breakableColor[1] = 0;
 colorMap.breakableColor[2] = 0;
 colorMap.unbreakableColor[0] = 0;
 colorMap.unbreakableColor[1] = 255;
 colorMap.unbreakableColor[2] = 0;
 colorMap.spawnColor[0] = 0;
 colorMap.spawnColor[1] = 0;
 colorMap.spawnColor[2] = 255;
 colorMap.enemySpawnColor[0] = 0;
 colorMap.enemySpawnColor[1] = 255;
 colorMap.enemySpawnColor[2] = 255;
 gameGridLoad(grid,fname,&colorMap);
 return grid;
}

variable_types:
fname
char *

variable_types:
grid
struct s_gameGrid *

variable_types: struct s_colorMap { unsigned char emptyColor[3]; unsigned char spawnColor[3]; unsigned char enemySpawnColor[3]; unsigned char breakableColor[3]; unsigned char unbreakableColor[3]; }

return_type: struct s_gameGrid { enum e_gridElements { Empty=0, Bomb=1, Fire=2, EnemySpawn=3, Spawn=4, PowerupBomb=5, PowerupPower=6, PowerupSpeed=7, BreakableWall=8, UnbreakableWall=9, NumElements=10 } *grid; unsigned int w; double cellSize; unsigned int spawnPoints; unsigned int enemySpawnPoints; } *


controlFramerate

decompiled_code:
__int64 __fastcall controlFramerate(int a1, int a2)
{
int v2; // eax
__int64 v4; // r12

v2 = SDL_GetTicks() - a2;
if ( v2 >= a1 )
return 0LL;
v4 = (unsigned int)(a1 - v2);
SDL_Delay(v4);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
int v2; // eax
__int64 v4; // r12

v2 = SDL_GetTicks() - a2;
if ( v2 >= a1 )
return 0LL;
v4 = (unsigned int)(a1 - v2);
SDL_Delay(v4);
return (unsigned int)v4;
}

original_code:
int controlFramerate(t_frameController frameCtrl)
{
 int delta = SDL_GetTicks() - frameCtrl.frameStart;
 if (delta<frameCtrl.duration)
 {
  SDL_Delay(frameCtrl.duration - delta);
  return frameCtrl.duration - delta;
 }
 return 0;
}

canonical_original_code:
int controlFramerate(struct s_frameController frameCtrl)
{
 int delta = SDL_GetTicks() - frameCtrl.frameStart;
 if (delta<frameCtrl.duration)
 {
  SDL_Delay(frameCtrl.duration - delta);
  return frameCtrl.duration - delta;
 }
 return 0;
}

variable_types: struct s_frameController { int duration; unsigned int framesPerSec; unsigned int frameStart; }

variable_types: delta int


initScene

original_code:
t_scene *initScene(t_scene *scene, t_gameGrid *grid)
{
 if(scene == ((void *)0))
  scene = malloc(sizeof(*scene));
 double margin = 0.01;
 scene->minPos[0] = - grid->cellSize/2;
 scene->minPos[1] = - margin;
 scene->minPos[2] = - grid->cellSize/2;
 scene->maxPos[0] = grid->w*grid->cellSize - grid->cellSize/2;
 scene->maxPos[1] = 20.0/3 + margin;
 scene->maxPos[2] = grid->h*grid->cellSize - grid->cellSize/2;
 int i;
 for(i=0 ; i<3 ; i++)
 {
  scene->maxPos[i] -= margin;
  scene->minPos[i] += margin;
 }
 return scene;
}

canonical_original_code:
struct s_scene *initScene(struct s_scene *scene, struct s_gameGrid *grid)
{
 if(scene == ((void *)0))
  scene = malloc(sizeof(*scene));
 double margin = 0.01;
 scene->minPos[0] = - grid->cellSize/2;
 scene->minPos[1] = - margin;
 scene->minPos[2] = - grid->cellSize/2;
 scene->maxPos[0] = grid->w*grid->cellSize - grid->cellSize/2;
 scene->maxPos[1] = 20.0/3 + margin;
 scene->maxPos[2] = grid->h*grid->cellSize - grid->cellSize/2;
 int i;
 for(i=0 ; i<3 ; i++)
 {
  scene->maxPos[i] -= margin;
  scene->minPos[i] += margin;
 }
 return scene;
}

variable_types:
scene
struct s_scene *

variable_types: struct s_gameGrid { enum e_gridElements { Empty=0, Bomb=1, Fire=2, EnemySpawn=3, Spawn=4, PowerupBomb=5, PowerupPower=6, PowerupSpeed=7, BreakableWall=8, UnbreakableWall=9, NumElements=10 } *grid; unsigned int w; double cellSize; unsigned int spawnPoints; unsigned int enemySpawnPoints; } *

variable_types: margin double

return_type: struct s_scene { double minPos[3]; double maxPos[3]; } *


satCrossover

repo: mgmillani/maxsat-GenAlg

original_code:
void satCrossover(t_individual *father, t_individual *mother, t_individual *child,unsigned int numVars)
{
 unsigned int i,j;
 for(i=0,j=numVars/2 ; i<numVars/2 ; i++,j++)
 {
  child->var[i] = father->var[i];
  child->var[j] = mother->var[j];
 }
 if((numVars&1) == 1)
 {
  child->var[numVars-1] = mother->var[numVars-1];
 }
}

canonical_original_code:
void satCrossover(struct s_individual *father, struct s_individual *mother, struct s_individual *child, unsigned int numVars)
{
 unsigned int i; unsigned int j;
 for(i=0,j=numVars/2 ; i<numVars/2 ; i++,j++)
 {
  child->var[i] = father->var[i];
  child->var[j] = mother->var[j];
 }
 if((numVars&1) == 1)
 {
  child->var[numVars-1] = mother->var[numVars-1];
 }
}

variable_types: struct s_individual { unsigned char *var; double fitness; } *

variable_types:
mother
struct s_individual *

variable_types:
child
struct s_individual *

variable_types:
numVars
unsigned int

variable_types:
i
unsigned int

variable_types:
j
unsigned int


satThreeParentCrossover

decompiled_code:
void __fastcall satThreeParentCrossover(_QWORD *a1, _QWORD *a2, _QWORD *a3, _QWORD *a4, int a5)
{
__int64 i; // rax
char v8; // dl
_BYTE *v9; // rsi

if ( a5 )
{
for ( i = 0LL; i != a5; ++i )
{
v8 = *(_BYTE *)(*a1 + i);
v9 = (_BYTE *)(i + *a4);
if ( v8 != *(_BYTE *)(*a2 + i) )
v8 = *(_BYTE *)(*a3 + i);
*v9 = v8;
}
}
}

original_code:
void satThreeParentCrossover(t_individual *father, t_individual *mother, t_individual *other, t_individual *child,unsigned int numVars)
{
 unsigned int i;
 for(i=0 ; i<numVars ; i++)
 {
  if(father->var[i] == mother->var[i])
   child->var[i] = father->var[i];
  else
   child->var[i] = other->var[i];
 }
}

canonical_original_code:
void satThreeParentCrossover(struct s_individual *father, struct s_individual *mother, struct s_individual *other, struct s_individual *child, unsigned int numVars)
{
 unsigned int i;
 for(i=0 ; i<numVars ; i++)
 {
  if(father->var[i] == mother->var[i])
   child->var[i] = father->var[i];
  else
   child->var[i] = other->var[i];
 }
}

variable_types:
other
struct s_individual *

user_defined_types: struct s_individual { unsigned char *var; double fitness; }


satMutation

decompiled_code:
int __fastcall satMutation(_QWORD *a1, int a2, unsigned int a3)
{
unsigned int v4; // eax
int result; // eax

while ( 1 )
{
result = rand();
if ( result >= a2 )
break;
v4 = rand();
*(_BYTE *)(*a1 + v4 % a3) ^= 1u;
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(_QWORD *a1, int a2, unsigned int a3)
{
unsigned int v4; // eax
int result; // eax

while ( 1 )
{
result = rand();
if ( result >= a2 )
break;
v4 = rand();
*(_BYTE *)(*a1 + v4 % a3) ^= 1u;
}
return result;
}

original_code:
void satMutation(t_individual *individual,int mutationLimit,unsigned int numVars)
{
 while(rand() < mutationLimit)
 {
  unsigned int index = rand()%numVars;
  individual->var[index] ^= 1;
 }
}

canonical_original_code:
void satMutation(struct s_individual *individual, int mutationLimit, unsigned int numVars)
{
 while(rand() < mutationLimit)
 {
  unsigned int index = rand()%numVars;
  individual->var[index] ^= 1;
 }
}

variable_types: mutationLimit int

variable_types:
index
unsigned int