decompiled_code:
int print_stored()
{
__int64 *v0; // rbx
unsigned int v1; // ebp
const char *v2; // rax
__int64 v3; // rdx
__int64 v4; // r9
int result; // eax
int v6; // eax
int v7; // er12
char s[1048]; // [rsp+0h] [rbp-418h] BYREF

wattrset(hw, 0x10000);
if ( wmove(hw, 9, 0) != -1 )
waddnstr(hw, "YOUR CURRENT CHARACTERS:", -1);
v0 = def_array;
v1 = 0;
wattrset(hw, 0);
wclrtoeol(hw);
do
{
v6 = v1++;
v7 = v6 + 11;
if ( *(_DWORD *)v0 )
{
v2 = which_class(*((_DWORD *)v0 + 8));
sprintf(
s,
"%2d. (%s): Int: %d Str: %d Wis: %d Dex: %d Con: %d Cha: %d Pow: %d Hpt: %d",
v3,
v2,
*((unsigned int *)v0 + 1),
v4,
*((unsigned int *)v0 + 2),
*((unsigned int *)v0 + 3),
*((unsigned int *)v0 + 4),
*((unsigned int *)v0 + 5),
*((unsigned int *)v0 + 7),
*((unsigned int *)v0 + 6));
}
else
{
sprintf(s, "%2d. ### NONE ###", v1);
}
result = wmove(hw, v7, 0);
if ( result != -1 )
result = waddnstr(hw, s, -1);
v0 = (__int64 *)((char *)v0 + 36);
}
while ( v1 != 10 );
return result;
}

canonical_decompiled_code:
int func3()
{
__int64 *v0; // rbx
unsigned int v1; // ebp
const char *v2; // rax
__int64 v3; // rdx
__int64 v4; // r9
int result; // eax
int v6; // eax
int v7; // er12
char s[1048]; // [rsp+0h] [rbp-418h] BYREF

wattrset(hw, 0x10000);
if ( wmove(hw, 9, 0) != -1 )
waddnstr(hw, "YOUR CURRENT CHARACTERS:", -1);
v0 = def_array;
v1 = 0;
wattrset(hw, 0);
wclrtoeol(hw);
do
{
v6 = v1++;
v7 = v6 + 11;
if ( *(_DWORD *)v0 )
{
v2 = func1(*((_DWORD *)v0 + 8));
sprintf(
s,
"%2d. (%s): Int: %d Str: %d Wis: %d Dex: %d Con: %d Cha: %d Pow: %d Hpt: %d",
v3,
v2,
*((unsigned int *)v0 + 1),
v4,
*((unsigned int *)v0 + 2),
*((unsigned int *)v0 + 3),
*((unsigned int *)v0 + 4),
*((unsigned int *)v0 + 5),
*((unsigned int *)v0 + 7),
*((unsigned int *)v0 + 6));
}
else
{
sprintf(s, "%2d. ### NONE ###", v1);
}
result = wmove(hw, v7, 0);
if ( result != -1 )
result = waddnstr(hw, s, -1);
v0 = (__int64 *)((char *)v0 + 36);
}
while ( v1 != 10 );
return result;
}

original_code:
void
print_stored(void)
{
    int i;
    char *class;
    char pbuf[2 * 512];
    (wattrset(hw,((chtype)((1U)) << ((8) + 8))));
    (wmove((hw),(9),(0)) == (-1) ? (-1) : waddnstr((hw),("YOUR CURRENT CHARACTERS:"),-1));
    (wattrset(hw,(1U - 1U)));
    wclrtoeol(hw);
    for (i = 0; i < 10; i++)
    {
        if (def_array[i][0])
        {
            class = which_class(def_array[i][8]);
            sprintf(pbuf,
                "%2d. (%s): Int: %d Str: %d Wis: %d Dex: %d Con: %d Cha: %d"
                " Pow: %d Hpt: %d",
                i + 1,
                class,
                def_array[i][1],
                def_array[i][0],
                def_array[i][2],
                def_array[i][3],
                def_array[i][4],
                def_array[i][5],
                def_array[i][7],
                def_array[i][6]);
            (wmove((hw),(11 + i),(0)) == (-1) ? (-1) : waddnstr((hw),(pbuf),-1));
        }
        else
        {
            sprintf(pbuf, "%2d.  ### NONE ###", i + 1);
            (wmove((hw),(11 + i),(0)) == (-1) ? (-1) : waddnstr((hw),(pbuf),-1));
        }
    }
}

canonical_original_code:
void print_stored()
{
    int i;
    char *class;
    char pbuf[-1];
    (wattrset(hw,((chtype)((1U)) << ((8) + 8))));
    (wmove((hw),(9),(0)) == (-1) ? (-1) : waddnstr((hw),("YOUR CURRENT CHARACTERS:"),-1));
    (wattrset(hw,(1U - 1U)));
    wclrtoeol(hw);
    for (i = 0; i < 10; i++)
    {
        if (def_array[i][0])
        {
            class = which_class(def_array[i][8]);
            sprintf(pbuf,
                "%2d. (%s): Int: %d Str: %d Wis: %d Dex: %d Con: %d Cha: %d"
                " Pow: %d Hpt: %d",
                i + 1,
                class,
                def_array[i][1],
                def_array[i][0],
                def_array[i][2],
                def_array[i][3],
                def_array[i][4],
                def_array[i][5],
                def_array[i][7],
                def_array[i][6]);
            (wmove((hw),(11 + i),(0)) == (-1) ? (-1) : waddnstr((hw),(pbuf),-1));
        }
        else
        {
            sprintf(pbuf, "%2d.  ### NONE ###", i + 1);
            (wmove((hw),(11 + i),(0)) == (-1) ? (-1) : waddnstr((hw),(pbuf),-1));
        }
    }
}

variable_types:
pbuf
char [-1]


repo: RoguelikeRestorationProject/urogue

decompiled_code:
__int64 do_getplayer()
{
__int64 result; // rax

print_stored();
result = char_type;
if ( char_type == 11 )
{
do
{
if ( wmove(hw, 3, 0) != -1 )
waddnstr(
hw,
"[a] Fighter\t[b] Paladin\t[c] Ranger\n"
"[d] Cleric\t[e] Druid\t[f] Magician\n"
"[g] Illusionist\t[h] Thief\t[i] Assasin\t[j] Ninja",
-1);
if ( wmove(hw, 0, 0) != -1 )
waddnstr(hw, "What character class do you desire? ", -1);
wrefresh(hw);
char_type = (char)readcharw(hw) - 97;
if ( char_type > 9u )
{
wattrset(hw, 0x10000);
if ( wmove(hw, 1, 0) != -1 )
waddnstr(hw, "Please enter a letter from a - j", -1);
wattrset(hw, 0);
wclrtoeol(hw);
wrefresh(hw);
}
else
{
if ( wmove(hw, 1, 0) != -1 )
waddnstr(hw, &byte_CD5, -1);
wclrtoeol(hw);
}
result = char_type;
}
while ( char_type > 9u );
}
player[90] = result;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax

func3();
result = char_type;
if ( char_type == 11 )
{
do
{
if ( wmove(hw, 3, 0) != -1 )
waddnstr(
hw,
"[a] Fighter\t[b] Paladin\t[c] Ranger\n"
"[d] Cleric\t[e] Druid\t[f] Magician\n"
"[g] Illusionist\t[h] Thief\t[i] Assasin\t[j] Ninja",
-1);
if ( wmove(hw, 0, 0) != -1 )
waddnstr(hw, "What character class do you desire? ", -1);
wrefresh(hw);
char_type = (char)readcharw(hw) - 97;
if ( char_type > 9u )
{
wattrset(hw, 0x10000);
if ( wmove(hw, 1, 0) != -1 )
waddnstr(hw, "Please enter a letter from a - j", -1);
wattrset(hw, 0);
wclrtoeol(hw);
wrefresh(hw);
}
else
{
if ( wmove(hw, 1, 0) != -1 )
waddnstr(hw, &byte_CD5, -1);
wclrtoeol(hw);
}
result = char_type;
}
while ( char_type > 9u );
}
player[90] = result;
return result;
}

original_code:
void
do_getplayer(void)
{
 print_stored();
    if (char_type == 11)
        do
        {
            (wmove((hw),(3),(0)) == (-1) ? (-1) : waddnstr((hw),("[a] Fighter\t" "[b] Paladin\t" "[c] Ranger\n" "[d] Cleric\t" "[e] Druid\t" "[f] Magician\n" "[g] Illusionist\t" "[h] Thief\t" "[i] Assasin\t" "[j] Ninja"),-1));
            (wmove((hw),(0),(0)) == (-1) ? (-1) : waddnstr((hw),("What character class do you desire? "),-1));
            wrefresh(hw);
            char_type = readcharw(hw) - 'a';
            if (char_type < 0 || char_type >= 10)
            {
                (wattrset(hw,((chtype)((1U)) << ((8) + 8))));
                (wmove((hw),(1),(0)) == (-1) ? (-1) : waddnstr((hw),("Please enter a letter from a - j"),-1));
                (wattrset(hw,(1U - 1U)));
                wclrtoeol(hw);
                wrefresh(hw);
            }
            else
            {
                (wmove((hw),(1),(0)) == (-1) ? (-1) : waddnstr((hw),(""),-1));
                wclrtoeol(hw);
            }
        }
        while (char_type < 0 || char_type >= 10);
   player.t_ctype = char_type;
}

canonical_original_code:
void do_getplayer()
{
 print_stored();
    if (char_type == 11)
        do
        {
            (wmove((hw),(3),(0)) == (-1) ? (-1) : waddnstr((hw),("[a] Fighter\t" "[b] Paladin\t" "[c] Ranger\n" "[d] Cleric\t" "[e] Druid\t" "[f] Magician\n" "[g] Illusionist\t" "[h] Thief\t" "[i] Assasin\t" "[j] Ninja"),-1));
            (wmove((hw),(0),(0)) == (-1) ? (-1) : waddnstr((hw),("What character class do you desire? "),-1));
            wrefresh(hw);
            char_type = readcharw(hw) - 'a';
            if (char_type < 0 || char_type >= 10)
            {
                (wattrset(hw,((chtype)((1U)) << ((8) + 8))));
                (wmove((hw),(1),(0)) == (-1) ? (-1) : waddnstr((hw),("Please enter a letter from a - j"),-1));
                (wattrset(hw,(1U - 1U)));
                wclrtoeol(hw);
                wrefresh(hw);
            }
            else
            {
                (wmove((hw),(1),(0)) == (-1) ? (-1) : waddnstr((hw),(""),-1));
                wclrtoeol(hw);
            }
        }
        while (char_type < 0 || char_type >= 10);
   player.t_ctype = char_type;
}

return_type: void


prayer

decompiled_code:
int prayer()
{
char v0; // al
__int64 v1; // rax
unsigned int v2; // er13
int v3; // er12
int v4; // er13
int v5; // ebx
__int64 v6; // rbp
__int64 v7; // rax
int v8; // eax
int v9; // eax
int v10; // ebx
int v11; // edx
char v13[72]; // [rsp+0h] [rbp-48h] BYREF

if ( *((_DWORD *)&player + 86) > *((_DWORD *)&player + 14) )
{
msg("Are you sure you want to bother the gods?");
v0 = readchar();
LODWORD(v1) = tolower(v0);
if ( (_DWORD)v1 != 121 )
{
after = 0;
return v1;
}
msg("Here goes...");
}
msg("You are surrounded by orange smoke...");
if ( !(unsigned int)rnd(3LL) )
--luck;
v2 = is_wearing(29LL);
if ( v2
|| !(unsigned int)rnd(luck)
&& ((v8 = *((_DWORD *)&player + 90), (unsigned int)(v8 - 3) <= 1)
|| (unsigned int)(v8 - 1) <= 1 && *((int *)&player + 14) > 8) )
{
v2 = 32;
}
if ( !(unsigned int)is_wearing(29LL) )
{
v3 = wizard;
++*((_DWORD *)&player + 86);
if ( v3 )
goto LABEL_12;
LABEL_32:
v10 = rnd(100LL);
LODWORD(v1) = v10 + roll(10LL, luck);
v11 = v1 - 5;
LODWORD(v1) = v1 + 45;
if ( *((_DWORD *)&player + 86) <= *((_DWORD *)&player + 14) )
LODWORD(v1) = v11;
if ( v2 )
{
LODWORD(v1) = v1 - 50;
if ( (int)v1 < 0 )
{
v4 = 8;
msg("The heavens open and glorious radiance surrounds you!");
*((_QWORD *)&player + 5) = *((_QWORD *)&player + 14);
*((_DWORD *)&player + 17) = *((_DWORD *)&player + 35);
}
else
{
v3 = 100;
if ( (int)v1 <= 100 )
v3 = v1;
if ( (_DWORD)v1 )
goto LABEL_40;
v3 = 0;
msg("The heavens open and glorious radiance surrounds you!");
v4 = 8;
*((_QWORD *)&player + 5) = *((_QWORD *)&player + 14);
*((_DWORD *)&player + 17) = *((_DWORD *)&player + 35);
}
}
else
{
if ( (int)v1 >= 0 )
{
v3 = 100;
if ( (int)v1 <= 100 )
v3 = v1;
if ( (_DWORD)v1 )
goto LABEL_40;
}
v4 = 1;
msg("The heavens open and glorious radiance surrounds you!");
*((_QWORD *)&player + 5) = *((_QWORD *)&player + 14);
*((_DWORD *)&player + 17) = *((_DWORD *)&player + 35);
}
LABEL_18:
v5 = 0;
do
{
v1 = f_mons_a(*((unsigned int *)&player + 49), *((unsigned int *)&player + 48), 1LL);
v6 = v1;
if ( v1 )
{
msg(
"A bolt of eldritch energy strikes down the %s!",
*((const char **)&monsters + 27 * *(int *)(*(_QWORD *)(v1 + 16) + 364LL)));
LODWORD(v1) = killed(0LL, v6, 0LL, 1LL);
}
++v5;
}
while ( v4 != v5 );
goto LABEL_22;
}
v9 = rnd(2LL);
v3 = wizard;
*((_DWORD *)&player + 86) += v9;
if ( !v3 )
goto LABEL_32;
LABEL_12:
msg("What roll?[0..%d] ", 99LL);
if ( (unsigned int)get_string(v13, cw) == 1 )
{
LODWORD(v1) = msg((const char *)&unk_12C6);
return v1;
}
v3 = 0;
LODWORD(v1) = atoi(v13);
if ( (int)v1 < 0 )
goto LABEL_17;
v3 = 100;
if ( (int)v1 <= 100 )
v3 = v1;
if ( !(_DWORD)v1 )
{
LABEL_17:
msg("The heavens open and glorious radiance surrounds you!");
*((_QWORD *)&player + 5) = *((_QWORD *)&player + 14);
v4 = v2 == 0 ? 1 : 8;
*((_DWORD *)&player + 17) = *((_DWORD *)&player + 35);
goto LABEL_18;
}
LABEL_40:
if ( (_DWORD)v1 == 2 )
{
msg("Aule, Lord of Crafts, hears your call.");
LODWORD(v1) = read_scroll(&player, 15LL, v2);
return v1;
}
if ( (int)v1 <= 14 )
{
msg("Orome, Lord of Forests, hears your call.");
LODWORD(v1) = read_scroll(&player, 23LL, v2);
}
else if ( (int)v1 <= 19 )
{
msg("Hermes, the Winged Messenger, hears your call.");
LODWORD(v1) = quaff(&player, 7LL, v2);
}
else if ( (int)v1 <= 24 )
{
msg("Lorien, Master of Dreams, hears your call.");
LODWORD(v1) = read_scroll(&player, 4LL, v2);
}
else if ( (int)v1 <= 29 )
{
msg("Este, Lady of Healing, hears your call.");
quaff(&player, 8LL, v2);
LODWORD(v1) = quaff(&player, 3LL, v2);
}
else if ( (int)v1 <= 34 )
{
msg("Thor, God of Thunder, hears your call.");
msg("A bolt of lighting strikes you!");
LODWORD(v1) = read_scroll(&player, 21LL, v2);
}
else if ( (int)v1 <= 39 )
{
msg("Lorien, Master of Illusion, hears your call.");
LODWORD(v1) = quaff(&player, 14LL, v2);
}
else if ( (int)v1 <= 59 )
{
LODWORD(v1) = msg("Boccob, the Uncaring, ignores you.");
}
else if ( (int)v1 <= 64 )
{
msg("Jubilex, Master of Slimes and Oozes, hears your call.");
LODWORD(v1) = read_scroll(&player, 3LL, v2);
++luck;
}
else if ( (int)v1 <= 69 )
{
msg("Sauron, Lord of the Ring, hears your call.");
LODWORD(v1) = quaff(&player, 10LL, v2);
++luck;
}
else if ( (int)v1 <= 74 )
{
msg("Orcus, Lord of Undead, hears your call.");
LODWORD(v1) = quaff(&player, 9LL, v2);
++luck;
}
else if ( (int)v1 <= 79 )
{
msg("Incabulos, God of Evil Sendings, hears your call.");
LODWORD(v1) = quaff(&player, 0LL, v2);
++luck;
}
else if ( (int)v1 <= 84 )
{
msg("Raxivort, Night Flutterer, hears your call.");
LODWORD(v1) = quaff(&player, 2LL, v2);
++luck;
}
else if ( (int)v1 <= 89 )
{
msg("Morgoth, Lord of Fire, hears your call.");
LODWORD(v1) = quaff(&player, 15LL, v2);
++luck;
}
else if ( (int)v1 <= 99 )
{
LODWORD(v1) = msg("You fall into a horrible trance-like state.");
no_command += 4;
}
LABEL_22:
if ( v3 == 100 )
{
msg("The heavens open - but wait!");
msg("A bolt of eldritch energy strikes you!");
v7 = *((_QWORD *)&player + 5);
if ( v7 > 1 )
*((_QWORD *)&player + 5) = v7 >> 1;
LODWORD(v1) = msg("The gods must be angry with you.");
}
return v1;
}

canonical_decompiled_code:
int func0()
{
char v0; // al
__int64 v1; // rax
unsigned int v2; // er13
int v3; // er12
int v4; // er13
int v5; // ebx
__int64 v6; // rbp
__int64 v7; // rax
int v8; // eax
int v9; // eax
int v10; // ebx
int v11; // edx
char v13[72]; // [rsp+0h] [rbp-48h] BYREF

if ( *((_DWORD *)&player + 86) > *((_DWORD *)&player + 14) )
{
msg("Are you sure you want to bother the gods?");
v0 = readchar();
LODWORD(v1) = tolower(v0);
if ( (_DWORD)v1 != 121 )
{
after = 0;
return v1;
}
msg("Here goes...");
}
msg("You are surrounded by orange smoke...");
if ( !(unsigned int)rnd(3LL) )
--luck;
v2 = is_wearing(29LL);
if ( v2
|| !(unsigned int)rnd(luck)
&& ((v8 = *((_DWORD *)&player + 90), (unsigned int)(v8 - 3) <= 1)
|| (unsigned int)(v8 - 1) <= 1 && *((int *)&player + 14) > 8) )
{
v2 = 32;
}
if ( !(unsigned int)is_wearing(29LL) )
{
v3 = wizard;
++*((_DWORD *)&player + 86);
if ( v3 )
goto LABEL_12;
LABEL_32:
v10 = rnd(100LL);
LODWORD(v1) = v10 + roll(10LL, luck);
v11 = v1 - 5;
LODWORD(v1) = v1 + 45;
if ( *((_DWORD *)&player + 86) <= *((_DWORD *)&player + 14) )
LODWORD(v1) = v11;
if ( v2 )
{
LODWORD(v1) = v1 - 50;
if ( (int)v1 < 0 )
{
v4 = 8;
msg("The heavens open and glorious radiance surrounds you!");
*((_QWORD *)&player + 5) = *((_QWORD *)&player + 14);
*((_DWORD *)&player + 17) = *((_DWORD *)&player + 35);
}
else
{
v3 = 100;
if ( (int)v1 <= 100 )
v3 = v1;
if ( (_DWORD)v1 )
goto LABEL_40;
v3 = 0;
msg("The heavens open and glorious radiance surrounds you!");
v4 = 8;
*((_QWORD *)&player + 5) = *((_QWORD *)&player + 14);
*((_DWORD *)&player + 17) = *((_DWORD *)&player + 35);
}
}
else
{
if ( (int)v1 >= 0 )
{
v3 = 100;
if ( (int)v1 <= 100 )
v3 = v1;
if ( (_DWORD)v1 )
goto LABEL_40;
}
v4 = 1;
msg("The heavens open and glorious radiance surrounds you!");
*((_QWORD *)&player + 5) = *((_QWORD *)&player + 14);
*((_DWORD *)&player + 17) = *((_DWORD *)&player + 35);
}
LABEL_18:
v5 = 0;
do
{
v1 = f_mons_a(*((unsigned int *)&player + 49), *((unsigned int *)&player + 48), 1LL);
v6 = v1;
if ( v1 )
{
msg(
"A bolt of eldritch energy strikes down the %s!",
*((const char **)&monsters + 27 * *(int *)(*(_QWORD *)(v1 + 16) + 364LL)));
LODWORD(v1) = killed(0LL, v6, 0LL, 1LL);
}
++v5;
}
while ( v4 != v5 );
goto LABEL_22;
}
v9 = rnd(2LL);
v3 = wizard;
*((_DWORD *)&player + 86) += v9;
if ( !v3 )
goto LABEL_32;
LABEL_12:
msg("What roll?[0..%d] ", 99LL);
if ( (unsigned int)get_string(v13, cw) == 1 )
{
LODWORD(v1) = msg((const char *)&unk_12C6);
return v1;
}
v3 = 0;
LODWORD(v1) = atoi(v13);
if ( (int)v1 < 0 )
goto LABEL_17;
v3 = 100;
if ( (int)v1 <= 100 )
v3 = v1;
if ( !(_DWORD)v1 )
{
LABEL_17:
msg("The heavens open and glorious radiance surrounds you!");
*((_QWORD *)&player + 5) = *((_QWORD *)&player + 14);
v4 = v2 == 0 ? 1 : 8;
*((_DWORD *)&player + 17) = *((_DWORD *)&player + 35);
goto LABEL_18;
}
LABEL_40:
if ( (_DWORD)v1 == 2 )
{
msg("Aule, Lord of Crafts, hears your call.");
LODWORD(v1) = read_scroll(&player, 15LL, v2);
return v1;
}
if ( (int)v1 <= 14 )
{
msg("Orome, Lord of Forests, hears your call.");
LODWORD(v1) = read_scroll(&player, 23LL, v2);
}
else if ( (int)v1 <= 19 )
{
msg("Hermes, the Winged Messenger, hears your call.");
LODWORD(v1) = quaff(&player, 7LL, v2);
}
else if ( (int)v1 <= 24 )
{
msg("Lorien, Master of Dreams, hears your call.");
LODWORD(v1) = read_scroll(&player, 4LL, v2);
}
else if ( (int)v1 <= 29 )
{
msg("Este, Lady of Healing, hears your call.");
quaff(&player, 8LL, v2);
LODWORD(v1) = quaff(&player, 3LL, v2);
}
else if ( (int)v1 <= 34 )
{
msg("Thor, God of Thunder, hears your call.");
msg("A bolt of lighting strikes you!");
LODWORD(v1) = read_scroll(&player, 21LL, v2);
}
else if ( (int)v1 <= 39 )
{
msg("Lorien, Master of Illusion, hears your call.");
LODWORD(v1) = quaff(&player, 14LL, v2);
}
else if ( (int)v1 <= 59 )
{
LODWORD(v1) = msg("Boccob, the Uncaring, ignores you.");
}
else if ( (int)v1 <= 64 )
{
msg("Jubilex, Master of Slimes and Oozes, hears your call.");
LODWORD(v1) = read_scroll(&player, 3LL, v2);
++luck;
}
else if ( (int)v1 <= 69 )
{
msg("Sauron, Lord of the Ring, hears your call.");
LODWORD(v1) = quaff(&player, 10LL, v2);
++luck;
}
else if ( (int)v1 <= 74 )
{
msg("Orcus, Lord of Undead, hears your call.");
LODWORD(v1) = quaff(&player, 9LL, v2);
++luck;
}
else if ( (int)v1 <= 79 )
{
msg("Incabulos, God of Evil Sendings, hears your call.");
LODWORD(v1) = quaff(&player, 0LL, v2);
++luck;
}
else if ( (int)v1 <= 84 )
{
msg("Raxivort, Night Flutterer, hears your call.");
LODWORD(v1) = quaff(&player, 2LL, v2);
++luck;
}
else if ( (int)v1 <= 89 )
{
msg("Morgoth, Lord of Fire, hears your call.");
LODWORD(v1) = quaff(&player, 15LL, v2);
++luck;
}
else if ( (int)v1 <= 99 )
{
LODWORD(v1) = msg("You fall into a horrible trance-like state.");
no_command += 4;
}
LABEL_22:
if ( v3 == 100 )
{
msg("The heavens open - but wait!");
msg("A bolt of eldritch energy strikes you!");
v7 = *((_QWORD *)&player + 5);
if ( v7 > 1 )
*((_QWORD *)&player + 5) = v7 >> 1;
LODWORD(v1) = msg("The gods must be angry with you.");
}
return v1;
}

original_code:
void
prayer(void)
{
    int chance, i, times;
    char num_str[20];
    int ch;
    struct linked_list *item;
    struct thing *tp;
    int is_godly;
    if (player.t_praycnt > player.t_stats.s_lvl)
    {
        msg("Are you sure you want to bother the gods?");
        ch = readchar();
        if (tolower(ch) != 'y')
        {
            after = 0;
            return;
        }
        else
            msg("Here goes...");
    }
    msg("You are surrounded by orange smoke...");
    if (rnd(3) == 0)
        luck--;
    if (is_wearing(29) || (rnd(luck) == 0 &&
         (player.t_ctype == 4 || player.t_ctype == 3 ||
        ((player.t_ctype == 1 || player.t_ctype == 2)
         && player.t_stats.s_lvl > 8))))
        is_godly = 0x00000020UL;
    else
        is_godly = 0x00000000UL;
    if (is_wearing(29))
        player.t_praycnt += rnd(2);
    else
        player.t_praycnt++;
    if (wizard)
    {
        msg("What roll?[0..%d] ", 99);
        ch = get_string(num_str, cw);
        if (ch == 1)
        {
            msg("");
            return;
        }
        chance = atoi(num_str);
    }
    else
    {
        chance = rnd(100) + roll(10, luck) - 5;
        if (player.t_praycnt > player.t_stats.s_lvl)
            chance += 50;
        if (is_godly)
            chance -= 50;
    }
    chance = ((0) > (((chance) < (100) ? (chance) : (100))) ? (0) : (((chance) < (100) ? (chance) : (100))));
    if (chance == 0)
    {
        msg("The heavens open and glorious radiance surrounds you!");
        player.t_stats.s_hpt = player.maxstats.s_hpt;
        player.t_stats.s_power = player.maxstats.s_power;
        if (is_godly)
            times = 8;
        else
            times = 1;
        for (i = 0; i < times; i++)
        {
            item = f_mons_a(player.t_pos.y, player.t_pos.x, 1);
            if (item)
            {
                tp = ((*item).data.th);
                msg("A bolt of eldritch energy strikes down the %s!",
                    monsters[tp->t_index].m_name);
                killed(((void *)0), item, 0, 1);
            }
        }
    }
    else if (chance == 2)
    {
        msg("Aule, Lord of Crafts, hears your call.");
        read_scroll(&player, 15, is_godly);
    }
    else if (chance < 15)
    {
        msg("Orome, Lord of Forests, hears your call.");
        read_scroll(&player, 23, is_godly);
    }
    else if (chance < 20)
    {
        msg("Hermes, the Winged Messenger, hears your call.");
        quaff(&player, 7, is_godly);
    }
    else if (chance < 25)
    {
        msg("Lorien, Master of Dreams, hears your call.");
        read_scroll(&player, 4, is_godly);
    }
    else if (chance < 30)
    {
        msg("Este, Lady of Healing, hears your call.");
        quaff(&player, 8, is_godly);
        quaff(&player, 3, is_godly);
    }
    else if (chance < 35)
    {
        msg("Thor, God of Thunder, hears your call.");
        msg("A bolt of lighting strikes you!");
        read_scroll(&player, 21, is_godly);
    }
    else if (chance < 40)
    {
        msg("Lorien, Master of Illusion, hears your call.");
        quaff(&player, 14, is_godly);
    }
    else if (chance < 60)
    {
        msg("Boccob, the Uncaring, ignores you.");
    }
    else if (chance < 65)
    {
        msg("Jubilex, Master of Slimes and Oozes, hears your call.");
        read_scroll(&player, 3, is_godly);
        luck++;
    }
    else if (chance < 70)
    {
        msg("Sauron, Lord of the Ring, hears your call.");
        quaff(&player, 10, is_godly);
        luck++;
    }
    else if (chance < 75)
    {
        msg("Orcus, Lord of Undead, hears your call.");
        quaff(&player, 9, is_godly);
        luck++;
    }
    else if (chance < 80)
    {
        msg("Incabulos, God of Evil Sendings, hears your call.");
        quaff(&player, 0, is_godly);
        luck++;
    }
    else if (chance < 85)
    {
        msg("Raxivort, Night Flutterer, hears your call.");
        quaff(&player, 2, is_godly);
        luck++;
    }
    else if (chance < 90)
    {
        msg("Morgoth, Lord of Fire, hears your call.");
        quaff(&player, 15, is_godly);
        luck++;
    }
    else if (chance < 100)
    {
        msg("You fall into a horrible trance-like state.");
        no_command += 4;
    }
    if (chance == 100)
    {
        msg("The heavens open - but wait!");
        msg("A bolt of eldritch energy strikes you!");
        if (player.t_stats.s_hpt > 1)
            player.t_stats.s_hpt /= 2;
        msg("The gods must be angry with you.");
    }
}

canonical_original_code:
void prayer()
{
    int chance; int i; int times;
    char num_str[20];
    int ch;
    struct linked_list *item;
    struct thing *tp;
    int is_godly;
    if (player.t_praycnt > player.t_stats.s_lvl)
    {
        msg("Are you sure you want to bother the gods?");
        ch = readchar();
        if (tolower(ch) != 'y')
        {
            after = 0;
            return;
        }
        else
            msg("Here goes...");
    }
    msg("You are surrounded by orange smoke...");
    if (rnd(3) == 0)
        luck--;
    if (is_wearing(29) || (rnd(luck) == 0 &&
         (player.t_ctype == 4 || player.t_ctype == 3 ||
        ((player.t_ctype == 1 || player.t_ctype == 2)
         && player.t_stats.s_lvl > 8))))
        is_godly = 0x00000020UL;
    else
        is_godly = 0x00000000UL;
    if (is_wearing(29))
        player.t_praycnt += rnd(2);
    else
        player.t_praycnt++;
    if (wizard)
    {
        msg("What roll?[0..%d] ", 99);
        ch = get_string(num_str, cw);
        if (ch == 1)
        {
            msg("");
            return;
        }
        chance = atoi(num_str);
    }
    else
    {
        chance = rnd(100) + roll(10, luck) - 5;
        if (player.t_praycnt > player.t_stats.s_lvl)
            chance += 50;
        if (is_godly)
            chance -= 50;
    }
    chance = ((0) > (((chance) < (100) ? (chance) : (100))) ? (0) : (((chance) < (100) ? (chance) : (100))));
    if (chance == 0)
    {
        msg("The heavens open and glorious radiance surrounds you!");
        player.t_stats.s_hpt = player.maxstats.s_hpt;
        player.t_stats.s_power = player.maxstats.s_power;
        if (is_godly)
            times = 8;
        else
            times = 1;
        for (i = 0; i < times; i++)
        {
            item = f_mons_a(player.t_pos.y, player.t_pos.x, 1);
            if (item)
            {
                tp = ((*item).data.th);
                msg("A bolt of eldritch energy strikes down the %s!",
                    monsters[tp->t_index].m_name);
                killed(((void *)0), item, 0, 1);
            }
        }
    }
    else if (chance == 2)
    {
        msg("Aule, Lord of Crafts, hears your call.");
        read_scroll(&player, 15, is_godly);
    }
    else if (chance < 15)
    {
        msg("Orome, Lord of Forests, hears your call.");
        read_scroll(&player, 23, is_godly);
    }
    else if (chance < 20)
    {
        msg("Hermes, the Winged Messenger, hears your call.");
        quaff(&player, 7, is_godly);
    }
    else if (chance < 25)
    {
        msg("Lorien, Master of Dreams, hears your call.");
        read_scroll(&player, 4, is_godly);
    }
    else if (chance < 30)
    {
        msg("Este, Lady of Healing, hears your call.");
        quaff(&player, 8, is_godly);
        quaff(&player, 3, is_godly);
    }
    else if (chance < 35)
    {
        msg("Thor, God of Thunder, hears your call.");
        msg("A bolt of lighting strikes you!");
        read_scroll(&player, 21, is_godly);
    }
    else if (chance < 40)
    {
        msg("Lorien, Master of Illusion, hears your call.");
        quaff(&player, 14, is_godly);
    }
    else if (chance < 60)
    {
        msg("Boccob, the Uncaring, ignores you.");
    }
    else if (chance < 65)
    {
        msg("Jubilex, Master of Slimes and Oozes, hears your call.");
        read_scroll(&player, 3, is_godly);
        luck++;
    }
    else if (chance < 70)
    {
        msg("Sauron, Lord of the Ring, hears your call.");
        quaff(&player, 10, is_godly);
        luck++;
    }
    else if (chance < 75)
    {
        msg("Orcus, Lord of Undead, hears your call.");
        quaff(&player, 9, is_godly);
        luck++;
    }
    else if (chance < 80)
    {
        msg("Incabulos, God of Evil Sendings, hears your call.");
        quaff(&player, 0, is_godly);
        luck++;
    }
    else if (chance < 85)
    {
        msg("Raxivort, Night Flutterer, hears your call.");
        quaff(&player, 2, is_godly);
        luck++;
    }
    else if (chance < 90)
    {
        msg("Morgoth, Lord of Fire, hears your call.");
        quaff(&player, 15, is_godly);
        luck++;
    }
    else if (chance < 100)
    {
        msg("You fall into a horrible trance-like state.");
        no_command += 4;
    }
    if (chance == 100)
    {
        msg("The heavens open - but wait!");
        msg("A bolt of eldritch energy strikes you!");
        if (player.t_stats.s_hpt > 1)
            player.t_stats.s_hpt /= 2;
        msg("The gods must be angry with you.");
    }
}

variable_types: chance int

variable_types: i int

variable_types: times int

variable_types: ch int

variable_types: struct linked_list { struct linked_list *l_next; struct linked_list *l_prev; union { struct object { struct coord { int x; int y; } o_pos; struct linked_list *next_obj; struct linked_list *o_bag; char *o_text; char *o_damage; char *o_hurldmg; long o_flags; long ar_flags; char o_type; int o_ident; unsigned int o_count; int o_which; int o_hplus; int o_dplus; int o_ac; int o_group; int o_weight; char o_launch; char o_mark[20]; long o_worth; } *obj; struct thing { long chasee_index; struct linked_list *t_pack; struct stats { char *s_dmg; long s_exp; long s_hpt; int s_pack; int s_carry; int s_lvl; int s_arm; int s_acmod; int s_power; int s_str; int s_intel; int s_wisdom; int s_dext; int s_const; int s_charisma; } t_stats; struct stats maxstats; int t_ischasing; struct thing *t_chasee; struct object *t_horde; struct coord t_pos; struct coord t_oldpos; struct coord t_nxtpos; long t_flags[16]; int t_praycnt; int t_trans; int t_turn; int t_wasshot; int t_ctype; int t_index; int t_no_move; int t_rest_hpt; int t_rest_pow; int t_doorgoal; char t_type; char t_disguise; char t_oldch; } *th; void *l_data; } data; } *

variable_types: struct thing { long chasee_index; struct linked_list { struct linked_list *l_next; struct linked_list *l_prev; union { struct object { struct coord { int x; int y; } o_pos; struct linked_list *next_obj; struct linked_list *o_bag; char *o_text; char *o_damage; char *o_hurldmg; long o_flags; long ar_flags; char o_type; int o_ident; unsigned int o_count; int o_which; int o_hplus; int o_dplus; int o_ac; int o_group; int o_weight; char o_launch; char o_mark[20]; long o_worth; } *obj; struct thing *th; void *l_data; } data; } *t_pack; struct stats { char *s_dmg; long s_exp; long s_hpt; int s_pack; int s_carry; int s_lvl; int s_arm; int s_acmod; int s_power; int s_str; int s_intel; int s_wisdom; int s_dext; int s_const; int s_charisma; } t_stats; struct stats maxstats; int t_ischasing; struct thing *t_chasee; struct object *t_horde; struct coord t_pos; struct coord t_oldpos; struct coord t_nxtpos; long t_flags[16]; int t_praycnt; int t_trans; int t_turn; int t_wasshot; int t_ctype; int t_index; int t_no_move; int t_rest_hpt; int t_rest_pow; int t_doorgoal; char t_type; char t_disguise; char t_oldch; } *

user_defined_types: struct linked_list { struct linked_list *l_next; struct linked_list *l_prev; union { struct object *obj; struct thing *th; void *l_data; } data; }

user_defined_types: struct thing { long chasee_index; struct linked_list *t_pack; struct stats t_stats; struct stats maxstats; int t_ischasing; struct thing *t_chasee; struct object *t_horde; struct coord t_pos; struct coord t_oldpos; struct coord t_nxtpos; long t_flags[16]; int t_praycnt; int t_trans; int t_turn; int t_wasshot; int t_ctype; int t_index; int t_no_move; int t_rest_hpt; int t_rest_pow; int t_doorgoal; char t_type; char t_disguise; char t_oldch; }

user_defined_types: struct object { struct coord o_pos; struct linked_list *next_obj; struct linked_list *o_bag; char *o_text; char *o_damage; char *o_hurldmg; long o_flags; long ar_flags; char o_type; int o_ident; unsigned int o_count; int o_which; int o_hplus; int o_dplus; int o_ac; int o_group; int o_weight; char o_launch; char o_mark[20]; long o_worth; }


gsense

decompiled_code:
__int64 gsense()
{
_QWORD *v0; // rbx
int v1; // ebp
__int64 v2; // rax
__int64 result; // rax

if ( !lvl_obj )
goto LABEL_9;
wclear(hw);
v0 = (_QWORD *)lvl_obj;
if ( !lvl_obj )
goto LABEL_9;
v1 = 0;
do
{
while ( 1 )
{
v2 = v0[2];
if ( *(_BYTE *)(v2 + 64) == 42 )
{
v1 += *(_DWORD *)(v2 + 72);
if ( wmove(hw, *(_DWORD *)(v2 + 4), *(_DWORD *)v2) != -1 )
break;
}
v0 = (_QWORD *)*v0;
if ( !v0 )
goto LABEL_8;
}
waddch(hw, 0x2AuLL);
v0 = (_QWORD *)*v0;
}
while ( v0 );
LABEL_8:
if ( v1 )
{
msg("You sense gold!");
overlay(hw, cw);
result = 1LL;
}
else
{
LABEL_9:
nothing_message(0LL);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
_QWORD *v0; // rbx
int v1; // ebp
__int64 v2; // rax
__int64 result; // rax

if ( !lvl_obj )
goto LABEL_9;
wclear(hw);
v0 = (_QWORD *)lvl_obj;
if ( !lvl_obj )
goto LABEL_9;
v1 = 0;
do
{
while ( 1 )
{
v2 = v0[2];
if ( *(_BYTE *)(v2 + 64) == 42 )
{
v1 += *(_DWORD *)(v2 + 72);
if ( wmove(hw, *(_DWORD *)(v2 + 4), *(_DWORD *)v2) != -1 )
break;
}
v0 = (_QWORD *)*v0;
if ( !v0 )
goto LABEL_8;
}
waddch(hw, 0x2AuLL);
v0 = (_QWORD *)*v0;
}
while ( v0 );
LABEL_8:
if ( v1 )
{
msg("You sense gold!");
overlay(hw, cw);
result = 1LL;
}
else
{
LABEL_9:
nothing_message(0LL);
result = 0LL;
}
return result;
}

original_code:
int
gsense(void)
{
    if (lvl_obj != ((void *)0))
    {
        struct linked_list *gitem;
        struct object *cur;
        int gtotal = 0;
        wclear(hw);
        for (gitem = lvl_obj; gitem != ((void *)0); gitem = ((gitem)?(gitem->l_next):((void *)0)))
        {
            cur = ((*gitem).data.obj);
            if (cur->o_type == '*')
            {
                gtotal += cur->o_count;
                (wmove((hw),(cur->o_pos.y),(cur->o_pos.x)) == (-1) ? (-1) : waddch((hw),('*')));
            }
        }
        if (gtotal)
        {
            msg("You sense gold!");
            overlay(hw, cw);
            return(1);
        }
    }
    nothing_message(0x00000000UL);
    return(0);
}

canonical_original_code:
int gsense()
{
    if (lvl_obj != ((void *)0))
    {
        struct linked_list *gitem;
        struct object *cur;
        int gtotal = 0;
        wclear(hw);
        for (gitem = lvl_obj; gitem != ((void *)0); gitem = ((gitem)?(gitem->l_next):((void *)0)))
        {
            cur = ((*gitem).data.obj);
            if (cur->o_type == '*')
            {
                gtotal += cur->o_count;
                (wmove((hw),(cur->o_pos.y),(cur->o_pos.x)) == (-1) ? (-1) : waddch((hw),('*')));
            }
        }
        if (gtotal)
        {
            msg("You sense gold!");
            overlay(hw, cw);
            return(1);
        }
    }
    nothing_message(0x00000000UL);
    return(0);
}

variable_types: struct object { struct coord { int x; int y; } o_pos; struct linked_list { struct linked_list *l_next; struct linked_list *l_prev; union { struct object *obj; struct thing { long chasee_index; struct linked_list *t_pack; struct stats { char *s_dmg; long s_exp; long s_hpt; int s_pack; int s_carry; int s_lvl; int s_arm; int s_acmod; int s_power; int s_str; int s_intel; int s_wisdom; int s_dext; int s_const; int s_charisma; } t_stats; struct stats maxstats; int t_ischasing; struct thing *t_chasee; struct object *t_horde; struct coord t_pos; struct coord t_oldpos; struct coord t_nxtpos; long t_flags[16]; int t_praycnt; int t_trans; int t_turn; int t_wasshot; int t_ctype; int t_index; int t_no_move; int t_rest_hpt; int t_rest_pow; int t_doorgoal; char t_type; char t_disguise; char t_oldch; } *th; void *l_data; } data; } *next_obj; struct linked_list *o_bag; char *o_text; char *o_damage; char *o_hurldmg; long o_flags; long ar_flags; char o_type; int o_ident; unsigned int o_count; int o_which; int o_hplus; int o_dplus; int o_ac; int o_group; int o_weight; char o_launch; char o_mark[20]; long o_worth; } *

variable_types: gtotal int

return_type: int


decompiled_code:
_BOOL8 __fastcall is_stealth(__int64 a1)
{
int v1; // er8
_BOOL8 result; // rax

v1 = rnd(25LL);
result = 1LL;
if ( v1 >= *(_DWORD *)(a1 + 84) )
{
result = 0LL;
if ( (_UNKNOWN *)a1 == &player )
result = (unsigned int)is_wearing(12LL) != 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
int v1; // er8
_BOOL8 result; // rax

v1 = rnd(25LL);
result = 1LL;
if ( v1 >= *(_DWORD *)(a1 + 84) )
{
result = 0LL;
if ( (_UNKNOWN *)a1 == &player )
result = (unsigned int)is_wearing(12LL) != 0;
}
return result;
}

original_code:
int
is_stealth(struct thing *tp)
{
    return (rnd(25) < tp->t_stats.s_dext ||
        (tp == &player && is_wearing(12)));
}

user_defined_types: struct stats { char *s_dmg; long s_exp; long s_hpt; int s_pack; int s_carry; int s_lvl; int s_arm; int s_acmod; int s_power; int s_str; int s_intel; int s_wisdom; int s_dext; int s_const; int s_charisma; }


steal

original_code:
void
steal(void)
{
    struct linked_list *item;
    struct thing *tp;
    coord new_pos;
    short thief_bonus;
    char *unsuccess = "";
    char *gain = "";
    char *notice = "is not";
    new_pos.y = player.t_pos.y + delta.y;
    new_pos.x = player.t_pos.x + delta.x;
    if (new_pos.y < 0 || new_pos.y > LINES - 3 ||
        new_pos.x < 0 || new_pos.x > COLS - 1 ||
        (wmove((mw),(new_pos.y),(new_pos.x)) == (-1) ? (chtype)((-1)) : winch(mw)) == ' ')
    {
        msg("There is no one to steal from.");
        return;
    }
    if ((item = find_mons(new_pos.y, new_pos.x)) == ((void *)0))
        return;
    tp = ((*item).data.th);
    if (player.t_ctype == 7 || player.t_ctype == 9)
        thief_bonus = 10;
    else
        thief_bonus = -50;
    if (rnd(50) >= 3 * player.t_stats.s_dext + thief_bonus)
    {
        chase_it(&new_pos, &player);
        ( (*tp).t_flags[(0x10800000UL >> 28UL) & 0x0000000fL] &= ~(0x10800000UL & 0x0fffffffL));
        notice = "is";
    }
    if (rnd(100) <
        (thief_bonus + 2 * player.t_stats.s_dext + 5 * player.t_stats.s_lvl -
         5 * (tp->t_stats.s_lvl - 3)))
    {
        struct linked_list *s_item, *pack_ptr;
        int cnt = 0;
        s_item = ((void *)0);
        if (tp->t_pack != ((void *)0))
        {
            for (pack_ptr = tp->t_pack; pack_ptr != ((void *)0); pack_ptr = ((pack_ptr)?(pack_ptr->l_next):((void *)0)))
                cnt++;
            cnt = rnd(cnt);
            for (pack_ptr = tp->t_pack; --cnt == 0; pack_ptr = ((pack_ptr)?(pack_ptr->l_next):((void *)0)))
                ;
            s_item = pack_ptr;
            _detach(&tp->t_pack, s_item);
            if (add_pack(s_item, 1) == 0)
            {
                (((*s_item).data.obj))->o_pos = player.t_pos;
                fall(&player, s_item, 1, 0);
            }
            if ((!((*tp).t_flags[(0x10800000UL >> 28UL) & 0x0000000fL] & (0x10800000UL & 0x0fffffffL))))
            {
                if (player.t_ctype == 7)
                    player.t_stats.s_exp += 2 * tp->t_stats.s_exp / 3;
                else
                    player.t_stats.s_exp += tp->t_stats.s_exp / ((player.t_stats.s_lvl) < (10) ? (player.t_stats.s_lvl) : (10));
                check_level();
            }
        }
        else
        {
            gain = " gains you nothing and";
        }
    }
    else
    {
        unsuccess = " unsuccessful";
    }
    msg("Your%s attempt%s %s noticed.", unsuccess, gain, notice);
}

canonical_original_code:
void steal()
{
    struct linked_list *item;
    struct thing *tp;
    struct coord new_pos;
    short thief_bonus;
    char *unsuccess = "";
    char *gain = "";
    char *notice = "is not";
    new_pos.y = player.t_pos.y + delta.y;
    new_pos.x = player.t_pos.x + delta.x;
    if (new_pos.y < 0 || new_pos.y > LINES - 3 ||
        new_pos.x < 0 || new_pos.x > COLS - 1 ||
        (wmove((mw),(new_pos.y),(new_pos.x)) == (-1) ? (chtype)((-1)) : winch(mw)) == ' ')
    {
        msg("There is no one to steal from.");
        return;
    }
    if ((item = find_mons(new_pos.y, new_pos.x)) == ((void *)0))
        return;
    tp = ((*item).data.th);
    if (player.t_ctype == 7 || player.t_ctype == 9)
        thief_bonus = 10;
    else
        thief_bonus = -50;
    if (rnd(50) >= 3 * player.t_stats.s_dext + thief_bonus)
    {
        chase_it(&new_pos, &player);
        ( (*tp).t_flags[(0x10800000UL >> 28UL) & 0x0000000fL] &= ~(0x10800000UL & 0x0fffffffL));
        notice = "is";
    }
    if (rnd(100) <
        (thief_bonus + 2 * player.t_stats.s_dext + 5 * player.t_stats.s_lvl -
         5 * (tp->t_stats.s_lvl - 3)))
    {
        struct linked_list *s_item; struct linked_list *pack_ptr;
        int cnt = 0;
        s_item = ((void *)0);
        if (tp->t_pack != ((void *)0))
        {
            for (pack_ptr = tp->t_pack; pack_ptr != ((void *)0); pack_ptr = ((pack_ptr)?(pack_ptr->l_next):((void *)0)))
                cnt++;
            cnt = rnd(cnt);
            for (pack_ptr = tp->t_pack; --cnt == 0; pack_ptr = ((pack_ptr)?(pack_ptr->l_next):((void *)0)))
                ;
            s_item = pack_ptr;
            _detach(&tp->t_pack, s_item);
            if (add_pack(s_item, 1) == 0)
            {
                (((*s_item).data.obj))->o_pos = player.t_pos;
                fall(&player, s_item, 1, 0);
            }
            if ((!((*tp).t_flags[(0x10800000UL >> 28UL) & 0x0000000fL] & (0x10800000UL & 0x0fffffffL))))
            {
                if (player.t_ctype == 7)
                    player.t_stats.s_exp += 2 * tp->t_stats.s_exp / 3;
                else
                    player.t_stats.s_exp += tp->t_stats.s_exp / ((player.t_stats.s_lvl) < (10) ? (player.t_stats.s_lvl) : (10));
                check_level();
            }
        }
        else
        {
            gain = " gains you nothing and";
        }
    }
    else
    {
        unsuccess = " unsuccessful";
    }
    msg("Your%s attempt%s %s noticed.", unsuccess, gain, notice);
}

variable_types:
unsuccess
char *

variable_types:
gain
char *

variable_types:
notice
char *

variable_types: cnt int


affect

decompiled_code:
unsigned __int64 affect()
{
int v0; // ebx
int v1; // esi
int v2; // edx
unsigned __int64 result; // rax
unsigned __int64 v4; // r12
__int64 v5; // rbp
const char *v6; // r13
__int64 v7; // rax
__int64 v8; // rax
unsigned int v9; // [rsp+8h] [rbp-30h] BYREF
unsigned int v10; // [rsp+Ch] [rbp-2Ch]

if ( (*((_DWORD *)&player + 90) & 0xFFFFFFFD) != 1 )
{
if ( !(unsigned int)is_wearing(29LL) )
return msg("Only clerics and paladins can affect undead.");
if ( (*((_DWORD *)&player + 90) & 0xFFFFFFFD) != 1 )
goto LABEL_3;
}
if ( (unsigned int)is_wearing(29LL) )
v0 = 2 * *((_DWORD *)&player + 14);
else
LABEL_3:
v0 = *((_DWORD *)&player + 14);
v1 = *((_DWORD *)&player + 49) + *((_DWORD *)&delta + 1);
v2 = *((_DWORD *)&player + 48) + delta;
v10 = v1;
v9 = v2;
if ( v1 < 0 || v1 >= LINES - 2 || v2 < 0 || v2 >= COLS || wmove(mw, v1, v2) != -1 && (unsigned int)winch(mw) == 32 )
return msg("Nothing to affect.");
result = find_mons(v10, v9);
v4 = result;
if ( !result )
{
if ( wizard )
{
result = wiz_verbose;
if ( wiz_verbose )
result = msg("Affect what @ %d,%d?", v10, v9);
}
return result;
}
v5 = *(_QWORD *)(result + 16);
v6 = (const char *)*((_QWORD *)&monsters + 27 * *(int *)(v5 + 364));
if ( (*(_BYTE *)(v5 + 240) & 1) == 0 )
{
result = msg("Your holy symbol has no effect on the %s.", *((const char **)&monsters + 27 * *(int *)(v5 + 364)));
goto LABEL_21;
}
if ( (*(_BYTE *)(v5 + 226) & 1) != 0 )
{
result = msg("Your holy symbol merely enrages the %s.", *((const char **)&monsters + 27 * *(int *)(v5 + 364)));
LABEL_21:
if ( (*(_BYTE *)(v5 + 226) & 1) == 0 )
result = chase_it(&v9, &player);
return result;
}
if ( 3 * *(_DWORD *)(v5 + 56) <= v0 )
{
msg("You have destroyed the %s.", *((const char **)&monsters + 27 * *(int *)(v5 + 364)));
return killed(&player, v4, 0LL, 1LL);
}
if ( (int)rnd(100LL) < 100 * (2 * *(_DWORD *)(v5 + 56) - v0) / v0 )
{
result = msg("The %s momentarily recoils from your holy symbol.", v6);
goto LABEL_21;
}
msg("You have turned the %s.", v6);
v7 = *(_QWORD *)(v5 + 224);
*(_QWORD *)(v5 + 216) |= 0xCuLL;
*(_QWORD *)(v5 + 224) = v7 | 0x10000;
if ( (v7 & 0x10) != 0 )
{
*(_QWORD *)(v5 + 224) = (v7 | 0x10000) & 0xFFFFFFFFFFFFFFEFLL;
extinguish_fuse(15LL);
}
v8 = *(_QWORD *)(v5 + 232);
if ( (v8 & 0x4000000) != 0 && !--hold_count )
*((_QWORD *)&player + 27) &= 0xFFFFFFFFFFFFFEFFLL;
result = v8 & 0xFFFFFFFFFBFFFFFFLL;
*(_QWORD *)(v5 + 232) = result;
return result;
}

canonical_decompiled_code:
unsigned __int64 func4()
{
int v0; // ebx
int v1; // esi
int v2; // edx
unsigned __int64 result; // rax
unsigned __int64 v4; // r12
__int64 v5; // rbp
const char *v6; // r13
__int64 v7; // rax
__int64 v8; // rax
unsigned int v9; // [rsp+8h] [rbp-30h] BYREF
unsigned int v10; // [rsp+Ch] [rbp-2Ch]

if ( (*((_DWORD *)&player + 90) & 0xFFFFFFFD) != 1 )
{
if ( !(unsigned int)is_wearing(29LL) )
return msg("Only clerics and paladins can affect undead.");
if ( (*((_DWORD *)&player + 90) & 0xFFFFFFFD) != 1 )
goto LABEL_3;
}
if ( (unsigned int)is_wearing(29LL) )
v0 = 2 * *((_DWORD *)&player + 14);
else
LABEL_3:
v0 = *((_DWORD *)&player + 14);
v1 = *((_DWORD *)&player + 49) + *((_DWORD *)&delta + 1);
v2 = *((_DWORD *)&player + 48) + delta;
v10 = v1;
v9 = v2;
if ( v1 < 0 || v1 >= LINES - 2 || v2 < 0 || v2 >= COLS || wmove(mw, v1, v2) != -1 && (unsigned int)winch(mw) == 32 )
return msg("Nothing to affect.");
result = find_mons(v10, v9);
v4 = result;
if ( !result )
{
if ( wizard )
{
result = wiz_verbose;
if ( wiz_verbose )
result = msg("Affect what @ %d,%d?", v10, v9);
}
return result;
}
v5 = *(_QWORD *)(result + 16);
v6 = (const char *)*((_QWORD *)&monsters + 27 * *(int *)(v5 + 364));
if ( (*(_BYTE *)(v5 + 240) & 1) == 0 )
{
result = msg("Your holy symbol has no effect on the %s.", *((const char **)&monsters + 27 * *(int *)(v5 + 364)));
goto LABEL_21;
}
if ( (*(_BYTE *)(v5 + 226) & 1) != 0 )
{
result = msg("Your holy symbol merely enrages the %s.", *((const char **)&monsters + 27 * *(int *)(v5 + 364)));
LABEL_21:
if ( (*(_BYTE *)(v5 + 226) & 1) == 0 )
result = chase_it(&v9, &player);
return result;
}
if ( 3 * *(_DWORD *)(v5 + 56) <= v0 )
{
msg("You have destroyed the %s.", *((const char **)&monsters + 27 * *(int *)(v5 + 364)));
return killed(&player, v4, 0LL, 1LL);
}
if ( (int)rnd(100LL) < 100 * (2 * *(_DWORD *)(v5 + 56) - v0) / v0 )
{
result = msg("The %s momentarily recoils from your holy symbol.", v6);
goto LABEL_21;
}
msg("You have turned the %s.", v6);
v7 = *(_QWORD *)(v5 + 224);
*(_QWORD *)(v5 + 216) |= 0xCuLL;
*(_QWORD *)(v5 + 224) = v7 | 0x10000;
if ( (v7 & 0x10) != 0 )
{
*(_QWORD *)(v5 + 224) = (v7 | 0x10000) & 0xFFFFFFFFFFFFFFEFLL;
extinguish_fuse(15LL);
}
v8 = *(_QWORD *)(v5 + 232);
if ( (v8 & 0x4000000) != 0 && !--hold_count )
*((_QWORD *)&player + 27) &= 0xFFFFFFFFFFFFFEFFLL;
result = v8 & 0xFFFFFFFFFBFFFFFFLL;
*(_QWORD *)(v5 + 232) = result;
return result;
}

original_code:
void
affect(void)
{
    struct linked_list *item;
    struct thing *tp;
    char *mname;
    coord new_pos;
    int is_godly;
    int effective_level;
    if (player.t_ctype != 3 && player.t_ctype != 1 &&
        !is_wearing(29))
    {
        msg("Only clerics and paladins can affect undead.");
        return;
    }
    is_godly = (player.t_ctype == 3 || player.t_ctype == 1);
    if (is_godly && is_wearing(29))
        effective_level = 2 * player.t_stats.s_lvl;
    else
        effective_level = player.t_stats.s_lvl;
    new_pos.y = player.t_pos.y + delta.y;
    new_pos.x = player.t_pos.x + delta.x;
    if (new_pos.y < 0 || new_pos.y > LINES - 3 ||
        new_pos.x < 0 || new_pos.x > COLS - 1 ||
        (wmove((mw),(new_pos.y),(new_pos.x)) == (-1) ? (chtype)((-1)) : winch(mw)) == ' ')
    {
        msg("Nothing to affect.");
        return;
    }
    if ((item = find_mons(new_pos.y, new_pos.x)) == ((void *)0))
    {
        if (wizard && wiz_verbose) msg("Affect what @ %d,%d?", new_pos.y, new_pos.x);
        return;
    }
    tp = ((*item).data.th);
    mname = monsters[tp->t_index].m_name;
    if ((!((*tp).t_flags[(0x30000001UL >> 28UL) & 0x0000000fL] & (0x30000001UL & 0x0fffffffL))))
    {
        msg("Your holy symbol has no effect on the %s.", mname);
        goto annoy;
    }
    if (((*tp).t_flags[(0x10010000UL >> 28UL) & 0x0000000fL] & (0x10010000UL & 0x0fffffffL)))
    {
        msg("Your holy symbol merely enrages the %s.", mname);
        goto annoy;
    }
    if (effective_level >= 3 * tp->t_stats.s_lvl)
    {
        msg("You have destroyed the %s.", mname);
        killed(&player, item, 0, 1);
        return;
    }
    if (rnd(100) + 1 >
        (100 * ((2 * tp->t_stats.s_lvl) - effective_level)) /
            effective_level)
    {
        msg("You have turned the %s.", mname);
        ( (*tp).t_flags[(0x10010000UL >> 28UL) & 0x0000000fL] |= (0x10010000UL & 0x0fffffffL));
        ( (*tp).t_flags[(0x00000004UL >> 28UL) & 0x0000000fL] |= (0x00000004UL & 0x0fffffffL));
        ( (*tp).t_flags[(0x00000008UL >> 28UL) & 0x0000000fL] |= (0x00000008UL & 0x0fffffffL));
        if (((*tp).t_flags[(0x10000010UL >> 28UL) & 0x0000000fL] & (0x10000010UL & 0x0fffffffL)))
        {
            ( (*tp).t_flags[(0x10000010UL >> 28UL) & 0x0000000fL] &= ~(0x10000010UL & 0x0fffffffL));
            extinguish_fuse(15);
        }
        if (((*tp).t_flags[(0x24000000UL >> 28UL) & 0x0000000fL] & (0x24000000UL & 0x0fffffffL)) && (--hold_count == 0))
            ( (player).t_flags[(0x00000100UL >> 28UL) & 0x0000000fL] &= ~(0x00000100UL & 0x0fffffffL));
        ( (*tp).t_flags[(0x24000000UL >> 28UL) & 0x0000000fL] &= ~(0x24000000UL & 0x0fffffffL));
        return;
    }
    msg("The %s momentarily recoils from your holy symbol.", mname);
annoy:
    if ((!((*tp).t_flags[(0x10010000UL >> 28UL) & 0x0000000fL] & (0x10010000UL & 0x0fffffffL))))
        chase_it(&new_pos, &player);
}

canonical_original_code:
void affect()
{
    struct linked_list *item;
    struct thing *tp;
    char *mname;
    struct coord new_pos;
    int is_godly;
    int effective_level;
    if (player.t_ctype != 3 && player.t_ctype != 1 &&
        !is_wearing(29))
    {
        msg("Only clerics and paladins can affect undead.");
        return;
    }
    is_godly = (player.t_ctype == 3 || player.t_ctype == 1);
    if (is_godly && is_wearing(29))
        effective_level = 2 * player.t_stats.s_lvl;
    else
        effective_level = player.t_stats.s_lvl;
    new_pos.y = player.t_pos.y + delta.y;
    new_pos.x = player.t_pos.x + delta.x;
    if (new_pos.y < 0 || new_pos.y > LINES - 3 ||
        new_pos.x < 0 || new_pos.x > COLS - 1 ||
        (wmove((mw),(new_pos.y),(new_pos.x)) == (-1) ? (chtype)((-1)) : winch(mw)) == ' ')
    {
        msg("Nothing to affect.");
        return;
    }
    if ((item = find_mons(new_pos.y, new_pos.x)) == ((void *)0))
    {
        if (wizard && wiz_verbose) msg("Affect what @ %d,%d?", new_pos.y, new_pos.x);
        return;
    }
    tp = ((*item).data.th);
    mname = monsters[tp->t_index].m_name;
    if ((!((*tp).t_flags[(0x30000001UL >> 28UL) & 0x0000000fL] & (0x30000001UL & 0x0fffffffL))))
    {
        msg("Your holy symbol has no effect on the %s.", mname);
        goto annoy;
    }
    if (((*tp).t_flags[(0x10010000UL >> 28UL) & 0x0000000fL] & (0x10010000UL & 0x0fffffffL)))
    {
        msg("Your holy symbol merely enrages the %s.", mname);
        goto annoy;
    }
    if (effective_level >= 3 * tp->t_stats.s_lvl)
    {
        msg("You have destroyed the %s.", mname);
        killed(&player, item, 0, 1);
        return;
    }
    if (rnd(100) + 1 >
        (100 * ((2 * tp->t_stats.s_lvl) - effective_level)) /
            effective_level)
    {
        msg("You have turned the %s.", mname);
        ( (*tp).t_flags[(0x10010000UL >> 28UL) & 0x0000000fL] |= (0x10010000UL & 0x0fffffffL));
        ( (*tp).t_flags[(0x00000004UL >> 28UL) & 0x0000000fL] |= (0x00000004UL & 0x0fffffffL));
        ( (*tp).t_flags[(0x00000008UL >> 28UL) & 0x0000000fL] |= (0x00000008UL & 0x0fffffffL));
        if (((*tp).t_flags[(0x10000010UL >> 28UL) & 0x0000000fL] & (0x10000010UL & 0x0fffffffL)))
        {
            ( (*tp).t_flags[(0x10000010UL >> 28UL) & 0x0000000fL] &= ~(0x10000010UL & 0x0fffffffL));
            extinguish_fuse(15);
        }
        if (((*tp).t_flags[(0x24000000UL >> 28UL) & 0x0000000fL] & (0x24000000UL & 0x0fffffffL)) && (--hold_count == 0))
            ( (player).t_flags[(0x00000100UL >> 28UL) & 0x0000000fL] &= ~(0x00000100UL & 0x0fffffffL));
        ( (*tp).t_flags[(0x24000000UL >> 28UL) & 0x0000000fL] &= ~(0x24000000UL & 0x0fffffffL));
        return;
    }
    msg("The %s momentarily recoils from your holy symbol.", mname);
annoy:
    if ((!((*tp).t_flags[(0x10010000UL >> 28UL) & 0x0000000fL] & (0x10010000UL & 0x0fffffffL))))
        chase_it(&new_pos, &player);
}

variable_types:
mname
char *


decompiled_code:
int undead_sense()
{
__int64 v0; // rax
_QWORD *v1; // rbx
int v2; // ebp

LODWORD(v0) = wclear(hw);
v1 = (_QWORD *)mlist;
if ( mlist )
{
v2 = 0;
do
{
while ( 1 )
{
v0 = v1[2];
if ( (*(_BYTE *)(v0 + 240) & 1) != 0 )
{
v2 = 1;
LODWORD(v0) = wmove(hw, *(_DWORD *)(v0 + 196), *(_DWORD *)(v0 + 192));
if ( (_DWORD)v0 != -1 )
break;
}
v1 = (_QWORD *)*v1;
if ( !v1 )
goto LABEL_7;
}
LODWORD(v0) = waddch(hw, 0x26uLL);
v1 = (_QWORD *)*v1;
}
while ( v1 );
LABEL_7:
if ( v2 )
{
msg("You feel the presense of the ungodly.");
overlay(hw, cw);
wrefresh(cw);
LODWORD(v0) = wclear(hw);
}
}
return v0;
}

canonical_decompiled_code:
int func5()
{
__int64 v0; // rax
_QWORD *v1; // rbx
int v2; // ebp

LODWORD(v0) = wclear(hw);
v1 = (_QWORD *)mlist;
if ( mlist )
{
v2 = 0;
do
{
while ( 1 )
{
v0 = v1[2];
if ( (*(_BYTE *)(v0 + 240) & 1) != 0 )
{
v2 = 1;
LODWORD(v0) = wmove(hw, *(_DWORD *)(v0 + 196), *(_DWORD *)(v0 + 192));
if ( (_DWORD)v0 != -1 )
break;
}
v1 = (_QWORD *)*v1;
if ( !v1 )
goto LABEL_7;
}
LODWORD(v0) = waddch(hw, 0x26uLL);
v1 = (_QWORD *)*v1;
}
while ( v1 );
LABEL_7:
if ( v2 )
{
msg("You feel the presense of the ungodly.");
overlay(hw, cw);
wrefresh(cw);
LODWORD(v0) = wclear(hw);
}
}
return v0;
}

original_code:
void
undead_sense(void)
{
    struct linked_list *item;
    struct thing *tp;
    int showit = 0;
    wclear(hw);
    for (item = mlist; item != ((void *)0); item = ((item)?(item->l_next):((void *)0)))
    {
        tp = ((*item).data.th);
        if (((*tp).t_flags[(0x30000001UL >> 28UL) & 0x0000000fL] & (0x30000001UL & 0x0fffffffL)))
        {
            (wmove((hw),(tp->t_pos.y),(tp->t_pos.x)) == (-1) ? (-1) : waddch((hw),('&')));
            showit = 1;
        }
    }
    if (showit)
    {
        msg("You feel the presense of the ungodly.");
        overlay(hw, cw);
        wrefresh(cw);
        wclear(hw);
    }
}

canonical_original_code:
void undead_sense()
{
    struct linked_list *item;
    struct thing *tp;
    int showit = 0;
    wclear(hw);
    for (item = mlist; item != ((void *)0); item = ((item)?(item->l_next):((void *)0)))
    {
        tp = ((*item).data.th);
        if (((*tp).t_flags[(0x30000001UL >> 28UL) & 0x0000000fL] & (0x30000001UL & 0x0fffffffL)))
        {
            (wmove((hw),(tp->t_pos.y),(tp->t_pos.x)) == (-1) ? (-1) : waddch((hw),('&')));
            showit = 1;
        }
    }
    if (showit)
    {
        msg("You feel the presense of the ungodly.");
        overlay(hw, cw);
        wrefresh(cw);
        wclear(hw);
    }
}

variable_types: showit int


original_code:
void
init_player(void)
{
    int special = rnd(100) < 20;
    struct linked_list *item;
    struct object *obj;
    int which_armor = 0, which_weapon = 0;
    int other_weapon_flags = 0;
    player.t_stats.s_lvl = 1;
    player.t_stats.s_exp = 0L;
    player.t_stats.s_arm = 10;
    if (!geta_player())
    {
        do_getplayer();
        player.t_stats.s_str = 8 + rnd(5);
        player.t_stats.s_intel = 8 + rnd(5);
        player.t_stats.s_wisdom = 8 + rnd(5);
        player.t_stats.s_dext = 8 + rnd(5);
        player.t_stats.s_const = 10 + rnd(8);
        player.t_stats.s_charisma = 8 + rnd(4);
        player.t_stats.s_power = 5 + rnd(5);
        player.t_stats.s_hpt = 15 + rnd(5);
        switch (char_type)
        {
            case 0:
                player.t_stats.s_str = 17;
                player.t_stats.s_const += rnd(4) + 1;
                if (special)
                {
                    player.t_stats.s_str += rnd(3);
                    player.t_stats.s_dext += rnd(4);
                }
                player.t_stats.s_const = ((player.t_stats.s_const) > (16) ? (player.t_stats.s_const) : (16));
                break;
            case 1:
                player.t_stats.s_charisma = 17;
                if (special)
                {
                    player.t_stats.s_charisma += rnd(3);
                    player.t_stats.s_wisdom += rnd(4);
                    player.t_stats.s_str += rnd(5);
                }
                player.t_stats.s_str = ((player.t_stats.s_str) > (16) ? (player.t_stats.s_str) : (16));
                player.t_stats.s_wisdom = ((player.t_stats.s_wisdom) > (16) ? (player.t_stats.s_wisdom) : (16));
                break;
            case 2:
                if (special)
                {
                    player.t_stats.s_wisdom += rnd(4);
                    player.t_stats.s_intel += rnd(4);
                    player.t_stats.s_str += rnd(5);
                }
                player.t_stats.s_str = ((player.t_stats.s_str) > (16) ? (player.t_stats.s_str) : (16));
                player.t_stats.s_wisdom = ((player.t_stats.s_wisdom) > (16) ? (player.t_stats.s_wisdom) : (16));
                player.t_stats.s_const = ((player.t_stats.s_const) > (14) ? (player.t_stats.s_const) : (14));
                break;
            case 5:
                player.t_stats.s_intel = (special) ? 18 : 16;
                player.t_stats.s_power += 5 + rnd(10);
                break;
            case 6:
                player.t_stats.s_intel = (special) ? 18 : 16;
                player.t_stats.s_dext = (special) ? 18 : 14;
                player.t_stats.s_power += 5 + rnd(10);
                break;
            case 3:
                player.t_stats.s_wisdom = (special) ? 18 : 16;
                player.t_stats.s_str += rnd(4);
                player.t_stats.s_power += 5 + rnd(10);
                break;
            case 4:
                if (special)
                {
                    player.t_stats.s_wisdom += rnd(5);
                    player.t_stats.s_charisma += rnd(4);
                }
                player.t_stats.s_str += rnd(4);
                player.t_stats.s_power += 5 + rnd(10);
                player.t_stats.s_wisdom = ((player.t_stats.s_wisdom) > (16) ? (player.t_stats.s_wisdom) : (16));
                break;
            case 7:
                player.t_stats.s_dext = 18;
                if (special)
                    player.t_stats.s_const += rnd(4) + 1;
                break;
            case 8:
                player.t_stats.s_dext = (special) ? 18 : 16;
                player.t_stats.s_intel = (special) ? 18 : 16;
                break;
            case 9:
                if (special)
                {
                    player.t_stats.s_dext += rnd(5);
                    player.t_stats.s_str += rnd(4);
                    player.t_stats.s_intel += rnd(3);
                    player.t_stats.s_wisdom += rnd(3);
                }
                player.t_stats.s_dext = ((player.t_stats.s_dext) > (16) ? (player.t_stats.s_dext) : (16));
                player.t_stats.s_str = ((player.t_stats.s_str) > (15) ? (player.t_stats.s_str) : (15));
                player.t_stats.s_wisdom = ((player.t_stats.s_wisdom) > (15) ? (player.t_stats.s_wisdom) : (15));
                player.t_stats.s_const = ((player.t_stats.s_const) > (15) ? (player.t_stats.s_const) : (15));
                player.t_stats.s_charisma = ((player.t_stats.s_charisma) > (11) ? (player.t_stats.s_charisma) : (11));
        }
        puta_player();
    }
    if (char_type == 8 || char_type == 9
        || char_type == 0)
        player.t_stats.s_dmg = "2d6";
    else
        player.t_stats.s_dmg = "1d4";
    if (char_type == 9 || char_type == 0)
        player.t_stats.s_arm = 8;
    if (player.t_stats.s_const > 15)
        player.t_stats.s_hpt += player.t_stats.s_const - 15;
    player.maxstats = player.t_stats;
    player.t_rest_hpt = player.t_rest_pow = 0;
    player.t_praycnt = 0;
    player.t_stats.s_carry = totalenc();
    player.t_pack = ((void *)0);
    switch (player.t_ctype)
    {
        case 1:
            purse = roll(20, 60);
            which_armor = 7;
            which_weapon = 47;
            break;
        case 0:
            purse = roll(50, 60);
            which_armor = 5;
            which_weapon = 38;
            break;
        case 2:
            purse = roll(50, 60);
            which_armor = 6;
            which_weapon = 21;
            other_weapon_flags |= 0x00000800UL | 0x00000400UL;
            break;
        case 3:
            purse = roll(30, 80);
            which_armor = 3;
            which_weapon = 37;
            break;
        case 4:
            purse = roll(30, 80);
            which_armor = 4;
            which_weapon = 36;
            break;
        case 7:
            purse = roll(40, 80);
            which_armor = 2;
            which_weapon = 44;
            break;
        case 8:
            purse = roll(20, 80);
            which_armor = 1;
            which_weapon = 50;
            other_weapon_flags |= 0x00000200UL;
            break;
        case 9:
            purse = roll(20, 80);
            which_armor = 1;
            which_weapon = 42;
            other_weapon_flags |= 0x00000200UL;
            item = spec_item(')', 22, 1, 1);
            obj = ((*item).data.obj);
            obj->o_count = 1;
            obj->o_flags |= 0x00000002UL | 0x00000200UL | 0x00000800UL | 0x00000400UL;
            add_pack(item, 0);
            break;
        case 5:
        case 6:
            purse = roll(20, 60);
            which_armor = 0;
            which_weapon = 31;
            break;
        default:
            break;
    }
    item = spec_item(')', which_weapon, 1, 1);
    obj = ((*item).data.obj);
    obj->o_flags |= 0x00000002UL;
    obj->o_flags |= other_weapon_flags;
    obj->o_count = 1;
    add_pack(item, 0);
    cur_weapon = obj;
    item = spec_item(']', which_armor, 0, 0);
    obj = ((*item).data.obj);
    obj->o_flags |= 0x00000002UL;
    obj->o_weight = armors[which_armor].a_wght;
    add_pack(item, 0);
    cur_armor = obj;
    item = spec_item(':', 2, 0, 0);
    obj = ((*item).data.obj);
    obj->o_weight = things[4].mi_worth;
    obj->o_count = 3;
    add_pack(item, 0);
}

canonical_original_code:
void init_player()
{
    int special = rnd(100) < 20;
    struct linked_list *item;
    struct object *obj;
    int which_armor = 0; int which_weapon = 0;
    int other_weapon_flags = 0;
    player.t_stats.s_lvl = 1;
    player.t_stats.s_exp = 0L;
    player.t_stats.s_arm = 10;
    if (!geta_player())
    {
        do_getplayer();
        player.t_stats.s_str = 8 + rnd(5);
        player.t_stats.s_intel = 8 + rnd(5);
        player.t_stats.s_wisdom = 8 + rnd(5);
        player.t_stats.s_dext = 8 + rnd(5);
        player.t_stats.s_const = 10 + rnd(8);
        player.t_stats.s_charisma = 8 + rnd(4);
        player.t_stats.s_power = 5 + rnd(5);
        player.t_stats.s_hpt = 15 + rnd(5);
        switch (char_type)
        {
            case 0:
                player.t_stats.s_str = 17;
                player.t_stats.s_const += rnd(4) + 1;
                if (special)
                {
                    player.t_stats.s_str += rnd(3);
                    player.t_stats.s_dext += rnd(4);
                }
                player.t_stats.s_const = ((player.t_stats.s_const) > (16) ? (player.t_stats.s_const) : (16));
                break;
            case 1:
                player.t_stats.s_charisma = 17;
                if (special)
                {
                    player.t_stats.s_charisma += rnd(3);
                    player.t_stats.s_wisdom += rnd(4);
                    player.t_stats.s_str += rnd(5);
                }
                player.t_stats.s_str = ((player.t_stats.s_str) > (16) ? (player.t_stats.s_str) : (16));
                player.t_stats.s_wisdom = ((player.t_stats.s_wisdom) > (16) ? (player.t_stats.s_wisdom) : (16));
                break;
            case 2:
                if (special)
                {
                    player.t_stats.s_wisdom += rnd(4);
                    player.t_stats.s_intel += rnd(4);
                    player.t_stats.s_str += rnd(5);
                }
                player.t_stats.s_str = ((player.t_stats.s_str) > (16) ? (player.t_stats.s_str) : (16));
                player.t_stats.s_wisdom = ((player.t_stats.s_wisdom) > (16) ? (player.t_stats.s_wisdom) : (16));
                player.t_stats.s_const = ((player.t_stats.s_const) > (14) ? (player.t_stats.s_const) : (14));
                break;
            case 5:
                player.t_stats.s_intel = (special) ? 18 : 16;
                player.t_stats.s_power += 5 + rnd(10);
                break;
            case 6:
                player.t_stats.s_intel = (special) ? 18 : 16;
                player.t_stats.s_dext = (special) ? 18 : 14;
                player.t_stats.s_power += 5 + rnd(10);
                break;
            case 3:
                player.t_stats.s_wisdom = (special) ? 18 : 16;
                player.t_stats.s_str += rnd(4);
                player.t_stats.s_power += 5 + rnd(10);
                break;
            case 4:
                if (special)
                {
                    player.t_stats.s_wisdom += rnd(5);
                    player.t_stats.s_charisma += rnd(4);
                }
                player.t_stats.s_str += rnd(4);
                player.t_stats.s_power += 5 + rnd(10);
                player.t_stats.s_wisdom = ((player.t_stats.s_wisdom) > (16) ? (player.t_stats.s_wisdom) : (16));
                break;
            case 7:
                player.t_stats.s_dext = 18;
                if (special)
                    player.t_stats.s_const += rnd(4) + 1;
                break;
            case 8:
                player.t_stats.s_dext = (special) ? 18 : 16;
                player.t_stats.s_intel = (special) ? 18 : 16;
                break;
            case 9:
                if (special)
                {
                    player.t_stats.s_dext += rnd(5);
                    player.t_stats.s_str += rnd(4);
                    player.t_stats.s_intel += rnd(3);
                    player.t_stats.s_wisdom += rnd(3);
                }
                player.t_stats.s_dext = ((player.t_stats.s_dext) > (16) ? (player.t_stats.s_dext) : (16));
                player.t_stats.s_str = ((player.t_stats.s_str) > (15) ? (player.t_stats.s_str) : (15));
                player.t_stats.s_wisdom = ((player.t_stats.s_wisdom) > (15) ? (player.t_stats.s_wisdom) : (15));
                player.t_stats.s_const = ((player.t_stats.s_const) > (15) ? (player.t_stats.s_const) : (15));
                player.t_stats.s_charisma = ((player.t_stats.s_charisma) > (11) ? (player.t_stats.s_charisma) : (11));
        }
        puta_player();
    }
    if (char_type == 8 || char_type == 9
        || char_type == 0)
        player.t_stats.s_dmg = "2d6";
    else
        player.t_stats.s_dmg = "1d4";
    if (char_type == 9 || char_type == 0)
        player.t_stats.s_arm = 8;
    if (player.t_stats.s_const > 15)
        player.t_stats.s_hpt += player.t_stats.s_const - 15;
    player.maxstats = player.t_stats;
    player.t_rest_hpt = player.t_rest_pow = 0;
    player.t_praycnt = 0;
    player.t_stats.s_carry = totalenc();
    player.t_pack = ((void *)0);
    switch (player.t_ctype)
    {
        case 1:
            purse = roll(20, 60);
            which_armor = 7;
            which_weapon = 47;
            break;
        case 0:
            purse = roll(50, 60);
            which_armor = 5;
            which_weapon = 38;
            break;
        case 2:
            purse = roll(50, 60);
            which_armor = 6;
            which_weapon = 21;
            other_weapon_flags |= 0x00000800UL | 0x00000400UL;
            break;
        case 3:
            purse = roll(30, 80);
            which_armor = 3;
            which_weapon = 37;
            break;
        case 4:
            purse = roll(30, 80);
            which_armor = 4;
            which_weapon = 36;
            break;
        case 7:
            purse = roll(40, 80);
            which_armor = 2;
            which_weapon = 44;
            break;
        case 8:
            purse = roll(20, 80);
            which_armor = 1;
            which_weapon = 50;
            other_weapon_flags |= 0x00000200UL;
            break;
        case 9:
            purse = roll(20, 80);
            which_armor = 1;
            which_weapon = 42;
            other_weapon_flags |= 0x00000200UL;
            item = spec_item(')', 22, 1, 1);
            obj = ((*item).data.obj);
            obj->o_count = 1;
            obj->o_flags |= 0x00000002UL | 0x00000200UL | 0x00000800UL | 0x00000400UL;
            add_pack(item, 0);
            break;
        case 5:
        case 6:
            purse = roll(20, 60);
            which_armor = 0;
            which_weapon = 31;
            break;
        default:
            break;
    }
    item = spec_item(')', which_weapon, 1, 1);
    obj = ((*item).data.obj);
    obj->o_flags |= 0x00000002UL;
    obj->o_flags |= other_weapon_flags;
    obj->o_count = 1;
    add_pack(item, 0);
    cur_weapon = obj;
    item = spec_item(']', which_armor, 0, 0);
    obj = ((*item).data.obj);
    obj->o_flags |= 0x00000002UL;
    obj->o_weight = armors[which_armor].a_wght;
    add_pack(item, 0);
    cur_armor = obj;
    item = spec_item(':', 2, 0, 0);
    obj = ((*item).data.obj);
    obj->o_weight = things[4].mi_worth;
    obj->o_count = 3;
    add_pack(item, 0);
}

variable_types: special int


decompiled_code:
__int64 init_flags()
{
__int64 result; // rax

result = (unsigned int)(*((_DWORD *)&player + 90) - 1);
if ( (unsigned int)result <= 5 )
*((_QWORD *)&player + 29) |= 0x400000uLL;
*((_QWORD *)&player + 30) |= 0x8000000uLL;
*((_QWORD *)&player + 31) |= 8uLL;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

result = (unsigned int)(*((_DWORD *)&player + 90) - 1);
if ( (unsigned int)result <= 5 )
*((_QWORD *)&player + 29) |= 0x400000uLL;
*((_QWORD *)&player + 30) |= 0x8000000uLL;
*((_QWORD *)&player + 31) |= 8uLL;
return result;
}


badcheck

decompiled_code:
__int64 __fastcall badcheck(const char *a1, unsigned __int64 a2, int a3)
{
__int64 result; // rax
unsigned __int64 v4; // rbx
unsigned __int64 v5; // rbp
__int64 v6; // rsi
const char *v7; // rdx

result = 5LL * a3;
if ( *(_DWORD *)(a2 + 40LL * a3 - 24) != 1000 )
{
v4 = a2;
v5 = a2 + 40LL * a3;
printf("\nBad percentages for %s:\n", a1);
if ( a2 < v5 )
{
do
{
v6 = *(unsigned int *)(v4 + 16);
v7 = *(const char **)v4;
v4 += 40LL;
printf("%3d%% %s\n", v6, v7);
}
while ( v5 > v4 );
}
printf("[Hit RETURN to continue]");
fflush(stdout);
do
result = readchar() & 0x7F;
while ( (_BYTE)result != 10 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, unsigned __int64 a2, int a3)
{
__int64 result; // rax
unsigned __int64 v4; // rbx
unsigned __int64 v5; // rbp
__int64 v6; // rsi
const char *v7; // rdx

result = 5LL * a3;
if ( *(_DWORD *)(a2 + 40LL * a3 - 24) != 1000 )
{
v4 = a2;
v5 = a2 + 40LL * a3;
printf("\nBad percentages for %s:\n", a1);
if ( a2 < v5 )
{
do
{
v6 = *(unsigned int *)(v4 + 16);
v7 = *(const char **)v4;
v4 += 40LL;
printf("%3d%% %s\n", v6, v7);
}
while ( v5 > v4 );
}
printf("[Hit RETURN to continue]");
fflush(stdout);
do
result = readchar() & 0x7F;
while ( (_BYTE)result != 10 );
}
return result;
}

original_code:
void
badcheck(char *name, struct magic_item *magic, int bound)
{
    struct magic_item *end;
    if (magic[bound - 1].mi_prob == 1000)
        return;
    printf("\nBad percentages for %s:\n", name);
    for (end = &magic[bound]; magic < end; magic++)
        printf("%3d%% %s\n", magic->mi_prob, magic->mi_name);
    printf("[Hit RETURN to continue]");
    fflush(stdout);
    while ((readchar() & 0177) != '\n')
        continue;
}

variable_types:
name
char *

variable_types: struct magic_item { char *mi_name; char *mi_abrev; int mi_prob; long mi_worth; int mi_curse; int mi_bless; } *

variable_types: bound int


decompiled_code:
__int64 init_things()
{
int v0; // edx
char **v1; // rcx
unsigned __int64 v2; // rax

v0 = numthings;
v1 = &things[5 * numthings];
if ( v1 > &things[5] )
{
v2 = (unsigned int)((_DWORD)things + 40);
do
{
*(_DWORD *)(v2 + 16) += *(_DWORD *)(v2 - 24);
v2 += 40LL;
}
while ( v2 < (unsigned __int64)v1 );
}
return badcheck("things", (unsigned __int64)things, v0);
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // edx
char **v1; // rcx
unsigned __int64 v2; // rax

v0 = numthings;
v1 = &things[5 * numthings];
if ( v1 > &things[5] )
{
v2 = (unsigned int)((_DWORD)things + 40);
do
{
*(_DWORD *)(v2 + 16) += *(_DWORD *)(v2 - 24);
v2 += 40LL;
}
while ( v2 < (unsigned __int64)v1 );
}
return func2("things", (unsigned __int64)things, v0);
}

original_code:
void
init_things(void)
{
    struct magic_item *mp;
    for (mp = &things[1]; mp < &things[numthings]; mp++)
        mp->mi_prob += (mp - 1)->mi_prob;
    badcheck("things", things, numthings);
}

canonical_original_code:
void init_things()
{
    struct magic_item *mp;
    for (mp = &things[1]; mp < &things[numthings]; mp++)
        mp->mi_prob += (mp - 1)->mi_prob;
    badcheck("things", things, numthings);
}

user_defined_types: struct magic_item { char *mi_name; char *mi_abrev; int mi_prob; long mi_worth; int mi_curse; int mi_bless; }


decompiled_code:
__int64 init_fd()
{
int v0; // edx
char **v1; // rcx
unsigned __int64 v2; // rax

v0 = maxfoods;
v1 = &fd_data[5 * maxfoods];
if ( v1 > &fd_data[5] )
{
v2 = (unsigned int)((_DWORD)fd_data + 40);
do
{
*(_DWORD *)(v2 + 16) += *(_DWORD *)(v2 - 24);
v2 += 40LL;
}
while ( v2 < (unsigned __int64)v1 );
}
return badcheck("food", (unsigned __int64)fd_data, v0);
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // edx
char **v1; // rcx
unsigned __int64 v2; // rax

v0 = maxfoods;
v1 = &fd_data[5 * maxfoods];
if ( v1 > &fd_data[5] )
{
v2 = (unsigned int)((_DWORD)fd_data + 40);
do
{
*(_DWORD *)(v2 + 16) += *(_DWORD *)(v2 - 24);
v2 += 40LL;
}
while ( v2 < (unsigned __int64)v1 );
}
return func2("food", (unsigned __int64)fd_data, v0);
}

original_code:
void
init_fd(void)
{
    struct magic_item *mp;
    for (mp = &fd_data[1]; mp < &fd_data[maxfoods]; mp++)
        mp->mi_prob += (mp - 1)->mi_prob;
    badcheck("food", fd_data, maxfoods);
}

canonical_original_code:
void init_fd()
{
    struct magic_item *mp;
    for (mp = &fd_data[1]; mp < &fd_data[maxfoods]; mp++)
        mp->mi_prob += (mp - 1)->mi_prob;
    badcheck("food", fd_data, maxfoods);
}


decompiled_code:
__int64 init_colors()
{
int v0; // edx
unsigned __int64 v1; // r12
__int64 v2; // rbp
const unsigned __int16 **v3; // rbx
const __int32_t **v4; // r13
_BYTE *v5; // rax
const __int32_t *v6; // rdx

v0 = maxpotions;
if ( maxpotions > 0 )
{
v1 = (unsigned int)((_DWORD)p_magic + 16);
v2 = 0LL;
v3 = _ctype_b_loc();
v4 = _ctype_tolower_loc();
do
{
while ( ((*v3)[*rainbow[(int)rnd(32LL)]] & 0x100) == 0 )
;
v5 = (_BYTE *)md_strdup();
v6 = *v4;
*((_QWORD *)&p_colors + v2) = v5;
*v5 = v6[(char)*v5];
*((_DWORD *)&know_items + v2) = 0;
*((_QWORD *)&guess_items + v2) = 0LL;
if ( v2 )
*(_DWORD *)v1 += *(_DWORD *)(v1 - 40);
v0 = maxpotions;
++v2;
v1 += 40LL;
}
while ( maxpotions > (int)v2 );
}
return badcheck("potions", (unsigned __int64)p_magic, v0);
}

canonical_decompiled_code:
__int64 func5()
{
int v0; // edx
unsigned __int64 v1; // r12
__int64 v2; // rbp
const unsigned __int16 **v3; // rbx
const __int32_t **v4; // r13
_BYTE *v5; // rax
const __int32_t *v6; // rdx

v0 = maxpotions;
if ( maxpotions > 0 )
{
v1 = (unsigned int)((_DWORD)p_magic + 16);
v2 = 0LL;
v3 = _ctype_b_loc();
v4 = _ctype_tolower_loc();
do
{
while ( ((*v3)[*rainbow[(int)rnd(32LL)]] & 0x100) == 0 )
;
v5 = (_BYTE *)md_strdup();
v6 = *v4;
*((_QWORD *)&p_colors + v2) = v5;
*v5 = v6[(char)*v5];
*((_DWORD *)&know_items + v2) = 0;
*((_QWORD *)&guess_items + v2) = 0LL;
if ( v2 )
*(_DWORD *)v1 += *(_DWORD *)(v1 - 40);
v0 = maxpotions;
++v2;
v1 += 40LL;
}
while ( maxpotions > (int)v2 );
}
return func2("potions", (unsigned __int64)p_magic, v0);
}

original_code:
void
init_colors(void)
{
    int i;
    char *str;
    for (i = 0; i < maxpotions; i++)
    {
        do
            str = rainbow[rnd((sizeof rainbow / sizeof (char *)))];
        while( !((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short int) _ISupper) );
        p_colors[i] = md_strdup(str);
        p_colors[i][0] = (char) tolower(p_colors[i][0]);
        know_items[0][i] = 0;
        guess_items[0][i] = ((void *)0);
        if (i > 0)
            p_magic[i].mi_prob += p_magic[i - 1].mi_prob;
    }
    badcheck("potions", p_magic, maxpotions);
}

canonical_original_code:
void init_colors()
{
    int i;
    char *str;
    for (i = 0; i < maxpotions; i++)
    {
        do
            str = rainbow[rnd((sizeof rainbow / sizeof (char *)))];
        while( !((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short) _ISupper) );
        p_colors[i] = md_strdup(str);
        p_colors[i][0] = (char) tolower(p_colors[i][0]);
        know_items[0][i] = 0;
        guess_items[0][i] = ((void *)0);
        if (i > 0)
            p_magic[i].mi_prob += p_magic[i - 1].mi_prob;
    }
    badcheck("potions", p_magic, maxpotions);
}

variable_types: i int

variable_types:
str
char *


decompiled_code:
__int64 init_names()
{
int v0; // edx
unsigned __int64 v1; // r13
__int64 v2; // r12
char *v3; // rbx
int v4; // eax
_BOOL4 v5; // edx
int v6; // ebp
int v7; // er14
char *v8; // rdx
char i; // al
char *v11; // rax
size_t v12; // rax
char *v13; // rax

v0 = maxscrolls;
if ( maxscrolls > 0 )
{
v1 = (unsigned int)((_DWORD)s_magic + 16);
v2 = 0LL;
do
{
v3 = &prbuf;
v4 = rnd((unsigned int)(COLS / 20));
v5 = COLS > 40;
v6 = v5 + v4 + 1;
if ( v5 + v4 != -1 )
{
do
{
v7 = rnd(3LL);
if ( v7 != -1 )
{
do
{
v8 = sylls[(int)rnd(159LL)];
for ( i = *v8; *v8; i = *v8 )
{
++v8;
*v3++ = i;
}
}
while ( v7-- != 0 );
}
v11 = v3++;
*v11 = 32;
--v6;
}
while ( v6 );
}
*(v3 - 1) = 0;
v12 = strlen(&prbuf);
v13 = (char *)new_alloc(v12 + 1);
know_items[v2 + 50] = 0;
*((_QWORD *)&s_names + v2) = v13;
guess_items[v2 + 50] = 0LL;
strcpy(v13, &prbuf);
if ( v2 )
*(_DWORD *)v1 += *(_DWORD *)(v1 - 40);
v0 = maxscrolls;
++v2;
v1 += 40LL;
}
while ( maxscrolls > (int)v2 );
}
return badcheck("scrolls", (unsigned __int64)s_magic, v0);
}

canonical_decompiled_code:
__int64 func6()
{
int v0; // edx
unsigned __int64 v1; // r13
__int64 v2; // r12
char *v3; // rbx
int v4; // eax
_BOOL4 v5; // edx
int v6; // ebp
int v7; // er14
char *v8; // rdx
char i; // al
char *v11; // rax
size_t v12; // rax
char *v13; // rax

v0 = maxscrolls;
if ( maxscrolls > 0 )
{
v1 = (unsigned int)((_DWORD)s_magic + 16);
v2 = 0LL;
do
{
v3 = &prbuf;
v4 = rnd((unsigned int)(COLS / 20));
v5 = COLS > 40;
v6 = v5 + v4 + 1;
if ( v5 + v4 != -1 )
{
do
{
v7 = rnd(3LL);
if ( v7 != -1 )
{
do
{
v8 = sylls[(int)rnd(159LL)];
for ( i = *v8; *v8; i = *v8 )
{
++v8;
*v3++ = i;
}
}
while ( v7-- != 0 );
}
v11 = v3++;
*v11 = 32;
--v6;
}
while ( v6 );
}
*(v3 - 1) = 0;
v12 = strlen(&prbuf);
v13 = (char *)new_alloc(v12 + 1);
know_items[v2 + 50] = 0;
*((_QWORD *)&s_names + v2) = v13;
guess_items[v2 + 50] = 0LL;
strcpy(v13, &prbuf);
if ( v2 )
*(_DWORD *)v1 += *(_DWORD *)(v1 - 40);
v0 = maxscrolls;
++v2;
v1 += 40LL;
}
while ( maxscrolls > (int)v2 );
}
return func2("scrolls", (unsigned __int64)s_magic, v0);
}

original_code:
void
init_names(void)
{
    int nsyl;
    char *cp, *sp;
    int i, nwords;
    for (i = 0; i < maxscrolls; i++)
    {
        cp = prbuf;
        nwords = rnd(COLS / 20) + 1 + (COLS > 40 ? 1 : 0);
        while (nwords--)
        {
            nsyl = rnd(3) + 1;
            while (nsyl--)
            {
                sp = sylls[rnd((sizeof sylls) /
                    (sizeof(char *)))];
                while (*sp)
                    *cp++ = *sp++;
            }
            *cp++ = ' ';
        }
        *--cp = '\0';
        s_names[i] = (char *) new_alloc(strlen(prbuf) + 1);
        know_items[1][i] = 0;
        guess_items[1][i] = 0;
        strcpy(s_names[i], prbuf);
        if (i > 0)
            s_magic[i].mi_prob += s_magic[i - 1].mi_prob;
    }
    badcheck("scrolls", s_magic, maxscrolls);
}

canonical_original_code:
void init_names()
{
    int nsyl;
    char *cp; char *sp;
    int i; int nwords;
    for (i = 0; i < maxscrolls; i++)
    {
        cp = prbuf;
        nwords = rnd(COLS / 20) + 1 + (COLS > 40 ? 1 : 0);
        while (nwords--)
        {
            nsyl = rnd(3) + 1;
            while (nsyl--)
            {
                sp = sylls[rnd((sizeof sylls) /
                    (sizeof(char *)))];
                while (*sp)
                    *cp++ = *sp++;
            }
            *cp++ = ' ';
        }
        *--cp = '\0';
        s_names[i] = (char *) new_alloc(strlen(prbuf) + 1);
        know_items[1][i] = 0;
        guess_items[1][i] = 0;
        strcpy(s_names[i], prbuf);
        if (i > 0)
            s_magic[i].mi_prob += s_magic[i - 1].mi_prob;
    }
    badcheck("scrolls", s_magic, maxscrolls);
}

variable_types: nsyl int

variable_types:
cp
char *

variable_types:
sp
char *

variable_types: nwords int


decompiled_code:
__int64 init_stones()
{
int v0; // edx
unsigned __int64 v1; // r12
__int64 v2; // rbp
const unsigned __int16 **v3; // rbx
const __int32_t **v4; // r13
_BYTE *v5; // rax
const __int32_t *v6; // rdx

v0 = maxrings;
if ( maxrings > 0 )
{
v1 = (unsigned int)((_DWORD)&r_magic + 16);
v2 = 0LL;
v3 = _ctype_b_loc();
v4 = _ctype_tolower_loc();
do
{
while ( ((*v3)[*stones[(int)rnd(35LL)]] & 0x100) == 0 )
;
v5 = (_BYTE *)md_strdup();
v6 = *v4;
*((_QWORD *)&r_stones + v2) = v5;
*v5 = v6[(char)*v5];
know_items[v2 + 100] = 0;
guess_items[v2 + 100] = 0LL;
if ( v2 )
*(_DWORD *)v1 += *(_DWORD *)(v1 - 40);
v0 = maxrings;
++v2;
v1 += 40LL;
}
while ( maxrings > (int)v2 );
}
return badcheck("rings", (unsigned __int64)&r_magic, v0);
}

canonical_decompiled_code:
__int64 func7()
{
int v0; // edx
unsigned __int64 v1; // r12
__int64 v2; // rbp
const unsigned __int16 **v3; // rbx
const __int32_t **v4; // r13
_BYTE *v5; // rax
const __int32_t *v6; // rdx

v0 = maxrings;
if ( maxrings > 0 )
{
v1 = (unsigned int)((_DWORD)&r_magic + 16);
v2 = 0LL;
v3 = _ctype_b_loc();
v4 = _ctype_tolower_loc();
do
{
while ( ((*v3)[*stones[(int)rnd(35LL)]] & 0x100) == 0 )
;
v5 = (_BYTE *)md_strdup();
v6 = *v4;
*((_QWORD *)&r_stones + v2) = v5;
*v5 = v6[(char)*v5];
know_items[v2 + 100] = 0;
guess_items[v2 + 100] = 0LL;
if ( v2 )
*(_DWORD *)v1 += *(_DWORD *)(v1 - 40);
v0 = maxrings;
++v2;
v1 += 40LL;
}
while ( maxrings > (int)v2 );
}
return func2("rings", (unsigned __int64)&r_magic, v0);
}

original_code:
void
init_stones(void)
{
    int i;
    char *str;
    for (i = 0; i < maxrings; i++)
    {
        do
            str = stones[rnd((sizeof stones / sizeof (char *)))];
        while(!((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short int) _ISupper));
        r_stones[i] = md_strdup(str);
        r_stones[i][0] = (char) tolower( r_stones[i][0] );
        know_items[2][i] = 0;
        guess_items[2][i] = ((void *)0);
        if (i > 0)
            r_magic[i].mi_prob += r_magic[i - 1].mi_prob;
    }
    badcheck("rings", r_magic, maxrings);
}

canonical_original_code:
void init_stones()
{
    int i;
    char *str;
    for (i = 0; i < maxrings; i++)
    {
        do
            str = stones[rnd((sizeof stones / sizeof (char *)))];
        while(!((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short) _ISupper));
        r_stones[i] = md_strdup(str);
        r_stones[i][0] = (char) tolower( r_stones[i][0] );
        know_items[2][i] = 0;
        guess_items[2][i] = ((void *)0);
        if (i > 0)
            r_magic[i].mi_prob += r_magic[i - 1].mi_prob;
    }
    badcheck("rings", r_magic, maxrings);
}


decompiled_code:
__int64 init_materials()
{
int v0; // edx
unsigned __int64 v1; // r12
__int64 v2; // rbx
const unsigned __int16 **v3; // rbp
const __int32_t **v4; // r13
char *v5; // rdi
const unsigned __int16 *v6; // rax
__int16 v7; // ax
_BYTE *v8; // rax
const __int32_t *v9; // rdx
char *v10; // rdi
const unsigned __int16 *v11; // rax

v0 = maxsticks;
if ( maxsticks > 0 )
{
v1 = (unsigned int)((_DWORD)ws_magic + 16);
v2 = 0LL;
v3 = _ctype_b_loc();
v4 = _ctype_tolower_loc();
while ( 1 )
{
while ( (int)rnd(100LL) > 50 )
{
v5 = metal[(int)rnd(23LL)];
v6 = *v3;
if ( ((*v3)[*v5] & 0x100) != 0 )
{
*((_QWORD *)&ws_type + v2) = "wand";
v7 = v6[*v5] & 0x100;
goto LABEL_6;
}
}
v10 = wood[(int)rnd(24LL)];
v11 = *v3;
if ( ((*v3)[*v10] & 0x100) != 0 )
{
*((_QWORD *)&ws_type + v2) = "staff";
v7 = v11[*v10] & 0x100;
LABEL_6:
if ( v7 )
{
v8 = (_BYTE *)md_strdup();
v9 = *v4;
*((_QWORD *)&ws_made + v2) = v8;
*v8 = v9[(char)*v8];
know_items[v2 + 150] = 0;
guess_items[v2 + 150] = 0LL;
if ( v2 )
*(_DWORD *)v1 += *(_DWORD *)(v1 - 40);
v0 = maxsticks;
++v2;
v1 += 40LL;
if ( maxsticks <= (int)v2 )
return badcheck("sticks", (unsigned __int64)ws_magic, v0);
}
}
}
}
return badcheck("sticks", (unsigned __int64)ws_magic, v0);
}

canonical_decompiled_code:
__int64 func8()
{
int v0; // edx
unsigned __int64 v1; // r12
__int64 v2; // rbx
const unsigned __int16 **v3; // rbp
const __int32_t **v4; // r13
char *v5; // rdi
const unsigned __int16 *v6; // rax
__int16 v7; // ax
_BYTE *v8; // rax
const __int32_t *v9; // rdx
char *v10; // rdi
const unsigned __int16 *v11; // rax

v0 = maxsticks;
if ( maxsticks > 0 )
{
v1 = (unsigned int)((_DWORD)ws_magic + 16);
v2 = 0LL;
v3 = _ctype_b_loc();
v4 = _ctype_tolower_loc();
while ( 1 )
{
while ( (int)rnd(100LL) > 50 )
{
v5 = metal[(int)rnd(23LL)];
v6 = *v3;
if ( ((*v3)[*v5] & 0x100) != 0 )
{
*((_QWORD *)&ws_type + v2) = "wand";
v7 = v6[*v5] & 0x100;
goto LABEL_6;
}
}
v10 = wood[(int)rnd(24LL)];
v11 = *v3;
if ( ((*v3)[*v10] & 0x100) != 0 )
{
*((_QWORD *)&ws_type + v2) = "staff";
v7 = v11[*v10] & 0x100;
LABEL_6:
if ( v7 )
{
v8 = (_BYTE *)md_strdup();
v9 = *v4;
*((_QWORD *)&ws_made + v2) = v8;
*v8 = v9[(char)*v8];
know_items[v2 + 150] = 0;
guess_items[v2 + 150] = 0LL;
if ( v2 )
*(_DWORD *)v1 += *(_DWORD *)(v1 - 40);
v0 = maxsticks;
++v2;
v1 += 40LL;
if ( maxsticks <= (int)v2 )
return func2("sticks", (unsigned __int64)ws_magic, v0);
}
}
}
}
return func2("sticks", (unsigned __int64)ws_magic, v0);
}

original_code:
void
init_materials(void)
{
    int i;
    char *str;
    for (i = 0; i < maxsticks; i++)
    {
        do
        {
            if (rnd(100) > 50)
            {
                str = metal[rnd((sizeof metal / sizeof (char *)))];
                if (((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short int) _ISupper))
                    ws_type[i] = "wand";
            }
            else
            {
                str = wood[rnd((sizeof wood / sizeof (char *)))];
                if (((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short int) _ISupper))
                    ws_type[i] = "staff";
            }
        }
        while(!((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short int) _ISupper));
        ws_made[i] = md_strdup(str);
        ws_made[i][0] = (char) tolower( ws_made[i][0] );
        know_items[3][i] = 0;
        guess_items[3][i] = 0;
        if (i > 0)
            ws_magic[i].mi_prob += ws_magic[i - 1].mi_prob;
    }
    badcheck("sticks", ws_magic, maxsticks);
}

canonical_original_code:
void init_materials()
{
    int i;
    char *str;
    for (i = 0; i < maxsticks; i++)
    {
        do
        {
            if (rnd(100) > 50)
            {
                str = metal[rnd((sizeof metal / sizeof (char *)))];
                if (((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short) _ISupper))
                    ws_type[i] = "wand";
            }
            else
            {
                str = wood[rnd((sizeof wood / sizeof (char *)))];
                if (((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short) _ISupper))
                    ws_type[i] = "staff";
            }
        }
        while(!((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short) _ISupper));
        ws_made[i] = md_strdup(str);
        ws_made[i][0] = (char) tolower( ws_made[i][0] );
        know_items[3][i] = 0;
        guess_items[3][i] = 0;
        if (i > 0)
            ws_magic[i].mi_prob += ws_magic[i - 1].mi_prob;
    }
    badcheck("sticks", ws_magic, maxsticks);
}


original_code:
int
get_ident(struct object *obj_p)
{
    int obj_type = obj_p->o_type;
    linked_list *list_p;
    int new_id = 1;
    struct object *tmp_obj_p;
    struct linked_list *new_place_p = ((void *)0);
    if ((obj_p->o_ident) != 0)
        return ((obj_p->o_ident));
    for (list_p = ident_list; list_p != ((void *)0); list_p = ((list_p)?(list_p->l_next):((void *)0)))
    {
        tmp_obj_p = ((*list_p).data.obj);
        if (tmp_obj_p->o_type == obj_type)
        {
            if ((tmp_obj_p->o_ident) == new_id)
            {
                new_place_p = list_p;
                new_id++;
            }
        }
    }
    list_p = new_list();
    _attach_after(&ident_list, new_place_p, list_p);
    (obj_p->o_ident) = new_id;
    list_p->data.obj = obj_p;
    return(new_id);
}

canonical_original_code:
int get_ident(struct object *obj_p)
{
    int obj_type = obj_p->o_type;
    struct linked_list *list_p;
    int new_id = 1;
    struct object *tmp_obj_p;
    struct linked_list *new_place_p = ((void *)0);
    if ((obj_p->o_ident) != 0)
        return ((obj_p->o_ident));
    for (list_p = ident_list; list_p != ((void *)0); list_p = ((list_p)?(list_p->l_next):((void *)0)))
    {
        tmp_obj_p = ((*list_p).data.obj);
        if (tmp_obj_p->o_type == obj_type)
        {
            if ((tmp_obj_p->o_ident) == new_id)
            {
                new_place_p = list_p;
                new_id++;
            }
        }
    }
    list_p = new_list();
    _attach_after(&ident_list, new_place_p, list_p);
    (obj_p->o_ident) = new_id;
    list_p->data.obj = obj_p;
    return(new_id);
}

variable_types: struct object { struct coord { int x; int y; } o_pos; struct linked_list { struct linked_list *l_next; struct linked_list *l_prev; union { struct object *obj; struct thing { long chasee_index; struct linked_list *t_pack; struct stats { char *s_dmg; long s_exp; long s_hpt; int s_pack; int s_carry; int s_lvl; int s_arm; int s_acmod; int s_power; int s_str; int s_intel; int s_wisdom; int s_dext; int s_const; int s_charisma; } t_stats; struct stats maxstats; int t_ischasing; struct thing *t_chasee; struct object *t_horde; struct coord t_pos; struct coord t_oldpos; struct coord t_nxtpos; long t_flags[16]; int t_praycnt; int t_trans; int t_turn; int t_wasshot; int t_ctype; int t_index; int t_no_move; int t_rest_hpt; int t_rest_pow; int t_doorgoal; char t_type; char t_disguise; char t_oldch; } *th; void *l_data; } data; } *next_obj; struct linked_list *o_bag; char *o_text; char *o_damage; char *o_hurldmg; long o_flags; long ar_flags; char o_type; int o_ident; unsigned int o_count; int o_which; int o_hplus; int o_dplus; int o_ac; int o_group; int o_weight; char o_launch; char o_mark[20]; long o_worth; } *

variable_types: struct linked_list { struct linked_list *l_next; struct linked_list *l_prev; union { struct object { struct coord { int x; int y; } o_pos; struct linked_list *next_obj; struct linked_list *o_bag; char *o_text; char *o_damage; char *o_hurldmg; long o_flags; long ar_flags; char o_type; int o_ident; unsigned int o_count; int o_which; int o_hplus; int o_dplus; int o_ac; int o_group; int o_weight; char o_launch; char o_mark[20]; long o_worth; } *obj; struct thing { long chasee_index; struct linked_list *t_pack; struct stats { char *s_dmg; long s_exp; long s_hpt; int s_pack; int s_carry; int s_lvl; int s_arm; int s_acmod; int s_power; int s_str; int s_intel; int s_wisdom; int s_dext; int s_const; int s_charisma; } t_stats; struct stats maxstats; int t_ischasing; struct thing *t_chasee; struct object *t_horde; struct coord t_pos; struct coord t_oldpos; struct coord t_nxtpos; long t_flags[16]; int t_praycnt; int t_trans; int t_turn; int t_wasshot; int t_ctype; int t_index; int t_no_move; int t_rest_hpt; int t_rest_pow; int t_doorgoal; char t_type; char t_disguise; char t_oldch; } *th; void *l_data; } data; } *


decompiled_code:
__int64 __fastcall free_ident(__int64 a1)
{
_QWORD *v1; // rbp
__int64 result; // rax

v1 = (_QWORD *)ident_list;
if ( ident_list )
{
while ( v1[2] != a1 )
{
v1 = (_QWORD *)*v1;
if ( !v1 )
return result;
}
detach(&ident_list, v1);
result = ur_free(v1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
_QWORD *v1; // rbp
__int64 result; // rax

v1 = (_QWORD *)ident_list;
if ( ident_list )
{
while ( v1[2] != a1 )
{
v1 = (_QWORD *)*v1;
if ( !v1 )
return result;
}
detach(&ident_list, v1);
result = ur_free(v1);
}
return result;
}

original_code:
void
free_ident(struct object *obj_p)
{
    linked_list *list_p;
    for (list_p = ident_list; list_p != ((void *)0); list_p = ((list_p)?(list_p->l_next):((void *)0)))
    {
        if (obj_p == ((*list_p).data.obj))
        {
            _detach(&ident_list, list_p);
            ur_free(list_p);
            break;
        }
    }
}

canonical_original_code:
void free_ident(struct object *obj_p)
{
    struct linked_list *list_p;
    for (list_p = ident_list; list_p != ((void *)0); list_p = ((list_p)?(list_p->l_next):((void *)0)))
    {
        if (obj_p == ((*list_p).data.obj))
        {
            _detach(&ident_list, list_p);
            ur_free(list_p);
            break;
        }
    }
}


decompiled_code:
signed __int64 __fastcall unprint_id(_BYTE *a1)
{
char *v1; // rax

if ( print_letters == *a1 )
return 0LL;
v1 = &print_letters;
do
++v1;
while ( *v1 != *a1 );
return v1 - &print_letters;
}

canonical_decompiled_code:
signed __int64 __fastcall func2(_BYTE *a1)
{
char *v1; // rax

if ( print_letters == *a1 )
return 0LL;
v1 = &print_letters;
do
++v1;
while ( *v1 != *a1 );
return v1 - &print_letters;
}

original_code:
int
unprint_id(char *print_id)
{
    char *id_p;
    for (id_p = print_letters; id_p != ((void *)0); id_p++)
        if (*id_p == *print_id)
            break;
    return( (int) (id_p - print_letters) );
}


decompiled_code:
__int64 max_print()
{
return 52LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 52LL;
}

original_code:
int
max_print(void)
{
    return(sizeof(print_letters) - 2);
}

canonical_original_code:
int max_print()
{
    return(sizeof(print_letters) - 2);
}


horiz

decompiled_code:
int __fastcall horiz(int a1)
{
int v1; // ebx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
result = waddch(stdscr, 0x2DuLL);
--v1;
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1)
{
int v1; // ebx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
result = waddch(stdscr, 0x2DuLL);
--v1;
}
while ( v1 );
}
return result;
}

original_code:
void
horiz(int cnt)
{
    while(cnt--)
        waddch(stdscr,('-'));
}


decompiled_code:
__int64 rnd_room()
{
__int64 result; // rax

if ( levtype )
return 0LL;
do
result = rnd(9LL);
while ( (rooms[60 * (int)result + 48] & 2) != 0 );
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax

if ( levtype )
return 0LL;
do
result = rnd(9LL);
while ( (rooms[60 * (int)result + 48] & 2) != 0 );
return result;
}

original_code:
int
rnd_room(void)
{
    int rm;
    if (levtype != NORMLEV)
        rm = 0;
    else
        do
        {
            rm = rnd(9);
        }
        while (rooms[rm].r_flags & 0x00000002UL);
    return(rm);
}

canonical_original_code:
int rnd_room()
{
    int rm;
    if (levtype != NORMLEV)
        rm = 0;
    else
        do
        {
            rm = rnd(9);
        }
        while (rooms[rm].r_flags & 0x00000002UL);
    return(rm);
}

variable_types: rm int