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

result = inform_user("* Client exit\n");
gDoExit = 1;
return result;
}

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

result = inform_user("* Client exit\n");
gDoExit = 1;
return result;
}

original_code:
void client_exit(int sig)
{
    inform_user("* Client exit\n");
    gDoExit = 1;
}

variable_types: sig int


repo: ptorpman/threet

decompiled_code:
void __fastcall __noreturn tp_thread(void *a1, double a2)
{
struct timeval anonymous0; // [rsp+0h] [rbp+0h] BYREF
struct timeval tv; // [rsp+10h] [rbp+10h] BYREF

gettimeofday(&anonymous0, 0LL);
while ( 1 )
{
gettimeofday(&tv, 0LL);
usleep((__useconds_t)&unk_F4240);
if ( gDoExit )
break;
report_statistics(&anonymous0, &tv, gClients, *(unsigned int *)(gAppArgs + 272), *(unsigned int *)(gAppArgs + 284));
if ( !*(_WORD *)(gAppArgs + 280) )
adjust_traffic(a2);
}
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(void *a1, double a2)
{
struct timeval anonymous0; // [rsp+0h] [rbp+0h] BYREF
struct timeval tv; // [rsp+10h] [rbp+10h] BYREF

gettimeofday(&anonymous0, 0LL);
while ( 1 )
{
gettimeofday(&tv, 0LL);
usleep((__useconds_t)&unk_F4240);
if ( gDoExit )
break;
report_statistics(&anonymous0, &tv, gClients, *(unsigned int *)(gAppArgs + 272), *(unsigned int *)(gAppArgs + 284));
if ( !*(_WORD *)(gAppArgs + 280) )
func5(a2);
}
pthread_exit(0LL);
}

original_code:
static void*
tp_thread(void* data)
{
    struct timeval startTime;
    struct timeval measurementStartTime;
    gettimeofday(&startTime, ((void *)0));
    while (1) {
        gettimeofday(&measurementStartTime, ((void *)0));
        usleep(1000000);
        if (gDoExit) {
            break;
        }
        double bitsPerSecNow = report_statistics(&startTime, &measurementStartTime,
                                                 gClients, gAppArgs->numConnections,
                                                 gAppArgs->processId);
        if (gAppArgs->packetSize == 0) {
            adjust_traffic(bitsPerSecNow);
        }
    }
    pthread_exit(((void *)0));
}

canonical_original_code:
static void *tp_thread(void *data)
{
    struct timeval startTime;
    struct timeval measurementStartTime;
    gettimeofday(&startTime, ((void *)0));
    while (1) {
        gettimeofday(&measurementStartTime, ((void *)0));
        usleep(1000000);
        if (gDoExit) {
            break;
        }
        double bitsPerSecNow = report_statistics(&startTime, &measurementStartTime,
                                                 gClients, gAppArgs->numConnections,
                                                 gAppArgs->processId);
        if (gAppArgs->packetSize == 0) {
            adjust_traffic(bitsPerSecNow);
        }
    }
    pthread_exit(((void *)0));
}

variable_types:
data
void *

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: bitsPerSecNow double

return_type: void *


decompiled_code:
__int64 get_aggregator_port()
{
return (unsigned int)dword_154;
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned int)dword_154;
}

original_code:
int
get_aggregator_port(void)
{
    return gAppArgs.aggregatorPort;
}

canonical_original_code:
int get_aggregator_port()
{
    return gAppArgs.aggregatorPort;
}

return_type: int


decompiled_code:
__int64 print_version()
{
return inform_user(
"conntest (Torpman's Test Tools) 0.1\n"
"Copyright (C) 2012-2022 Peter Torpman (peter@torpman.se)\n"
"This is free software. \n"
"You may redistribute copies of it under the terms of the GNU General Public License \n"
"<http://www.gnu.org/licenses/gpl.html>.\n"
"There is NO WARRANTY, to the extent permitted by law.\n");
}

canonical_decompiled_code:
__int64 func0()
{
return inform_user(
"conntest (Torpman's Test Tools) 0.1\n"
"Copyright (C) 2012-2022 Peter Torpman (peter@torpman.se)\n"
"This is free software. \n"
"You may redistribute copies of it under the terms of the GNU General Public License \n"
"<http://www.gnu.org/licenses/gpl.html>.\n"
"There is NO WARRANTY, to the extent permitted by law.\n");
}

original_code:
static void
print_version(void)
{
    inform_user("conntest (Torpman's Test Tools) 0.1\n"
                "Copyright (C) 2012-2022 Peter Torpman (peter@torpman.se)\n"
                "This is free software.  \nYou may redistribute copies of it under "
                "the terms of the GNU General Public License \n"
                "<http://www.gnu.org/licenses/gpl.html>.\n"
                "There is NO WARRANTY, to the extent permitted by law.\n");
}

canonical_original_code:
static void print_version()
{
    inform_user("conntest (Torpman's Test Tools) 0.1\n"
                "Copyright (C) 2012-2022 Peter Torpman (peter@torpman.se)\n"
                "This is free software.  \nYou may redistribute copies of it under "
                "the terms of the GNU General Public License \n"
                "<http://www.gnu.org/licenses/gpl.html>.\n"
                "There is NO WARRANTY, to the extent permitted by law.\n");
}

return_type: void


decompiled_code:
__int64 print_usage()
{
return inform_user(
"Usage: conntest [options]\n"
" Options:\n"
" -id <num> Process ID.\n"
" -s Server mode\n"
" -c Client mode\n"
" -a <port> Aggregator port\n"
" -n <num> Number of connections.\n"
" -t <kbps> Throughput to aim for in kbps\n"
" -l <hostip> Host IP address\n"
" -p <port> Server port number. (Used as base port for UDP communication)\n"
" -z <size> Packet size\n"
" -udp Use UDP communication\n"
" -v Display version information\n"
" -h Display this text\n"
"\n"
"For bug reporting and suggestions, mail peter@torpman.se\n");
}

canonical_decompiled_code:
__int64 func1()
{
return inform_user(
"Usage: conntest [options]\n"
" Options:\n"
" -id <num> Process ID.\n"
" -s Server mode\n"
" -c Client mode\n"
" -a <port> Aggregator port\n"
" -n <num> Number of connections.\n"
" -t <kbps> Throughput to aim for in kbps\n"
" -l <hostip> Host IP address\n"
" -p <port> Server port number. (Used as base port for UDP communication)\n"
" -z <size> Packet size\n"
" -udp Use UDP communication\n"
" -v Display version information\n"
" -h Display this text\n"
"\n"
"For bug reporting and suggestions, mail peter@torpman.se\n");
}

original_code:
static void
print_usage(void)
{
    inform_user("Usage: conntest [options]\n"
                "  Options:\n"
                "  -id <num>   Process ID.\n"
                "  -s          Server mode\n"
                "  -c          Client mode\n"
                "  -a <port>   Aggregator port\n"
                "  -n <num>    Number of connections.\n"
                "  -t <kbps>   Throughput to aim for in kbps\n"
                "  -l <hostip> Host IP address\n"
                "  -p <port>   Server port number. (Used as base port for UDP communication)\n"
                "  -z <size>   Packet size\n"
                "  -udp        Use UDP communication\n"
                "  -v          Display version information\n"
                "  -h          Display this text\n\n"
                "For bug reporting and suggestions, mail peter@torpman.se\n");
}

canonical_original_code:
static void print_usage()
{
    inform_user("Usage: conntest [options]\n"
                "  Options:\n"
                "  -id <num>   Process ID.\n"
                "  -s          Server mode\n"
                "  -c          Client mode\n"
                "  -a <port>   Aggregator port\n"
                "  -n <num>    Number of connections.\n"
                "  -t <kbps>   Throughput to aim for in kbps\n"
                "  -l <hostip> Host IP address\n"
                "  -p <port>   Server port number. (Used as base port for UDP communication)\n"
                "  -z <size>   Packet size\n"
                "  -udp        Use UDP communication\n"
                "  -v          Display version information\n"
                "  -h          Display this text\n\n"
                "For bug reporting and suggestions, mail peter@torpman.se\n");
}


main

canonical_name: main

original_code:
int
main(int argc, char **argv)
{
    memset(&gAppArgs, 0, sizeof(app_arg_t));
    strcpy(gAppArgs.serverIp, "127.0.0.1");
    int i = 1;
    int val = 0;
    int procId = -1;
    if (argc < 2)
    {
        print_usage ();
        return 0;
    }
    while (i < argc)
    {
        if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
            print_usage ();
            return 0;
        }
        else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
            print_version();
            return 0;
        }
        else if (!strcmp(argv[i], "-s")) {
            gAppArgs.isServer = 1;
            i++;
            continue;
        }
        else if (!strcmp(argv[i], "-c")) {
            gAppArgs.isServer = 0;
            i++;
            continue;
        }
        else if (!strcmp(argv[i], "-udp")) {
            gAppArgs.useUdp = 1;
            i++;
            continue;
        }
        else if (!strcmp(argv[i], "-id")) {
            if (argv[i + 1] == ((void *)0)) {
                print_usage();
                return 1;
            }
            if (sscanf(argv[i + 1], "%d", &val) != 1) {
                inform_user ("ERROR: Incorrect process ID '%s'\n", argv[i + 1]);
                return 1;
            }
            gAppArgs.processId = val;
            i += 2;
            continue;
        }
        else if (!strcmp(argv[i], "-a")) {
            if (argv[i + 1] == ((void *)0)) {
                print_usage();
                return 1;
            }
            if (sscanf(argv[i + 1], "%d", &val) != 1) {
                inform_user("ERROR: Incorrect aggregator port '%s'\n",
                            argv[i + 1]);
                return 1;
            }
            gAppArgs.aggregatorPort = val;
            i += 2;
            continue;
        }
        else if (!strcmp(argv[i], "-n")) {
            if (argv[i + 1] == ((void *)0)) {
                print_usage();
                return 1;
            }
            if (sscanf(argv[i + 1], "%u", &val) != 1) {
                inform_user("ERROR: Incorrect number of connections '%s'\n",
                            argv[i + 1]);
                return 1;
            }
            gAppArgs.numConnections = val;
            i += 2;
            continue;
        }
        else if (!strcmp(argv[i], "-t")) {
            if (argv[i + 1] == ((void *)0)) {
                print_usage();
                return 1;
            }
            if (sscanf(argv[i + 1], "%u", &val) != 1) {
                inform_user("ERROR: Incorrect throughput '%s'\n", argv[i + 1]);
                return 1;
            }
            gAppArgs.wantedThroughput = val;
            i += 2;
            continue;
        }
        else if (!strcmp(argv[i], "-z")) {
            if (argv[i + 1] == ((void *)0)) {
                print_usage();
                return 1;
            }
            if (sscanf(argv[i + 1], "%u", &val) != 1) {
                inform_user("ERROR: Incorrect packet size '%s'\n",
                            argv[i + 1]);
                return 1;
            }
            if ((val - (14 + 4)) <= 0) {
                inform_user("ERROR: Packet size minus ethernet header size is <= 0'%s'\n",
                            argv[i + 1]);
                return 1;
            }
            gAppArgs.packetSize = val;
            i += 2;
            continue;
        }
        else if (!strcmp(argv[i], "-l")) {
            if (argv[i + 1] == ((void *)0)) {
                print_usage();
                return 1;
            }
            strcpy(gAppArgs.serverIp, argv[i + 1]);
            i += 2;
            continue;
        }
        else if (!strcmp(argv[i], "-p")) {
            if (argv[i + 1] == ((void *)0)) {
                print_usage();
                return 1;
            }
            if (sscanf (argv[i + 1], "%u", &val) != 1) {
                inform_user("ERROR: Incorrect server port '%s'\n",
                            argv[i + 1]);
                return 1;
            }
            gAppArgs.serverPort = val;
            i += 2;
            continue;
        }
        else {
            inform_user("Bad parameter! (%s)\n", argv[i]);
            print_usage();
            return 1;
        }
    }
    if (gAppArgs.processId == -1) {
        inform_user("ERROR: Process ID not specified!\n");
        print_usage();
        return 1;
    }
    if (gAppArgs.isServer) {
        server_start(&gAppArgs);
    }
    else {
        signal(15, client_exit);
        signal(2, client_exit);
        client_start(&gAppArgs);
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int

variable_types: val int

variable_types: procId int


decompiled_code:
void __fastcall __noreturn udp_recv_thread(void *a1)
{
pthread_mutex_t *v1; // r15
int v2; // eax
int v3; // ebx
socklen_t addr_len; // [rsp+Ch] [rbp-1004Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-10048h] BYREF
char buf[65592]; // [rsp+20h] [rbp-10038h] BYREF

v1 = (pthread_mutex_t *)((char *)a1 + 24);
while ( 1 )
{
v2 = recvfrom(*(_DWORD *)a1, buf, 0xFFFFuLL, 0, &addr, &addr_len);
if ( v2 > 0 )
{
v3 = v2;
pthread_mutex_lock(v1);
*((_QWORD *)a1 + 9) += v3;
*((_QWORD *)a1 + 8) += v3;
pthread_mutex_unlock(v1);
}
else if ( !v2 )
{
pthread_exit(a1);
}
}
}

canonical_decompiled_code:
void __fastcall __noreturn func0(void *a1)
{
pthread_mutex_t *v1; // r15
int v2; // eax
int v3; // ebx
socklen_t addr_len; // [rsp+Ch] [rbp-1004Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-10048h] BYREF
char buf[65592]; // [rsp+20h] [rbp-10038h] BYREF

v1 = (pthread_mutex_t *)((char *)a1 + 24);
while ( 1 )
{
v2 = recvfrom(*(_DWORD *)a1, buf, 0xFFFFuLL, 0, &addr, &addr_len);
if ( v2 > 0 )
{
v3 = v2;
pthread_mutex_lock(v1);
*((_QWORD *)a1 + 9) += v3;
*((_QWORD *)a1 + 8) += v3;
pthread_mutex_unlock(v1);
}
else if ( !v2 )
{
pthread_exit(a1);
}
}
}

original_code:
static void*
udp_recv_thread(void* data)
{
    client_data_t* cliData = (client_data_t*)data;
    char buff[0xFFFF];
    size_t buffLen = 0xFFFF;
    int res = 0;
    struct sockaddr_in sockAddr;
    socklen_t addrLen;
    while (1) {
        res = recvfrom(cliData->sock, buff, buffLen, 0, (struct sockaddr*) &sockAddr, &addrLen);
        if (res > 0) {
            pthread_mutex_lock(&cliData->mutex);
            cliData->numSinceMeasure += res;
            cliData->numSinceStart += res;
            pthread_mutex_unlock(&cliData->mutex);
        }
        if (res == 0) {
            pthread_exit(cliData);
        }
    }
    pthread_exit(cliData);
}

canonical_original_code:
static void *udp_recv_thread(void *data)
{
    struct client_data_t *cliData = (client_data_t*)data;
    char buff[65535];
    unsigned long buffLen = 0xFFFF;
    int res = 0;
    struct sockaddr_in sockAddr;
    unsigned int addrLen;
    while (1) {
        res = recvfrom(cliData->sock, buff, buffLen, 0, (struct sockaddr *) &sockAddr, &addrLen);
        if (res > 0) {
            pthread_mutex_lock(&cliData->mutex);
            cliData->numSinceMeasure += res;
            cliData->numSinceStart += res;
            pthread_mutex_unlock(&cliData->mutex);
        }
        if (res == 0) {
            pthread_exit(cliData);
        }
    }
    pthread_exit(cliData);
}

variable_types: struct client_data_t { int sock; int clientNum; int port; unsigned long thread; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; unsigned long numSinceStart; unsigned long numSinceMeasure; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } serverAddress; } *

variable_types:
buff
char [65535]

variable_types:
buffLen
unsigned long

variable_types: res int

variable_types:
addrLen
unsigned int

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct client_data_t { int sock; int clientNum; int port; unsigned long thread; union pthread_mutex_t mutex; unsigned long numSinceStart; unsigned long numSinceMeasure; struct sockaddr_in serverAddress; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
__int64 __fastcall udp_create_servers(__int64 a1, int a2, unsigned int a3)
{
__int64 v4; // r12
__int64 i; // rbp
char *v6; // rax
void *v7; // rbx
__int64 v8; // rdi
int v9; // eax

if ( !a3 )
return 0LL;
v4 = a3;
for ( i = 0LL; i != v4; ++i )
{
v6 = (char *)calloc(0x60uLL, 1uLL);
*((_DWORD *)v6 + 1) = i;
v7 = v6;
pthread_mutex_init((pthread_mutex_t *)(v6 + 24), 0LL);
v8 = (unsigned int)(a2 + i);
*((_DWORD *)v7 + 2) = v8;
v9 = server_create_and_bind_socket(v8, 2LL);
*(_DWORD *)v7 = v9;
if ( v9 < 0 )
return 0xFFFFFFFFLL;
*((_QWORD *)v7 + 8) = 0LL;
*((_QWORD *)v7 + 9) = 0LL;
if ( pthread_create((pthread_t *)v7 + 2, 0LL, (void *(*)(void *))udp_recv_thread, v7) < 0 )
return 0xFFFFFFFFLL;
*(_QWORD *)(a1 + 8 * i) = v7;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, unsigned int a3)
{
__int64 v4; // r12
__int64 i; // rbp
char *v6; // rax
void *v7; // rbx
__int64 v8; // rdi
int v9; // eax

if ( !a3 )
return 0LL;
v4 = a3;
for ( i = 0LL; i != v4; ++i )
{
v6 = (char *)calloc(0x60uLL, 1uLL);
*((_DWORD *)v6 + 1) = i;
v7 = v6;
pthread_mutex_init((pthread_mutex_t *)(v6 + 24), 0LL);
v8 = (unsigned int)(a2 + i);
*((_DWORD *)v7 + 2) = v8;
v9 = server_create_and_bind_socket(v8, 2LL);
*(_DWORD *)v7 = v9;
if ( v9 < 0 )
return 0xFFFFFFFFLL;
*((_QWORD *)v7 + 8) = 0LL;
*((_QWORD *)v7 + 9) = 0LL;
if ( pthread_create((pthread_t *)v7 + 2, 0LL, (void *(*)(void *))udp_recv_thread, v7) < 0 )
return 0xFFFFFFFFLL;
*(_QWORD *)(a1 + 8 * i) = v7;
}
return 0LL;
}

original_code:
int
udp_create_servers(client_data_t** servers, uint32_t basePort, uint32_t numPorts)
{
    for (uint32_t i = 0; i < numPorts; i++) {
        client_data_t* data = (client_data_t*)malloc(sizeof(client_data_t));
        memset(data, 0, sizeof(client_data_t));
        data->clientNum = i;
        pthread_mutex_init(&data->mutex, ((void *)0));
        data->port = basePort + i;
        data->sock = server_create_and_bind_socket(data->port, SOCK_DGRAM);
        if (data->sock < 0)
        {
            return -1;
        }
        data->numSinceStart = 0;
        data->numSinceMeasure = 0;
        if (pthread_create(&data->thread, ((void *)0), udp_recv_thread, (void*)data) < 0) {
            return -1;
        }
        servers[i] = data;
    }
    return 0;
}

canonical_original_code:
int udp_create_servers(struct client_data_t **servers, unsigned int basePort, unsigned int numPorts)
{
    for (unsigned int i = 0; i < numPorts; i++) {
        struct client_data_t *data = (client_data_t*)malloc(sizeof(client_data_t));
        memset(data, 0, sizeof(client_data_t));
        data->clientNum = i;
        pthread_mutex_init(&data->mutex, ((void *)0));
        data->port = basePort + i;
        data->sock = server_create_and_bind_socket(data->port, SOCK_DGRAM);
        if (data->sock < 0)
        {
            return -1;
        }
        data->numSinceStart = 0;
        data->numSinceMeasure = 0;
        if (pthread_create(&data->thread, ((void *)0), udp_recv_thread, (void *)data) < 0) {
            return -1;
        }
        servers[i] = data;
    }
    return 0;
}

variable_types: struct client_data_t { int sock; int clientNum; int port; unsigned long thread; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; unsigned long numSinceStart; unsigned long numSinceMeasure; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } serverAddress; } **

variable_types:
basePort
unsigned int

variable_types:
numPorts
unsigned int

variable_types:
i
unsigned int


repo: ptorpman/toollogger

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
logToolUsage("TestProg", &unk_402004, 0LL, 1LL);
sleep(3u);
logToolUsage("TestProg", &unk_402004, 0LL, 0LL);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7("TestProg", &unk_402004, 0LL, 1LL);
sleep(3u);
func7("TestProg", &unk_402004, 0LL, 0LL);
return 0;
}

original_code:
int main(int argc, char** argv)
{
  logToolUsage("TestProg", "1.0", ((void *)0), true);
  sleep(3);
  logToolUsage("TestProg", "1.0", ((void *)0), false);
  return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
  logToolUsage("TestProg", "1.0", ((void *)0), true);
  sleep(3);
  logToolUsage("TestProg", "1.0", ((void *)0), false);
  return 0;
}


repo: ptrayal/dungeonworld

decompiled_code:
__int64 __fastcall do_check(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v3; // rax
__int64 *v4; // rbx
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // r9
__int64 v8; // rax
__int64 result; // rax
int v10; // er15
__int64 v11; // rax
int v12; // er15
__int64 v13; // r8
__int64 v14; // rcx
const char *v15; // rdx
unsigned int v16; // er14
__int64 v17; // rax
__int64 *v18; // rbx
__int64 v19; // r12
int v20; // er13
__int64 v21; // rcx
__int64 v22; // rax
unsigned int v23; // er13
__int64 v24; // rax
__int64 *v25; // rbx
int v26; // er14
__int64 v27; // rax
__int64 v28; // rcx
__m128i v29; // [rsp+0h] [rbp-13A8h] BYREF
char v30[8]; // [rsp+10h] [rbp-1398h] BYREF
__int128 v31[16]; // [rsp+70h] [rbp-1338h] BYREF
char s[16]; // [rsp+170h] [rbp-1238h] BYREF
char v33[4592]; // [rsp+180h] [rbp-1228h] BYREF

*(_OWORD *)s = 0LL;
memset(v33, 0, sizeof(v33));
v31[0] = 0LL;
v31[1] = 0LL;
v31[2] = 0LL;
v31[3] = 0LL;
v31[4] = 0LL;
v31[5] = 0LL;
v31[6] = 0LL;
v31[7] = 0LL;
v31[8] = 0LL;
v31[9] = 0LL;
v31[10] = 0LL;
v31[11] = 0LL;
v31[12] = 0LL;
v31[13] = 0LL;
v31[14] = 0LL;
v31[15] = 0LL;
one_argument(a2, v31);
send_to_char("Syntax: 'check' display info about players\n\r", a1);
send_to_char(" 'check stats' display info and resume stats\n\r", a1);
send_to_char(" 'check eq' resume eq of all players\n\r", a1);
send_to_char("\n\r", a1);
if ( LOBYTE(v31[0]) && (unsigned __int8)str_prefix(v31, "stats") )
{
if ( (unsigned __int8)str_prefix(v31, "eq") )
{
result = str_prefix(v31, "snoop");
if ( (_BYTE)result )
return result;
if ( *(__int16 *)(a1 + 250) <= 59 )
return send_to_char("You can't use this check option.\n\r", a1);
v23 = 1;
v24 = _new_buf("check.c", "do_check", 189LL);
v25 = (__int64 *)char_list;
v19 = v24;
if ( char_list )
{
do
{
if ( (v25[40] & 1) == 0 && !*(_WORD *)(v25[11] + 50) )
{
if ( (unsigned __int8)can_see(a1, v25) )
{
v26 = get_trust(v25);
if ( v26 <= (int)get_trust(a1) )
{
v27 = *(_QWORD *)(v25[11] + 8);
if ( v27 )
{
snprintf(v29.m128i_i8, 0x64uLL, " %15s .", *(const char **)(*(_QWORD *)(v27 + 16) + 176LL));
}
else
{
strcpy(v30, " .");
v29 = _mm_load_si128((const __m128i *)&LC19);
}
v28 = v23++;
snprintf(s, 0x1200uLL, "%3d %15s : %s \n\r", v28, (const char *)v25[22], v29.m128i_i8);
add_buf(v19, s);
}
}
}
v25 = (__int64 *)*v25;
}
while ( v25 );
}
}
else
{
v16 = 1;
v17 = _new_buf("check.c", "do_check", 158LL);
v18 = (__int64 *)char_list;
v19 = v17;
if ( char_list )
{
do
{
if ( (v18[40] & 1) == 0 && !*(_WORD *)(v18[11] + 50) )
{
if ( (unsigned __int8)can_see(a1, v18) )
{
v20 = get_trust(v18);
if ( v20 <= (int)get_trust(a1) )
{
v21 = v16++;
snprintf(
s,
0x1200uLL,
"%3d) %s, %d items (weight %d) Hit:%d Dam:%d Save:%d AC:%d %d %d %d.\n\r",
v21,
(const char *)v18[22],
(unsigned int)*((__int16 *)v18 + 196),
(unsigned int)*((__int16 *)v18 + 195),
(unsigned int)*((__int16 *)v18 + 199),
(unsigned int)*((__int16 *)v18 + 200),
(unsigned int)*((__int16 *)v18 + 197),
(unsigned int)*((__int16 *)v18 + 201),
(unsigned int)*((__int16 *)v18 + 202),
(unsigned int)*((__int16 *)v18 + 203),
(unsigned int)*((__int16 *)v18 + 204));
add_buf(v19, s);
}
}
}
v18 = (__int64 *)*v18;
}
while ( v18 );
}
}
v22 = buf_string(v19);
page_to_char(v22, a1);
return free_buf(v19);
}
v2 = 1;
v3 = _new_buf("check.c", "do_check", 85LL);
v4 = (__int64 *)char_list;
v5 = v3;
if ( char_list )
{
do
{
if ( (v4[40] & 1) != 0 || !(unsigned __int8)can_see(a1, v4) )
goto LABEL_13;
v6 = v4[11];
if ( !v6 )
{
snprintf(s, 0x1200uLL, "%3d) %s is linkdead.\n\r", v2, v4[22]);
goto LABEL_26;
}
v7 = (unsigned int)*(__int16 *)(v6 + 50);
if ( (unsigned __int16)(*(_WORD *)(v6 + 50) - 6) <= 6u )
{
v13 = v4[22];
v14 = v2;
v15 = "%3d) %s is being created.\n\r";
goto LABEL_25;
}
if ( *(_WORD *)(v6 + 50) == 2 || *(__int16 *)(v6 + 50) > 12 )
{
v10 = get_trust(v4);
if ( v10 <= (int)get_trust(a1) )
{
v13 = v4[22];
v14 = v2;
v15 = "%3d) %s is connecting.\n\r";
LABEL_25:
snprintf(s, 0x1200uLL, v15, v14, v13);
LABEL_26:
++v2;
add_buf(v5, s);
goto LABEL_13;
}
v11 = v4[11];
v7 = (unsigned int)*(__int16 *)(v11 + 50);
if ( *(_WORD *)(v11 + 50) )
{
LABEL_11:
snprintf(s, 0x1200uLL, "%3d) bug (oops)...please report to Staff: %s %d\n\r", v2, (const char *)v4[22], v7);
add_buf(v5, s);
goto LABEL_12;
}
}
else if ( *(_WORD *)(v6 + 50) )
{
goto LABEL_11;
}
v12 = get_trust(v4);
if ( v12 > (int)get_trust(a1) )
{
snprintf(s, 0x1200uLL, "%3d) %s.\n\r", v2, (const char *)v4[22]);
goto LABEL_13;
}
snprintf(
s,
0x1200uLL,
"%3d) %s, Level %d connected since %d hours (%d total hours)\n\r",
v2,
(const char *)v4[22],
(unsigned int)*((__int16 *)v4 + 125),
(unsigned int)((current_time - *((_DWORD *)v4 + 66)) / 3600),
(unsigned int)((current_time - *((_DWORD *)v4 + 66) + *((_DWORD *)v4 + 64)) / 3600));
add_buf(v5, s);
if ( LOBYTE(v31[0]) )
{
if ( !(unsigned __int8)str_prefix(v31, "stats") )
{
snprintf(
s,
0x1200uLL,
" %d HP %d Mana (%d %d %d %d %d) %ld golds %d Tr %d Pr.\n\r",
(unsigned int)*((__int16 *)v4 + 140),
(unsigned int)*((__int16 *)v4 + 142),
(unsigned int)*((__int16 *)v4 + 206),
(unsigned int)*((__int16 *)v4 + 207),
(unsigned int)*((__int16 *)v4 + 208),
(unsigned int)*((__int16 *)v4 + 209),
(unsigned int)*((__int16 *)v4 + 210),
v4[37] + v4[38] / 100,
(unsigned int)*((__int16 *)v4 + 194),
(unsigned int)*((__int16 *)v4 + 193));
add_buf(v5, s);
}
}
LABEL_12:
++v2;
LABEL_13:
v4 = (__int64 *)*v4;
}
while ( v4 );
}
v8 = buf_string(v5);
page_to_char(v8, a1);
return free_buf(v5);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v3; // rax
__int64 *v4; // rbx
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // r9
__int64 v8; // rax
__int64 result; // rax
int v10; // er15
__int64 v11; // rax
int v12; // er15
__int64 v13; // r8
__int64 v14; // rcx
const char *v15; // rdx
unsigned int v16; // er14
__int64 v17; // rax
__int64 *v18; // rbx
__int64 v19; // r12
int v20; // er13
__int64 v21; // rcx
__int64 v22; // rax
unsigned int v23; // er13
__int64 v24; // rax
__int64 *v25; // rbx
int v26; // er14
__int64 v27; // rax
__int64 v28; // rcx
__m128i v29; // [rsp+0h] [rbp-13A8h] BYREF
char v30[8]; // [rsp+10h] [rbp-1398h] BYREF
__int128 v31[16]; // [rsp+70h] [rbp-1338h] BYREF
char s[16]; // [rsp+170h] [rbp-1238h] BYREF
char v33[4592]; // [rsp+180h] [rbp-1228h] BYREF

*(_OWORD *)s = 0LL;
memset(v33, 0, sizeof(v33));
v31[0] = 0LL;
v31[1] = 0LL;
v31[2] = 0LL;
v31[3] = 0LL;
v31[4] = 0LL;
v31[5] = 0LL;
v31[6] = 0LL;
v31[7] = 0LL;
v31[8] = 0LL;
v31[9] = 0LL;
v31[10] = 0LL;
v31[11] = 0LL;
v31[12] = 0LL;
v31[13] = 0LL;
v31[14] = 0LL;
v31[15] = 0LL;
one_argument(a2, v31);
send_to_char("Syntax: 'check' display info about players\n\r", a1);
send_to_char(" 'check stats' display info and resume stats\n\r", a1);
send_to_char(" 'check eq' resume eq of all players\n\r", a1);
send_to_char("\n\r", a1);
if ( LOBYTE(v31[0]) && (unsigned __int8)str_prefix(v31, "stats") )
{
if ( (unsigned __int8)str_prefix(v31, "eq") )
{
result = str_prefix(v31, "snoop");
if ( (_BYTE)result )
return result;
if ( *(__int16 *)(a1 + 250) <= 59 )
return send_to_char("You can't use this check option.\n\r", a1);
v23 = 1;
v24 = _new_buf("check.c", "do_check", 189LL);
v25 = (__int64 *)char_list;
v19 = v24;
if ( char_list )
{
do
{
if ( (v25[40] & 1) == 0 && !*(_WORD *)(v25[11] + 50) )
{
if ( (unsigned __int8)can_see(a1, v25) )
{
v26 = get_trust(v25);
if ( v26 <= (int)get_trust(a1) )
{
v27 = *(_QWORD *)(v25[11] + 8);
if ( v27 )
{
snprintf(v29.m128i_i8, 0x64uLL, " %15s .", *(const char **)(*(_QWORD *)(v27 + 16) + 176LL));
}
else
{
strcpy(v30, " .");
v29 = _mm_load_si128((const __m128i *)&LC19);
}
v28 = v23++;
snprintf(s, 0x1200uLL, "%3d %15s : %s \n\r", v28, (const char *)v25[22], v29.m128i_i8);
add_buf(v19, s);
}
}
}
v25 = (__int64 *)*v25;
}
while ( v25 );
}
}
else
{
v16 = 1;
v17 = _new_buf("check.c", "do_check", 158LL);
v18 = (__int64 *)char_list;
v19 = v17;
if ( char_list )
{
do
{
if ( (v18[40] & 1) == 0 && !*(_WORD *)(v18[11] + 50) )
{
if ( (unsigned __int8)can_see(a1, v18) )
{
v20 = get_trust(v18);
if ( v20 <= (int)get_trust(a1) )
{
v21 = v16++;
snprintf(
s,
0x1200uLL,
"%3d) %s, %d items (weight %d) Hit:%d Dam:%d Save:%d AC:%d %d %d %d.\n\r",
v21,
(const char *)v18[22],
(unsigned int)*((__int16 *)v18 + 196),
(unsigned int)*((__int16 *)v18 + 195),
(unsigned int)*((__int16 *)v18 + 199),
(unsigned int)*((__int16 *)v18 + 200),
(unsigned int)*((__int16 *)v18 + 197),
(unsigned int)*((__int16 *)v18 + 201),
(unsigned int)*((__int16 *)v18 + 202),
(unsigned int)*((__int16 *)v18 + 203),
(unsigned int)*((__int16 *)v18 + 204));
add_buf(v19, s);
}
}
}
v18 = (__int64 *)*v18;
}
while ( v18 );
}
}
v22 = buf_string(v19);
page_to_char(v22, a1);
return free_buf(v19);
}
v2 = 1;
v3 = _new_buf("check.c", "do_check", 85LL);
v4 = (__int64 *)char_list;
v5 = v3;
if ( char_list )
{
do
{
if ( (v4[40] & 1) != 0 || !(unsigned __int8)can_see(a1, v4) )
goto LABEL_13;
v6 = v4[11];
if ( !v6 )
{
snprintf(s, 0x1200uLL, "%3d) %s is linkdead.\n\r", v2, v4[22]);
goto LABEL_26;
}
v7 = (unsigned int)*(__int16 *)(v6 + 50);
if ( (unsigned __int16)(*(_WORD *)(v6 + 50) - 6) <= 6u )
{
v13 = v4[22];
v14 = v2;
v15 = "%3d) %s is being created.\n\r";
goto LABEL_25;
}
if ( *(_WORD *)(v6 + 50) == 2 || *(__int16 *)(v6 + 50) > 12 )
{
v10 = get_trust(v4);
if ( v10 <= (int)get_trust(a1) )
{
v13 = v4[22];
v14 = v2;
v15 = "%3d) %s is connecting.\n\r";
LABEL_25:
snprintf(s, 0x1200uLL, v15, v14, v13);
LABEL_26:
++v2;
add_buf(v5, s);
goto LABEL_13;
}
v11 = v4[11];
v7 = (unsigned int)*(__int16 *)(v11 + 50);
if ( *(_WORD *)(v11 + 50) )
{
LABEL_11:
snprintf(s, 0x1200uLL, "%3d) bug (oops)...please report to Staff: %s %d\n\r", v2, (const char *)v4[22], v7);
add_buf(v5, s);
goto LABEL_12;
}
}
else if ( *(_WORD *)(v6 + 50) )
{
goto LABEL_11;
}
v12 = get_trust(v4);
if ( v12 > (int)get_trust(a1) )
{
snprintf(s, 0x1200uLL, "%3d) %s.\n\r", v2, (const char *)v4[22]);
goto LABEL_13;
}
snprintf(
s,
0x1200uLL,
"%3d) %s, Level %d connected since %d hours (%d total hours)\n\r",
v2,
(const char *)v4[22],
(unsigned int)*((__int16 *)v4 + 125),
(unsigned int)((current_time - *((_DWORD *)v4 + 66)) / 3600),
(unsigned int)((current_time - *((_DWORD *)v4 + 66) + *((_DWORD *)v4 + 64)) / 3600));
add_buf(v5, s);
if ( LOBYTE(v31[0]) )
{
if ( !(unsigned __int8)str_prefix(v31, "stats") )
{
snprintf(
s,
0x1200uLL,
" %d HP %d Mana (%d %d %d %d %d) %ld golds %d Tr %d Pr.\n\r",
(unsigned int)*((__int16 *)v4 + 140),
(unsigned int)*((__int16 *)v4 + 142),
(unsigned int)*((__int16 *)v4 + 206),
(unsigned int)*((__int16 *)v4 + 207),
(unsigned int)*((__int16 *)v4 + 208),
(unsigned int)*((__int16 *)v4 + 209),
(unsigned int)*((__int16 *)v4 + 210),
v4[37] + v4[38] / 100,
(unsigned int)*((__int16 *)v4 + 194),
(unsigned int)*((__int16 *)v4 + 193));
add_buf(v5, s);
}
}
LABEL_12:
++v2;
LABEL_13:
v4 = (__int64 *)*v4;
}
while ( v4 );
}
v8 = buf_string(v5);
page_to_char(v8, a1);
return free_buf(v5);
}

original_code:
void do_check( CHAR_DATA *ch, char *argument )
{
    char buf[4608] = {'\0'};
    char arg[256] = {'\0'};
    BUFFER *buffer;
    CHAR_DATA *victim;
    AFFECT_DATA *paf;
    int count = 1;
    int last_room = 0;
    one_argument( argument, arg );
    send_to_char("Syntax: 'check'       display info about players\n\r", ch);
    send_to_char("        'check stats' display info and resume stats\n\r",ch);
    send_to_char("        'check eq'    resume eq of all players\n\r", ch);
    send_to_char("\n\r", ch);
    if ( ((arg) == ((void *)0) || (arg)[0] == '\0') || !str_prefix(arg,"stats"))
    {
        buffer = __new_buf("check.c", __FUNCTION__, 85);
     for (victim = char_list; victim != ((void *)0); victim = victim->next)
     {
         if (((((victim)->act) & ((1)))) || !can_see(ch,victim))
          continue;
     if (victim->desc == ((void *)0))
     {
      snprintf(buf, sizeof(buf), "%3d) %s is linkdead.\n\r", count, victim->name);
      add_buf(buffer, buf);
      count++;
      continue;
     }
     if (victim->desc->connected >= 6
      && victim->desc->connected <= 12)
     {
      snprintf(buf, sizeof(buf), "%3d) %s is being created.\n\r",
           count, victim->name);
      add_buf(buffer, buf);
      count++;
      continue;
     }
     if ( (victim->desc->connected == 2
        || victim->desc->connected >= 13)
      && get_trust(victim) <= get_trust(ch) )
     {
      snprintf(buf, sizeof(buf), "%3d) %s is connecting.\n\r",
           count, victim->name);
      add_buf(buffer, buf);
      count++;
      continue;
     }
     if (victim->desc->connected == 0)
     {
         if (get_trust(victim) > get_trust(ch))
             snprintf(buf, sizeof(buf), "%3d) %s.\n\r", count, victim->name);
         else
         {
      snprintf(buf, sizeof(buf), "%3d) %s, Level %d connected since %d hours (%d total hours)\n\r",
       count, victim->name,victim->level,
                        ((int)(current_time - victim->logon)) /3600,
       (victim->played + (int)(current_time - victim->logon)) /3600 );
      add_buf(buffer, buf);
      if (arg[0]!='\0' && !str_prefix(arg,"stats"))
      {
        snprintf(buf, sizeof(buf), "  %d HP %d Mana (%d %d %d %d %d) %ld golds %d Tr %d Pr.\n\r",
       victim->max_hit, victim->max_mana,victim->perm_stat[0],
       victim->perm_stat[1],victim->perm_stat[2],
       victim->perm_stat[3],victim->perm_stat[4],
       victim->gold + victim->silver/100,
       victim->train, victim->practice);
        add_buf(buffer, buf);
      }
      count++;
  }
         continue;
     }
     snprintf(buf, sizeof(buf), "%3d) bug (oops)...please report to Staff: %s %d\n\r",
      count, victim->name, victim->desc->connected);
     add_buf(buffer, buf);
     count++;
     }
     page_to_char(buf_string(buffer),ch);
     free_buf(buffer);
     return;
    }
    if (!str_prefix(arg,"eq"))
    {
        buffer = __new_buf("check.c", __FUNCTION__, 158);
     for (victim = char_list; victim != ((void *)0); victim = victim->next)
     {
         if (((((victim)->act) & ((1))))
          || victim->desc->connected != 0
          || !can_see(ch,victim)
          || get_trust(victim) > get_trust(ch) )
          continue;
         snprintf(buf, sizeof(buf), "%3d) %s, %d items (weight %d) Hit:%d Dam:%d Save:%d AC:%d %d %d %d.\n\r",
          count, victim->name, victim->carry_number, victim->carry_weight,
          victim->hitroll, victim->damroll, victim->saving_throw,
          victim->armor[0], victim->armor[1],
          victim->armor[2], victim->armor[3]);
         add_buf(buffer, buf);
         count++;
     }
     page_to_char(buf_string(buffer),ch);
     free_buf(buffer);
     return;
    }
  if (!str_prefix(arg,"snoop"))
    {
        char bufsnoop [100];
        if(ch->level < 60 )
          {
            send_to_char("You can't use this check option.\n\r",ch);
            return;
          }
        buffer = __new_buf("check.c", __FUNCTION__, 189);
        for (victim = char_list; victim != ((void *)0); victim = victim->next)
        {
            if (((((victim)->act) & ((1))))
             || victim->desc->connected != 0
             || !can_see(ch,victim)
             || get_trust(victim) > get_trust(ch) )
                continue;
            if(victim->desc->snoop_by != ((void *)0))
              snprintf(bufsnoop, sizeof(bufsnoop)," %15s .",victim->desc->snoop_by->character->name);
            else
              snprintf(bufsnoop,sizeof(bufsnoop), "     (none)      ." );
            snprintf(buf, sizeof(buf), "%3d %15s : %s \n\r",count,victim->name, bufsnoop);
            add_buf(buffer, buf);
            count++;
        }
        page_to_char(buf_string(buffer),ch);
        free_buf(buffer);
        return;
    }
    return;
}

canonical_original_code:
void do_check(struct char_data *ch, char *argument)
{
    char buf[4608] = {'\0'};
    char arg[256] = {'\0'};
    struct buf_type *buffer;
    struct char_data *victim;
    struct affect_data *paf;
    int count = 1;
    int last_room = 0;
    one_argument( argument, arg );
    send_to_char("Syntax: 'check'       display info about players\n\r", ch);
    send_to_char("        'check stats' display info and resume stats\n\r",ch);
    send_to_char("        'check eq'    resume eq of all players\n\r", ch);
    send_to_char("\n\r", ch);
    if ( ((arg) == ((void *)0) || (arg)[0] == '\0') || !str_prefix(arg,"stats"))
    {
        buffer = __new_buf("check.c", __FUNCTION__, 85);
     for (victim = char_list; victim != ((void *)0); victim = victim->next)
     {
         if (((((victim)->act) & ((1)))) || !can_see(ch,victim))
          continue;
     if (victim->desc == ((void *)0))
     {
      snprintf(buf, sizeof(buf), "%3d) %s is linkdead.\n\r", count, victim->name);
      add_buf(buffer, buf);
      count++;
      continue;
     }
     if (victim->desc->connected >= 6
      && victim->desc->connected <= 12)
     {
      snprintf(buf, sizeof(buf), "%3d) %s is being created.\n\r",
           count, victim->name);
      add_buf(buffer, buf);
      count++;
      continue;
     }
     if ( (victim->desc->connected == 2
        || victim->desc->connected >= 13)
      && get_trust(victim) <= get_trust(ch) )
     {
      snprintf(buf, sizeof(buf), "%3d) %s is connecting.\n\r",
           count, victim->name);
      add_buf(buffer, buf);
      count++;
      continue;
     }
     if (victim->desc->connected == 0)
     {
         if (get_trust(victim) > get_trust(ch))
             snprintf(buf, sizeof(buf), "%3d) %s.\n\r", count, victim->name);
         else
         {
      snprintf(buf, sizeof(buf), "%3d) %s, Level %d connected since %d hours (%d total hours)\n\r",
       count, victim->name,victim->level,
                        ((int)(current_time - victim->logon)) /3600,
       (victim->played + (int)(current_time - victim->logon)) /3600 );
      add_buf(buffer, buf);
      if (arg[0]!='\0' && !str_prefix(arg,"stats"))
      {
        snprintf(buf, sizeof(buf), "  %d HP %d Mana (%d %d %d %d %d) %ld golds %d Tr %d Pr.\n\r",
       victim->max_hit, victim->max_mana,victim->perm_stat[0],
       victim->perm_stat[1],victim->perm_stat[2],
       victim->perm_stat[3],victim->perm_stat[4],
       victim->gold + victim->silver/100,
       victim->train, victim->practice);
        add_buf(buffer, buf);
      }
      count++;
  }
         continue;
     }
     snprintf(buf, sizeof(buf), "%3d) bug (oops)...please report to Staff: %s %d\n\r",
      count, victim->name, victim->desc->connected);
     add_buf(buffer, buf);
     count++;
     }
     page_to_char(buf_string(buffer),ch);
     free_buf(buffer);
     return;
    }
    if (!str_prefix(arg,"eq"))
    {
        buffer = __new_buf("check.c", __FUNCTION__, 158);
     for (victim = char_list; victim != ((void *)0); victim = victim->next)
     {
         if (((((victim)->act) & ((1))))
          || victim->desc->connected != 0
          || !can_see(ch,victim)
          || get_trust(victim) > get_trust(ch) )
          continue;
         snprintf(buf, sizeof(buf), "%3d) %s, %d items (weight %d) Hit:%d Dam:%d Save:%d AC:%d %d %d %d.\n\r",
          count, victim->name, victim->carry_number, victim->carry_weight,
          victim->hitroll, victim->damroll, victim->saving_throw,
          victim->armor[0], victim->armor[1],
          victim->armor[2], victim->armor[3]);
         add_buf(buffer, buf);
         count++;
     }
     page_to_char(buf_string(buffer),ch);
     free_buf(buffer);
     return;
    }
  if (!str_prefix(arg,"snoop"))
    {
        char bufsnoop[100];
        if(ch->level < 60 )
          {
            send_to_char("You can't use this check option.\n\r",ch);
            return;
          }
        buffer = __new_buf("check.c", __FUNCTION__, 189);
        for (victim = char_list; victim != ((void *)0); victim = victim->next)
        {
            if (((((victim)->act) & ((1))))
             || victim->desc->connected != 0
             || !can_see(ch,victim)
             || get_trust(victim) > get_trust(ch) )
                continue;
            if(victim->desc->snoop_by != ((void *)0))
              snprintf(bufsnoop, sizeof(bufsnoop)," %15s .",victim->desc->snoop_by->character->name);
            else
              snprintf(bufsnoop,sizeof(bufsnoop), "     (none)      ." );
            snprintf(buf, sizeof(buf), "%3d %15s : %s \n\r",count,victim->name, bufsnoop);
            add_buf(buffer, buf);
            count++;
        }
        page_to_char(buf_string(buffer),ch);
        free_buf(buffer);
        return;
    }
    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:
argument
char *

variable_types:
buf
char [4608]

variable_types:
arg
char [256]

variable_types: count int

variable_types:
bufsnoop
char [100]

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 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 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:
__int64 __fastcall matedit_name(__int64 a1, _BYTE *a2)
{
__int64 v3; // rbx
void *v4; // rdi
__int64 result; // rax
__int64 v6; // rax

if ( a2 && *a2 )
{
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 88) + 1632LL);
v4 = *(void **)(v3 + 8);
if ( v4 )
{
free(v4);
}
else if ( logFail )
{
v6 = Format(
"clear_free_lists: unable to purge_data as it was NULL from: %s %s %d",
"olc_mat.c",
"matedit_name",
247LL);
log_string(v6);
}
*(_QWORD *)(v3 + 8) = 0LL;
*(_QWORD *)(v3 + 8) = str_dup(a2, "olc_mat.c", "matedit_name", 248LL);
send_to_char("Name set.\n\r", a1);
result = 1LL;
}
else
{
send_to_char("Syntax: name [name]\n\r", a1);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _BYTE *a2)
{
__int64 v3; // rbx
void *v4; // rdi
__int64 result; // rax
__int64 v6; // rax

if ( a2 && *a2 )
{
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 88) + 1632LL);
v4 = *(void **)(v3 + 8);
if ( v4 )
{
free(v4);
}
else if ( logFail )
{
v6 = Format(
"clear_free_lists: unable to purge_data as it was NULL from: %s %s %d",
"olc_mat.c",
"matedit_name",
247LL);
log_string(v6);
}
*(_QWORD *)(v3 + 8) = 0LL;
*(_QWORD *)(v3 + 8) = str_dup(a2, "olc_mat.c", "matedit_name", 248LL);
send_to_char("Name set.\n\r", a1);
result = 1LL;
}
else
{
send_to_char("Syntax: name [name]\n\r", a1);
result = 0LL;
}
return result;
}

original_code:
bool matedit_name( CHAR_DATA *ch, char *argument )
{
 MAT_TYPE *pMat;
 ( pMat = (MAT_TYPE *)ch->desc->pEdit );
 if ( ((argument) == ((void *)0) || (argument)[0] == '\0') )
 {
 send_to_char( "Syntax:  name [name]\n\r", ch );
 return 0;
 }
 do { if(pMat->name) { free((void *)pMat->name); } else { if(logFail) { log_string((char *)Format("clear_free_lists: unable to purge_data as it was NULL from: %s %s %d", "olc_mat.c", __FUNCTION__, 247)); } } pMat->name = ((void *)0); } while(0);
 pMat->name = _str_dup(argument, "olc_mat.c", __FUNCTION__, 248);
 send_to_char( "Name set.\n\r", ch );
 return 1;
}

canonical_original_code:
unsigned char matedit_name(struct char_data *ch, char *argument)
{
 struct material_type *pMat;
 ( pMat = (struct material_type *)ch->desc->pEdit );
 if ( ((argument) == ((void *)0) || (argument)[0] == '\0') )
 {
 send_to_char( "Syntax:  name [name]\n\r", ch );
 return 0;
 }
 do { if(pMat->name) { free((void *)pMat->name); } else { if(logFail) { log_string((char *)Format("clear_free_lists: unable to purge_data as it was NULL from: %s %s %d", "olc_mat.c", __FUNCTION__, 247)); } } pMat->name = ((void *)0); } while(0);
 pMat->name = _str_dup(argument, "olc_mat.c", __FUNCTION__, 248);
 send_to_char( "Name set.\n\r", ch );
 return 1;
}

variable_types: struct material_type { struct material_type *next; char *name; int assignedValue; } *

return_type: 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 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: 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 buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; }

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; }


decompiled_code:
__int64 __fastcall matedit_show(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rax

v1 = *(_QWORD *)(*(_QWORD *)(a1 + 88) + 1632LL);
v2 = Format("Name: %s\n\r", *(const char **)(v1 + 8));
send_to_char(v2, a1);
v3 = Format("assignedValue: %d (Non-Settable)\n\r", *(unsigned int *)(v1 + 16));
send_to_char(v3, a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rax

v1 = *(_QWORD *)(*(_QWORD *)(a1 + 88) + 1632LL);
v2 = Format("Name: %s\n\r", *(const char **)(v1 + 8));
send_to_char(v2, a1);
v3 = Format("assignedValue: %d (Non-Settable)\n\r", *(unsigned int *)(v1 + 16));
send_to_char(v3, a1);
return 0LL;
}

original_code:
bool matedit_show( CHAR_DATA *ch, char *argument ) {
 MAT_TYPE *pMat;
 ( pMat = (MAT_TYPE *)ch->desc->pEdit );
 send_to_char(Format("Name: %s\n\r", pMat->name), ch);
 send_to_char(Format("assignedValue: %d (Non-Settable)\n\r", pMat->assignedValue), ch);
 return 0;
}

canonical_original_code:
unsigned char matedit_show(struct char_data *ch, char *argument) {
 struct material_type *pMat;
 ( pMat = (struct material_type *)ch->desc->pEdit );
 send_to_char(Format("Name: %s\n\r", pMat->name), ch);
 send_to_char(Format("assignedValue: %d (Non-Settable)\n\r", pMat->assignedValue), ch);
 return 0;
}

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 material_type { struct material_type *next; char *name; int assignedValue; }

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; }


decompiled_code:
void *new_mat()
{
void *result; // rax

result = calloc(1uLL, 0x18uLL);
if ( !result )
{
logfmt(
"Unable to calloc new data from file: %s function: %s, line: %d\t *** ABORTING ***",
"olc_mat.c",
"new_mat",
41LL);
abort();
}
return result;
}

canonical_decompiled_code:
void *func2()
{
void *result; // rax

result = calloc(1uLL, 0x18uLL);
if ( !result )
{
logfmt(
"Unable to calloc new data from file: %s function: %s, line: %d\t *** ABORTING ***",
"olc_mat.c",
"new_mat",
41LL);
abort();
}
return result;
}

original_code:
MAT_TYPE *new_mat()
{
 MAT_TYPE *mat;
 do { if (!((mat) = (MAT_TYPE *) calloc ((1), sizeof(MAT_TYPE)))) { logfmt("Unable to calloc new data from file: %s function: %s, line: %d\t *** ABORTING ***", "olc_mat.c", __FUNCTION__, 41); abort(); } } while(0);
 mat->next = ((void *)0);
 mat->name = ((void *)0);
 mat->assignedValue = 0;
 return mat;
}

canonical_original_code:
struct material_type *new_mat()
{
 struct material_type *mat;
 do { if (!((mat) = (struct material_type *) calloc ((1), sizeof(MAT_TYPE)))) { logfmt("Unable to calloc new data from file: %s function: %s, line: %d\t *** ABORTING ***", "olc_mat.c", __FUNCTION__, 41); abort(); } } while(0);
 mat->next = ((void *)0);
 mat->name = ((void *)0);
 mat->assignedValue = 0;
 return mat;
}

return_type: struct material_type { struct material_type *next; char *name; int assignedValue; } *


decompiled_code:
void __fastcall free_mat(void *ptr)
{
void *v2; // rdi
__int64 v3; // rax

if ( !ptr )
free_mat_cold();
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
{
free(v2);
LABEL_4:
free(ptr);
return;
}
if ( !logFail )
goto LABEL_4;
v3 = Format("clear_free_lists: unable to purge_data as it was NULL from: %s %s %d", "olc_mat.c", "free_mat", 53LL);
log_string(v3);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
void *v2; // rdi
__int64 v3; // rax

if ( !ptr )
func12();
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
{
free(v2);
LABEL_4:
free(ptr);
return;
}
if ( !logFail )
goto LABEL_4;
v3 = Format("clear_free_lists: unable to purge_data as it was NULL from: %s %s %d", "olc_mat.c", "free_mat", 53LL);
log_string(v3);
free(ptr);
}

original_code:
void free_mat(MAT_TYPE *mat) {
 do { if(!(mat)) abort(); }while(0);
 do { if(mat->name) { free((void *)mat->name); } else { if(logFail) { log_string((char *)Format("clear_free_lists: unable to purge_data as it was NULL from: %s %s %d", "olc_mat.c", __FUNCTION__, 53)); } } mat->name = ((void *)0); } while(0);
 do { if(mat) { free((void *)mat); } else { if(logFail) { log_string((char *)Format("clear_free_lists: unable to purge_data as it was NULL from: %s %s %d", "olc_mat.c", __FUNCTION__, 54)); } } mat = ((void *)0); } while(0);
}

canonical_original_code:
void free_mat(struct material_type *mat) {
 do { if(!(mat)) abort(); }while(0);
 do { if(mat->name) { free((void *)mat->name); } else { if(logFail) { log_string((char *)Format("clear_free_lists: unable to purge_data as it was NULL from: %s %s %d", "olc_mat.c", __FUNCTION__, 53)); } } mat->name = ((void *)0); } while(0);
 do { if(mat) { free((void *)mat); } else { if(logFail) { log_string((char *)Format("clear_free_lists: unable to purge_data as it was NULL from: %s %s %d", "olc_mat.c", __FUNCTION__, 54)); } } mat = ((void *)0); } while(0);
}


decompiled_code:
void clear_materials()
{
_QWORD *v0; // rbx
void *v1; // rdi

log_string("Cleaning: mat_list");
v0 = mat_list;
if ( mat_list )
{
do
{
v1 = v0;
v0 = (_QWORD *)*v0;
free_mat(v1);
}
while ( v0 );
}
mat_list = 0LL;
}

canonical_decompiled_code:
void func4()
{
_QWORD *v0; // rbx
void *v1; // rdi

log_string("Cleaning: mat_list");
v0 = mat_list;
if ( mat_list )
{
do
{
v1 = v0;
v0 = (_QWORD *)*v0;
func3(v1);
}
while ( v0 );
}
mat_list = 0LL;
}

original_code:
void clear_materials(void) {
 MAT_TYPE *mat, *mat_next;
 log_string("Cleaning: mat_list");
 for(mat = mat_list; mat; mat = mat_next) {
  mat_next = mat->next;
  free_mat(mat);
 }
 mat_list = ((void *)0);
 return;
}

canonical_original_code:
void clear_materials() {
 struct material_type *mat; struct material_type *mat_next;
 log_string("Cleaning: mat_list");
 for(mat = mat_list; mat; mat = mat_next) {
  mat_next = mat->next;
  free_mat(mat);
 }
 mat_list = ((void *)0);
 return;
}


decompiled_code:
void __fastcall confirm_material(_BYTE *a1)
{
_QWORD *v2; // rbx
_QWORD *v3; // rax
_BYTE *v4; // rdi
_QWORD *v5; // rbx
void *v6; // rax

if ( a1 && *a1 && !(unsigned __int8)is_number() )
{
v2 = mat_list;
while ( v2 )
{
while ( 1 )
{
v3 = v2;
v2 = (_QWORD *)*v2;
v4 = (_BYTE *)v3[1];
if ( !v4 || !*v4 )
break;
if ( !(unsigned __int8)_strcmp(v4, a1, "olc_mat.c", "confirm_material", 106LL) )
return;
if ( !v2 )
goto LABEL_11;
}
}
LABEL_11:
++matValue;
v5 = new_mat();
v5[1] = str_dup(a1, "olc_mat.c", "confirm_material", 113LL);
*((_DWORD *)v5 + 4) = matValue;
v6 = mat_list;
mat_list = v5;
*v5 = v6;
}
}

canonical_decompiled_code:
void __fastcall func5(_BYTE *a1)
{
_QWORD *v2; // rbx
_QWORD *v3; // rax
_BYTE *v4; // rdi
_QWORD *v5; // rbx
void *v6; // rax

if ( a1 && *a1 && !(unsigned __int8)is_number() )
{
v2 = mat_list;
while ( v2 )
{
while ( 1 )
{
v3 = v2;
v2 = (_QWORD *)*v2;
v4 = (_BYTE *)v3[1];
if ( !v4 || !*v4 )
break;
if ( !(unsigned __int8)_strcmp(v4, a1, "olc_mat.c", "confirm_material", 106LL) )
return;
if ( !v2 )
goto LABEL_11;
}
}
LABEL_11:
++matValue;
v5 = func2();
v5[1] = str_dup(a1, "olc_mat.c", "confirm_material", 113LL);
*((_DWORD *)v5 + 4) = matValue;
v6 = mat_list;
mat_list = v5;
*v5 = v6;
}
}

original_code:
void confirm_material(const char *name) {
 MAT_TYPE *mat, *mat_next;
 if(((name) == ((void *)0) || (name)[0] == '\0'))
  return;
 if(is_number(name))
  return;
 for(mat = mat_list; mat; mat = mat_next) {
  mat_next = mat->next;
  if(((mat->name) == ((void *)0) || (mat->name)[0] == '\0'))
   continue;
  if(!__strcmp(mat->name, name, "olc_mat.c", __FUNCTION__, 106))
   return;
 }
 matValue++;
 mat = new_mat();
 mat->name = _str_dup(name, "olc_mat.c", __FUNCTION__, 113);
 mat->assignedValue = matValue;
 mat->next = mat_list;
 mat_list = mat;
 return;
}

canonical_original_code:
void confirm_material(char *name) {
 struct material_type *mat; struct material_type *mat_next;
 if(((name) == ((void *)0) || (name)[0] == '\0'))
  return;
 if(is_number(name))
  return;
 for(mat = mat_list; mat; mat = mat_next) {
  mat_next = mat->next;
  if(((mat->name) == ((void *)0) || (mat->name)[0] == '\0'))
   continue;
  if(!__strcmp(mat->name, name, "olc_mat.c", __FUNCTION__, 106))
   return;
 }
 matValue++;
 mat = new_mat();
 mat->name = _str_dup(name, "olc_mat.c", __FUNCTION__, 113);
 mat->assignedValue = matValue;
 mat->next = mat_list;
 mat_list = mat;
 return;
}

variable_types:
name
char *


decompiled_code:
__int64 __fastcall matedit_create(__int64 a1, _BYTE *a2)
{
__int64 result; // rax
_QWORD *v3; // rbx
__int64 v4; // rax
void *v5; // rax

if ( a2 && *a2 )
{
if ( find_mat(a2) )
{
send_to_char("MATEdit: That material already exists\n\r", a1);
result = 0LL;
}
else
{
v3 = new_mat();
v4 = str_dup(a2, "olc_mat.c", "matedit_create", 222LL);
*((_DWORD *)v3 + 4) = 0;
v3[1] = v4;
v5 = mat_list;
mat_list = v3;
*v3 = v5;
*(_QWORD *)(*(_QWORD *)(a1 + 88) + 1632LL) = v3;
send_to_char("Material created.\n\r", a1);
save_materials();
result = 1LL;
}
}
else
{
send_to_char("Syntax: create [name]\n\r", a1);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, _BYTE *a2)
{
__int64 result; // rax
_QWORD *v3; // rbx
__int64 v4; // rax
void *v5; // rax

if ( a2 && *a2 )
{
if ( find_mat(a2) )
{
send_to_char("MATEdit: That material already exists\n\r", a1);
result = 0LL;
}
else
{
v3 = func2();
v4 = str_dup(a2, "olc_mat.c", "matedit_create", 222LL);
*((_DWORD *)v3 + 4) = 0;
v3[1] = v4;
v5 = mat_list;
mat_list = v3;
*v3 = v5;
*(_QWORD *)(*(_QWORD *)(a1 + 88) + 1632LL) = v3;
send_to_char("Material created.\n\r", a1);
func6();
result = 1LL;
}
}
else
{
send_to_char("Syntax: create [name]\n\r", a1);
result = 0LL;
}
return result;
}

original_code:
bool matedit_create( CHAR_DATA *ch, char *argument )
{
 MAT_TYPE *pMat;
 if ( ((argument) == ((void *)0) || (argument)[0] == '\0'))
 {
 send_to_char( "Syntax:  create [name]\n\r", ch );
 return 0;
 }
 pMat = find_mat( argument );
 if ( pMat )
 {
  send_to_char( "MATEdit:  That material already exists\n\r", ch );
  return 0;
 }
 pMat = new_mat();
 pMat->name = _str_dup(argument, "olc_mat.c", __FUNCTION__, 222);
 pMat->assignedValue = 0;
 pMat->next = mat_list;
 mat_list = pMat;
 ch->desc->pEdit = (void *)pMat;
 send_to_char( "Material created.\n\r", ch );
 save_materials();
 return 1;
}

canonical_original_code:
unsigned char matedit_create(struct char_data *ch, char *argument)
{
 struct material_type *pMat;
 if ( ((argument) == ((void *)0) || (argument)[0] == '\0'))
 {
 send_to_char( "Syntax:  create [name]\n\r", ch );
 return 0;
 }
 pMat = find_mat( argument );
 if ( pMat )
 {
  send_to_char( "MATEdit:  That material already exists\n\r", ch );
  return 0;
 }
 pMat = new_mat();
 pMat->name = _str_dup(argument, "olc_mat.c", __FUNCTION__, 222);
 pMat->assignedValue = 0;
 pMat->next = mat_list;
 mat_list = pMat;
 ch->desc->pEdit = (void *)pMat;
 send_to_char( "Material created.\n\r", ch );
 save_materials();
 return 1;
}

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 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 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 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; }


matedit

decompiled_code:
__int64 __fastcall matedit(__int64 a1, const char *a2)
{
__int64 v2; // r12
__int64 v3; // rbx
const char *v4; // rsi
__int64 result; // rax
char v6[256]; // [rsp+0h] [rbp-228h] BYREF
char dest[296]; // [rsp+100h] [rbp-128h] BYREF

smash_tilde(a2);
strcpy(dest, a2);
v2 = one_argument(a2, v6);
if ( !(unsigned __int8)_strcmp(v6, "done", "olc_mat.c", "matedit", 276LL) )
{
save_materials();
send_to_char("Materials Saved to disk.\n\r", a1);
result = edit_done(a1);
}
else
{
v3 = 0LL;
v4 = "create";
if ( v6[0] )
{
do
{
if ( !(unsigned __int8)str_prefix(v6, v4) )
return ((__int64 (__fastcall *)(__int64, __int64))(&matedit_table)[2 * (int)v3 + 1])(a1, v2);
++v3;
v4 = (&matedit_table)[2 * v3];
}
while ( v4 );
result = interpret(a1, dest);
}
else
{
result = matedit_show(a1);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, const char *a2)
{
__int64 v2; // r12
__int64 v3; // rbx
const char *v4; // rsi
__int64 result; // rax
char v6[256]; // [rsp+0h] [rbp-228h] BYREF
char dest[296]; // [rsp+100h] [rbp-128h] BYREF

smash_tilde(a2);
strcpy(dest, a2);
v2 = one_argument(a2, v6);
if ( !(unsigned __int8)_strcmp(v6, "done", "olc_mat.c", "matedit", 276LL) )
{
func6();
send_to_char("Materials Saved to disk.\n\r", a1);
result = edit_done(a1);
}
else
{
v3 = 0LL;
v4 = "create";
if ( v6[0] )
{
do
{
if ( !(unsigned __int8)str_prefix(v6, v4) )
return ((__int64 (__fastcall *)(__int64, __int64))(&matedit_table)[2 * (int)v3 + 1])(a1, v2);
++v3;
v4 = (&matedit_table)[2 * v3];
}
while ( v4 );
result = interpret(a1, dest);
}
else
{
result = func1(a1);
}
}
return result;
}

original_code:
void matedit( CHAR_DATA *ch, char *argument )
{
    MAT_TYPE *pMat;
    char command[256];
    char arg[256];
    int cmd;
    ( pMat = (MAT_TYPE *)ch->desc->pEdit );
    smash_tilde( argument );
    strcpy( arg, argument );
    argument = one_argument( argument, command );
    if ( !__strcmp(command, "done", "olc_mat.c", __FUNCTION__, 276) )
    {
     save_materials();
     send_to_char("Materials Saved to disk.\n\r", ch);
  edit_done( ch );
  return;
    }
    if ( ((command) == ((void *)0) || (command)[0] == '\0') )
    {
  matedit_show( ch, argument );
  return;
    }
    for ( cmd = 0; matedit_table[cmd].name != ((void *)0); cmd++ )
    {
 if ( !str_prefix( command, matedit_table[cmd].name ) )
 {
     if ( (*matedit_table[cmd].olc_fun) ( ch, argument ) )
     {
   return;
     }
     else
   return;
 }
    }
    interpret( ch, arg );
    return;
}

canonical_original_code:
void matedit(struct char_data *ch, char *argument)
{
    struct material_type *pMat;
    char command[256];
    char arg[256];
    int cmd;
    ( pMat = (struct material_type *)ch->desc->pEdit );
    smash_tilde( argument );
    strcpy( arg, argument );
    argument = one_argument( argument, command );
    if ( !__strcmp(command, "done", "olc_mat.c", __FUNCTION__, 276) )
    {
     save_materials();
     send_to_char("Materials Saved to disk.\n\r", ch);
  edit_done( ch );
  return;
    }
    if ( ((command) == ((void *)0) || (command)[0] == '\0') )
    {
  matedit_show( ch, argument );
  return;
    }
    for ( cmd = 0; matedit_table[cmd].name != ((void *)0); cmd++ )
    {
 if ( !str_prefix( command, matedit_table[cmd].name ) )
 {
     if ( (*matedit_table[cmd].olc_fun) ( ch, argument ) )
     {
   return;
     }
     else
   return;
 }
    }
    interpret( ch, arg );
    return;
}

variable_types:
command
char [256]

variable_types: cmd int

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: 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 buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; }

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; }


decompiled_code:
__int64 __fastcall do_matedit(__int64 a1, __int64 a2)
{
__int64 result; // rax
_BYTE *v3; // r12
__int64 v4; // r12
__int128 v5; // [rsp+0h] [rbp-1218h] BYREF
char v6[4592]; // [rsp+10h] [rbp-1208h] BYREF

result = 0LL;
v5 = 0LL;
memset(v6, 0, sizeof(v6));
if ( (*(_BYTE *)(a1 + 320) & 1) == 0 )
{
v3 = (_BYTE *)one_argument(a2, &v5);
if ( find_mat(&v5) )
{
v4 = *(_QWORD *)(a1 + 88);
*(_QWORD *)(v4 + 1632) = find_mat(&v5);
result = *(_QWORD *)(a1 + 88);
*(_DWORD *)(result + 1648) = 7;
}
else if ( !(unsigned __int8)_strcmp(&v5, "create", "olc_mat.c", "do_matedit", 328LL) )
{
if ( find_mat(v3) )
{
result = send_to_char("That material already exists!\n\r", a1);
}
else if ( v3 && *v3 )
{
result = matedit_create(a1, v3);
}
else
{
result = send_to_char("Syntax: edit material create [name]\n\r", a1);
}
}
else
{
result = send_to_char("MATEdit: There is no default material to edit.\n\r", a1);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
__int64 result; // rax
_BYTE *v3; // r12
__int64 v4; // r12
__int128 v5; // [rsp+0h] [rbp-1218h] BYREF
char v6[4592]; // [rsp+10h] [rbp-1208h] BYREF

result = 0LL;
v5 = 0LL;
memset(v6, 0, sizeof(v6));
if ( (*(_BYTE *)(a1 + 320) & 1) == 0 )
{
v3 = (_BYTE *)one_argument(a2, &v5);
if ( find_mat(&v5) )
{
v4 = *(_QWORD *)(a1 + 88);
*(_QWORD *)(v4 + 1632) = find_mat(&v5);
result = *(_QWORD *)(a1 + 88);
*(_DWORD *)(result + 1648) = 7;
}
else if ( !(unsigned __int8)_strcmp(&v5, "create", "olc_mat.c", "do_matedit", 328LL) )
{
if ( find_mat(v3) )
{
result = send_to_char("That material already exists!\n\r", a1);
}
else if ( v3 && *v3 )
{
result = func7(a1, v3);
}
else
{
result = send_to_char("Syntax: edit material create [name]\n\r", a1);
}
}
else
{
result = send_to_char("MATEdit: There is no default material to edit.\n\r", a1);
}
}
return result;
}

original_code:
void do_matedit( CHAR_DATA *ch, char *argument )
{
    char arg1[4608]={'\0'};
    if ( ((((ch)->act) & ((1)))) )
 return;
    argument = one_argument( argument, arg1 );
    if ( find_mat(arg1) )
    {
 ch->desc->pEdit = (void *)find_mat(arg1);
 ch->desc->editor = 7;
 return;
    }
    else
    {
 if ( !__strcmp(arg1, "create", "olc_mat.c", __FUNCTION__, 328) )
 {
  if(find_mat(argument)) {
   send_to_char("That material already exists!\n\r", ch);
   return;
  }
     if ( ((argument) == ((void *)0) || (argument)[0] == '\0'))
     {
  send_to_char( "Syntax:  edit material create [name]\n\r", ch );
  return;
     }
  matedit_create(ch, argument);
     return;
 }
    }
    send_to_char( "MATEdit:  There is no default material to edit.\n\r", ch );
    return;
}

canonical_original_code:
void do_matedit(struct char_data *ch, char *argument)
{
    char arg1[4608] = {'\0'};
    if ( ((((ch)->act) & ((1)))) )
 return;
    argument = one_argument( argument, arg1 );
    if ( find_mat(arg1) )
    {
 ch->desc->pEdit = (void *)find_mat(arg1);
 ch->desc->editor = 7;
 return;
    }
    else
    {
 if ( !__strcmp(arg1, "create", "olc_mat.c", __FUNCTION__, 328) )
 {
  if(find_mat(argument)) {
   send_to_char("That material already exists!\n\r", ch);
   return;
  }
     if ( ((argument) == ((void *)0) || (argument)[0] == '\0'))
     {
  send_to_char( "Syntax:  edit material create [name]\n\r", ch );
  return;
     }
  matedit_create(ch, argument);
     return;
 }
    }
    send_to_char( "MATEdit:  There is no default material to edit.\n\r", ch );
    return;
}

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; }


original_code:
void do_matlist(CHAR_DATA *ch, char *argument) {
 MAT_TYPE *mat, *mat_next;
 BUFFER *output = __new_buf("olc_mat.c", __FUNCTION__, 351);
 int col = 0;
 for(mat = mat_list; mat; mat = mat_next) {
  mat_next = mat->next;
  add_buf(output, Format("%-15s", mat->name) );
  if(++col == 5) {
   col = 0;
   add_buf(output, "\n\r");
  }
 }
 page_to_char(buf_string(output), ch);
 free_buf(output);
 return;
}

canonical_original_code:
void do_matlist(struct char_data *ch, char *argument) {
 struct material_type *mat; struct material_type *mat_next;
 struct buf_type *output = __new_buf("olc_mat.c", __FUNCTION__, 351);
 int col = 0;
 for(mat = mat_list; mat; mat = mat_next) {
  mat_next = mat->next;
  add_buf(output, Format("%-15s", mat->name) );
  if(++col == 5) {
   col = 0;
   add_buf(output, "\n\r");
  }
 }
 page_to_char(buf_string(output), ch);
 free_buf(output);
 return;
}

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

user_defined_types: struct material_type { struct material_type *next; char *name; int assignedValue; }

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 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 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 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; }


decompiled_code:
__int64 __fastcall sort_cmd_table(const void *a1, const void *a2)
{
__int64 v2; // rdx
char *v3; // rsi
char v4; // al
__int64 v5; // rcx
char *v6; // rdi
char v7; // dl

v2 = *(int *)a2;
v3 = (&cmd_table)[3 * *(int *)a1];
v4 = *v3;
if ( !*v3 )
return 0LL;
v5 = 0LL;
v6 = (&cmd_table)[3 * v2];
while ( 1 )
{
v7 = v6[v5];
if ( v7 != v4 )
{
if ( !v7 || v7 < v4 )
return 1LL;
if ( v7 > v4 )
break;
}
v4 = v3[++v5];
if ( !v4 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
__int64 v2; // rdx
char *v3; // rsi
char v4; // al
__int64 v5; // rcx
char *v6; // rdi
char v7; // dl

v2 = *(int *)a2;
v3 = (&cmd_table)[3 * *(int *)a1];
v4 = *v3;
if ( !*v3 )
return 0LL;
v5 = 0LL;
v6 = (&cmd_table)[3 * v2];
while ( 1 )
{
v7 = v6[v5];
if ( v7 != v4 )
{
if ( !v7 || v7 < v4 )
return 1LL;
if ( v7 > v4 )
break;
}
v4 = v3[++v5];
if ( !v4 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int sort_cmd_table( const void *v1, const void *v2 )
{
 int idx1 = *(int *) v1;
 int idx2 = *(int *) v2;
 int i = 0;
 for (i = 0; cmd_table[idx1].name[i] != '\0'; i++)
 {
  if (cmd_table[idx1].name[i] == cmd_table[idx2].name[i]) continue;
  if (cmd_table[idx2].name[i] == '\0') return 1;
  if (cmd_table[idx1].name[i] > cmd_table[idx2].name[i]) return 1;
  if (cmd_table[idx1].name[i] < cmd_table[idx2].name[i]) return -1;
 }
 return 0;
}

canonical_original_code:
int sort_cmd_table(void *v1, void *v2)
{
 int idx1 = *(int *) v1;
 int idx2 = *(int *) v2;
 int i = 0;
 for (i = 0; cmd_table[idx1].name[i] != '\0'; i++)
 {
  if (cmd_table[idx1].name[i] == cmd_table[idx2].name[i]) continue;
  if (cmd_table[idx2].name[i] == '\0') return 1;
  if (cmd_table[idx1].name[i] > cmd_table[idx2].name[i]) return 1;
  if (cmd_table[idx1].name[i] < cmd_table[idx2].name[i]) return -1;
 }
 return 0;
}

variable_types: i int


decompiled_code:
__int64 __fastcall do_commands(__int64 a1)
{
const char **v1; // rdx
const char *v2; // rcx
int v3; // ebx
char *v4; // r12
char *v5; // rax
__int64 v6; // rax
char *v7; // rbx
char *v8; // r13
__int64 result; // rax
__int64 v10; // r15
char **v11; // r14
int v12; // er12
__int64 v13; // rax
int v14; // [rsp+Ch] [rbp-1203Ch]
char base[4]; // [rsp+10h] [rbp-12038h] BYREF
_DWORD v16[18445]; // [rsp+14h] [rbp-12034h] BYREF

v1 = (const char **)(unsigned int)((_DWORD)&cmd_table + 48);
v2 = "east";
v3 = 0;
v4 = base;
v5 = base;
while ( 1 )
{
*(_DWORD *)v5 = v3;
v5 += 4;
if ( !*v2 )
break;
v2 = *v1;
++v3;
v1 += 3;
}
qsort(base, v3 + 1, 4uLL, (__compar_fn_t)sort_cmd_table);
v6 = v3;
v7 = (char *)v16;
v14 = 0;
v8 = (char *)&v16[v6];
while ( 1 )
{
result = *(int *)v4;
v10 = 3 * result;
v11 = &(&cmd_table)[3 * result];
v12 = *((__int16 *)v11 + 9);
if ( *((__int16 *)v11 + 9) <= 50 )
{
result = get_trust(a1);
if ( v12 <= (int)result )
{
if ( *((_WORD *)v11 + 11) )
{
v13 = Format("%-12s", (&cmd_table)[v10]);
send_to_char(v13, a1);
result = (unsigned int)++v14;
if ( (v14 & 3) == 0 )
break;
}
}
}
v4 = v7;
if ( v8 == v7 )
goto LABEL_12;
LABEL_6:
v7 += 4;
}
v4 = v7;
result = send_to_char("\n\r", a1);
if ( v8 != v7 )
goto LABEL_6;
LABEL_12:
if ( (v14 & 3) != 0 )
result = send_to_char("\n\r", a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
const char **v1; // rdx
const char *v2; // rcx
int v3; // ebx
char *v4; // r12
char *v5; // rax
__int64 v6; // rax
char *v7; // rbx
char *v8; // r13
__int64 result; // rax
__int64 v10; // r15
char **v11; // r14
int v12; // er12
__int64 v13; // rax
int v14; // [rsp+Ch] [rbp-1203Ch]
char base[4]; // [rsp+10h] [rbp-12038h] BYREF
_DWORD v16[18445]; // [rsp+14h] [rbp-12034h] BYREF

v1 = (const char **)(unsigned int)((_DWORD)&cmd_table + 48);
v2 = "east";
v3 = 0;
v4 = base;
v5 = base;
while ( 1 )
{
*(_DWORD *)v5 = v3;
v5 += 4;
if ( !*v2 )
break;
v2 = *v1;
++v3;
v1 += 3;
}
qsort(base, v3 + 1, 4uLL, (__compar_fn_t)sort_cmd_table);
v6 = v3;
v7 = (char *)v16;
v14 = 0;
v8 = (char *)&v16[v6];
while ( 1 )
{
result = *(int *)v4;
v10 = 3 * result;
v11 = &(&cmd_table)[3 * result];
v12 = *((__int16 *)v11 + 9);
if ( *((__int16 *)v11 + 9) <= 50 )
{
result = get_trust(a1);
if ( v12 <= (int)result )
{
if ( *((_WORD *)v11 + 11) )
{
v13 = Format("%-12s", (&cmd_table)[v10]);
send_to_char(v13, a1);
result = (unsigned int)++v14;
if ( (v14 & 3) == 0 )
break;
}
}
}
v4 = v7;
if ( v8 == v7 )
goto LABEL_12;
LABEL_6:
v7 += 4;
}
v4 = v7;
result = send_to_char("\n\r", a1);
if ( v8 != v7 )
goto LABEL_6;
LABEL_12:
if ( (v14 & 3) != 0 )
result = send_to_char("\n\r", a1);
return result;
}

original_code:
void do_commands( CHAR_DATA *ch, char *argument )
{
 int index[4608*4];
 int cmd = 0;
 int col = 0;
 int count = 0;
 int i = 0;
 for ( count = 0; cmd_table[count].name[0] != '\0'; count++ )
    {
     index[count] = count;
    }
 qsort(index, count, sizeof(int), sort_cmd_table);
    for ( i = 0; i < count; i++ )
 {
  cmd = index[i];
  if ( cmd_table[cmd].level < (60 - 9)
   && cmd_table[cmd].level <= get_trust( ch )
   && cmd_table[cmd].show)
  {
   send_to_char( Format("%-12s", cmd_table[cmd].name), ch );
   if ( ++col % 4 == 0 )
    send_to_char( "\n\r", ch );
  }
 }
 if ( col % 4 != 0 )
  send_to_char( "\n\r", ch );
 return;
}

canonical_original_code:
void do_commands(struct char_data *ch, char *argument)
{
 int index[-1];
 int cmd = 0;
 int col = 0;
 int count = 0;
 int i = 0;
 for ( count = 0; cmd_table[count].name[0] != '\0'; count++ )
    {
     index[count] = count;
    }
 qsort(index, count, sizeof(int), sort_cmd_table);
    for ( i = 0; i < count; i++ )
 {
  cmd = index[i];
  if ( cmd_table[cmd].level < (60 - 9)
   && cmd_table[cmd].level <= get_trust( ch )
   && cmd_table[cmd].show)
  {
   send_to_char( Format("%-12s", cmd_table[cmd].name), ch );
   if ( ++col % 4 == 0 )
    send_to_char( "\n\r", ch );
  }
 }
 if ( col % 4 != 0 )
  send_to_char( "\n\r", ch );
 return;
}

variable_types:
index
int [-1]

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: 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 buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; }

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 MSDP_t { enum bool_t bReport; enum bool_t bDirty; int ValueInt; char *pValueString; }

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; }