decompiled_code:
__int64 __fastcall position_lookup(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12
int v4; // edx
int v5; // eax

v1 = (_BYTE *)position_table[0];
if ( !position_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (_BYTE *)position_table[2 * v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12
int v4; // edx
int v5; // eax

v1 = (_BYTE *)position_table[0];
if ( !position_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (_BYTE *)position_table[2 * v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int position_lookup (const char *name)
{
   int pos;
   for (pos = 0; position_table[pos].name != ((void *)0); pos++)
   {
 if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((position_table[pos].name[0]) >= 'A' && (position_table[pos].name[0]) <= 'Z' ? (position_table[pos].name[0])+'a'-'A' : (position_table[pos].name[0]))
 && !str_prefix(name,position_table[pos].name))
     return pos;
   }
   return -1;
}

canonical_original_code:
int position_lookup(char *name)
{
   int pos;
   for (pos = 0; position_table[pos].name != ((void *)0); pos++)
   {
 if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((position_table[pos].name[0]) >= 'A' && (position_table[pos].name[0]) <= 'Z' ? (position_table[pos].name[0])+'a'-'A' : (position_table[pos].name[0]))
 && !str_prefix(name,position_table[pos].name))
     return pos;
   }
   return -1;
}

variable_types: pos int


repo: ptrayal/dungeonworld

decompiled_code:
__int64 __fastcall sex_lookup(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12
int v4; // edx
int v5; // eax

v1 = (_BYTE *)sex_table;
if ( !sex_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (_BYTE *)*((_QWORD *)&sex_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12
int v4; // edx
int v5; // eax

v1 = (_BYTE *)sex_table;
if ( !sex_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (_BYTE *)*((_QWORD *)&sex_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int sex_lookup (const char *name)
{
   int sex;
   for (sex = 0; sex_table[sex].name != ((void *)0); sex++)
   {
 if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((sex_table[sex].name[0]) >= 'A' && (sex_table[sex].name[0]) <= 'Z' ? (sex_table[sex].name[0])+'a'-'A' : (sex_table[sex].name[0]))
 && !str_prefix(name,sex_table[sex].name))
     return sex;
   }
   return -1;
}

canonical_original_code:
int sex_lookup(char *name)
{
   int sex;
   for (sex = 0; sex_table[sex].name != ((void *)0); sex++)
   {
 if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((sex_table[sex].name[0]) >= 'A' && (sex_table[sex].name[0]) <= 'Z' ? (sex_table[sex].name[0])+'a'-'A' : (sex_table[sex].name[0]))
 && !str_prefix(name,sex_table[sex].name))
     return sex;
   }
   return -1;
}

variable_types:
name
char *

variable_types: sex int

return_type: int


decompiled_code:
__int64 __fastcall size_lookup(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12
int v4; // edx
int v5; // eax

v1 = (_BYTE *)size_table;
if ( !size_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (_BYTE *)*((_QWORD *)&size_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12
int v4; // edx
int v5; // eax

v1 = (_BYTE *)size_table;
if ( !size_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (_BYTE *)*((_QWORD *)&size_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int size_lookup (const char *name)
{
   int size;
   for ( size = 0; size_table[size].name != ((void *)0); size++)
   {
        if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((size_table[size].name[0]) >= 'A' && (size_table[size].name[0]) <= 'Z' ? (size_table[size].name[0])+'a'-'A' : (size_table[size].name[0]))
        && !str_prefix( name,size_table[size].name))
            return size;
   }
   return -1;
}

canonical_original_code:
int size_lookup(char *name)
{
   int size;
   for ( size = 0; size_table[size].name != ((void *)0); size++)
   {
        if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((size_table[size].name[0]) >= 'A' && (size_table[size].name[0]) <= 'Z' ? (size_table[size].name[0])+'a'-'A' : (size_table[size].name[0]))
        && !str_prefix( name,size_table[size].name))
            return size;
   }
   return -1;
}

variable_types: size int


decompiled_code:
__int64 __fastcall race_lookup(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // ebp
int v4; // edx
int v5; // eax

v1 = (_BYTE *)race_table;
if ( !race_table )
return 0;
v2 = (unsigned int)((_DWORD)&race_table + 80);
v3 = 0;
while ( 1 )
{
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v3;
v2 += 80LL;
v1 = *(_BYTE **)(v2 - 80);
if ( !v1 )
return 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func5(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // ebp
int v4; // edx
int v5; // eax

v1 = (_BYTE *)race_table;
if ( !race_table )
return 0;
v2 = (unsigned int)((_DWORD)&race_table + 80);
v3 = 0;
while ( 1 )
{
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v3;
v2 += 80LL;
v1 = *(_BYTE **)(v2 - 80);
if ( !v1 )
return 0;
}
return v3;
}

original_code:
int race_lookup (const char *name)
{
   int race;
   for ( race = 0; race_table[race].name != ((void *)0); race++)
   {
 if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((race_table[race].name[0]) >= 'A' && (race_table[race].name[0]) <= 'Z' ? (race_table[race].name[0])+'a'-'A' : (race_table[race].name[0]))
 && !str_prefix( name,race_table[race].name))
     return race;
   }
   return 0;
}

canonical_original_code:
int race_lookup(char *name)
{
   int race;
   for ( race = 0; race_table[race].name != ((void *)0); race++)
   {
 if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((race_table[race].name[0]) >= 'A' && (race_table[race].name[0]) <= 'Z' ? (race_table[race].name[0])+'a'-'A' : (race_table[race].name[0]))
 && !str_prefix( name,race_table[race].name))
     return race;
   }
   return 0;
}

variable_types: race int


decompiled_code:
__int64 __fastcall item_lookup(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
int v3; // edx
int v4; // eax

v1 = (_BYTE *)*((_QWORD *)&item_table + 1);
if ( !v1 )
return 0xFFFFFFFFLL;
v2 = 0LL;
do
{
v3 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v3 = (char)*a1;
v4 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v4 = (char)*v1 + 32;
if ( v3 == v4 && !(unsigned __int8)str_prefix(a1) )
return *((unsigned int *)&item_table + 4 * (int)v2);
++v2;
v1 = (_BYTE *)*((_QWORD *)&item_table + 2 * v2 + 1);
}
while ( v1 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func6(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
int v3; // edx
int v4; // eax

v1 = (_BYTE *)*((_QWORD *)&item_table + 1);
if ( !v1 )
return 0xFFFFFFFFLL;
v2 = 0LL;
do
{
v3 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v3 = (char)*a1;
v4 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v4 = (char)*v1 + 32;
if ( v3 == v4 && !(unsigned __int8)str_prefix(a1) )
return *((unsigned int *)&item_table + 4 * (int)v2);
++v2;
v1 = (_BYTE *)*((_QWORD *)&item_table + 2 * v2 + 1);
}
while ( v1 );
return 0xFFFFFFFFLL;
}

original_code:
int item_lookup(const char *name)
{
    int type;
    for (type = 0; item_table[type].name != ((void *)0); type++)
    {
        if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((item_table[type].name[0]) >= 'A' && (item_table[type].name[0]) <= 'Z' ? (item_table[type].name[0])+'a'-'A' : (item_table[type].name[0]))
        && !str_prefix(name,item_table[type].name))
            return item_table[type].type;
    }
    return -1;
}

canonical_original_code:
int item_lookup(char *name)
{
    int type;
    for (type = 0; item_table[type].name != ((void *)0); type++)
    {
        if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((item_table[type].name[0]) >= 'A' && (item_table[type].name[0]) <= 'Z' ? (item_table[type].name[0])+'a'-'A' : (item_table[type].name[0]))
        && !str_prefix(name,item_table[type].name))
            return item_table[type].type;
    }
    return -1;
}

variable_types: type int


decompiled_code:
__int64 __fastcall liq_lookup(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12
int v4; // edx
int v5; // eax

v1 = (_BYTE *)liq_table[0];
if ( !liq_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (_BYTE *)liq_table[4 * v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(_BYTE *a1)
{
_BYTE *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12
int v4; // edx
int v5; // eax

v1 = (_BYTE *)liq_table[0];
if ( !liq_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
v4 = (char)*a1 + 32;
if ( (unsigned __int8)(*a1 - 65) > 0x19u )
v4 = (char)*a1;
v5 = (char)*v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
v5 = (char)*v1 + 32;
if ( v4 == v5 && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (_BYTE *)liq_table[4 * v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int liq_lookup (const char *name)
{
    int liq;
    for ( liq = 0; liq_table[liq].liq_name != ((void *)0); liq++)
    {
 if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((liq_table[liq].liq_name[0]) >= 'A' && (liq_table[liq].liq_name[0]) <= 'Z' ? (liq_table[liq].liq_name[0])+'a'-'A' : (liq_table[liq].liq_name[0]))
 && !str_prefix(name,liq_table[liq].liq_name))
     return liq;
    }
    return -1;
}

canonical_original_code:
int liq_lookup(char *name)
{
    int liq;
    for ( liq = 0; liq_table[liq].liq_name != ((void *)0); liq++)
    {
 if (((name[0]) >= 'A' && (name[0]) <= 'Z' ? (name[0])+'a'-'A' : (name[0])) == ((liq_table[liq].liq_name[0]) >= 'A' && (liq_table[liq].liq_name[0]) <= 'Z' ? (liq_table[liq].liq_name[0])+'a'-'A' : (liq_table[liq].liq_name[0]))
 && !str_prefix(name,liq_table[liq].liq_name))
     return liq;
    }
    return -1;
}

variable_types: liq int


decompiled_code:
__int64 __fastcall is_stat(void *a1)
{
unsigned __int64 v1; // rax
void *v2; // rdx

v1 = (unsigned int)((_DWORD)&flag_stat_table + 8);
v2 = &area_flags;
do
{
if ( a1 == v2 && *(_BYTE *)v1 )
return 1LL;
v1 += 16LL;
v2 = *(void **)(v1 - 8);
}
while ( v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *a1)
{
unsigned __int64 v1; // rax
void *v2; // rdx

v1 = (unsigned int)((_DWORD)&flag_stat_table + 8);
v2 = &area_flags;
do
{
if ( a1 == v2 && *(_BYTE *)v1 )
return 1LL;
v1 += 16LL;
v2 = *(void **)(v1 - 8);
}
while ( v2 );
return 0LL;
}

original_code:
bool is_stat( const struct flag_type *flag_table )
{
    int flag = 0;
    for (flag = 0; flag_stat_table[flag].structure; flag++)
    {
 if ( flag_stat_table[flag].structure == flag_table
   && flag_stat_table[flag].stat )
     return 1;
    }
    return 0;
}

canonical_original_code:
unsigned char is_stat(struct flag_type *flag_table)
{
    int flag = 0;
    for (flag = 0; flag_stat_table[flag].structure; flag++)
    {
 if ( flag_stat_table[flag].structure == flag_table
   && flag_stat_table[flag].stat )
     return 1;
    }
    return 0;
}

variable_types: struct flag_type { char *name; int bit; unsigned char settable; } *

variable_types: flag int

return_type: unsigned char


decompiled_code:
__int64 __fastcall flag_value(void *a1, __int64 a2)
{
__int64 v2; // rbx
char v3; // r13
unsigned int v4; // ebp
int v5; // eax
char v7[296]; // [rsp+0h] [rbp-128h] BYREF

v2 = a2;
v3 = is_stat(a1);
v4 = 0;
if ( v3 )
return (unsigned int)flag_lookup(a2, a1);
while ( 1 )
{
v2 = one_argument(v2, v7);
if ( !v7[0] )
break;
v5 = flag_lookup(v7, a1);
if ( v5 != -99 )
{
v4 |= v5;
v3 = 1;
}
}
if ( !v3 )
v4 = -99;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *a1, __int64 a2)
{
__int64 v2; // rbx
char v3; // r13
unsigned int v4; // ebp
int v5; // eax
char v7[296]; // [rsp+0h] [rbp-128h] BYREF

v2 = a2;
v3 = func0(a1);
v4 = 0;
if ( v3 )
return (unsigned int)flag_lookup(a2, a1);
while ( 1 )
{
v2 = one_argument(v2, v7);
if ( !v7[0] )
break;
v5 = flag_lookup(v7, a1);
if ( v5 != -99 )
{
v4 |= v5;
v3 = 1;
}
}
if ( !v3 )
v4 = -99;
return v4;
}

original_code:
int flag_value( const struct flag_type *flag_table, char *argument)
{
    char word[256];
    int bit = 0;
    int marked = 0;
    bool found = 0;
    if ( is_stat( flag_table ) )
 return flag_lookup(argument, flag_table);
    for (; ;)
    {
        argument = one_argument( argument, word );
        if ( word[0] == '\0' )
     break;
        if ( ( bit = flag_lookup( word, flag_table ) ) != -99 )
        {
            ((marked) |= (bit));
            found = 1;
        }
    }
    if ( found )
 return marked;
    else
 return -99;
}

canonical_original_code:
int flag_value(struct flag_type *flag_table, char *argument)
{
    char word[256];
    int bit = 0;
    int marked = 0;
    unsigned char found = 0;
    if ( is_stat( flag_table ) )
 return flag_lookup(argument, flag_table);
    for (; ;)
    {
        argument = one_argument( argument, word );
        if ( word[0] == '\0' )
     break;
        if ( ( bit = flag_lookup( word, flag_table ) ) != -99 )
        {
            ((marked) |= (bit));
            found = 1;
        }
    }
    if ( found )
 return marked;
    else
 return -99;
}

variable_types:
argument
char *

variable_types:
word
char [256]

variable_types: bit int

variable_types: marked int

variable_types:
found
unsigned char

user_defined_types: struct flag_type { char *name; int bit; unsigned char settable; }


decompiled_code:
const char *__fastcall flag_string(_QWORD *a1, int a2)
{
int v2; // er12
_QWORD *v3; // rbx
char v4; // r13
char *v5; // r14
const char *result; // rax

v2 = cnt_1 + 1;
if ( cnt_1 + 1 > 1 )
v2 = 0;
cnt_1 = v2;
buf_0[512 * (__int64)v2] = 0;
if ( !*a1 )
return "none";
v3 = a1;
v4 = is_stat(a1);
v5 = &buf_0[512 * (__int64)v2];
while ( 1 )
{
if ( !v4 && ((_DWORD)v3[1] & a2) != 0 )
{
*(_WORD *)&v5[strlen(v5)] = 32;
strcat(v5, (const char *)*v3);
goto LABEL_6;
}
if ( *((_DWORD *)v3 + 2) == a2 )
break;
LABEL_6:
v3 += 2;
if ( !*v3 )
goto LABEL_11;
}
*(_WORD *)&v5[strlen(v5)] = 32;
strcat(v5, (const char *)*v3);
LABEL_11:
result = "none";
if ( buf_0[512 * (__int64)v2] )
result = v5 + 1;
return result;
}

canonical_decompiled_code:
const char *__fastcall func2(_QWORD *a1, int a2)
{
int v2; // er12
_QWORD *v3; // rbx
char v4; // r13
char *v5; // r14
const char *result; // rax

v2 = cnt_1 + 1;
if ( cnt_1 + 1 > 1 )
v2 = 0;
cnt_1 = v2;
buf_0[512 * (__int64)v2] = 0;
if ( !*a1 )
return "none";
v3 = a1;
v4 = func0(a1);
v5 = &buf_0[512 * (__int64)v2];
while ( 1 )
{
if ( !v4 && ((_DWORD)v3[1] & a2) != 0 )
{
*(_WORD *)&v5[strlen(v5)] = 32;
strcat(v5, (const char *)*v3);
goto LABEL_6;
}
if ( *((_DWORD *)v3 + 2) == a2 )
break;
LABEL_6:
v3 += 2;
if ( !*v3 )
goto LABEL_11;
}
*(_WORD *)&v5[strlen(v5)] = 32;
strcat(v5, (const char *)*v3);
LABEL_11:
result = "none";
if ( buf_0[512 * (__int64)v2] )
result = v5 + 1;
return result;
}

original_code:
char *flag_string( const struct flag_type *flag_table, int bits )
{
    static char buf[2][512];
    static int cnt = 0;
    int flag = 0;
    if ( ++cnt > 1 )
     cnt = 0;
    buf[cnt][0] = '\0';
    for (flag = 0; flag_table[flag].name != ((void *)0); flag++)
    {
 if ( !is_stat( flag_table ) && ((bits) & (flag_table[flag].bit)) )
 {
     strcat( buf[cnt], " " );
     strcat( buf[cnt], flag_table[flag].name );
 }
 else
 if ( flag_table[flag].bit == bits )
 {
     strcat( buf[cnt], " " );
     strcat( buf[cnt], flag_table[flag].name );
     break;
 }
    }
    return (buf[cnt][0] != '\0') ? buf[cnt]+1 : (char *)"none";
}

canonical_original_code:
char *flag_string(struct flag_type *flag_table, int bits)
{
    static char buf[2][512];
    static int cnt = 0;
    int flag = 0;
    if ( ++cnt > 1 )
     cnt = 0;
    buf[cnt][0] = '\0';
    for (flag = 0; flag_table[flag].name != ((void *)0); flag++)
    {
 if ( !is_stat( flag_table ) && ((bits) & (flag_table[flag].bit)) )
 {
     strcat( buf[cnt], " " );
     strcat( buf[cnt], flag_table[flag].name );
 }
 else
 if ( flag_table[flag].bit == bits )
 {
     strcat( buf[cnt], " " );
     strcat( buf[cnt], flag_table[flag].name );
     break;
 }
    }
    return (buf[cnt][0] != '\0') ? buf[cnt]+1 : (char *)"none";
}

variable_types: bits int

variable_types: cnt int

return_type: char *


decompiled_code:
__int64 __fastcall get_random_room(__int64 a1)
{
unsigned int v1; // eax
__int64 v2; // rax
__int64 v3; // rbx
int v4; // eax

while ( 1 )
{
do
{
v1 = number_range(0LL, 0xFFFFLL);
v2 = get_room_index(v1);
v3 = v2;
}
while ( !v2 );
if ( (unsigned __int8)can_see_room(a1, v2) )
{
if ( !(unsigned __int8)room_is_private(v3) )
{
v4 = *(_DWORD *)(v3 + 132);
if ( (v4 & 0xE00) == 0 && ((*(_BYTE *)(a1 + 320) & 0x21) != 0 || (v4 & 0x40000) == 0) )
break;
}
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
unsigned int v1; // eax
__int64 v2; // rax
__int64 v3; // rbx
int v4; // eax

while ( 1 )
{
do
{
v1 = number_range(0LL, 0xFFFFLL);
v2 = get_room_index(v1);
v3 = v2;
}
while ( !v2 );
if ( (unsigned __int8)can_see_room(a1, v2) )
{
if ( !(unsigned __int8)room_is_private(v3) )
{
v4 = *(_DWORD *)(v3 + 132);
if ( (v4 & 0xE00) == 0 && ((*(_BYTE *)(a1 + 320) & 0x21) != 0 || (v4 & 0x40000) == 0) )
break;
}
}
}
return v3;
}

original_code:
ROOM_INDEX_DATA *get_random_room(CHAR_DATA *ch)
{
    ROOM_INDEX_DATA *room;
    for ( ; ; )
    {
        room = get_room_index( number_range( 0, 65535 ) );
        if ( room != ((void *)0) )
        if ( can_see_room(ch,room)
 && !room_is_private(room)
        && !((room->room_flags) & ((512)))
        && !((room->room_flags) & ((2048)))
 && !((room->room_flags) & ((1024)))
 && (((((ch)->act) & ((1)))) || ((ch->act) & ((32)))
 || !((room->room_flags) & ((262144)))))
            break;
    }
    return room;
}

canonical_original_code:
struct room_index_data *get_random_room(struct char_data *ch)
{
    struct room_index_data *room;
    for ( ; ; )
    {
        room = get_room_index( number_range( 0, 65535 ) );
        if ( room != ((void *)0) )
        if ( can_see_room(ch,room)
 && !room_is_private(room)
        && !((room->room_flags) & ((512)))
        && !((room->room_flags) & ((2048)))
 && !((room->room_flags) & ((1024)))
 && (((((ch)->act) & ((1)))) || ((ch->act) & ((32)))
 || !((room->room_flags) & ((262144)))))
            break;
    }
    return room;
}

variable_types:
ch
struct char_data *

variable_types: struct room_index_data { struct room_index_data *next; struct char_data { struct char_data *next; struct char_data *next_in_room; struct char_data *master; struct char_data *leader; struct char_data *fighting; struct char_data *reply; struct char_data *pet; struct char_data *mprog_target; struct mem_data { struct mem_data *next; unsigned char valid; int id; int reaction; long when; } *memory; unsigned char (*spec_fun)(struct char_data *ch); struct mob_index_data { struct mob_index_data *next; unsigned char (*spec_fun)(struct char_data *ch); struct shop_data { struct shop_data *next; short keeper; short buy_type[5]; short profit_buy; short profit_sell; short open_hour; short close_hour; } *pShop; struct mprog_list { int trig_type; char *trig_phrase; short vnum; char *code; struct mprog_list *next; unsigned char valid; } *mprogs; struct area_data { struct area_data *next; struct help_area_data { struct help_area_data *next; struct help_data { struct help_data *next; struct help_data *next_area; short level; char *keyword; char *text; } *first; struct help_data *last; struct area_data *area; char *filename; unsigned char changed; } *helps; char *file_name; char *name; char *credits; short age; short nplayer; short low_range; short high_range; short min_vnum; short max_vnum; unsigned char empty; char *builders; int vnum; int area_flags; int security; } *area; short vnum; short group; unsigned char new_format; short count; short killed; char *player_name; char *short_descr; char *long_descr; char *description; long act; long affected_by; short alignment; short level; short hitroll; short hit[3]; short mana[3]; short damage[3]; short ac[4]; short dam_type; long off_flags; long imm_flags; long res_flags; long vuln_flags; short start_pos; short default_pos; short sex; short race; long wealth; long form; long parts; short size; char *material; long mprog_flags; } *pIndexData; struct descriptor_data { struct descriptor_data *next; struct descriptor_data *snoop_by; struct char_data *character; struct char_data *original; unsigned char valid; char *host; short descriptor; short connected; unsigned char fcommand; char inbuf[-1]; char incomm[256]; char inlast[256]; int repeat; char *outbuf; int outsize; int outtop; char *showstr_head; char *showstr_point; void *pEdit; char **pString; int editor; struct protocol_t { int WriteOOB; enum bool_t { false=0, true=1 } Negotiated[-1]; enum bool_t { false=0, true=1 } bIACMode; enum bool_t { false=0, true=1 } bNegotiated; enum bool_t { false=0, true=1 } bRenegotiate; enum bool_t { false=0, true=1 } bNeedMXPVersion; enum bool_t { false=0, true=1 } bBlockMXP; enum bool_t { false=0, true=1 } bTTYPE; enum bool_t { false=0, true=1 } bECHO; enum bool_t { false=0, true=1 } bNAWS; enum bool_t { false=0, true=1 } bCHARSET; enum bool_t { false=0, true=1 } bMSDP; enum bool_t { false=0, true=1 } bMSSP; enum bool_t { false=0, true=1 } bATCP; enum bool_t { false=0, true=1 } bMSP; enum bool_t { false=0, true=1 } bMXP; enum bool_t { false=0, true=1 } bMCCP; enum support_t { eUNKNOWN=0, eNO=1, eSOMETIMES=2, eYES=3 } b256Support; int ScreenWidth; int ScreenHeight; char *pMXPVersion; char *pLastTTYPE; struct MSDP_t { enum bool_t { false=0, true=1 } bReport; enum bool_t { false=0, true=1 } bDirty; int ValueInt; char *pValueString; } **pVariables; } *pProtocol; } *desc; struct affect_data { struct affect_data *next; unsigned char valid; short where; short type; short level; short duration; short location; short modifier; int bitvector; } *affected; struct note_data { struct note_data *next; unsigned char valid; short type; char *sender; char *date; char *to_list; char *subject; char *text; long date_stamp; } *pnote; struct obj_data { struct obj_data *next; struct obj_data *next_content; struct obj_data *contains; struct obj_data *in_obj; struct obj_data *on; struct char_data *carried_by; struct extra_descr_data { struct extra_descr_data *next; unsigned char valid; char *keyword; char *description; } *extra_descr; struct affect_data *affected; struct obj_index_data { struct obj_index_data *next; struct extra_descr_data *extra_descr; struct affect_data *affected; struct area_data *area; unsigned char new_format; char *name; char *short_descr; char *description; short vnum; short reset_num; char *material; short item_type; int extra_flags; int wear_flags; short level; short condition; short count; short weight; int cost; int value[5]; } *pIndexData; struct room_index_data *in_room; unsigned char valid; unsigned char enchanted; char *owner; char *name; char *short_descr; char *description; short item_type; int extra_flags; int wear_flags; short wear_loc; short weight; int cost; short level; short condition; char *material; short timer; int value[5]; } *carrying; struct obj_data *on; struct room_index_data *in_room; struct room_index_data *was_in_room; struct area_data *zone; struct pc_data { struct pc_data *next; struct buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; } *buffer; unsigned char valid; char *pwd; char *bamfin; char *bamfout; char *title; long last_note; long last_idea; long last_penalty; long last_news; long last_changes; short perm_hit; short perm_mana; short perm_move; short true_sex; int last_level; short condition[4]; short learned[151]; unsigned char group_known[30]; short points; unsigned char confirm_delete; char *alias[5]; char *alias_sub[5]; int security; } *pcdata; struct gen_data { struct gen_data *next; unsigned char valid; unsigned char skill_chosen[151]; unsigned char group_chosen[30]; int points_chosen; } *gen_data; unsigned char valid; char *name; long id; short version; char *short_descr; char *long_descr; char *description; char *prompt; char *prefix; short group; short clan; short sex; short iclass; short race; short level; short trust; int played; int lines; long logon; short timer; short wait; short daze; short hit; short max_hit; short mana; short max_mana; short move; short max_move; long gold; long silver; int exp; long act; long comm; long wiznet; long imm_flags; long res_flags; long vuln_flags; short invis_level; short incog_level; long affected_by; short position; short practice; short train; short carry_weight; short carry_number; short saving_throw; short alignment; short hitroll; short damroll; short armor[4]; short wimpy; short perm_stat[5]; short mod_stat[5]; long form; long parts; short size; char *material; long off_flags; short damage[3]; short dam_type; short start_pos; short default_pos; short mprog_delay; } *people; struct obj_data *contents; struct extra_descr_data *extra_descr; struct area_data *area; struct exit_data { union { struct room_index_data *to_room; short vnum; } u1; int exit_info; short key; char *keyword; char *description; struct exit_data *next; int rs_flags; int orig_door; } *exit[6]; struct reset_data { struct reset_data *next; char command; short arg1; short arg2; short arg3; short arg4; } *reset_first; struct reset_data *reset_last; char *name; char *description; char *owner; short vnum; int room_flags; short light; short sector_type; short heal_rate; short mana_rate; short clan; } *

user_defined_types: struct room_index_data { struct room_index_data *next; struct char_data *people; struct obj_data *contents; struct extra_descr_data *extra_descr; struct area_data *area; struct exit_data *exit[6]; struct reset_data *reset_first; struct reset_data *reset_last; char *name; char *description; char *owner; short vnum; int room_flags; short light; short sector_type; short heal_rate; short mana_rate; short clan; }

user_defined_types: struct char_data { struct char_data *next; struct char_data *next_in_room; struct char_data *master; struct char_data *leader; struct char_data *fighting; struct char_data *reply; struct char_data *pet; struct char_data *mprog_target; struct mem_data *memory; unsigned char (*spec_fun)(struct char_data *ch); struct mob_index_data *pIndexData; struct descriptor_data *desc; struct affect_data *affected; struct note_data *pnote; struct obj_data *carrying; struct obj_data *on; struct room_index_data *in_room; struct room_index_data *was_in_room; struct area_data *zone; struct pc_data *pcdata; struct gen_data *gen_data; unsigned char valid; char *name; long id; short version; char *short_descr; char *long_descr; char *description; char *prompt; char *prefix; short group; short clan; short sex; short iclass; short race; short level; short trust; int played; int lines; long logon; short timer; short wait; short daze; short hit; short max_hit; short mana; short max_mana; short move; short max_move; long gold; long silver; int exp; long act; long comm; long wiznet; long imm_flags; long res_flags; long vuln_flags; short invis_level; short incog_level; long affected_by; short position; short practice; short train; short carry_weight; short carry_number; short saving_throw; short alignment; short hitroll; short damroll; short armor[4]; short wimpy; short perm_stat[5]; short mod_stat[5]; long form; long parts; short size; char *material; long off_flags; short damage[3]; short dam_type; short start_pos; short default_pos; short mprog_delay; }

user_defined_types: struct mob_index_data { struct mob_index_data *next; unsigned char (*spec_fun)(struct char_data *ch); struct shop_data *pShop; struct mprog_list *mprogs; struct area_data *area; short vnum; short group; unsigned char new_format; short count; short killed; char *player_name; char *short_descr; char *long_descr; char *description; long act; long affected_by; short alignment; short level; short hitroll; short hit[3]; short mana[3]; short damage[3]; short ac[4]; short dam_type; long off_flags; long imm_flags; long res_flags; long vuln_flags; short start_pos; short default_pos; short sex; short race; long wealth; long form; long parts; short size; char *material; long mprog_flags; }

user_defined_types: struct descriptor_data { struct descriptor_data *next; struct descriptor_data *snoop_by; struct char_data *character; struct char_data *original; unsigned char valid; char *host; short descriptor; short connected; unsigned char fcommand; char inbuf[-1]; char incomm[256]; char inlast[256]; int repeat; char *outbuf; int outsize; int outtop; char *showstr_head; char *showstr_point; void *pEdit; char **pString; int editor; struct protocol_t *pProtocol; }

user_defined_types: struct obj_data { struct obj_data *next; struct obj_data *next_content; struct obj_data *contains; struct obj_data *in_obj; struct obj_data *on; struct char_data *carried_by; struct extra_descr_data *extra_descr; struct affect_data *affected; struct obj_index_data *pIndexData; struct room_index_data *in_room; unsigned char valid; unsigned char enchanted; char *owner; char *name; char *short_descr; char *description; short item_type; int extra_flags; int wear_flags; short wear_loc; short weight; int cost; short level; short condition; char *material; short timer; int value[5]; }

user_defined_types: struct pc_data { struct pc_data *next; struct buf_type *buffer; unsigned char valid; char *pwd; char *bamfin; char *bamfout; char *title; long last_note; long last_idea; long last_penalty; long last_news; long last_changes; short perm_hit; short perm_mana; short perm_move; short true_sex; int last_level; short condition[4]; short learned[151]; unsigned char group_known[30]; short points; unsigned char confirm_delete; char *alias[5]; char *alias_sub[5]; int security; }

user_defined_types: struct area_data { struct area_data *next; struct help_area_data *helps; char *file_name; char *name; char *credits; short age; short nplayer; short low_range; short high_range; short min_vnum; short max_vnum; unsigned char empty; char *builders; int vnum; int area_flags; int security; }

user_defined_types: struct protocol_t { int WriteOOB; enum bool_t Negotiated[-1]; enum bool_t bIACMode; enum bool_t bNegotiated; enum bool_t bRenegotiate; enum bool_t bNeedMXPVersion; enum bool_t bBlockMXP; enum bool_t bTTYPE; enum bool_t bECHO; enum bool_t bNAWS; enum bool_t bCHARSET; enum bool_t bMSDP; enum bool_t bMSSP; enum bool_t bATCP; enum bool_t bMSP; enum bool_t bMXP; enum bool_t bMCCP; enum support_t b256Support; int ScreenWidth; int ScreenHeight; char *pMXPVersion; char *pLastTTYPE; struct MSDP_t **pVariables; }

user_defined_types: struct help_area_data { struct help_area_data *next; struct help_data *first; struct help_data *last; struct area_data *area; char *filename; unsigned char changed; }

user_defined_types: struct MSDP_t { enum bool_t bReport; enum bool_t bDirty; int ValueInt; char *pValueString; }


decompiled_code:
void __fastcall do_enter(__int64 a1, _BYTE *a2)
{
__int64 v2; // r14
__int64 v3; // rax
__int64 v4; // rbp
int v5; // eax
__int64 v6; // r13
int v7; // eax
int v8; // eax
__int64 v9; // r13
__int64 v10; // r15
__int64 v11; // rsi

if ( !*(_QWORD *)(a1 + 32) )
{
if ( *a2 )
{
v2 = *(_QWORD *)(a1 + 128);
v3 = get_obj_list(a1, a2, *(_QWORD *)(v2 + 16));
v4 = v3;
if ( !v3 )
{
send_to_char("You don't see that here.\n\r", a1);
return;
}
if ( *(_WORD *)(v3 + 120) != 29 || (*(_BYTE *)(v3 + 160) & 2) != 0 && (int)get_trust(a1) <= 52 )
{
send_to_char("You can't seem to find a way in.\n\r", a1);
return;
}
if ( (int)get_trust(a1) <= 52
&& (*(_BYTE *)(v4 + 164) & 2) == 0
&& ((*(_BYTE *)(a1 + 377) & 4) != 0 || (*(_BYTE *)(v2 + 133) & 0x20) != 0) )
{
goto LABEL_46;
}
v5 = *(_DWORD *)(v4 + 164);
if ( (v5 & 0x10) != 0 || *(_DWORD *)(v4 + 168) == -1 )
{
v6 = get_random_room(a1);
*(_DWORD *)(v4 + 168) = *(__int16 *)(v6 + 128);
}
else if ( (v5 & 8) != 0 && (int)number_percent() <= 4 )
{
v6 = get_random_room(a1);
}
else
{
v6 = get_room_index(*(unsigned int *)(v4 + 168));
}
if ( !v6
|| v6 == v2
|| !(unsigned __int8)can_see_room(a1, v6)
|| (unsigned __int8)room_is_private(v6) && (int)get_trust(a1) <= 59 )
{
act_new("$p doesn't seem to go anywhere.", a1, v4, 0LL, 3LL, 5LL);
return;
}
if ( (*(_QWORD *)(a1 + 320) & 0x21LL) == 33 && (*(_BYTE *)(v6 + 134) & 4) != 0 )
{
LABEL_46:
send_to_char("Something prevents you from leaving...\n\r", a1);
}
else
{
act_new("$n steps into $p.", a1, v4, 0LL, 0LL, 5LL);
if ( (*(_BYTE *)(v4 + 164) & 1) != 0 )
act_new("You enter $p.", a1, v4, 0LL, 3LL, 5LL);
else
act_new("You walk through $p and find yourself somewhere else...", a1, v4, 0LL, 3LL, 5LL);
char_from_room(a1);
char_to_room(a1, v6);
if ( (*(_BYTE *)(v4 + 164) & 4) != 0 )
{
obj_from_room(v4);
obj_to_room(v4, v6);
}
if ( (*(_BYTE *)(v4 + 164) & 1) != 0 )
act_new("$n has arrived.", a1, v4, 0LL, 0LL, 5LL);
else
act_new("$n has arrived through $p.", a1, v4, 0LL, 0LL, 5LL);
do_function(a1, &do_look, "auto");
v7 = *(_DWORD *)(v4 + 156);
if ( v7 > 0 )
{
v8 = v7 - 1;
if ( !v8 )
v8 = -1;
*(_DWORD *)(v4 + 156) = v8;
}
v9 = *(_QWORD *)(v2 + 8);
while ( v9 )
{
v10 = v9;
v9 = *(_QWORD *)(v9 + 8);
if ( *(_DWORD *)(v4 + 156) != -1 && *(_QWORD *)(v10 + 16) == a1 )
{
if ( (*(_BYTE *)(v10 + 378) & 4) == 0
|| *(__int16 *)(v10 + 384) > 7
|| (do_function(v10, &do_stand, &unk_5D0), *(_QWORD *)(v10 + 16) == a1) )
{
if ( *(_WORD *)(v10 + 384) == 8 )
{
if ( (*(_BYTE *)(*(_QWORD *)(a1 + 128) + 134LL) & 4) != 0 && (*(_QWORD *)(v10 + 320) & 0x21LL) == 33 )
{
act_new("You can't bring $N into the city.", a1, 0LL, v10, 3LL, 5LL);
act_new("You aren't allowed in the city.", v10, 0LL, 0LL, 3LL, 5LL);
}
else
{
act_new("You follow $N.", v10, 0LL, a1, 3LL, 5LL);
do_function(v10, do_enter, a2);
}
}
}
}
}
if ( *(_DWORD *)(v4 + 156) == -1 )
{
act_new("$p fades out of existence.", a1, v4, 0LL, 3LL, 5LL);
if ( *(_QWORD *)(a1 + 128) == v2 )
{
act_new("$p fades out of existence.", a1, v4, 0LL, 0LL, 5LL);
}
else
{
v11 = *(_QWORD *)(v2 + 8);
if ( v11 )
{
act_new("$p fades out of existence.", v11, v4, 0LL, 3LL, 5LL);
act_new("$p fades out of existence.", *(_QWORD *)(v2 + 8), v4, 0LL, 0LL, 5LL);
}
}
extract_obj(v4);
}
if ( (*(_BYTE *)(a1 + 320) & 1) == 0
|| (*(_BYTE *)(*(_QWORD *)(a1 + 80) + 224LL) & 8) != 0
&& (mp_percent_trigger(a1, 0LL, 0LL, 0LL, 8LL), (*(_BYTE *)(a1 + 320) & 1) == 0) )
{
mp_greet_trigger(a1);
}
}
}
else
{
send_to_char("Nope, can't do it.\n\r", a1);
}
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, _BYTE *a2)
{
__int64 v2; // r14
__int64 v3; // rax
__int64 v4; // rbp
int v5; // eax
__int64 v6; // r13
int v7; // eax
int v8; // eax
__int64 v9; // r13
__int64 v10; // r15
__int64 v11; // rsi

if ( !*(_QWORD *)(a1 + 32) )
{
if ( *a2 )
{
v2 = *(_QWORD *)(a1 + 128);
v3 = get_obj_list(a1, a2, *(_QWORD *)(v2 + 16));
v4 = v3;
if ( !v3 )
{
send_to_char("You don't see that here.\n\r", a1);
return;
}
if ( *(_WORD *)(v3 + 120) != 29 || (*(_BYTE *)(v3 + 160) & 2) != 0 && (int)get_trust(a1) <= 52 )
{
send_to_char("You can't seem to find a way in.\n\r", a1);
return;
}
if ( (int)get_trust(a1) <= 52
&& (*(_BYTE *)(v4 + 164) & 2) == 0
&& ((*(_BYTE *)(a1 + 377) & 4) != 0 || (*(_BYTE *)(v2 + 133) & 0x20) != 0) )
{
goto LABEL_46;
}
v5 = *(_DWORD *)(v4 + 164);
if ( (v5 & 0x10) != 0 || *(_DWORD *)(v4 + 168) == -1 )
{
v6 = func0(a1);
*(_DWORD *)(v4 + 168) = *(__int16 *)(v6 + 128);
}
else if ( (v5 & 8) != 0 && (int)number_percent() <= 4 )
{
v6 = func0(a1);
}
else
{
v6 = get_room_index(*(unsigned int *)(v4 + 168));
}
if ( !v6
|| v6 == v2
|| !(unsigned __int8)can_see_room(a1, v6)
|| (unsigned __int8)room_is_private(v6) && (int)get_trust(a1) <= 59 )
{
act_new("$p doesn't seem to go anywhere.", a1, v4, 0LL, 3LL, 5LL);
return;
}
if ( (*(_QWORD *)(a1 + 320) & 0x21LL) == 33 && (*(_BYTE *)(v6 + 134) & 4) != 0 )
{
LABEL_46:
send_to_char("Something prevents you from leaving...\n\r", a1);
}
else
{
act_new("$n steps into $p.", a1, v4, 0LL, 0LL, 5LL);
if ( (*(_BYTE *)(v4 + 164) & 1) != 0 )
act_new("You enter $p.", a1, v4, 0LL, 3LL, 5LL);
else
act_new("You walk through $p and find yourself somewhere else...", a1, v4, 0LL, 3LL, 5LL);
char_from_room(a1);
char_to_room(a1, v6);
if ( (*(_BYTE *)(v4 + 164) & 4) != 0 )
{
obj_from_room(v4);
obj_to_room(v4, v6);
}
if ( (*(_BYTE *)(v4 + 164) & 1) != 0 )
act_new("$n has arrived.", a1, v4, 0LL, 0LL, 5LL);
else
act_new("$n has arrived through $p.", a1, v4, 0LL, 0LL, 5LL);
do_function(a1, &do_look, "auto");
v7 = *(_DWORD *)(v4 + 156);
if ( v7 > 0 )
{
v8 = v7 - 1;
if ( !v8 )
v8 = -1;
*(_DWORD *)(v4 + 156) = v8;
}
v9 = *(_QWORD *)(v2 + 8);
while ( v9 )
{
v10 = v9;
v9 = *(_QWORD *)(v9 + 8);
if ( *(_DWORD *)(v4 + 156) != -1 && *(_QWORD *)(v10 + 16) == a1 )
{
if ( (*(_BYTE *)(v10 + 378) & 4) == 0
|| *(__int16 *)(v10 + 384) > 7
|| (do_function(v10, &do_stand, &unk_5D0), *(_QWORD *)(v10 + 16) == a1) )
{
if ( *(_WORD *)(v10 + 384) == 8 )
{
if ( (*(_BYTE *)(*(_QWORD *)(a1 + 128) + 134LL) & 4) != 0 && (*(_QWORD *)(v10 + 320) & 0x21LL) == 33 )
{
act_new("You can't bring $N into the city.", a1, 0LL, v10, 3LL, 5LL);
act_new("You aren't allowed in the city.", v10, 0LL, 0LL, 3LL, 5LL);
}
else
{
act_new("You follow $N.", v10, 0LL, a1, 3LL, 5LL);
do_function(v10, do_enter, a2);
}
}
}
}
}
if ( *(_DWORD *)(v4 + 156) == -1 )
{
act_new("$p fades out of existence.", a1, v4, 0LL, 3LL, 5LL);
if ( *(_QWORD *)(a1 + 128) == v2 )
{
act_new("$p fades out of existence.", a1, v4, 0LL, 0LL, 5LL);
}
else
{
v11 = *(_QWORD *)(v2 + 8);
if ( v11 )
{
act_new("$p fades out of existence.", v11, v4, 0LL, 3LL, 5LL);
act_new("$p fades out of existence.", *(_QWORD *)(v2 + 8), v4, 0LL, 0LL, 5LL);
}
}
extract_obj(v4);
}
if ( (*(_BYTE *)(a1 + 320) & 1) == 0
|| (*(_BYTE *)(*(_QWORD *)(a1 + 80) + 224LL) & 8) != 0
&& (mp_percent_trigger(a1, 0LL, 0LL, 0LL, 8LL), (*(_BYTE *)(a1 + 320) & 1) == 0) )
{
mp_greet_trigger(a1);
}
}
}
else
{
send_to_char("Nope, can't do it.\n\r", a1);
}
}
}

original_code:
void do_enter( CHAR_DATA *ch, char *argument)
{
 ROOM_INDEX_DATA *location;
 if ( ch->fighting != ((void *)0) )
  return;
 if (argument[0] != '\0')
 {
  ROOM_INDEX_DATA *old_room;
  OBJ_DATA *portal;
  CHAR_DATA *fch, *fch_next;
  old_room = ch->in_room;
  portal = get_obj_list( ch, argument, ch->in_room->contents );
  if (portal == ((void *)0))
  {
   send_to_char("You don't see that here.\n\r",ch);
   return;
  }
  if (portal->item_type != 29
   || (((portal->value[1]) & ((2))) && !(get_trust((ch)) >= ((60 - 7)))))
  {
   send_to_char("You can't seem to find a way in.\n\r",ch);
   return;
  }
  if (!(get_trust((ch)) >= ((60 - 7))) && !((portal->value[2]) & ((2)))
   && (((((ch)->affected_by) & (((1024)))))
    || ((old_room->room_flags) & ((8192)))))
  {
   send_to_char("Something prevents you from leaving...\n\r",ch);
   return;
  }
  if (((portal->value[2]) & ((16))) || portal->value[3] == -1)
  {
   location = get_random_room(ch);
     portal->value[3] = location->vnum;
  }
  else if (((portal->value[2]) & ((8))) && (number_percent() < 5))
   location = get_random_room(ch);
  else
   location = get_room_index(portal->value[3]);
  if (location == ((void *)0)
   || location == old_room
   || !can_see_room(ch,location)
   || (room_is_private(location) && !(get_trust((ch)) >= (60))))
  {
   act_new(("$p doesn't seem to go anywhere."),(ch),(portal),(((void *)0)),(3),5);
   return;
  }
  if (((((ch)->act) & ((1)))) && ((ch->act) & ((32)))
   && ((location->room_flags) & ((262144))))
  {
   send_to_char("Something prevents you from leaving...\n\r",ch);
   return;
  }
  act_new(("$n steps into $p."),(ch),(portal),(((void *)0)),(0),5);
  if (((portal->value[2]) & ((1))))
   act_new(("You enter $p."),(ch),(portal),(((void *)0)),(3),5);
  else
   act_new(("You walk through $p and find yourself somewhere else..."),(ch),(portal),(((void *)0)),(3),5);
  char_from_room(ch);
  char_to_room(ch, location);
 if (((portal->value[2]) & ((4))))
  {
   obj_from_room(portal);
   obj_to_room(portal,location);
  }
  if (((portal->value[2]) & ((1))))
   act_new(("$n has arrived."),(ch),(portal),(((void *)0)),(0),5);
  else
   act_new(("$n has arrived through $p."),(ch),(portal),(((void *)0)),(0),5);
  do_function(ch, &do_look, "auto");
  if (portal->value[0] > 0)
  {
   portal->value[0]--;
   if (portal->value[0] == 0)
    portal->value[0] = -1;
  }
  if (old_room == location)
   return;
  for ( fch = old_room->people; fch != ((void *)0); fch = fch_next )
  {
   fch_next = fch->next_in_room;
   if (portal == ((void *)0) || portal->value[0] == -1)
    continue;
   if ( fch->master == ch && ((((fch)->affected_by) & (((262144)))))
    && fch->position < 8)
    do_function(fch, &do_stand, "");
   if ( fch->master == ch && fch->position == 8)
   {
    if (((ch->in_room->room_flags) & ((262144)))
     && (((((fch)->act) & ((1)))) && ((fch->act) & ((32)))))
    {
     act_new(("You can't bring $N into the city."),(ch),(((void *)0)),(fch),(3),5);
     act_new(("You aren't allowed in the city."),(fch),(((void *)0)),(((void *)0)),(3),5);
     continue;
    }
    act_new(("You follow $N."),(fch),(((void *)0)),(ch),(3),5);
    do_function(fch, &do_enter, argument);
   }
  }
  if (portal != ((void *)0) && portal->value[0] == -1)
  {
   act_new(("$p fades out of existence."),(ch),(portal),(((void *)0)),(3),5);
   if (ch->in_room == old_room)
    act_new(("$p fades out of existence."),(ch),(portal),(((void *)0)),(0),5);
   else if (old_room->people != ((void *)0))
   {
    act_new(("$p fades out of existence."),(old_room->people),(portal),(((void *)0)),(3),5);
    act_new(("$p fades out of existence."),(old_room->people),(portal),(((void *)0)),(0),5);
   }
   extract_obj(portal);
  }
  if ( ((((ch)->act) & ((1)))) && ((((ch)->pIndexData->mprog_flags) & (((8))))) )
   mp_percent_trigger( ch, ((void *)0), ((void *)0), ((void *)0), (8) );
  if ( !((((ch)->act) & ((1)))) )
   mp_greet_trigger( ch );
  return;
 }
 send_to_char("Nope, can't do it.\n\r",ch);
 return;
}

canonical_original_code:
void do_enter(struct char_data *ch, char *argument)
{
 struct room_index_data *location;
 if ( ch->fighting != ((void *)0) )
  return;
 if (argument[0] != '\0')
 {
  struct room_index_data *old_room;
  struct obj_data *portal;
  struct char_data *fch; struct char_data *fch_next;
  old_room = ch->in_room;
  portal = get_obj_list( ch, argument, ch->in_room->contents );
  if (portal == ((void *)0))
  {
   send_to_char("You don't see that here.\n\r",ch);
   return;
  }
  if (portal->item_type != 29
   || (((portal->value[1]) & ((2))) && !(get_trust((ch)) >= ((60 - 7)))))
  {
   send_to_char("You can't seem to find a way in.\n\r",ch);
   return;
  }
  if (!(get_trust((ch)) >= ((60 - 7))) && !((portal->value[2]) & ((2)))
   && (((((ch)->affected_by) & (((1024)))))
    || ((old_room->room_flags) & ((8192)))))
  {
   send_to_char("Something prevents you from leaving...\n\r",ch);
   return;
  }
  if (((portal->value[2]) & ((16))) || portal->value[3] == -1)
  {
   location = get_random_room(ch);
     portal->value[3] = location->vnum;
  }
  else if (((portal->value[2]) & ((8))) && (number_percent() < 5))
   location = get_random_room(ch);
  else
   location = get_room_index(portal->value[3]);
  if (location == ((void *)0)
   || location == old_room
   || !can_see_room(ch,location)
   || (room_is_private(location) && !(get_trust((ch)) >= (60))))
  {
   act_new(("$p doesn't seem to go anywhere."),(ch),(portal),(((void *)0)),(3),5);
   return;
  }
  if (((((ch)->act) & ((1)))) && ((ch->act) & ((32)))
   && ((location->room_flags) & ((262144))))
  {
   send_to_char("Something prevents you from leaving...\n\r",ch);
   return;
  }
  act_new(("$n steps into $p."),(ch),(portal),(((void *)0)),(0),5);
  if (((portal->value[2]) & ((1))))
   act_new(("You enter $p."),(ch),(portal),(((void *)0)),(3),5);
  else
   act_new(("You walk through $p and find yourself somewhere else..."),(ch),(portal),(((void *)0)),(3),5);
  char_from_room(ch);
  char_to_room(ch, location);
 if (((portal->value[2]) & ((4))))
  {
   obj_from_room(portal);
   obj_to_room(portal,location);
  }
  if (((portal->value[2]) & ((1))))
   act_new(("$n has arrived."),(ch),(portal),(((void *)0)),(0),5);
  else
   act_new(("$n has arrived through $p."),(ch),(portal),(((void *)0)),(0),5);
  do_function(ch, &do_look, "auto");
  if (portal->value[0] > 0)
  {
   portal->value[0]--;
   if (portal->value[0] == 0)
    portal->value[0] = -1;
  }
  if (old_room == location)
   return;
  for ( fch = old_room->people; fch != ((void *)0); fch = fch_next )
  {
   fch_next = fch->next_in_room;
   if (portal == ((void *)0) || portal->value[0] == -1)
    continue;
   if ( fch->master == ch && ((((fch)->affected_by) & (((262144)))))
    && fch->position < 8)
    do_function(fch, &do_stand, "");
   if ( fch->master == ch && fch->position == 8)
   {
    if (((ch->in_room->room_flags) & ((262144)))
     && (((((fch)->act) & ((1)))) && ((fch->act) & ((32)))))
    {
     act_new(("You can't bring $N into the city."),(ch),(((void *)0)),(fch),(3),5);
     act_new(("You aren't allowed in the city."),(fch),(((void *)0)),(((void *)0)),(3),5);
     continue;
    }
    act_new(("You follow $N."),(fch),(((void *)0)),(ch),(3),5);
    do_function(fch, &do_enter, argument);
   }
  }
  if (portal != ((void *)0) && portal->value[0] == -1)
  {
   act_new(("$p fades out of existence."),(ch),(portal),(((void *)0)),(3),5);
   if (ch->in_room == old_room)
    act_new(("$p fades out of existence."),(ch),(portal),(((void *)0)),(0),5);
   else if (old_room->people != ((void *)0))
   {
    act_new(("$p fades out of existence."),(old_room->people),(portal),(((void *)0)),(3),5);
    act_new(("$p fades out of existence."),(old_room->people),(portal),(((void *)0)),(0),5);
   }
   extract_obj(portal);
  }
  if ( ((((ch)->act) & ((1)))) && ((((ch)->pIndexData->mprog_flags) & (((8))))) )
   mp_percent_trigger( ch, ((void *)0), ((void *)0), ((void *)0), (8) );
  if ( !((((ch)->act) & ((1)))) )
   mp_greet_trigger( ch );
  return;
 }
 send_to_char("Nope, can't do it.\n\r",ch);
 return;
}

variable_types: struct char_data { struct char_data *next; struct char_data *next_in_room; struct char_data *master; struct char_data *leader; struct char_data *fighting; struct char_data *reply; struct char_data *pet; struct char_data *mprog_target; struct mem_data { struct mem_data *next; unsigned char valid; int id; int reaction; long when; } *memory; unsigned char (*spec_fun)(struct char_data *ch); struct mob_index_data { struct mob_index_data *next; unsigned char (*spec_fun)(struct char_data *ch); struct shop_data { struct shop_data *next; short keeper; short buy_type[5]; short profit_buy; short profit_sell; short open_hour; short close_hour; } *pShop; struct mprog_list { int trig_type; char *trig_phrase; short vnum; char *code; struct mprog_list *next; unsigned char valid; } *mprogs; struct area_data { struct area_data *next; struct help_area_data { struct help_area_data *next; struct help_data { struct help_data *next; struct help_data *next_area; short level; char *keyword; char *text; } *first; struct help_data *last; struct area_data *area; char *filename; unsigned char changed; } *helps; char *file_name; char *name; char *credits; short age; short nplayer; short low_range; short high_range; short min_vnum; short max_vnum; unsigned char empty; char *builders; int vnum; int area_flags; int security; } *area; short vnum; short group; unsigned char new_format; short count; short killed; char *player_name; char *short_descr; char *long_descr; char *description; long act; long affected_by; short alignment; short level; short hitroll; short hit[3]; short mana[3]; short damage[3]; short ac[4]; short dam_type; long off_flags; long imm_flags; long res_flags; long vuln_flags; short start_pos; short default_pos; short sex; short race; long wealth; long form; long parts; short size; char *material; long mprog_flags; } *pIndexData; struct descriptor_data { struct descriptor_data *next; struct descriptor_data *snoop_by; struct char_data *character; struct char_data *original; unsigned char valid; char *host; short descriptor; short connected; unsigned char fcommand; char inbuf[-1]; char incomm[256]; char inlast[256]; int repeat; char *outbuf; int outsize; int outtop; char *showstr_head; char *showstr_point; void *pEdit; char **pString; int editor; struct protocol_t { int WriteOOB; enum bool_t { false=0, true=1 } Negotiated[-1]; enum bool_t { false=0, true=1 } bIACMode; enum bool_t { false=0, true=1 } bNegotiated; enum bool_t { false=0, true=1 } bRenegotiate; enum bool_t { false=0, true=1 } bNeedMXPVersion; enum bool_t { false=0, true=1 } bBlockMXP; enum bool_t { false=0, true=1 } bTTYPE; enum bool_t { false=0, true=1 } bECHO; enum bool_t { false=0, true=1 } bNAWS; enum bool_t { false=0, true=1 } bCHARSET; enum bool_t { false=0, true=1 } bMSDP; enum bool_t { false=0, true=1 } bMSSP; enum bool_t { false=0, true=1 } bATCP; enum bool_t { false=0, true=1 } bMSP; enum bool_t { false=0, true=1 } bMXP; enum bool_t { false=0, true=1 } bMCCP; enum support_t { eUNKNOWN=0, eNO=1, eSOMETIMES=2, eYES=3 } b256Support; int ScreenWidth; int ScreenHeight; char *pMXPVersion; char *pLastTTYPE; struct MSDP_t { enum bool_t { false=0, true=1 } bReport; enum bool_t { false=0, true=1 } bDirty; int ValueInt; char *pValueString; } **pVariables; } *pProtocol; } *desc; struct affect_data { struct affect_data *next; unsigned char valid; short where; short type; short level; short duration; short location; short modifier; int bitvector; } *affected; struct note_data { struct note_data *next; unsigned char valid; short type; char *sender; char *date; char *to_list; char *subject; char *text; long date_stamp; } *pnote; struct obj_data { struct obj_data *next; struct obj_data *next_content; struct obj_data *contains; struct obj_data *in_obj; struct obj_data *on; struct char_data *carried_by; struct extra_descr_data { struct extra_descr_data *next; unsigned char valid; char *keyword; char *description; } *extra_descr; struct affect_data *affected; struct obj_index_data { struct obj_index_data *next; struct extra_descr_data *extra_descr; struct affect_data *affected; struct area_data *area; unsigned char new_format; char *name; char *short_descr; char *description; short vnum; short reset_num; char *material; short item_type; int extra_flags; int wear_flags; short level; short condition; short count; short weight; int cost; int value[5]; } *pIndexData; struct room_index_data { struct room_index_data *next; struct char_data *people; struct obj_data *contents; struct extra_descr_data *extra_descr; struct area_data *area; struct exit_data { union { struct room_index_data *to_room; short vnum; } u1; int exit_info; short key; char *keyword; char *description; struct exit_data *next; int rs_flags; int orig_door; } *exit[6]; struct reset_data { struct reset_data *next; char command; short arg1; short arg2; short arg3; short arg4; } *reset_first; struct reset_data *reset_last; char *name; char *description; char *owner; short vnum; int room_flags; short light; short sector_type; short heal_rate; short mana_rate; short clan; } *in_room; unsigned char valid; unsigned char enchanted; char *owner; char *name; char *short_descr; char *description; short item_type; int extra_flags; int wear_flags; short wear_loc; short weight; int cost; short level; short condition; char *material; short timer; int value[5]; } *carrying; struct obj_data *on; struct room_index_data *in_room; struct room_index_data *was_in_room; struct area_data *zone; struct pc_data { struct pc_data *next; struct buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; } *buffer; unsigned char valid; char *pwd; char *bamfin; char *bamfout; char *title; long last_note; long last_idea; long last_penalty; long last_news; long last_changes; short perm_hit; short perm_mana; short perm_move; short true_sex; int last_level; short condition[4]; short learned[151]; unsigned char group_known[30]; short points; unsigned char confirm_delete; char *alias[5]; char *alias_sub[5]; int security; } *pcdata; struct gen_data { struct gen_data *next; unsigned char valid; unsigned char skill_chosen[151]; unsigned char group_chosen[30]; int points_chosen; } *gen_data; unsigned char valid; char *name; long id; short version; char *short_descr; char *long_descr; char *description; char *prompt; char *prefix; short group; short clan; short sex; short iclass; short race; short level; short trust; int played; int lines; long logon; short timer; short wait; short daze; short hit; short max_hit; short mana; short max_mana; short move; short max_move; long gold; long silver; int exp; long act; long comm; long wiznet; long imm_flags; long res_flags; long vuln_flags; short invis_level; short incog_level; long affected_by; short position; short practice; short train; short carry_weight; short carry_number; short saving_throw; short alignment; short hitroll; short damroll; short armor[4]; short wimpy; short perm_stat[5]; short mod_stat[5]; long form; long parts; short size; char *material; long off_flags; short damage[3]; short dam_type; short start_pos; short default_pos; short mprog_delay; } *

variable_types: struct obj_data { struct obj_data *next; struct obj_data *next_content; struct obj_data *contains; struct obj_data *in_obj; struct obj_data *on; struct char_data { struct char_data *next; struct char_data *next_in_room; struct char_data *master; struct char_data *leader; struct char_data *fighting; struct char_data *reply; struct char_data *pet; struct char_data *mprog_target; struct mem_data { struct mem_data *next; unsigned char valid; int id; int reaction; long when; } *memory; unsigned char (*spec_fun)(struct char_data *ch); struct mob_index_data { struct mob_index_data *next; unsigned char (*spec_fun)(struct char_data *ch); struct shop_data { struct shop_data *next; short keeper; short buy_type[5]; short profit_buy; short profit_sell; short open_hour; short close_hour; } *pShop; struct mprog_list { int trig_type; char *trig_phrase; short vnum; char *code; struct mprog_list *next; unsigned char valid; } *mprogs; struct area_data { struct area_data *next; struct help_area_data { struct help_area_data *next; struct help_data { struct help_data *next; struct help_data *next_area; short level; char *keyword; char *text; } *first; struct help_data *last; struct area_data *area; char *filename; unsigned char changed; } *helps; char *file_name; char *name; char *credits; short age; short nplayer; short low_range; short high_range; short min_vnum; short max_vnum; unsigned char empty; char *builders; int vnum; int area_flags; int security; } *area; short vnum; short group; unsigned char new_format; short count; short killed; char *player_name; char *short_descr; char *long_descr; char *description; long act; long affected_by; short alignment; short level; short hitroll; short hit[3]; short mana[3]; short damage[3]; short ac[4]; short dam_type; long off_flags; long imm_flags; long res_flags; long vuln_flags; short start_pos; short default_pos; short sex; short race; long wealth; long form; long parts; short size; char *material; long mprog_flags; } *pIndexData; struct descriptor_data { struct descriptor_data *next; struct descriptor_data *snoop_by; struct char_data *character; struct char_data *original; unsigned char valid; char *host; short descriptor; short connected; unsigned char fcommand; char inbuf[-1]; char incomm[256]; char inlast[256]; int repeat; char *outbuf; int outsize; int outtop; char *showstr_head; char *showstr_point; void *pEdit; char **pString; int editor; struct protocol_t { int WriteOOB; enum bool_t { false=0, true=1 } Negotiated[-1]; enum bool_t { false=0, true=1 } bIACMode; enum bool_t { false=0, true=1 } bNegotiated; enum bool_t { false=0, true=1 } bRenegotiate; enum bool_t { false=0, true=1 } bNeedMXPVersion; enum bool_t { false=0, true=1 } bBlockMXP; enum bool_t { false=0, true=1 } bTTYPE; enum bool_t { false=0, true=1 } bECHO; enum bool_t { false=0, true=1 } bNAWS; enum bool_t { false=0, true=1 } bCHARSET; enum bool_t { false=0, true=1 } bMSDP; enum bool_t { false=0, true=1 } bMSSP; enum bool_t { false=0, true=1 } bATCP; enum bool_t { false=0, true=1 } bMSP; enum bool_t { false=0, true=1 } bMXP; enum bool_t { false=0, true=1 } bMCCP; enum support_t { eUNKNOWN=0, eNO=1, eSOMETIMES=2, eYES=3 } b256Support; int ScreenWidth; int ScreenHeight; char *pMXPVersion; char *pLastTTYPE; struct MSDP_t { enum bool_t { false=0, true=1 } bReport; enum bool_t { false=0, true=1 } bDirty; int ValueInt; char *pValueString; } **pVariables; } *pProtocol; } *desc; struct affect_data { struct affect_data *next; unsigned char valid; short where; short type; short level; short duration; short location; short modifier; int bitvector; } *affected; struct note_data { struct note_data *next; unsigned char valid; short type; char *sender; char *date; char *to_list; char *subject; char *text; long date_stamp; } *pnote; struct obj_data *carrying; struct obj_data *on; struct room_index_data { struct room_index_data *next; struct char_data *people; struct obj_data *contents; struct extra_descr_data { struct extra_descr_data *next; unsigned char valid; char *keyword; char *description; } *extra_descr; struct area_data *area; struct exit_data { union { struct room_index_data *to_room; short vnum; } u1; int exit_info; short key; char *keyword; char *description; struct exit_data *next; int rs_flags; int orig_door; } *exit[6]; struct reset_data { struct reset_data *next; char command; short arg1; short arg2; short arg3; short arg4; } *reset_first; struct reset_data *reset_last; char *name; char *description; char *owner; short vnum; int room_flags; short light; short sector_type; short heal_rate; short mana_rate; short clan; } *in_room; struct room_index_data *was_in_room; struct area_data *zone; struct pc_data { struct pc_data *next; struct buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; } *buffer; unsigned char valid; char *pwd; char *bamfin; char *bamfout; char *title; long last_note; long last_idea; long last_penalty; long last_news; long last_changes; short perm_hit; short perm_mana; short perm_move; short true_sex; int last_level; short condition[4]; short learned[151]; unsigned char group_known[30]; short points; unsigned char confirm_delete; char *alias[5]; char *alias_sub[5]; int security; } *pcdata; struct gen_data { struct gen_data *next; unsigned char valid; unsigned char skill_chosen[151]; unsigned char group_chosen[30]; int points_chosen; } *gen_data; unsigned char valid; char *name; long id; short version; char *short_descr; char *long_descr; char *description; char *prompt; char *prefix; short group; short clan; short sex; short iclass; short race; short level; short trust; int played; int lines; long logon; short timer; short wait; short daze; short hit; short max_hit; short mana; short max_mana; short move; short max_move; long gold; long silver; int exp; long act; long comm; long wiznet; long imm_flags; long res_flags; long vuln_flags; short invis_level; short incog_level; long affected_by; short position; short practice; short train; short carry_weight; short carry_number; short saving_throw; short alignment; short hitroll; short damroll; short armor[4]; short wimpy; short perm_stat[5]; short mod_stat[5]; long form; long parts; short size; char *material; long off_flags; short damage[3]; short dam_type; short start_pos; short default_pos; short mprog_delay; } *carried_by; struct extra_descr_data *extra_descr; struct affect_data *affected; struct obj_index_data { struct obj_index_data *next; struct extra_descr_data *extra_descr; struct affect_data *affected; struct area_data *area; unsigned char new_format; char *name; char *short_descr; char *description; short vnum; short reset_num; char *material; short item_type; int extra_flags; int wear_flags; short level; short condition; short count; short weight; int cost; int value[5]; } *pIndexData; struct room_index_data *in_room; unsigned char valid; unsigned char enchanted; char *owner; char *name; char *short_descr; char *description; short item_type; int extra_flags; int wear_flags; short wear_loc; short weight; int cost; short level; short condition; char *material; short timer; int value[5]; } *

return_type: void


decompiled_code:
int song_update()
{
__int64 v0; // rax
__int64 *v1; // rbx
__int64 *v2; // rbx
__int64 v3; // rdx
__int64 v4; // rbp
__int64 v5; // rsi
int v6; // edx
const char *v7; // rax
__int64 v8; // rsi
__int64 v10[2]; // [rsp+0h] [rbp-1218h] BYREF
char v11[4592]; // [rsp+10h] [rbp-1208h] BYREF

v10[0] = 0LL;
v10[1] = 0LL;
memset(v11, 0, sizeof(v11));
LODWORD(v0) = channel_songs[1];
if ( (int)v0 <= 19 )
{
if ( (int)v0 >= 0 )
{
if ( channel_songs[0] <= 99 && channel_songs[0] < SLODWORD(song_table[103 * (int)v0 + 102]) )
{
if ( channel_songs[0] < 0 )
{
LODWORD(v0) = sprintf(
(char *)v10,
"Music: %s, %s",
(const char *)song_table[103 * (int)v0],
(const char *)song_table[103 * (int)v0 + 1]);
channel_songs[0] = 0;
}
else
{
LODWORD(v0) = sprintf(
(char *)v10,
"Music: '%s'",
(const char *)song_table[103 * (int)v0 + 2 + channel_songs[0]]);
++channel_songs[0];
}
v2 = (__int64 *)descriptor_list;
if ( descriptor_list )
{
do
{
v0 = v2[3];
if ( !v0 )
v0 = v2[2];
if ( !*((_WORD *)v2 + 25) && (*(_BYTE *)(v0 + 328) & 0x41) == 0 )
LODWORD(v0) = ((__int64 (__fastcall *)(const char *, __int64, __int64 *, _QWORD, __int64, __int64))act_new)(
"$t",
v2[2],
v10,
0LL,
3LL,
4LL);
v2 = (__int64 *)*v2;
}
while ( v2 );
}
}
else
{
channel_songs[0] = -1;
v0 = (unsigned int)((_DWORD)channel_songs + 4);
do
{
*(_DWORD *)v0 = *(_DWORD *)(v0 + 4);
v0 += 4LL;
}
while ( (_DWORD)channel_songs + 40 != v0 );
channel_songs[10] = -1;
}
}
}
else
{
channel_songs[1] = -1;
}
v1 = (__int64 *)object_list;
if ( object_list )
{
do
{
if ( *((_WORD *)v1 + 60) == 34 )
{
LODWORD(v0) = *((_DWORD *)v1 + 40);
if ( (int)v0 >= 0 )
{
if ( (int)v0 > 19 )
{
*((_DWORD *)v1 + 40) = -1;
}
else
{
v4 = v1[9];
if ( v4 || (v3 = v1[5]) != 0 && (v4 = *(_QWORD *)(v3 + 128)) != 0 )
{
v6 = *((_DWORD *)v1 + 39);
if ( v6 < 0 )
{
LODWORD(v0) = sprintf(
(char *)v10,
"$p starts playing %s, %s.",
(const char *)song_table[103 * (int)v0],
(const char *)song_table[103 * (int)v0 + 1]);
v5 = *(_QWORD *)(v4 + 8);
if ( v5 )
LODWORD(v0) = ((__int64 (__fastcall *)(__int64 *, __int64, __int64 *, _QWORD, __int64, __int64))act_new)(
v10,
v5,
v1,
0LL,
4LL,
5LL);
*((_DWORD *)v1 + 39) = 0;
}
else if ( v6 > 99 || v6 >= SLODWORD(song_table[103 * (int)v0 + 102]) )
{
*((_DWORD *)v1 + 39) = -1;
*((_DWORD *)v1 + 40) = *((_DWORD *)v1 + 41);
*((_DWORD *)v1 + 41) = *((_DWORD *)v1 + 42);
LODWORD(v0) = *((_DWORD *)v1 + 43);
*((_DWORD *)v1 + 42) = v0;
*((_DWORD *)v1 + 43) = -1;
}
else
{
v7 = (const char *)song_table[103 * (int)v0 + 2 + v6];
*((_DWORD *)v1 + 39) = v6 + 1;
LODWORD(v0) = sprintf((char *)v10, "$p bops: '%s'", v7);
v8 = *(_QWORD *)(v4 + 8);
if ( v8 )
LODWORD(v0) = ((__int64 (__fastcall *)(__int64 *, __int64, __int64 *, _QWORD, __int64, __int64))act_new)(
v10,
v8,
v1,
0LL,
4LL,
5LL);
}
}
}
}
}
v1 = (__int64 *)*v1;
}
while ( v1 );
}
return v0;
}

canonical_decompiled_code:
int func0()
{
__int64 v0; // rax
__int64 *v1; // rbx
__int64 *v2; // rbx
__int64 v3; // rdx
__int64 v4; // rbp
__int64 v5; // rsi
int v6; // edx
const char *v7; // rax
__int64 v8; // rsi
__int64 v10[2]; // [rsp+0h] [rbp-1218h] BYREF
char v11[4592]; // [rsp+10h] [rbp-1208h] BYREF

v10[0] = 0LL;
v10[1] = 0LL;
memset(v11, 0, sizeof(v11));
LODWORD(v0) = channel_songs[1];
if ( (int)v0 <= 19 )
{
if ( (int)v0 >= 0 )
{
if ( channel_songs[0] <= 99 && channel_songs[0] < SLODWORD(song_table[103 * (int)v0 + 102]) )
{
if ( channel_songs[0] < 0 )
{
LODWORD(v0) = sprintf(
(char *)v10,
"Music: %s, %s",
(const char *)song_table[103 * (int)v0],
(const char *)song_table[103 * (int)v0 + 1]);
channel_songs[0] = 0;
}
else
{
LODWORD(v0) = sprintf(
(char *)v10,
"Music: '%s'",
(const char *)song_table[103 * (int)v0 + 2 + channel_songs[0]]);
++channel_songs[0];
}
v2 = (__int64 *)descriptor_list;
if ( descriptor_list )
{
do
{
v0 = v2[3];
if ( !v0 )
v0 = v2[2];
if ( !*((_WORD *)v2 + 25) && (*(_BYTE *)(v0 + 328) & 0x41) == 0 )
LODWORD(v0) = ((__int64 (__fastcall *)(const char *, __int64, __int64 *, _QWORD, __int64, __int64))act_new)(
"$t",
v2[2],
v10,
0LL,
3LL,
4LL);
v2 = (__int64 *)*v2;
}
while ( v2 );
}
}
else
{
channel_songs[0] = -1;
v0 = (unsigned int)((_DWORD)channel_songs + 4);
do
{
*(_DWORD *)v0 = *(_DWORD *)(v0 + 4);
v0 += 4LL;
}
while ( (_DWORD)channel_songs + 40 != v0 );
channel_songs[10] = -1;
}
}
}
else
{
channel_songs[1] = -1;
}
v1 = (__int64 *)object_list;
if ( object_list )
{
do
{
if ( *((_WORD *)v1 + 60) == 34 )
{
LODWORD(v0) = *((_DWORD *)v1 + 40);
if ( (int)v0 >= 0 )
{
if ( (int)v0 > 19 )
{
*((_DWORD *)v1 + 40) = -1;
}
else
{
v4 = v1[9];
if ( v4 || (v3 = v1[5]) != 0 && (v4 = *(_QWORD *)(v3 + 128)) != 0 )
{
v6 = *((_DWORD *)v1 + 39);
if ( v6 < 0 )
{
LODWORD(v0) = sprintf(
(char *)v10,
"$p starts playing %s, %s.",
(const char *)song_table[103 * (int)v0],
(const char *)song_table[103 * (int)v0 + 1]);
v5 = *(_QWORD *)(v4 + 8);
if ( v5 )
LODWORD(v0) = ((__int64 (__fastcall *)(__int64 *, __int64, __int64 *, _QWORD, __int64, __int64))act_new)(
v10,
v5,
v1,
0LL,
4LL,
5LL);
*((_DWORD *)v1 + 39) = 0;
}
else if ( v6 > 99 || v6 >= SLODWORD(song_table[103 * (int)v0 + 102]) )
{
*((_DWORD *)v1 + 39) = -1;
*((_DWORD *)v1 + 40) = *((_DWORD *)v1 + 41);
*((_DWORD *)v1 + 41) = *((_DWORD *)v1 + 42);
LODWORD(v0) = *((_DWORD *)v1 + 43);
*((_DWORD *)v1 + 42) = v0;
*((_DWORD *)v1 + 43) = -1;
}
else
{
v7 = (const char *)song_table[103 * (int)v0 + 2 + v6];
*((_DWORD *)v1 + 39) = v6 + 1;
LODWORD(v0) = sprintf((char *)v10, "$p bops: '%s'", v7);
v8 = *(_QWORD *)(v4 + 8);
if ( v8 )
LODWORD(v0) = ((__int64 (__fastcall *)(__int64 *, __int64, __int64 *, _QWORD, __int64, __int64))act_new)(
v10,
v8,
v1,
0LL,
4LL,
5LL);
}
}
}
}
}
v1 = (__int64 *)*v1;
}
while ( v1 );
}
return v0;
}

original_code:
void song_update(void)
{
    OBJ_DATA *obj;
    CHAR_DATA *victim;
    ROOM_INDEX_DATA *room;
    DESCRIPTOR_DATA *d;
    char buf[4608]={'\0'};
    char *line;
    int i;
    if (channel_songs[1] >= 20)
 channel_songs[1] = -1;
    if (channel_songs[1] > -1)
    {
        if (channel_songs[0] >= 100
        || channel_songs[0] >= song_table[channel_songs[1]].lines)
        {
     channel_songs[0] = -1;
     for (i = 1; i < 10; i++)
      channel_songs[i] = channel_songs[i+1];
     channel_songs[10] = -1;
 }
 else
 {
     if (channel_songs[0] < 0)
     {
      sprintf(buf,"Music: %s, %s",
      song_table[channel_songs[1]].group,
      song_table[channel_songs[1]].name);
      channel_songs[0] = 0;
     }
     else
     {
  sprintf(buf,"Music: '%s'",
      song_table[channel_songs[1]].lyrics[channel_songs[0]]);
  channel_songs[0]++;
     }
     for (d = descriptor_list; d != ((void *)0); d = d->next)
     {
  victim = d->original ? d->original : d->character;
         if ( d->connected == 0 &&
                   !((victim->comm) & ((64))) &&
                   !((victim->comm) & ((1))) )
                  act_new("$t",d->character,buf,((void *)0),3,4);
            }
 }
    }
    for (obj = object_list; obj != ((void *)0); obj = obj->next)
    {
 if (obj->item_type != 34 || obj->value[1] < 0)
     continue;
  if (obj->value[1] >= 20)
 {
     obj->value[1] = -1;
     continue;
 }
 if ((room = obj->in_room) == ((void *)0))
 {
     if (obj->carried_by == ((void *)0))
      continue;
     else
      if ((room = obj->carried_by->in_room) == ((void *)0))
      continue;
 }
 if (obj->value[0] < 0)
 {
     sprintf(buf,"$p starts playing %s, %s.",
  song_table[obj->value[1]].group,song_table[obj->value[1]].name);
     if (room->people != ((void *)0))
  act_new((buf),(room->people),(obj),(((void *)0)),(4),5);
     obj->value[0] = 0;
     continue;
 }
 else
 {
     if (obj->value[0] >= 100
     || obj->value[0] >= song_table[obj->value[1]].lines)
     {
  obj->value[0] = -1;
  obj->value[1] = obj->value[2];
  obj->value[2] = obj->value[3];
  obj->value[3] = obj->value[4];
  obj->value[4] = -1;
  continue;
     }
     line = song_table[obj->value[1]].lyrics[obj->value[0]];
     obj->value[0]++;
 }
 sprintf(buf,"$p bops: '%s'",line);
 if (room->people != ((void *)0))
     act_new((buf),(room->people),(obj),(((void *)0)),(4),5);
    }
}

canonical_original_code:
void song_update()
{
    struct obj_data *obj;
    struct char_data *victim;
    struct room_index_data *room;
    struct descriptor_data *d;
    char buf[4608] = {'\0'};
    char *line;
    int i;
    if (channel_songs[1] >= 20)
 channel_songs[1] = -1;
    if (channel_songs[1] > -1)
    {
        if (channel_songs[0] >= 100
        || channel_songs[0] >= song_table[channel_songs[1]].lines)
        {
     channel_songs[0] = -1;
     for (i = 1; i < 10; i++)
      channel_songs[i] = channel_songs[i+1];
     channel_songs[10] = -1;
 }
 else
 {
     if (channel_songs[0] < 0)
     {
      sprintf(buf,"Music: %s, %s",
      song_table[channel_songs[1]].group,
      song_table[channel_songs[1]].name);
      channel_songs[0] = 0;
     }
     else
     {
  sprintf(buf,"Music: '%s'",
      song_table[channel_songs[1]].lyrics[channel_songs[0]]);
  channel_songs[0]++;
     }
     for (d = descriptor_list; d != ((void *)0); d = d->next)
     {
  victim = d->original ? d->original : d->character;
         if ( d->connected == 0 &&
                   !((victim->comm) & ((64))) &&
                   !((victim->comm) & ((1))) )
                  act_new("$t",d->character,buf,((void *)0),3,4);
            }
 }
    }
    for (obj = object_list; obj != ((void *)0); obj = obj->next)
    {
 if (obj->item_type != 34 || obj->value[1] < 0)
     continue;
  if (obj->value[1] >= 20)
 {
     obj->value[1] = -1;
     continue;
 }
 if ((room = obj->in_room) == ((void *)0))
 {
     if (obj->carried_by == ((void *)0))
      continue;
     else
      if ((room = obj->carried_by->in_room) == ((void *)0))
      continue;
 }
 if (obj->value[0] < 0)
 {
     sprintf(buf,"$p starts playing %s, %s.",
  song_table[obj->value[1]].group,song_table[obj->value[1]].name);
     if (room->people != ((void *)0))
  act_new((buf),(room->people),(obj),(((void *)0)),(4),5);
     obj->value[0] = 0;
     continue;
 }
 else
 {
     if (obj->value[0] >= 100
     || obj->value[0] >= song_table[obj->value[1]].lines)
     {
  obj->value[0] = -1;
  obj->value[1] = obj->value[2];
  obj->value[2] = obj->value[3];
  obj->value[3] = obj->value[4];
  obj->value[4] = -1;
  continue;
     }
     line = song_table[obj->value[1]].lyrics[obj->value[0]];
     obj->value[0]++;
 }
 sprintf(buf,"$p bops: '%s'",line);
 if (room->people != ((void *)0))
     act_new((buf),(room->people),(obj),(((void *)0)),(4),5);
    }
}

variable_types: struct descriptor_data { struct descriptor_data *next; struct descriptor_data *snoop_by; struct char_data { struct char_data *next; struct char_data *next_in_room; struct char_data *master; struct char_data *leader; struct char_data *fighting; struct char_data *reply; struct char_data *pet; struct char_data *mprog_target; struct mem_data { struct mem_data *next; unsigned char valid; int id; int reaction; long when; } *memory; unsigned char (*spec_fun)(struct char_data *ch); struct mob_index_data { struct mob_index_data *next; unsigned char (*spec_fun)(struct char_data *ch); struct shop_data { struct shop_data *next; short keeper; short buy_type[5]; short profit_buy; short profit_sell; short open_hour; short close_hour; } *pShop; struct mprog_list { int trig_type; char *trig_phrase; short vnum; char *code; struct mprog_list *next; unsigned char valid; } *mprogs; struct area_data { struct area_data *next; struct help_area_data { struct help_area_data *next; struct help_data { struct help_data *next; struct help_data *next_area; short level; char *keyword; char *text; } *first; struct help_data *last; struct area_data *area; char *filename; unsigned char changed; } *helps; char *file_name; char *name; char *credits; short age; short nplayer; short low_range; short high_range; short min_vnum; short max_vnum; unsigned char empty; char *builders; int vnum; int area_flags; int security; } *area; short vnum; short group; unsigned char new_format; short count; short killed; char *player_name; char *short_descr; char *long_descr; char *description; long act; long affected_by; short alignment; short level; short hitroll; short hit[3]; short mana[3]; short damage[3]; short ac[4]; short dam_type; long off_flags; long imm_flags; long res_flags; long vuln_flags; short start_pos; short default_pos; short sex; short race; long wealth; long form; long parts; short size; char *material; long mprog_flags; } *pIndexData; struct descriptor_data *desc; struct affect_data { struct affect_data *next; unsigned char valid; short where; short type; short level; short duration; short location; short modifier; int bitvector; } *affected; struct note_data { struct note_data *next; unsigned char valid; short type; char *sender; char *date; char *to_list; char *subject; char *text; long date_stamp; } *pnote; struct obj_data { struct obj_data *next; struct obj_data *next_content; struct obj_data *contains; struct obj_data *in_obj; struct obj_data *on; struct char_data *carried_by; struct extra_descr_data { struct extra_descr_data *next; unsigned char valid; char *keyword; char *description; } *extra_descr; struct affect_data *affected; struct obj_index_data { struct obj_index_data *next; struct extra_descr_data *extra_descr; struct affect_data *affected; struct area_data *area; unsigned char new_format; char *name; char *short_descr; char *description; short vnum; short reset_num; char *material; short item_type; int extra_flags; int wear_flags; short level; short condition; short count; short weight; int cost; int value[5]; } *pIndexData; struct room_index_data { struct room_index_data *next; struct char_data *people; struct obj_data *contents; struct extra_descr_data *extra_descr; struct area_data *area; struct exit_data { union { struct room_index_data *to_room; short vnum; } u1; int exit_info; short key; char *keyword; char *description; struct exit_data *next; int rs_flags; int orig_door; } *exit[6]; struct reset_data { struct reset_data *next; char command; short arg1; short arg2; short arg3; short arg4; } *reset_first; struct reset_data *reset_last; char *name; char *description; char *owner; short vnum; int room_flags; short light; short sector_type; short heal_rate; short mana_rate; short clan; } *in_room; unsigned char valid; unsigned char enchanted; char *owner; char *name; char *short_descr; char *description; short item_type; int extra_flags; int wear_flags; short wear_loc; short weight; int cost; short level; short condition; char *material; short timer; int value[5]; } *carrying; struct obj_data *on; struct room_index_data *in_room; struct room_index_data *was_in_room; struct area_data *zone; struct pc_data { struct pc_data *next; struct buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; } *buffer; unsigned char valid; char *pwd; char *bamfin; char *bamfout; char *title; long last_note; long last_idea; long last_penalty; long last_news; long last_changes; short perm_hit; short perm_mana; short perm_move; short true_sex; int last_level; short condition[4]; short learned[151]; unsigned char group_known[30]; short points; unsigned char confirm_delete; char *alias[5]; char *alias_sub[5]; int security; } *pcdata; struct gen_data { struct gen_data *next; unsigned char valid; unsigned char skill_chosen[151]; unsigned char group_chosen[30]; int points_chosen; } *gen_data; unsigned char valid; char *name; long id; short version; char *short_descr; char *long_descr; char *description; char *prompt; char *prefix; short group; short clan; short sex; short iclass; short race; short level; short trust; int played; int lines; long logon; short timer; short wait; short daze; short hit; short max_hit; short mana; short max_mana; short move; short max_move; long gold; long silver; int exp; long act; long comm; long wiznet; long imm_flags; long res_flags; long vuln_flags; short invis_level; short incog_level; long affected_by; short position; short practice; short train; short carry_weight; short carry_number; short saving_throw; short alignment; short hitroll; short damroll; short armor[4]; short wimpy; short perm_stat[5]; short mod_stat[5]; long form; long parts; short size; char *material; long off_flags; short damage[3]; short dam_type; short start_pos; short default_pos; short mprog_delay; } *character; struct char_data *original; unsigned char valid; char *host; short descriptor; short connected; unsigned char fcommand; char inbuf[-1]; char incomm[256]; char inlast[256]; int repeat; char *outbuf; int outsize; int outtop; char *showstr_head; char *showstr_point; void *pEdit; char **pString; int editor; struct protocol_t { int WriteOOB; enum bool_t { false=0, true=1 } Negotiated[-1]; enum bool_t { false=0, true=1 } bIACMode; enum bool_t { false=0, true=1 } bNegotiated; enum bool_t { false=0, true=1 } bRenegotiate; enum bool_t { false=0, true=1 } bNeedMXPVersion; enum bool_t { false=0, true=1 } bBlockMXP; enum bool_t { false=0, true=1 } bTTYPE; enum bool_t { false=0, true=1 } bECHO; enum bool_t { false=0, true=1 } bNAWS; enum bool_t { false=0, true=1 } bCHARSET; enum bool_t { false=0, true=1 } bMSDP; enum bool_t { false=0, true=1 } bMSSP; enum bool_t { false=0, true=1 } bATCP; enum bool_t { false=0, true=1 } bMSP; enum bool_t { false=0, true=1 } bMXP; enum bool_t { false=0, true=1 } bMCCP; enum support_t { eUNKNOWN=0, eNO=1, eSOMETIMES=2, eYES=3 } b256Support; int ScreenWidth; int ScreenHeight; char *pMXPVersion; char *pLastTTYPE; struct MSDP_t { enum bool_t { false=0, true=1 } bReport; enum bool_t { false=0, true=1 } bDirty; int ValueInt; char *pValueString; } **pVariables; } *pProtocol; } *

variable_types:
buf
char [4608]

variable_types:
line
char *

variable_types: i int


decompiled_code:
__int64 __fastcall do_play(__int64 a1, _BYTE *a2)
{
_BYTE *v2; // r14
__int64 v3; // rbx
__int64 result; // rax
char v5; // r15
__int64 v6; // r13
char v7; // r14
char v8; // r15
__int64 v9; // rax
const char **v10; // rbx
__int64 v11; // rax
unsigned __int64 v12; // r13
int v13; // er12
char v14; // [rsp+4h] [rbp-1344h]
char *v15; // [rsp+8h] [rbp-1340h]
char s[8]; // [rsp+10h] [rbp-1338h] BYREF
__int64 v17; // [rsp+18h] [rbp-1330h]
char v18[4592]; // [rsp+20h] [rbp-1328h] BYREF
char v19[312]; // [rsp+1210h] [rbp-138h] BYREF

v2 = (_BYTE *)one_argument(a2, v19);
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 128) + 16LL);
if ( v3 )
{
while ( *(_WORD *)(v3 + 120) != 34 || !(unsigned __int8)can_see_obj(a1, v3) )
{
v3 = *(_QWORD *)(v3 + 8);
if ( !v3 )
goto LABEL_2;
}
if ( !*a2 )
return send_to_char("Play what?\n\r", a1);
if ( !(unsigned __int8)_strcmp(v19, "list", "music.c", "do_play", 243LL) )
{
*(_QWORD *)s = 0LL;
v17 = 0LL;
memset(v18, 0, sizeof(v18));
v6 = _new_buf("music.c", "do_play", 250LL);
v15 = (char *)one_argument(v2, v19);
v7 = _strcmp(v19, "artist", "music.c", "do_play", 254LL);
v8 = *v15;
sprintf(s, "%s has the following songs available:\n\r", *(const char **)(v3 + 104));
v9 = capitalize(s);
add_buf(v6, v9);
v10 = (const char **)(unsigned int)((_DWORD)song_table + 8);
v14 = 0;
do
{
if ( !*v10 )
break;
if ( v7 )
{
if ( !v8 || !(unsigned __int8)str_prefix(v15) )
{
sprintf(s, "%-35s ", *v10);
add_buf(v6, s);
if ( (++v14 & 1) == 0 )
add_buf(v6, "\n\r");
}
}
else if ( !v8 || !(unsigned __int8)str_prefix(v15) )
{
sprintf(s, "%-39s %-39s\n\r", *(v10 - 1), *v10);
add_buf(v6, s);
}
v10 += 103;
}
while ( v10 != (const char **)&song_table[2061] );
if ( v7 && (v14 & 1) != 0 )
add_buf(v6, "\n\r");
v11 = buf_string(v6);
page_to_char(v11, a1);
return free_buf(v6);
}
if ( !(unsigned __int8)_strcmp(v19, "loud", "music.c", "do_play", 290LL) )
{
if ( !*v2 )
return send_to_char("Play what?\n\r", a1);
v5 = 1;
if ( channel_songs[10] >= 0 )
return send_to_char("The jukebox is full up right now.\n\r", a1);
}
else
{
if ( !*a2 )
return send_to_char("Play what?\n\r", a1);
v2 = a2;
v5 = 0;
if ( *(int *)(v3 + 172) >= 0 )
return send_to_char("The jukebox is full up right now.\n\r", a1);
}
v12 = (unsigned int)((_DWORD)song_table + 8);
v13 = 0;
while ( 1 )
{
if ( !*(_QWORD *)v12 )
return send_to_char("That song isn't available.\n\r", a1);
if ( !(unsigned __int8)str_prefix(v2) )
break;
++v13;
v12 += 824LL;
if ( v13 == 20 )
return send_to_char("That song isn't available.\n\r", a1);
}
if ( v13 > 19 )
return send_to_char("That song isn't available.\n\r", a1);
send_to_char("Coming right up.\n\r", a1);
if ( v5 )
{
result = 1LL;
while ( channel_songs[result] >= 0 )
{
if ( ++result == 11 )
return result;
}
if ( (_DWORD)result == 1 )
channel_songs[0] = -1;
channel_songs[(int)result] = v13;
}
else
{
result = 1LL;
while ( *(int *)(v3 + 4 * result + 156) >= 0 )
{
if ( ++result == 5 )
return result;
}
if ( (_DWORD)result == 1 )
*(_DWORD *)(v3 + 156) = -1;
*(_DWORD *)(v3 + 4LL * (int)result + 156) = v13;
}
return result;
}
LABEL_2:
if ( !*a2 )
return send_to_char("Play what?\n\r", a1);
return send_to_char("You see nothing to play.\n\r", a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _BYTE *a2)
{
_BYTE *v2; // r14
__int64 v3; // rbx
__int64 result; // rax
char v5; // r15
__int64 v6; // r13
char v7; // r14
char v8; // r15
__int64 v9; // rax
const char **v10; // rbx
__int64 v11; // rax
unsigned __int64 v12; // r13
int v13; // er12
char v14; // [rsp+4h] [rbp-1344h]
char *v15; // [rsp+8h] [rbp-1340h]
char s[8]; // [rsp+10h] [rbp-1338h] BYREF
__int64 v17; // [rsp+18h] [rbp-1330h]
char v18[4592]; // [rsp+20h] [rbp-1328h] BYREF
char v19[312]; // [rsp+1210h] [rbp-138h] BYREF

v2 = (_BYTE *)one_argument(a2, v19);
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 128) + 16LL);
if ( v3 )
{
while ( *(_WORD *)(v3 + 120) != 34 || !(unsigned __int8)can_see_obj(a1, v3) )
{
v3 = *(_QWORD *)(v3 + 8);
if ( !v3 )
goto LABEL_2;
}
if ( !*a2 )
return send_to_char("Play what?\n\r", a1);
if ( !(unsigned __int8)_strcmp(v19, "list", "music.c", "do_play", 243LL) )
{
*(_QWORD *)s = 0LL;
v17 = 0LL;
memset(v18, 0, sizeof(v18));
v6 = _new_buf("music.c", "do_play", 250LL);
v15 = (char *)one_argument(v2, v19);
v7 = _strcmp(v19, "artist", "music.c", "do_play", 254LL);
v8 = *v15;
sprintf(s, "%s has the following songs available:\n\r", *(const char **)(v3 + 104));
v9 = capitalize(s);
add_buf(v6, v9);
v10 = (const char **)(unsigned int)((_DWORD)song_table + 8);
v14 = 0;
do
{
if ( !*v10 )
break;
if ( v7 )
{
if ( !v8 || !(unsigned __int8)str_prefix(v15) )
{
sprintf(s, "%-35s ", *v10);
add_buf(v6, s);
if ( (++v14 & 1) == 0 )
add_buf(v6, "\n\r");
}
}
else if ( !v8 || !(unsigned __int8)str_prefix(v15) )
{
sprintf(s, "%-39s %-39s\n\r", *(v10 - 1), *v10);
add_buf(v6, s);
}
v10 += 103;
}
while ( v10 != (const char **)&song_table[2061] );
if ( v7 && (v14 & 1) != 0 )
add_buf(v6, "\n\r");
v11 = buf_string(v6);
page_to_char(v11, a1);
return free_buf(v6);
}
if ( !(unsigned __int8)_strcmp(v19, "loud", "music.c", "do_play", 290LL) )
{
if ( !*v2 )
return send_to_char("Play what?\n\r", a1);
v5 = 1;
if ( channel_songs[10] >= 0 )
return send_to_char("The jukebox is full up right now.\n\r", a1);
}
else
{
if ( !*a2 )
return send_to_char("Play what?\n\r", a1);
v2 = a2;
v5 = 0;
if ( *(int *)(v3 + 172) >= 0 )
return send_to_char("The jukebox is full up right now.\n\r", a1);
}
v12 = (unsigned int)((_DWORD)song_table + 8);
v13 = 0;
while ( 1 )
{
if ( !*(_QWORD *)v12 )
return send_to_char("That song isn't available.\n\r", a1);
if ( !(unsigned __int8)str_prefix(v2) )
break;
++v13;
v12 += 824LL;
if ( v13 == 20 )
return send_to_char("That song isn't available.\n\r", a1);
}
if ( v13 > 19 )
return send_to_char("That song isn't available.\n\r", a1);
send_to_char("Coming right up.\n\r", a1);
if ( v5 )
{
result = 1LL;
while ( channel_songs[result] >= 0 )
{
if ( ++result == 11 )
return result;
}
if ( (_DWORD)result == 1 )
channel_songs[0] = -1;
channel_songs[(int)result] = v13;
}
else
{
result = 1LL;
while ( *(int *)(v3 + 4 * result + 156) >= 0 )
{
if ( ++result == 5 )
return result;
}
if ( (_DWORD)result == 1 )
*(_DWORD *)(v3 + 156) = -1;
*(_DWORD *)(v3 + 4LL * (int)result + 156) = v13;
}
return result;
}
LABEL_2:
if ( !*a2 )
return send_to_char("Play what?\n\r", a1);
return send_to_char("You see nothing to play.\n\r", a1);
}

original_code:
void do_play(CHAR_DATA *ch, char *argument)
{
    OBJ_DATA *juke;
    char *str,arg[256];
    int song,i;
    bool global = 0;
    str = one_argument(argument,arg);
    for (juke = ch->in_room->contents; juke != ((void *)0); juke = juke->next_content)
 if (juke->item_type == 34 && can_see_obj(ch,juke))
     break;
    if (argument[0] == '\0')
    {
 send_to_char("Play what?\n\r",ch);
 return;
    }
    if (juke == ((void *)0))
    {
 send_to_char("You see nothing to play.\n\r",ch);
 return;
    }
    if (!__strcmp(arg, "list", "music.c", __FUNCTION__, 243))
    {
 BUFFER *buffer;
   char buf[4608]={'\0'};
 int col = 0;
 bool artist = 0, match = 0;
 buffer = __new_buf("music.c", __FUNCTION__, 250);
 argument = str;
 argument = one_argument(argument,arg);
 if (!__strcmp(arg, "artist", "music.c", __FUNCTION__, 254))
     artist = 1;
 if (argument[0] != '\0')
     match = 1;
 sprintf(buf,"%s has the following songs available:\n\r",
     juke->short_descr);
 add_buf(buffer,capitalize(buf));
 for (i = 0; i < 20; i++)
 {
     if (song_table[i].name == ((void *)0))
  break;
     if (artist && (!match
     || !str_prefix(argument,song_table[i].group)))
  sprintf(buf,"%-39s %-39s\n\r",
      song_table[i].group,song_table[i].name);
     else if (!artist && (!match
     || !str_prefix(argument,song_table[i].name)))
      sprintf(buf,"%-35s ",song_table[i].name);
     else
  continue;
     add_buf(buffer,buf);
     if (!artist && ++col % 2 == 0)
  add_buf(buffer,"\n\r");
        }
        if (!artist && col % 2 != 0)
     add_buf(buffer,"\n\r");
 page_to_char(buf_string(buffer),ch);
 free_buf(buffer);
 return;
    }
    if (!__strcmp(arg, "loud", "music.c", __FUNCTION__, 290))
    {
        argument = str;
        global = 1;
    }
    if (argument[0] == '\0')
    {
        send_to_char("Play what?\n\r",ch);
        return;
    }
    if ((global && channel_songs[10] > -1)
    || (!global && juke->value[4] > -1))
    {
        send_to_char("The jukebox is full up right now.\n\r",ch);
        return;
    }
    for (song = 0; song < 20; song++)
    {
 if (song_table[song].name == ((void *)0))
 {
     send_to_char("That song isn't available.\n\r",ch);
     return;
 }
 if (!str_prefix(argument,song_table[song].name))
     break;
    }
    if (song >= 20)
    {
 send_to_char("That song isn't available.\n\r",ch);
 return;
    }
    send_to_char("Coming right up.\n\r",ch);
    if (global)
    {
 for (i = 1; i <= 10; i++)
     if (channel_songs[i] < 0)
     {
  if (i == 1)
      channel_songs[0] = -1;
  channel_songs[i] = song;
  return;
     }
    }
    else
    {
 for (i = 1; i < 5; i++)
     if (juke->value[i] < 0)
     {
  if (i == 1)
      juke->value[0] = -1;
  juke->value[i] = song;
  return;
      }
    }
}

canonical_original_code:
void do_play(struct char_data *ch, char *argument)
{
    struct obj_data *juke;
    char *str; char arg[256];
    int song; int i;
    unsigned char global = 0;
    str = one_argument(argument,arg);
    for (juke = ch->in_room->contents; juke != ((void *)0); juke = juke->next_content)
 if (juke->item_type == 34 && can_see_obj(ch,juke))
     break;
    if (argument[0] == '\0')
    {
 send_to_char("Play what?\n\r",ch);
 return;
    }
    if (juke == ((void *)0))
    {
 send_to_char("You see nothing to play.\n\r",ch);
 return;
    }
    if (!__strcmp(arg, "list", "music.c", __FUNCTION__, 243))
    {
 struct buf_type *buffer;
   char buf[4608] = {'\0'};
 int col = 0;
 unsigned char artist = 0; unsigned char match = 0;
 buffer = __new_buf("music.c", __FUNCTION__, 250);
 argument = str;
 argument = one_argument(argument,arg);
 if (!__strcmp(arg, "artist", "music.c", __FUNCTION__, 254))
     artist = 1;
 if (argument[0] != '\0')
     match = 1;
 sprintf(buf,"%s has the following songs available:\n\r",
     juke->short_descr);
 add_buf(buffer,capitalize(buf));
 for (i = 0; i < 20; i++)
 {
     if (song_table[i].name == ((void *)0))
  break;
     if (artist && (!match
     || !str_prefix(argument,song_table[i].group)))
  sprintf(buf,"%-39s %-39s\n\r",
      song_table[i].group,song_table[i].name);
     else if (!artist && (!match
     || !str_prefix(argument,song_table[i].name)))
      sprintf(buf,"%-35s ",song_table[i].name);
     else
  continue;
     add_buf(buffer,buf);
     if (!artist && ++col % 2 == 0)
  add_buf(buffer,"\n\r");
        }
        if (!artist && col % 2 != 0)
     add_buf(buffer,"\n\r");
 page_to_char(buf_string(buffer),ch);
 free_buf(buffer);
 return;
    }
    if (!__strcmp(arg, "loud", "music.c", __FUNCTION__, 290))
    {
        argument = str;
        global = 1;
    }
    if (argument[0] == '\0')
    {
        send_to_char("Play what?\n\r",ch);
        return;
    }
    if ((global && channel_songs[10] > -1)
    || (!global && juke->value[4] > -1))
    {
        send_to_char("The jukebox is full up right now.\n\r",ch);
        return;
    }
    for (song = 0; song < 20; song++)
    {
 if (song_table[song].name == ((void *)0))
 {
     send_to_char("That song isn't available.\n\r",ch);
     return;
 }
 if (!str_prefix(argument,song_table[song].name))
     break;
    }
    if (song >= 20)
    {
 send_to_char("That song isn't available.\n\r",ch);
 return;
    }
    send_to_char("Coming right up.\n\r",ch);
    if (global)
    {
 for (i = 1; i <= 10; i++)
     if (channel_songs[i] < 0)
     {
  if (i == 1)
      channel_songs[0] = -1;
  channel_songs[i] = song;
  return;
     }
    }
    else
    {
 for (i = 1; i < 5; i++)
     if (juke->value[i] < 0)
     {
  if (i == 1)
      juke->value[0] = -1;
  juke->value[i] = song;
  return;
      }
    }
}

variable_types:
str
char *

variable_types:
arg
char [256]

variable_types: song int

variable_types:
global
unsigned char

variable_types: struct buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; } *

variable_types: col int

variable_types:
artist
unsigned char

variable_types:
match
unsigned char

user_defined_types: struct mem_data { struct mem_data *next; unsigned char valid; int id; int reaction; long when; }

user_defined_types: struct affect_data { struct affect_data *next; unsigned char valid; short where; short type; short level; short duration; short location; short modifier; int bitvector; }

user_defined_types: struct note_data { struct note_data *next; unsigned char valid; short type; char *sender; char *date; char *to_list; char *subject; char *text; long date_stamp; }

user_defined_types: struct gen_data { struct gen_data *next; unsigned char valid; unsigned char skill_chosen[151]; unsigned char group_chosen[30]; int points_chosen; }

user_defined_types: struct obj_index_data { struct obj_index_data *next; struct extra_descr_data *extra_descr; struct affect_data *affected; struct area_data *area; unsigned char new_format; char *name; char *short_descr; char *description; short vnum; short reset_num; char *material; short item_type; int extra_flags; int wear_flags; short level; short condition; short count; short weight; int cost; int value[5]; }

user_defined_types: struct shop_data { struct shop_data *next; short keeper; short buy_type[5]; short profit_buy; short profit_sell; short open_hour; short close_hour; }

user_defined_types: struct mprog_list { int trig_type; char *trig_phrase; short vnum; char *code; struct mprog_list *next; unsigned char valid; }

user_defined_types: struct extra_descr_data { struct extra_descr_data *next; unsigned char valid; char *keyword; char *description; }

user_defined_types: enum support_t { eUNKNOWN=0, eNO=1, eSOMETIMES=2, eYES=3 }

user_defined_types: struct reset_data { struct reset_data *next; char command; short arg1; short arg2; short arg3; short arg4; }

user_defined_types: struct exit_data { union { struct room_index_data *to_room; short vnum; } u1; int exit_info; short key; char *keyword; char *description; struct exit_data *next; int rs_flags; int orig_door; }

user_defined_types: struct help_data { struct help_data *next; struct help_data *next_area; short level; char *keyword; char *text; }