main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v5; // cf
bool v6; // zf
int v7; // ebx
const char *v8; // r15
const char *v9; // r14
__int64 v10; // rdx
const char *v11; // rsi
__int64 v12; // rcx
const char *v13; // rdi
bool v14; // cf
bool v15; // zf
char v16; // al
bool v17; // cf
bool v18; // zf
__int64 v19; // r12
__int64 v20; // rcx
const char *v21; // rdi
char v22; // al
__int64 v23; // rcx
const char *v24; // rdi
__int64 v25; // rbx
__int64 v26; // rbx
_BYTE *v28; // rax
int v29; // [rsp+Ch] [rbp-4Ch]
struct timespec requested_time; // [rsp+10h] [rbp-48h] BYREF

logging_init(argc, argv, envp);
logmsg(2LL, "Server started and logging started.");
v5 = 0;
v6 = argc == 0;
if ( argc <= 0 )
{
v8 = 0LL;
LODWORD(v10) = 5;
v29 = 5;
}
else
{
v7 = 0;
v8 = 0LL;
v9 = 0LL;
v10 = 5LL;
v29 = 5;
do
{
v19 = v7;
v11 = "-s";
v20 = 3LL;
v21 = argv[v19];
do
{
if ( !v20 )
break;
v5 = *v11 < (unsigned int)*v21;
v6 = *v11++ == *v21++;
--v20;
}
while ( v6 );
v22 = (!v5 && !v6) - v5;
v14 = 0;
v15 = v22 == 0;
if ( v22 )
{
v11 = "-f";
v12 = 3LL;
v13 = argv[v7];
do
{
if ( !v12 )
break;
v14 = *v11 < (unsigned int)*v13;
v15 = *v11++ == *v13++;
--v12;
}
while ( v15 );
v16 = (!v14 && !v15) - v14;
v17 = 0;
v18 = v16 == 0;
if ( v16 )
{
v11 = "-o";
v23 = 3LL;
v24 = argv[v7];
do
{
if ( !v23 )
break;
v17 = *v11 < (unsigned int)*v24;
v18 = *v11++ == *v24++;
--v23;
}
while ( v18 );
if ( (!v17 && !v18) == v17 )
v8 = argv[v19 + 1];
}
else
{
v9 = argv[v19 + 1];
}
}
else
{
v29 = atoi(argv[v19 + 1]);
v10 = (unsigned int)atoi(argv[v19 + 2]);
v7 += 2;
}
v5 = argc < (unsigned int)++v7;
v6 = argc == v7;
}
while ( argc > v7 );
if ( v9 )
{
v25 = Map_read(v9, v11, v10);
goto LABEL_21;
}
}
v25 = Map_new_air(v29, (int)v10);
Map_set_below(v25, 1LL, 60LL);
v28 = **(_BYTE ***)(v25 + 16);
*v28 = 20;
v28[1] = 0;
v9 = v8;
LABEL_21:
v26 = Server_create(v25, 10LL);
sigint_server = v26;
*(_BYTE *)(v26 + 56) = 1;
*(_QWORD *)(v26 + 232) = v9;
signal(2, (__sighandler_t)catch_sigint);
pthread_create((pthread_t *)(v26 + 240), 0LL, (void *(*)(void *))&connection_distributor_thread, (void *)v26);
logmsg(2LL, "Distributor thread started.");
requested_time.tv_sec = 0LL;
requested_time.tv_nsec = 50000000LL;
while ( *(_BYTE *)(v26 + 56) )
{
pthread_rwlock_wrlock((pthread_rwlock_t *)v26);
pthread_rwlock_wrlock((pthread_rwlock_t *)(v26 + 96));
Server_tick(v26);
pthread_rwlock_unlock((pthread_rwlock_t *)v26);
pthread_rwlock_unlock((pthread_rwlock_t *)(v26 + 96));
nanosleep(&requested_time, 0LL);
}
pthread_join(*(_QWORD *)(v26 + 240), 0LL);
logmsg(2LL, "Server shutting down!");
return 0;
}

original_code:
int main(int argc, char *argv[]){
    logging_init();
    logmsg(2, "Server started and logging started.");
    int xsize = 5;
    int zsize = 5;
    char *filename = ((void *)0);
    char *out_name = ((void *)0);
    for(int i=0; i < argc; i++){
 if (strcmp("-s", argv[i])== 0){
     xsize = atoi(argv[i+1]);
     zsize = atoi(argv[i+2]);
     i += 2;
 } else if (strcmp("-f", argv[i]) == 0){
     filename = argv[i+1];
 } else if (strcmp("-o", argv[i]) == 0){
     out_name = argv[i+1];
 }
    }
    Map *map;
    if (filename == ((void *)0)){
 map = Map_new_air(xsize,zsize);
 Block b;
 b.id = 1;
 b.metadata = 0;
 Map_set_below(map, b, 60);
 b.id=20; map->chunks[0]->blocks[0] = b;
 if (out_name != ((void *)0)){
     filename = out_name;
 }
    } else {
 map = Map_read(filename);
    }
    Server *server = Server_create(map, 10);
    sigint_server = server;
    server->is_running = 1;
    server->filename = filename;
    signal(2, catch_sigint);
    pthread_create(&(server->distributor_thread),
     ((void *)0), &connection_distributor_thread, server);
    logmsg(2, "Distributor thread started.");
    struct timespec sleeptime;
    sleeptime.tv_sec = 0;
    sleeptime.tv_nsec = 50000000;
    while (server->is_running){
 pthread_rwlock_wrlock(&server->state_lock);
 pthread_rwlock_wrlock(&server->players_lock);
 Server_tick(server);
 pthread_rwlock_unlock(&server->state_lock);
 pthread_rwlock_unlock(&server->players_lock);
 nanosleep(&sleeptime, ((void *)0));
    }
    pthread_join(server->distributor_thread, ((void *)0));
    logmsg(2, "Server shutting down!");
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
    logging_init();
    logmsg(2, "Server started and logging started.");
    int xsize = 5;
    int zsize = 5;
    char *filename = ((void *)0);
    char *out_name = ((void *)0);
    for(int i = 0; i < argc; i++){
 if (strcmp("-s", argv[i])== 0){
     xsize = atoi(argv[i+1]);
     zsize = atoi(argv[i+2]);
     i += 2;
 } else if (strcmp("-f", argv[i]) == 0){
     filename = argv[i+1];
 } else if (strcmp("-o", argv[i]) == 0){
     out_name = argv[i+1];
 }
    }
    struct Map *map;
    if (filename == ((void *)0)){
 map = Map_new_air(xsize,zsize);
 struct Block b;
 b.id = 1;
 b.metadata = 0;
 Map_set_below(map, b, 60);
 b.id=20; map->chunks[0]->blocks[0] = b;
 if (out_name != ((void *)0)){
     filename = out_name;
 }
    } else {
 map = Map_read(filename);
    }
    struct Server *server = Server_create(map, 10);
    sigint_server = server;
    server->is_running = 1;
    server->filename = filename;
    signal(2, catch_sigint);
    pthread_create(&(server->distributor_thread),
     ((void *)0), &connection_distributor_thread, server);
    logmsg(2, "Distributor thread started.");
    struct timespec sleeptime;
    sleeptime.tv_sec = 0;
    sleeptime.tv_nsec = 50000000;
    while (server->is_running){
 pthread_rwlock_wrlock(&server->state_lock);
 pthread_rwlock_wrlock(&server->players_lock);
 Server_tick(server);
 pthread_rwlock_unlock(&server->state_lock);
 pthread_rwlock_unlock(&server->players_lock);
 nanosleep(&sleeptime, ((void *)0));
    }
    pthread_join(server->distributor_thread, ((void *)0));
    logmsg(2, "Server shutting down!");
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: xsize int

variable_types: zsize int

variable_types:
filename
char *

variable_types: i int

variable_types: struct Server { union pthread_rwlock_t { struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; char __rwelision; unsigned char __pad1[7]; unsigned long __pad2; unsigned int __flags; } __data; char __size[56]; long __align; } state_lock; char is_running; long time; int last_entity_id; int spawnx; int spawny; int spawnz; unsigned long max_players; union pthread_rwlock_t players_lock; int num_players; struct Player { union pthread_rwlock_t lock; char *username; int entity_id; int socket; struct Inventory { unsigned long size; struct Slot { short id; char count; short damage; short nbt_len; char *nbt; } **slots; } *inventory; int held_slot_num; double x; double y; double z; float yaw; float pitch; double last_x; double last_y; double last_z; } **players; union pthread_rwlock_t map_lock; struct Map { unsigned long xchunks; unsigned long zchunks; struct Chunk { struct Block { unsigned char id; unsigned char metadata; } blocks[-1]; char biome_data[-1]; } **chunks; } *map; char *filename; unsigned long distributor_thread; int distributor_socket; } *

variable_types: struct timespec { long tv_sec; long tv_nsec; }


repo: SpenceSellers/microMC

decompiled_code:
void __fastcall __noreturn connection_distributor_thread(__int64 a1)
{
int v1; // ebp
int v2; // ebx
pthread_t newthread; // [rsp+8h] [rbp-130h] BYREF
int arg; // [rsp+10h] [rbp-128h] BYREF
__int64 v5; // [rsp+18h] [rbp-120h]
pthread_attr_t attr; // [rsp+20h] [rbp-118h] BYREF
struct addrinfo *pai; // [rsp+58h] [rbp-E0h] BYREF
struct addrinfo req; // [rsp+60h] [rbp-D8h] BYREF
socklen_t addr_len; // [rsp+9Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+A0h] [rbp-98h] BYREF

logmsg(2LL, "Started new distributor thread.");
*(_QWORD *)&req.ai_flags = 1LL;
*(_QWORD *)&req.ai_socktype = 1LL;
*(_QWORD *)&req.ai_addrlen = 0LL;
req.ai_addr = 0LL;
req.ai_canonname = 0LL;
req.ai_next = 0LL;
getaddrinfo(0LL, "25565", &req, &pai);
v1 = socket(pai->ai_family, pai->ai_socktype, pai->ai_protocol);
if ( bind(v1, pai->ai_addr, pai->ai_addrlen) != -1 )
{
listen(v1, 10);
addr_len = 128;
*(_DWORD *)(a1 + 248) = v1;
while ( 1 )
{
logmsg(3LL, "Distributor waiting on new connection.");
v2 = accept(v1, &addr, &addr_len);
if ( v2 == -1 )
logmsg(0LL, "Error accepting connection!");
logmsg(2LL, "Accepted connection. Starting new thread!");
v5 = a1;
arg = v2;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 0);
pthread_create(&newthread, &attr, (void *(*)(void *))connection_thread, &arg);
pthread_attr_destroy(&attr);
}
}
logmsg(0LL, "Unable to bind socket!");
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(__int64 a1)
{
int v1; // ebp
int v2; // ebx
pthread_t newthread; // [rsp+8h] [rbp-130h] BYREF
int arg; // [rsp+10h] [rbp-128h] BYREF
__int64 v5; // [rsp+18h] [rbp-120h]
pthread_attr_t attr; // [rsp+20h] [rbp-118h] BYREF
struct addrinfo *pai; // [rsp+58h] [rbp-E0h] BYREF
struct addrinfo req; // [rsp+60h] [rbp-D8h] BYREF
socklen_t addr_len; // [rsp+9Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+A0h] [rbp-98h] BYREF

logmsg(2LL, "Started new distributor thread.");
*(_QWORD *)&req.ai_flags = 1LL;
*(_QWORD *)&req.ai_socktype = 1LL;
*(_QWORD *)&req.ai_addrlen = 0LL;
req.ai_addr = 0LL;
req.ai_canonname = 0LL;
req.ai_next = 0LL;
getaddrinfo(0LL, "25565", &req, &pai);
v1 = socket(pai->ai_family, pai->ai_socktype, pai->ai_protocol);
if ( bind(v1, pai->ai_addr, pai->ai_addrlen) != -1 )
{
listen(v1, 10);
addr_len = 128;
*(_DWORD *)(a1 + 248) = v1;
while ( 1 )
{
logmsg(3LL, "Distributor waiting on new connection.");
v2 = accept(v1, &addr, &addr_len);
if ( v2 == -1 )
logmsg(0LL, "Error accepting connection!");
logmsg(2LL, "Accepted connection. Starting new thread!");
v5 = a1;
arg = v2;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 0);
pthread_create(&newthread, &attr, (void *(*)(void *))connection_thread, &arg);
pthread_attr_destroy(&attr);
}
}
logmsg(0LL, "Unable to bind socket!");
exit(1);
}

original_code:
void *connection_distributor_thread(void *args){
    Server *server = (Server*) args;
    logmsg(2, "Started new distributor thread.");
    struct sockaddr_storage their_addr;
    socklen_t addr_size;
    struct addrinfo hints, *res;
    int new_fd;
    memset(&hints, 0, sizeof hints);
    hints.ai_family = 0;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = 0x0001;
    getaddrinfo(((void *)0), "25565", &hints, &res);
    int sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
    int binderr = bind(sock, res->ai_addr, res->ai_addrlen);
    if (binderr == -1){
 logmsg(0, "Unable to bind socket!");
 exit(1);
    }
    listen(sock, 10);
    addr_size = sizeof their_addr;
    server->distributor_socket = sock;
    while (1){
 logmsg(3, "Distributor waiting on new connection.");
 new_fd = accept(sock, (struct sockaddr *)&their_addr, &addr_size);
 if (new_fd == -1){
     logmsg(0, "Error accepting connection!");
 }
 logmsg(2, "Accepted connection. Starting new thread!");
 struct ConnectionThreadArgs ctargs;
 ctargs.server = server;
 ctargs.sock = new_fd;
 pthread_t thread;
 pthread_attr_t attr;
 pthread_attr_init(&attr);
 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 pthread_create(&thread, &attr, &connection_thread, &ctargs);
 pthread_attr_destroy(&attr);
    }
    logmsg(2, "Closing distributor socket/thread.");
    close(sock);
    pthread_exit(((void *)0));
}

canonical_original_code:
void *connection_distributor_thread(void *args){
    struct Server *server = (Server*) args;
    logmsg(2, "Started new distributor thread.");
    struct sockaddr_storage their_addr;
    unsigned int addr_size;
    struct addrinfo hints; struct addrinfo *res;
    int new_fd;
    memset(&hints, 0, sizeof hints);
    hints.ai_family = 0;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = 0x0001;
    getaddrinfo(((void *)0), "25565", &hints, &res);
    int sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
    int binderr = bind(sock, res->ai_addr, res->ai_addrlen);
    if (binderr == -1){
 logmsg(0, "Unable to bind socket!");
 exit(1);
    }
    listen(sock, 10);
    addr_size = sizeof their_addr;
    server->distributor_socket = sock;
    while (1){
 logmsg(3, "Distributor waiting on new connection.");
 new_fd = accept(sock, (struct sockaddr *)&their_addr, &addr_size);
 if (new_fd == -1){
     logmsg(0, "Error accepting connection!");
 }
 logmsg(2, "Accepted connection. Starting new thread!");
 struct ConnectionThreadArgs ctargs;
 ctargs.server = server;
 ctargs.sock = new_fd;
 unsigned long thread;
 union pthread_attr_t attr;
 pthread_attr_init(&attr);
 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 pthread_create(&thread, &attr, &connection_thread, &ctargs);
 pthread_attr_destroy(&attr);
    }
    logmsg(2, "Closing distributor socket/thread.");
    close(sock);
    pthread_exit(((void *)0));
}

variable_types:
args
void *

variable_types: struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; }

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *

variable_types: sock int

variable_types: binderr int

variable_types: struct ConnectionThreadArgs { int sock; struct Server { union pthread_rwlock_t { struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; char __rwelision; unsigned char __pad1[7]; unsigned long __pad2; unsigned int __flags; } __data; char __size[56]; long __align; } state_lock; char is_running; long time; int last_entity_id; int spawnx; int spawny; int spawnz; unsigned long max_players; union pthread_rwlock_t players_lock; int num_players; struct Player { union pthread_rwlock_t lock; char *username; int entity_id; int socket; struct Inventory { unsigned long size; struct Slot { short id; char count; short damage; short nbt_len; char *nbt; } **slots; } *inventory; int held_slot_num; double x; double y; double z; float yaw; float pitch; double last_x; double last_y; double last_z; } **players; union pthread_rwlock_t map_lock; struct Map { unsigned long xchunks; unsigned long zchunks; struct Chunk { struct Block { unsigned char id; unsigned char metadata; } blocks[-1]; char biome_data[-1]; } **chunks; } *map; char *filename; unsigned long distributor_thread; int distributor_socket; } *server; }

variable_types:
thread
unsigned long

variable_types: union pthread_attr_t { char __size[56]; long __align; }

return_type: void *

user_defined_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }

user_defined_types: struct ConnectionThreadArgs { int sock; struct Server *server; }

user_defined_types: struct Server { union pthread_rwlock_t state_lock; char is_running; long time; int last_entity_id; int spawnx; int spawny; int spawnz; unsigned long max_players; union pthread_rwlock_t players_lock; int num_players; struct Player **players; union pthread_rwlock_t map_lock; struct Map *map; char *filename; unsigned long distributor_thread; int distributor_socket; }

user_defined_types: union pthread_rwlock_t { struct __pthread_rwlock_arch_t __data; char __size[56]; long __align; }

user_defined_types: struct Map { unsigned long xchunks; unsigned long zchunks; struct Chunk **chunks; }

user_defined_types: struct Player { union pthread_rwlock_t lock; char *username; int entity_id; int socket; struct Inventory *inventory; int held_slot_num; double x; double y; double z; float yaw; float pitch; double last_x; double last_y; double last_z; }

user_defined_types: struct Inventory { unsigned long size; struct Slot **slots; }

user_defined_types: struct Chunk { struct Block blocks[-1]; char biome_data[-1]; }


wait

decompiled_code:
int __fastcall wait(unsigned __int16 a1, int a2)
{
int result; // eax
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = a1;
sops.sem_op = -1;
sops.sem_flg = 4096;
result = semop(a2, &sops, 1uLL);
if ( result == -1 )
{
perror("Error in semop");
exit(-1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(unsigned __int16 a1, int a2)
{
int result; // eax
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = a1;
sops.sem_op = -1;
sops.sem_flg = 4096;
result = semop(a2, &sops, 1uLL);
if ( result == -1 )
{
perror("Error in semop");
exit(-1);
}
return result;
}

original_code:
void wait(int sem, int semID, int nBuffers){
 struct sembuf sembuffer;
 sembuffer.sem_num = sem;
 sembuffer.sem_op = -1;
 sembuffer.sem_flg = 0x1000;
 if(semop(semID, &sembuffer, 1) == -1){
  perror("Error in semop");
  exit(-1);
 }
}

variable_types: sem int

variable_types: semID int

variable_types: nBuffers int

variable_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }

return_type: void


signal

decompiled_code:
int __fastcall signal(unsigned __int16 a1, int a2)
{
int result; // eax
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = a1;
sops.sem_op = 1;
sops.sem_flg = 4096;
result = semop(a2, &sops, 1uLL);
if ( result == -1 )
{
perror("Error in semop");
exit(-1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(unsigned __int16 a1, int a2)
{
int result; // eax
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = a1;
sops.sem_op = 1;
sops.sem_flg = 4096;
result = semop(a2, &sops, 1uLL);
if ( result == -1 )
{
perror("Error in semop");
exit(-1);
}
return result;
}

original_code:
void signal(int sem, int semID, int nBuffers){
 struct sembuf sembuffer;
 sembuffer.sem_num = sem;
 sembuffer.sem_op = 1;
 sembuffer.sem_flg = 0x1000;
 if(semop(semID, &sembuffer, 1) == -1){
  perror("Error in semop");
  exit(-1);
 }
}

user_defined_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


decompiled_code:
__int64 __fastcall str2int(const char *a1)
{
return strtol(a1, 0LL, 10);
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1)
{
return strtol(a1, 0LL, 10);
}

original_code:
int str2int(char *str){
 return strtol(str, 0, 10);
}

variable_types:
str
char *

return_type: int


decompiled_code:
float __fastcall str2float(const char *a1)
{
char *endptr; // [rsp+8h] [rbp-10h] BYREF

return strtof(a1, &endptr);
}

canonical_decompiled_code:
float __fastcall func10(const char *a1)
{
char *endptr; // [rsp+8h] [rbp-10h] BYREF

return strtof(a1, &endptr);
}

original_code:
float str2float(char *str){
 char *end;
 return strtof(str, &end);
}

variable_types:
end
char *

return_type: float


decompiled_code:
void mon_strlen_setup()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void mon_strlen_setup(struct mu_test_desc *desc) {
}

variable_types: struct mu_test_desc { void (*test)(struct mu_test_desc *desc); char *test_name; int success; int performed; } *


decompiled_code:
void mon_strlen_tear_down()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void mon_strlen_tear_down(struct mu_test_desc *desc) {
}

user_defined_types: struct mu_test_desc { void (*test)(struct mu_test_desc *desc); char *test_name; int success; int performed; }


decompiled_code:
void mon_strcmp_setup()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void mon_strcmp_setup(struct mu_test_desc *desc) {
}


decompiled_code:
void mon_strcmp_tear_down()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void mon_strcmp_tear_down(struct mu_test_desc *desc) {
}


decompiled_code:
void mon_strncmp_setup()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void mon_strncmp_setup(struct mu_test_desc *desc) {
}


decompiled_code:
void mon_strncmp_tear_down()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void mon_strncmp_tear_down(struct mu_test_desc *desc) {
}


decompiled_code:
int *mon_strcat_setup()
{
int *result; // rax

result = &dest;
do
{
*(_BYTE *)result = -1;
result = (int *)((char *)result + 1);
}
while ( result != (int *)(unsigned int)((_DWORD)&dest + 128) );
return result;
}

canonical_decompiled_code:
int *func7()
{
int *result; // rax

result = &dest;
do
{
*(_BYTE *)result = -1;
result = (int *)((char *)result + 1);
}
while ( result != (int *)(unsigned int)((_DWORD)&dest + 128) );
return result;
}

original_code:
void mon_strcat_setup(struct mu_test_desc *desc) {
    int i ;
    for (i = 0 ; i < (128) ; i++) {
        dest[i] = (-1) ;
    }
}

canonical_original_code:
void mon_strcat_setup(struct mu_test_desc *desc) {
    int i;
    for (i = 0 ; i < (128) ; i++) {
        dest[i] = (-1) ;
    }
}

variable_types: i int


decompiled_code:
void mon_strcat_tear_down()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void mon_strcat_tear_down(struct mu_test_desc *desc) {
}


decompiled_code:
void mon_strchr_setup()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void mon_strchr_setup(struct mu_test_desc *desc) {
}


decompiled_code:
void mon_strchr_tear_down()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
void mon_strchr_tear_down(struct mu_test_desc *desc) {
}


decompiled_code:
void mon_strstr_setup()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code:
void mon_strstr_setup(struct mu_test_desc *desc) {
}


decompiled_code:
void mon_strstr_tear_down()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code:
void mon_strstr_tear_down(struct mu_test_desc *desc) {
}


decompiled_code:
__int64 __fastcall mon_strlen_strlen5(__int64 a1)
{
__int64 result; // rax

result = mon_strlen("12345");
if ( (_DWORD)result == 5 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
__int64 result; // rax

result = mon_strlen("12345");
if ( (_DWORD)result == 5 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strlen_strlen5(struct mu_test_desc *desc) {
    do { if ( ((mon_strlen("12345")) == (5)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strlen_strlen0(__int64 a1)
{
__int64 result; // rax

result = mon_strlen(&unk_C66);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
__int64 result; // rax

result = mon_strlen(&unk_C66);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strlen_strlen0(struct mu_test_desc *desc) {
    do { if ( ((mon_strlen("")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strlen_strlen_multi0(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+6h] [rbp-12h] BYREF
__int16 v3; // [rsp+Eh] [rbp-Ah]

v2 = 0x4100414141414141LL;
v3 = 65;
result = mon_strlen(&v2);
if ( (_DWORD)result == 6 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strlen_strlen_multi0(struct mu_test_desc *desc) {
    char str[] = {'A','A','A','A','A','A','\0','A','A','\0'} ;
    do { if ( ((mon_strlen(str)) == (6)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strlen_strlen_multi0(struct mu_test_desc *desc) {
    char str[] = {'A','A','A','A','A','A','\0','A','A','\0'};
    do { if ( ((mon_strlen(str)) == (6)) ) desc->success++; desc->performed++; } while (0) ;
}

variable_types:
str
char []


decompiled_code:
__int64 __fastcall mon_strcmp_mon_strcmp_a_equals_b_vide(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp(&unk_C66);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp(&unk_C66);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcmp_mon_strcmp_a_equals_b_vide(struct mu_test_desc *desc) {
    do { if ( ((mon_strcmp("","")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strcmp_mon_strcmp_a_equals_b_non_vide(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("UIO");
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("UIO");
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcmp_mon_strcmp_a_equals_b_non_vide(struct mu_test_desc *desc) {
    do { if ( ((mon_strcmp("UIO","UIO")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strcmp_mon_strcmp_a_less_than_b(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("BCD");
if ( (int)result < 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("BCD");
if ( (int)result < 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcmp_mon_strcmp_a_less_than_b(struct mu_test_desc *desc) {
    do { if ( ((mon_strcmp("BCD","EF")) < (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strcmp_mon_strcmp_a_left_factor_of_b(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("BCD");
if ( (int)result < 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("BCD");
if ( (int)result < 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcmp_mon_strcmp_a_left_factor_of_b(struct mu_test_desc *desc) {
    do { if ( ((mon_strcmp("BCD","BCDYU")) < (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strcmp_mon_strcmp_a_greater_than_b(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("KCD");
if ( (int)result > 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("KCD");
if ( (int)result > 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcmp_mon_strcmp_a_greater_than_b(struct mu_test_desc *desc) {
    do { if ( ((mon_strcmp("KCD","EF")) > (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strcmp_mon_strcmp_a_greater_than_b_vide(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("AZE");
if ( (int)result > 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1)
{
__int64 result; // rax

result = mon_strcmp("AZE");
if ( (int)result > 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcmp_mon_strcmp_a_greater_than_b_vide(struct mu_test_desc *desc) {
    do { if ( ((mon_strcmp("AZE","")) > (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strncmp_mon_strncmp_a_equals_b_vide(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp(&unk_C66, &unk_C66, 0LL);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp(&unk_C66, &unk_C66, 0LL);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strncmp_mon_strncmp_a_equals_b_vide(struct mu_test_desc *desc) {
    do { if ( ((mon_strncmp("","", 0)) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strncmp_mon_strncmp_a_equals_b_n_too_large(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp(&unk_C66, &unk_C66, 6LL);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp(&unk_C66, &unk_C66, 6LL);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strncmp_mon_strncmp_a_equals_b_n_too_large(struct mu_test_desc *desc) {
    do { if ( ((mon_strncmp("","", 6)) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strncmp_monstrncmp_n_restrict(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp("ABCDEF", "ABCTYU", 3LL);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp("ABCDEF", "ABCTYU", 3LL);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strncmp_monstrncmp_n_restrict(struct mu_test_desc *desc) {
    do { if ( ((mon_strncmp("ABCDEF","ABCTYU", 3)) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strncmp_monstrncmp_a_greater(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp("ABDTYY", "ABCTYU", 3LL);
if ( (int)result > 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func25(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp("ABDTYY", "ABCTYU", 3LL);
if ( (int)result > 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strncmp_monstrncmp_a_greater(struct mu_test_desc *desc) {
    do { if ( ((mon_strncmp("ABDTYY","ABCTYU", 3)) > (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strncmp_monstrncmp_a_lower(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp("ABBWYY", "ABCTYU", 3LL);
if ( (int)result < 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func26(__int64 a1)
{
__int64 result; // rax

result = mon_strncmp("ABBWYY", "ABCTYU", 3LL);
if ( (int)result < 0 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strncmp_monstrncmp_a_lower(struct mu_test_desc *desc) {
    do { if ( ((mon_strncmp("ABBWYY","ABCTYU", 3)) < (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
bool __fastcall mon_strcat_mon_strcat_a_et_b_non_vides(__int64 a1)
{
bool v1; // zf
bool result; // al

strcpy((char *)dest, "PREM");
v1 = strcmp((const char *)mon_strcat(dest, "IJKLM"), "PREMIJKLM") == 0;
result = !v1;
if ( v1 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
bool __fastcall func27(__int64 a1)
{
bool v1; // zf
bool result; // al

strcpy((char *)dest, "PREM");
v1 = strcmp((const char *)mon_strcat(dest, "IJKLM"), "PREMIJKLM") == 0;
result = !v1;
if ( v1 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcat_mon_strcat_a_et_b_non_vides(struct mu_test_desc *desc) {
    char *result ;
    strcpy(dest, "PREM") ;
    result = mon_strcat(dest, "IJKLM") ;
    do { if ( ((strcmp(result,"PREMIJKLM")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strcat_mon_strcat_a_et_b_non_vides(struct mu_test_desc *desc) {
    char *result;
    strcpy(dest, "PREM") ;
    result = mon_strcat(dest, "IJKLM") ;
    do { if ( ((strcmp(result,"PREMIJKLM")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}

variable_types:
result
char *


decompiled_code:
bool __fastcall mon_strcat_mon_strcat_a_vide_et_b(__int64 a1)
{
bool v1; // zf
bool result; // al

LOBYTE(dest[0]) = 0;
v1 = strcmp((const char *)mon_strcat(dest, "IJKLM"), "IJKLM") == 0;
result = !v1;
if ( v1 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
bool __fastcall func28(__int64 a1)
{
bool v1; // zf
bool result; // al

LOBYTE(dest[0]) = 0;
v1 = strcmp((const char *)mon_strcat(dest, "IJKLM"), "IJKLM") == 0;
result = !v1;
if ( v1 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcat_mon_strcat_a_vide_et_b(struct mu_test_desc *desc) {
    char *result ;
    strcpy(dest, "") ;
    result = mon_strcat(dest, "IJKLM") ;
    do { if ( ((strcmp(result,"IJKLM")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strcat_mon_strcat_a_vide_et_b(struct mu_test_desc *desc) {
    char *result;
    strcpy(dest, "") ;
    result = mon_strcat(dest, "IJKLM") ;
    do { if ( ((strcmp(result,"IJKLM")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
bool __fastcall mon_strcat_mon_strcat_a_b_vide(__int64 a1)
{
bool v1; // zf
bool result; // al

strcpy((char *)dest, "PREM");
v1 = strcmp((const char *)mon_strcat(dest, &unk_C66), "PREM") == 0;
result = !v1;
if ( v1 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
bool __fastcall func29(__int64 a1)
{
bool v1; // zf
bool result; // al

strcpy((char *)dest, "PREM");
v1 = strcmp((const char *)mon_strcat(dest, &unk_C66), "PREM") == 0;
result = !v1;
if ( v1 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strcat_mon_strcat_a_b_vide(struct mu_test_desc *desc) {
    char *result ;
    strcpy(dest, "PREM") ;
    result = mon_strcat(dest, "") ;
    do { if ( ((strcmp(result,"PREM")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strcat_mon_strcat_a_b_vide(struct mu_test_desc *desc) {
    char *result;
    strcpy(dest, "PREM") ;
    result = mon_strcat(dest, "") ;
    do { if ( ((strcmp(result,"PREM")) == (0)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
char *__fastcall mon_strchr_mon_strchr_c_found(__int64 a1)
{
char *result; // rax

result = (char *)mon_strchr("ABCDEF", 68LL);
if ( result == "DEF" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
char *__fastcall func30(__int64 a1)
{
char *result; // rax

result = (char *)mon_strchr("ABCDEF", 68LL);
if ( result == "DEF" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strchr_mon_strchr_c_found(struct mu_test_desc *desc) {
    const char *str = "ABCDEF" ;
    const char *result ;
    result = mon_strchr(str, 'D') ;
    do { if ( ((result) == (str+3)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strchr_mon_strchr_c_found(struct mu_test_desc *desc) {
    char *str = "ABCDEF";
    char *result;
    result = mon_strchr(str, 'D') ;
    do { if ( ((result) == (str+3)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strchr_mon_strchr_c_not_found(__int64 a1)
{
__int64 result; // rax

result = mon_strchr("ABCDEF", 71LL);
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func31(__int64 a1)
{
__int64 result; // rax

result = mon_strchr("ABCDEF", 71LL);
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strchr_mon_strchr_c_not_found(struct mu_test_desc *desc) {
    const char *str = "ABCDEF" ;
    const char *result ;
    result = mon_strchr(str, 'G') ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strchr_mon_strchr_c_not_found(struct mu_test_desc *desc) {
    char *str = "ABCDEF";
    char *result;
    result = mon_strchr(str, 'G') ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
char *__fastcall mon_strchr_mon_strchr_c_first_found(__int64 a1)
{
char *result; // rax

result = (char *)mon_strchr("ABCDECFG", 67LL);
if ( result == "CDECFG" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
char *__fastcall func32(__int64 a1)
{
char *result; // rax

result = (char *)mon_strchr("ABCDECFG", 67LL);
if ( result == "CDECFG" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strchr_mon_strchr_c_first_found(struct mu_test_desc *desc) {
    const char *str = "ABCDECFG" ;
    const char *result ;
    result = mon_strchr(str, 'C') ;
    do { if ( ((result) == (str+2)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strchr_mon_strchr_c_first_found(struct mu_test_desc *desc) {
    char *str = "ABCDECFG";
    char *result;
    result = mon_strchr(str, 'C') ;
    do { if ( ((result) == (str+2)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strchr_mon_strchr_empty_string(__int64 a1)
{
__int64 result; // rax

result = mon_strchr(&unk_C66, 67LL);
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func33(__int64 a1)
{
__int64 result; // rax

result = mon_strchr(&unk_C66, 67LL);
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strchr_mon_strchr_empty_string(struct mu_test_desc *desc) {
    const char *str = "" ;
    const char *result ;
    result = mon_strchr(str, 'C') ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strchr_mon_strchr_empty_string(struct mu_test_desc *desc) {
    char *str = "";
    char *result;
    result = mon_strchr(str, 'C') ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
char *__fastcall mon_strstr_mon_strstr_str_found(__int64 a1)
{
char *result; // rax

result = (char *)mon_strstr("0123456789", "345");
if ( result == "3456789" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strstr_mon_strstr_str_found(struct mu_test_desc *desc) {
    const char *str = "0123456789" ;
    const char *result ;
    result = mon_strstr(str, "345") ;
    do { if ( ((result) == (str+3)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strstr_mon_strstr_str_found(struct mu_test_desc *desc) {
    char *str = "0123456789";
    char *result;
    result = mon_strstr(str, "345") ;
    do { if ( ((result) == (str+3)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strstr_mon_strstr_str_not_found(__int64 a1)
{
__int64 result; // rax

result = mon_strstr("0123456789", "346");
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strstr_mon_strstr_str_not_found(struct mu_test_desc *desc) {
    const char *str = "0123456789" ;
    const char *result ;
    result = mon_strstr(str, "346") ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strstr_mon_strstr_str_not_found(struct mu_test_desc *desc) {
    char *str = "0123456789";
    char *result;
    result = mon_strstr(str, "346") ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strstr_mon_strstr_str_vide(__int64 a1)
{
__int64 result; // rax

result = mon_strstr(&unk_C66, "CDEZ");
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func36(__int64 a1)
{
__int64 result; // rax

result = mon_strstr(&unk_C66, "CDEZ");
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strstr_mon_strstr_str_vide(struct mu_test_desc *desc) {
    const char *str = "" ;
    const char *result ;
    result = mon_strstr(str, "CDEZ") ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strstr_mon_strstr_str_vide(struct mu_test_desc *desc) {
    char *str = "";
    char *result;
    result = mon_strstr(str, "CDEZ") ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
char *__fastcall mon_strstr_mon_strstr_needle_vide(__int64 a1)
{
char *result; // rax

result = (char *)mon_strstr("0123456789", &unk_C66);
if ( result == "0123456789" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
char *__fastcall func37(__int64 a1)
{
char *result; // rax

result = (char *)mon_strstr("0123456789", &unk_C66);
if ( result == "0123456789" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strstr_mon_strstr_needle_vide(struct mu_test_desc *desc) {
    const char *str = "0123456789" ;
    const char *result ;
    result = mon_strstr(str, "") ;
    do { if ( ((result) == (str)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strstr_mon_strstr_needle_vide(struct mu_test_desc *desc) {
    char *str = "0123456789";
    char *result;
    result = mon_strstr(str, "") ;
    do { if ( ((result) == (str)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
__int64 __fastcall mon_strstr_mon_strstr_not_found_ends(__int64 a1)
{
__int64 result; // rax

result = mon_strstr("0123456789", "789A");
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func38(__int64 a1)
{
__int64 result; // rax

result = mon_strstr("0123456789", "789A");
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strstr_mon_strstr_not_found_ends(struct mu_test_desc *desc) {
    const char *str = "0123456789" ;
    const char *result ;
    result = mon_strstr(str, "789A") ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strstr_mon_strstr_not_found_ends(struct mu_test_desc *desc) {
    char *str = "0123456789";
    char *result;
    result = mon_strstr(str, "789A") ;
    do { if ( ((result) == (((void *)0))) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
char *__fastcall mon_strstr_mon_strstr_found_ends(__int64 a1)
{
char *result; // rax

result = (char *)mon_strstr("0123456789", "789");
if ( result == "789" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
char *__fastcall func39(__int64 a1)
{
char *result; // rax

result = (char *)mon_strstr("0123456789", "789");
if ( result == "789" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strstr_mon_strstr_found_ends(struct mu_test_desc *desc) {
    const char *str = "0123456789" ;
    const char *result ;
    result = mon_strstr(str, "789") ;
    do { if ( ((result) == (str+7)) ) desc->success++; desc->performed++; } while (0) ;
}

canonical_original_code:
void mon_strstr_mon_strstr_found_ends(struct mu_test_desc *desc) {
    char *str = "0123456789";
    char *result;
    result = mon_strstr(str, "789") ;
    do { if ( ((result) == (str+7)) ) desc->success++; desc->performed++; } while (0) ;
}


decompiled_code:
int __fastcall mu_report_test_suite(const char *a1, _QWORD *a2, unsigned int a3, unsigned int a4)
{
int result; // eax
_QWORD *v7; // rbx

printf("%s", "Suite ");
printf("%s", a1);
printf("%s", ": ");
printf("%d", a3);
putchar(47);
printf("%d", a4);
result = putchar(10);
if ( a3 != a4 )
{
result = puts("\tFailing tests:");
if ( *a2 )
{
v7 = a2 + 3;
do
{
result = *((_DWORD *)v7 - 1);
if ( !result || result != *((_DWORD *)v7 - 2) )
{
printf("%s", "\t\t");
printf("%s", (const char *)*(v7 - 2));
printf("%s", ": ");
if ( *((_DWORD *)v7 - 1) )
{
printf("%d", *((unsigned int *)v7 - 2));
putchar(47);
printf("%d", *((unsigned int *)v7 - 1));
result = puts(" passed");
}
else
{
result = puts("no test performed");
}
}
v7 += 3;
}
while ( *(v7 - 3) );
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func40(const char *a1, _QWORD *a2, unsigned int a3, unsigned int a4)
{
int result; // eax
_QWORD *v7; // rbx

printf("%s", "Suite ");
printf("%s", a1);
printf("%s", ": ");
printf("%d", a3);
putchar(47);
printf("%d", a4);
result = putchar(10);
if ( a3 != a4 )
{
result = puts("\tFailing tests:");
if ( *a2 )
{
v7 = a2 + 3;
do
{
result = *((_DWORD *)v7 - 1);
if ( !result || result != *((_DWORD *)v7 - 2) )
{
printf("%s", "\t\t");
printf("%s", (const char *)*(v7 - 2));
printf("%s", ": ");
if ( *((_DWORD *)v7 - 1) )
{
printf("%d", *((unsigned int *)v7 - 2));
putchar(47);
printf("%d", *((unsigned int *)v7 - 1));
result = puts(" passed");
}
else
{
result = puts("no test performed");
}
}
v7 += 3;
}
while ( *(v7 - 3) );
}
}
return result;
}

original_code:
static inline void mu_report_test_suite(const char *suite_name, struct mu_test_desc *tests_array, int success, int total)
{
    printf("%s", ("Suite "));
    printf("%s", (suite_name));
    printf("%s", (": "));
    printf("%d", (success));
    printf("%c", ('/'));
    printf("%d", (total));
    printf("%c", ('\n'));
    if (success != total)
    {
 int i;
 printf("%s", ("\tFailing tests:\n"));
 for (i = 0 ; tests_array[i].test != ((void *)0) ; ++i)
 {
     struct mu_test_desc *desc = &tests_array[i];
     if (!((desc)->performed != 0 && ((desc)->success == (desc)->performed)))
     {
  printf("%s", ("\t\t"));
  printf("%s", (desc->test_name));
  printf("%s", (": "));
  if (desc->performed != 0)
  {
      printf("%d", (desc->success));
      printf("%c", ('/'));
      printf("%d", (desc->performed));
      printf("%s", (" passed\n"));
  }
  else
  {
      printf("%s", ("no test performed\n"));
  }
     }
 }
    }
}

canonical_original_code:
static inline void mu_report_test_suite(char *suite_name, struct mu_test_desc *tests_array, int success, int total)
{
    printf("%s", ("Suite "));
    printf("%s", (suite_name));
    printf("%s", (": "));
    printf("%d", (success));
    printf("%c", ('/'));
    printf("%d", (total));
    printf("%c", ('\n'));
    if (success != total)
    {
 int i;
 printf("%s", ("\tFailing tests:\n"));
 for (i = 0 ; tests_array[i].test != ((void *)0) ; ++i)
 {
     struct mu_test_desc *desc = &tests_array[i];
     if (!((desc)->performed != 0 && ((desc)->success == (desc)->performed)))
     {
  printf("%s", ("\t\t"));
  printf("%s", (desc->test_name));
  printf("%s", (": "));
  if (desc->performed != 0)
  {
      printf("%d", (desc->success));
      printf("%c", ('/'));
      printf("%d", (desc->performed));
      printf("%s", (" passed\n"));
  }
  else
  {
      printf("%s", ("no test performed\n"));
  }
     }
 }
    }
}

variable_types: success int

variable_types: total int


decompiled_code:
__int64 __fastcall mon_strlen_strlen_non_ascii(__int64 a1)
{
__int64 result; // rax

result = mon_strlen(&unk_D18);
if ( (_DWORD)result == 8 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func41(__int64 a1)
{
__int64 result; // rax

result = mon_strlen(&unk_D18);
if ( (_DWORD)result == 8 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void mon_strlen_strlen_non_ascii(struct mu_test_desc *desc) {
    do { if ( ((mon_strlen("12345ééé")) == (8)) ) desc->success++; desc->performed++; } while (0) ;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4; // [rsp+8h] [rbp-10h] BYREF
unsigned int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4 = 0;
v5[0] = 0;
mu_run_test_suite(
(void (__fastcall *)(_QWORD *))mon_strlen_setup,
(void (__fastcall *)(_QWORD *))mon_strlen_tear_down,
&mon_strlen_tests_array,
&v4,
v5);
mu_report_test_suite("mon_strlen", &mon_strlen_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite(
(void (__fastcall *)(_QWORD *))mon_strcmp_setup,
(void (__fastcall *)(_QWORD *))mon_strcmp_tear_down,
&mon_strcmp_tests_array,
&v4,
v5);
mu_report_test_suite("mon_strcmp", &mon_strcmp_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite(
(void (__fastcall *)(_QWORD *))mon_strncmp_setup,
(void (__fastcall *)(_QWORD *))mon_strncmp_tear_down,
&mon_strncmp_tests_array,
&v4,
v5);
mu_report_test_suite("mon_strncmp", &mon_strncmp_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite(
(void (__fastcall *)(_QWORD *))mon_strcat_setup,
(void (__fastcall *)(_QWORD *))mon_strcat_tear_down,
&mon_strcat_tests_array,
&v4,
v5);
mu_report_test_suite("mon_strcat", &mon_strcat_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite(
(void (__fastcall *)(_QWORD *))mon_strchr_setup,
(void (__fastcall *)(_QWORD *))mon_strchr_tear_down,
&mon_strchr_tests_array,
&v4,
v5);
mu_report_test_suite("mon_strchr", &mon_strchr_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite(
(void (__fastcall *)(_QWORD *))mon_strstr_setup,
(void (__fastcall *)(_QWORD *))mon_strstr_tear_down,
&mon_strstr_tests_array,
&v4,
v5);
mu_report_test_suite("mon_strstr", &mon_strstr_tests_array, v4, v5[0]);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4; // [rsp+8h] [rbp-10h] BYREF
unsigned int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4 = 0;
v5[0] = 0;
func0(
(void (__fastcall *)(_QWORD *))mon_strlen_setup,
(void (__fastcall *)(_QWORD *))mon_strlen_tear_down,
&mon_strlen_tests_array,
&v4,
v5);
func40("mon_strlen", &mon_strlen_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
func0(
(void (__fastcall *)(_QWORD *))mon_strcmp_setup,
(void (__fastcall *)(_QWORD *))mon_strcmp_tear_down,
&mon_strcmp_tests_array,
&v4,
v5);
func40("mon_strcmp", &mon_strcmp_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
func0(
(void (__fastcall *)(_QWORD *))mon_strncmp_setup,
(void (__fastcall *)(_QWORD *))mon_strncmp_tear_down,
&mon_strncmp_tests_array,
&v4,
v5);
func40("mon_strncmp", &mon_strncmp_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
func0(
(void (__fastcall *)(_QWORD *))mon_strcat_setup,
(void (__fastcall *)(_QWORD *))mon_strcat_tear_down,
&mon_strcat_tests_array,
&v4,
v5);
func40("mon_strcat", &mon_strcat_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
func0(
(void (__fastcall *)(_QWORD *))mon_strchr_setup,
(void (__fastcall *)(_QWORD *))mon_strchr_tear_down,
&mon_strchr_tests_array,
&v4,
v5);
func40("mon_strchr", &mon_strchr_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
func0(
(void (__fastcall *)(_QWORD *))mon_strstr_setup,
(void (__fastcall *)(_QWORD *))mon_strstr_tear_down,
&mon_strstr_tests_array,
&v4,
v5);
func40("mon_strstr", &mon_strstr_tests_array, v4, v5[0]);
return 0;
}

original_code:
int main(int argc, char **argv) {
    do { int success = 0; int total = 0; mu_run_test_suite(mon_strlen_setup, mon_strlen_tear_down, mon_strlen_tests_array, (&success), (&total)); mu_report_test_suite("mon_strlen", mon_strlen_tests_array, success, total); } while(0) ;
    do { int success = 0; int total = 0; mu_run_test_suite(mon_strcmp_setup, mon_strcmp_tear_down, mon_strcmp_tests_array, (&success), (&total)); mu_report_test_suite("mon_strcmp", mon_strcmp_tests_array, success, total); } while(0) ;
    do { int success = 0; int total = 0; mu_run_test_suite(mon_strncmp_setup, mon_strncmp_tear_down, mon_strncmp_tests_array, (&success), (&total)); mu_report_test_suite("mon_strncmp", mon_strncmp_tests_array, success, total); } while(0) ;
    do { int success = 0; int total = 0; mu_run_test_suite(mon_strcat_setup, mon_strcat_tear_down, mon_strcat_tests_array, (&success), (&total)); mu_report_test_suite("mon_strcat", mon_strcat_tests_array, success, total); } while(0) ;
    do { int success = 0; int total = 0; mu_run_test_suite(mon_strchr_setup, mon_strchr_tear_down, mon_strchr_tests_array, (&success), (&total)); mu_report_test_suite("mon_strchr", mon_strchr_tests_array, success, total); } while(0) ;
    do { int success = 0; int total = 0; mu_run_test_suite(mon_strstr_setup, mon_strstr_tear_down, mon_strstr_tests_array, (&success), (&total)); mu_report_test_suite("mon_strstr", mon_strstr_tests_array, success, total); } while(0) ;
    return 0 ;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall mon_strlen(_BYTE *a1)
{
__int64 v1; // rax
unsigned int v2; // edx

if ( !*a1 )
return 0;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
__int64 v1; // rax
unsigned int v2; // edx

if ( !*a1 )
return 0;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

original_code:
int mon_strlen(const char s[]){
 int i=0;
 while(s[i]!='\0'){
  i++;
 }
 return i;
}

canonical_original_code:
int mon_strlen(char s[]){
 int i = 0;
 while(s[i]!='\0'){
  i++;
 }
 return i;
}

variable_types:
s
char []


decompiled_code:
__int64 __fastcall mon_strcmp(_BYTE *a1, _BYTE *a2)
{
int v2; // ecx
char v3; // dl
char v4; // al
int v5; // ebp
int v6; // edx
__int64 result; // rax

v2 = 0;
while ( 1 )
{
v4 = a1[v2];
if ( !v4 )
break;
v3 = a2[v2];
if ( v3 == v4 )
{
++v2;
}
else
{
LABEL_4:
if ( v4 > v3 )
return 1LL;
if ( v4 < v3 )
return 0xFFFFFFFFLL;
}
}
v3 = a2[v2];
if ( v3 )
goto LABEL_4;
v5 = mon_strlen(a1);
v6 = mon_strlen(a2);
result = 1LL;
if ( v5 <= v6 )
result = (unsigned int)-(v5 < v6);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1, _BYTE *a2)
{
int v2; // ecx
char v3; // dl
char v4; // al
int v5; // ebp
int v6; // edx
__int64 result; // rax

v2 = 0;
while ( 1 )
{
v4 = a1[v2];
if ( !v4 )
break;
v3 = a2[v2];
if ( v3 == v4 )
{
++v2;
}
else
{
LABEL_4:
if ( v4 > v3 )
return 1LL;
if ( v4 < v3 )
return 0xFFFFFFFFLL;
}
}
v3 = a2[v2];
if ( v3 )
goto LABEL_4;
v5 = func0(a1);
v6 = func0(a2);
result = 1LL;
if ( v5 <= v6 )
result = (unsigned int)-(v5 < v6);
return result;
}

original_code:
int mon_strcmp(const char *s1, const char *s2){
 int i=0;
 while(*(s1+i)!='\0'||*(s2+i)!='\0'){
  if(*(s1+i)==*(s2+i)){
   i++;
  } else if(*(s1+i)>*(s2+i)){
   return 1;
  } else if(*(s1+i)<*(s2+i)){
   return -1;
  }
 }
 if(mon_strlen(s1)>mon_strlen(s2)){
  return 1;
 } else if( mon_strlen(s2)>mon_strlen(s1)){
  return -1;
 }
 return 0;
}

canonical_original_code:
int mon_strcmp(char *s1, char *s2){
 int i = 0;
 while(*(s1+i)!='\0'||*(s2+i)!='\0'){
  if(*(s1+i)==*(s2+i)){
   i++;
  } else if(*(s1+i)>*(s2+i)){
   return 1;
  } else if(*(s1+i)<*(s2+i)){
   return -1;
  }
 }
 if(mon_strlen(s1)>mon_strlen(s2)){
  return 1;
 } else if( mon_strlen(s2)>mon_strlen(s1)){
  return -1;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall mon_strncmp(char *a1, _BYTE *a2, int a3)
{
char v4; // al
int v5; // ecx
__int64 v6; // rdx
char v7; // dl
__int64 result; // rax
int v9; // er12
int v10; // edx
int v11; // edx

v4 = *a1;
if ( a3 > 0 && v4 )
{
v5 = 0;
v6 = 0LL;
do
{
v7 = a2[v6];
if ( v7 == v4 )
{
++v5;
}
else
{
if ( v7 < v4 )
return 1LL;
if ( v7 > v4 )
return 0xFFFFFFFFLL;
}
v6 = v5;
v4 = a1[v5];
}
while ( a3 > v5 && v4 );
}
v9 = mon_strlen(a1);
if ( v9 < a3 || (v10 = mon_strlen(a2), result = 0LL, v10 < a3) )
{
v11 = mon_strlen(a2);
result = 1LL;
if ( v9 <= v11 )
result = (unsigned int)-(v9 < v11);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1, _BYTE *a2, int a3)
{
char v4; // al
int v5; // ecx
__int64 v6; // rdx
char v7; // dl
__int64 result; // rax
int v9; // er12
int v10; // edx
int v11; // edx

v4 = *a1;
if ( a3 > 0 && v4 )
{
v5 = 0;
v6 = 0LL;
do
{
v7 = a2[v6];
if ( v7 == v4 )
{
++v5;
}
else
{
if ( v7 < v4 )
return 1LL;
if ( v7 > v4 )
return 0xFFFFFFFFLL;
}
v6 = v5;
v4 = a1[v5];
}
while ( a3 > v5 && v4 );
}
v9 = func0(a1);
if ( v9 < a3 || (v10 = func0(a2), result = 0LL, v10 < a3) )
{
v11 = func0(a2);
result = 1LL;
if ( v9 <= v11 )
result = (unsigned int)-(v9 < v11);
}
return result;
}

original_code:
int mon_strncmp(const char *s1, const char *s2, int n){
 int i=0;
 while((*(s1+i)!='\0'||*(s1+i)!='\0') && i<n){
  if(*(s1+i)==*(s2+i)){
   i++;
  } else if(*(s1+i)>*(s2+i)){
   return 1;
  } else if(*(s1+i)<*(s2+i)){
   return -1;
  }
 }
 if((mon_strlen(s1)<n)||(mon_strlen(s2)<n)){
  if(mon_strlen(s1)>mon_strlen(s2)){
   return 1;
  } else if( mon_strlen(s2)>mon_strlen(s1)){
   return -1;
  }
 }
 return 0;
}

canonical_original_code:
int mon_strncmp(char *s1, char *s2, int n){
 int i = 0;
 while((*(s1+i)!='\0'||*(s1+i)!='\0') && i<n){
  if(*(s1+i)==*(s2+i)){
   i++;
  } else if(*(s1+i)>*(s2+i)){
   return 1;
  } else if(*(s1+i)<*(s2+i)){
   return -1;
  }
 }
 if((mon_strlen(s1)<n)||(mon_strlen(s2)<n)){
  if(mon_strlen(s1)>mon_strlen(s2)){
   return 1;
  } else if( mon_strlen(s2)>mon_strlen(s1)){
   return -1;
  }
 }
 return 0;
}

variable_types: n int


decompiled_code:
char *__fastcall mon_strstr(char *a1, _BYTE *a2)
{
int v2; // eax
char *v3; // rbp
int v4; // er12
__int64 v5; // rbx
int v6; // er15

v2 = mon_strlen(a2);
v3 = a1;
if ( v2 )
{
v4 = v2;
v5 = 0LL;
v6 = mon_strlen(a1) - v2;
while ( v6 > (int)v5 )
{
v3 = &a1[++v5];
if ( !(unsigned int)mon_strncmp(v3, a2, v4) )
return v3;
}
v3 = 0LL;
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func4(char *a1, _BYTE *a2)
{
int v2; // eax
char *v3; // rbp
int v4; // er12
__int64 v5; // rbx
int v6; // er15

v2 = func0(a2);
v3 = a1;
if ( v2 )
{
v4 = v2;
v5 = 0LL;
v6 = func0(a1) - v2;
while ( v6 > (int)v5 )
{
v3 = &a1[++v5];
if ( !(unsigned int)func2(v3, a2, v4) )
return v3;
}
v3 = 0LL;
}
return v3;
}

original_code:
char *mon_strstr(const char *haystack, const char *needle){
        int h_size = mon_strlen(haystack), n_size = mon_strlen(needle);
        int i=0;
        if(n_size==0){
                return (char*)haystack;
        }
        while(i<h_size-n_size){
                i++;
                if(mon_strncmp(haystack+i, needle, n_size)==0)
                        return (char*)haystack+i;
        }
        return ((void *)0);
}

canonical_original_code:
char *mon_strstr(char *haystack, char *needle){
        int h_size = mon_strlen(haystack); int n_size = mon_strlen(needle);
        int i = 0;
        if(n_size==0){
                return (char *)haystack;
        }
        while(i<h_size-n_size){
                i++;
                if(mon_strncmp(haystack+i, needle, n_size)==0)
                        return (char *)haystack+i;
        }
        return ((void *)0);
}

variable_types:
haystack
char *

variable_types:
needle
char *

return_type: char *


CreateStack

repo: Stabbath/nonogram-solver

decompiled_code:
_QWORD *CreateStack()
{
_QWORD *result; // rax

result = malloc(8uLL);
*result = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(8uLL);
*result = 0LL;
return result;
}

original_code:
Stack* CreateStack() {
 Stack* stack = (Stack*) malloc(sizeof(Stack));
 stack->top = ((void *)0);
 return stack;
}

canonical_original_code:
struct _stack *CreateStack() {
 struct _stack *stack = (Stack*) malloc(sizeof(Stack));
 stack->top = ((void *)0);
 return stack;
}

variable_types: struct _stack { struct _element { void *item; struct _element *next; } *top; } *


Push

original_code:
void Push(Stack* stack, Item* item) {
 if (stack == ((void *)0)) return;
 Element* element = (Element*) malloc(sizeof(Element));
 Element* buffer = stack->top;
 stack->top = element;
 stack->top->next = buffer;
 stack->top->item = item;
}

canonical_original_code:
void Push(struct _stack *stack, void *item) {
 if (stack == ((void *)0)) return;
 struct _element *element = (Element*) malloc(sizeof(Element));
 struct _element *buffer = stack->top;
 stack->top = element;
 stack->top->next = buffer;
 stack->top->item = item;
}

variable_types:
item
void *

variable_types: struct _element { void *item; struct _element *next; } *


IsStackEmpty

decompiled_code:
_BOOL8 __fastcall IsStackEmpty(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
int IsStackEmpty(Stack* stack) {
 return (stack->top == ((void *)0));
}

canonical_original_code:
int IsStackEmpty(struct _stack *stack) {
 return (stack->top == ((void *)0));
}

user_defined_types: struct _element { void *item; struct _element *next; }


Pop

original_code:
Item* Pop(Stack* stack) {
 if (IsStackEmpty(stack)) return ((void *)0);
 Element* top = stack->top;
 Item* item = top->item;
 stack->top = stack->top->next;
 free(top);
 return item;
}

canonical_original_code:
void *Pop(struct _stack *stack) {
 if (IsStackEmpty(stack)) return ((void *)0);
 struct _element *top = stack->top;
 void *item = top->item;
 stack->top = stack->top->next;
 free(top);
 return item;
}


ClearStack

decompiled_code:
__int64 __fastcall ClearStack(__int64 **a1)
{
__int64 result; // rax

do
result = Pop(a1);
while ( result );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 **a1)
{
__int64 result; // rax

do
result = func3(a1);
while ( result );
return result;
}

original_code:
void ClearStack(Stack* stack) {
 while (Pop(stack) != ((void *)0));
}

canonical_original_code:
void ClearStack(struct _stack *stack) {
 while (Pop(stack) != ((void *)0));
}


errorout

decompiled_code:
void __fastcall __noreturn errorout(const char *a1, const char *a2)
{
printf("%s %s\n", a1, a2);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(const char *a1, const char *a2)
{
printf("%s %s\n", a1, a2);
exit(1);
}

original_code:
void errorout(char* type, char* details) {
 printf("%s %s\n", type, details);
 exit(1);
}

canonical_original_code:
void errorout(char *type, char *details) {
 printf("%s %s\n", type, details);
 exit(1);
}

variable_types:
type
char *

variable_types:
details
char *


getSumOfBlocks

original_code:
int getSumOfBlocks(Line* line) {
 if (line->block[0].length == 0) return 0;
 int i, count = 0;
 for (i = 0; i < line->blockNum; i++) {
  count += line->block[i].length;
 }
 return count;
}

canonical_original_code:
int getSumOfBlocks(struct _line *line) {
 if (line->block[0].length == 0) return 0;
 int i; int count = 0;
 for (i = 0; i < line->blockNum; i++) {
  count += line->block[i].length;
 }
 return count;
}

variable_types: struct _line { struct _cell { char state; struct _line *row; struct _line *col; } **cells; struct _block { int length; int min; int max; } *block; int blockNum; int unsolvedCells; } *

variable_types: count int

user_defined_types: struct _line { struct _cell **cells; struct _block *block; int blockNum; int unsolvedCells; }


checkpuzzle

original_code:
int checkpuzzle(Puzzle* puzzle) {
 int i, x;
 Line* lines;
 for (x = 0; x < 2; x++) {
  lines = puzzle->line[x];
  for (i = 0; i < puzzle->length[x]; i++) {
   if (!checkline(&lines[i], puzzle->length[!x])) return 0;
  }
 }
 return 1;
}

canonical_original_code:
int checkpuzzle(struct _puzzle *puzzle) {
 int i; int x;
 struct _line *lines;
 for (x = 0; x < 2; x++) {
  lines = puzzle->line[x];
  for (i = 0; i < puzzle->length[x]; i++) {
   if (!checkline(&lines[i], puzzle->length[!x])) return 0;
  }
 }
 return 1;
}

variable_types: struct _puzzle { char *name; int *length; struct _line { struct _cell { char state; struct _line *row; struct _line *col; } **cells; struct _block { int length; int min; int max; } *block; int blockNum; int unsolvedCells; } **line; } *

variable_types: i int

variable_types: x int

user_defined_types: struct _puzzle { char *name; int *length; struct _line **line; }


getMinSumOfBlocksAndBlanks

decompiled_code:
__int64 __fastcall getMinSumOfBlocksAndBlanks(__int64 a1, int a2)
{
unsigned int *v2; // rdx
__int64 result; // rax
int v4; // edi
unsigned int *v5; // rax
unsigned __int64 v6; // rcx
int v7; // edx

v2 = *(unsigned int **)(a1 + 8);
result = *v2;
if ( (_DWORD)result )
{
v4 = *(_DWORD *)(a1 + 16);
if ( a2 >= v4 )
{
v7 = 0;
}
else
{
v5 = &v2[3 * a2];
v6 = (unsigned __int64)&v2[3 * a2 + 3 + 3 * (unsigned __int64)(unsigned int)(v4 + ~a2)];
v7 = 0;
do
{
v7 += *v5;
v5 += 3;
}
while ( v5 != (unsigned int *)v6 );
}
result = (unsigned int)(v7 + v4 - a2 - 1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
unsigned int *v2; // rdx
__int64 result; // rax
int v4; // edi
unsigned int *v5; // rax
unsigned __int64 v6; // rcx
int v7; // edx

v2 = *(unsigned int **)(a1 + 8);
result = *v2;
if ( (_DWORD)result )
{
v4 = *(_DWORD *)(a1 + 16);
if ( a2 >= v4 )
{
v7 = 0;
}
else
{
v5 = &v2[3 * a2];
v6 = (unsigned __int64)&v2[3 * a2 + 3 + 3 * (unsigned __int64)(unsigned int)(v4 + ~a2)];
v7 = 0;
do
{
v7 += *v5;
v5 += 3;
}
while ( v5 != (unsigned int *)v6 );
}
result = (unsigned int)(v7 + v4 - a2 - 1);
}
return result;
}

original_code:
int getMinSumOfBlocksAndBlanks(Line* line, int n) {
 int i, count = 0;
 if (line->block[0].length == 0) return 0;
 for (i = n; i < line->blockNum; i++) {
  count = count + line->block[i].length;
 }
 return count + (line->blockNum - n - 1);
}

canonical_original_code:
int getMinSumOfBlocksAndBlanks(struct _line *line, int n) {
 int i; int count = 0;
 if (line->block[0].length == 0) return 0;
 for (i = n; i < line->blockNum; i++) {
  count = count + line->block[i].length;
 }
 return count + (line->blockNum - n - 1);
}

user_defined_types: struct _block { int length; int min; int max; }

user_defined_types: struct _cell { char state; struct _line *row; struct _line *col; }


getMinSumOfBlocksAndBlanksPrev

decompiled_code:
__int64 __fastcall getMinSumOfBlocksAndBlanksPrev(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v3; // rcx
__int64 v4; // rdx
_DWORD *v5; // rax
__int64 v6; // rcx
int v7; // edx

result = (unsigned int)a2;
if ( a2 )
{
if ( a2 <= 0 )
{
v7 = 0;
}
else
{
v3 = *(_QWORD *)(a1 + 8);
v4 = 12LL * a2;
v5 = (_DWORD *)(v3 + v4 - 12);
v6 = v3 + v4 - 24 - 12LL * (unsigned int)(a2 - 1);
v7 = 0;
do
{
v7 += *v5;
v5 -= 3;
}
while ( v5 != (_DWORD *)v6 );
}
result = (unsigned int)(a2 + v7);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v3; // rcx
__int64 v4; // rdx
_DWORD *v5; // rax
__int64 v6; // rcx
int v7; // edx

result = (unsigned int)a2;
if ( a2 )
{
if ( a2 <= 0 )
{
v7 = 0;
}
else
{
v3 = *(_QWORD *)(a1 + 8);
v4 = 12LL * a2;
v5 = (_DWORD *)(v3 + v4 - 12);
v6 = v3 + v4 - 24 - 12LL * (unsigned int)(a2 - 1);
v7 = 0;
do
{
v7 += *v5;
v5 -= 3;
}
while ( v5 != (_DWORD *)v6 );
}
result = (unsigned int)(a2 + v7);
}
return result;
}

original_code:
int getMinSumOfBlocksAndBlanksPrev(Line* line, int n) {
 if (n == 0) return 0;
 int i, count = 0;
 for (i = n - 1; i >= 0; i--) {
  count += line->block[i].length;
 }
 return count + n;
}

canonical_original_code:
int getMinSumOfBlocksAndBlanksPrev(struct _line *line, int n) {
 if (n == 0) return 0;
 int i; int count = 0;
 for (i = n - 1; i >= 0; i--) {
  count += line->block[i].length;
 }
 return count + n;
}


getLengthOfLargestBlock

decompiled_code:
__int64 __fastcall getLengthOfLargestBlock(__int64 a1)
{
int v1; // edx
unsigned int *v2; // rax
__int64 v3; // rsi
unsigned int v4; // edx

v1 = *(_DWORD *)(a1 + 16);
if ( v1 <= 0 )
return 0;
v2 = *(unsigned int **)(a1 + 8);
v3 = (__int64)&v2[3 * (v1 - 1) + 3];
v4 = 0;
do
{
if ( (int)v4 < (int)*v2 )
v4 = *v2;
v2 += 3;
}
while ( v2 != (unsigned int *)v3 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
int v1; // edx
unsigned int *v2; // rax
__int64 v3; // rsi
unsigned int v4; // edx

v1 = *(_DWORD *)(a1 + 16);
if ( v1 <= 0 )
return 0;
v2 = *(unsigned int **)(a1 + 8);
v3 = (__int64)&v2[3 * (v1 - 1) + 3];
v4 = 0;
do
{
if ( (int)v4 < (int)*v2 )
v4 = *v2;
v2 += 3;
}
while ( v2 != (unsigned int *)v3 );
return v4;
}

original_code:
int getLengthOfLargestBlock(Line* line) {
 int i, size;
 for (i = 0, size = 0; i < line->blockNum; i++) {
  if (line->block[i].length > size) size = line->block[i].length;
 }
 return size;
}

canonical_original_code:
int getLengthOfLargestBlock(struct _line *line) {
 int i; int size;
 for (i = 0, size = 0; i < line->blockNum; i++) {
  if (line->block[i].length > size) size = line->block[i].length;
 }
 return size;
}

variable_types: size int


FreePuzzle

original_code:
void FreePuzzle(Puzzle* puzzle) {
 int i, j;
 for (i = 0; i < puzzle->length[0]; i++){
  for (j = 0; j < puzzle->length[1]; j++){
   free(puzzle->line[0][i].cells[j]);
  }
  free(puzzle->line[0][i].cells);
  free(puzzle->line[0][i].block);
 }
 for (i = 0; i < puzzle->length[1]; i++){
  free(puzzle->line[1][i].cells);
  free(puzzle->line[1][i].block);
 }
 free(puzzle->line[0]);
 free(puzzle->line[1]);
 free(puzzle->line);
 free(puzzle->length);
 free(puzzle);
}

canonical_original_code:
void FreePuzzle(struct _puzzle *puzzle) {
 int i; int j;
 for (i = 0; i < puzzle->length[0]; i++){
  for (j = 0; j < puzzle->length[1]; j++){
   free(puzzle->line[0][i].cells[j]);
  }
  free(puzzle->line[0][i].cells);
  free(puzzle->line[0][i].block);
 }
 for (i = 0; i < puzzle->length[1]; i++){
  free(puzzle->line[1][i].cells);
  free(puzzle->line[1][i].block);
 }
 free(puzzle->line[0]);
 free(puzzle->line[1]);
 free(puzzle->line);
 free(puzzle->length);
 free(puzzle);
}

variable_types: j int


stackline

original_code:
int stackline(Line* line, int length) {
 int sum = getMinSumOfBlocksAndBlanks(line, 0);
 int cap = getLengthOfLargestBlock(line);
 if (sum > length) {
  return -1;
 }
 Cell** cells = line->cells;
 Block* block = line->block;
 int blockNum = line->blockNum;
 int i, ret = 0;
 if (sum == 0) {
  for (i = 0; i < length; i++) {
   if (cells[i]->state == '?') {
    cells[i]->state = '-';
    ret++;
   } else
   if (cells[i]->state == '#') {
    return -1;
   }
  }
  return ret;
 } else
 if (length == sum) {
  int i, j, l = 0;
  for (i = 0; i < blockNum; i++, l++) {
   for (j = 0; j < block[i].length; j++, l++) {
    if (cells[l]->state == '?') {
     cells[l]->state = '#';
     ret++;
    } else
    if (cells[l]->state == '-') {
     return -1;
    }
   }
   if (l < length) {
    if (cells[l]->state == '?') {
     cells[l]->state = '-';
     ret++;
    } else
    if (cells[l]->state == '#') {
     return -1;
    }
   }
  }
  return ret;
 } else
 if (length - sum < cap) {
  int n = 0;
  i = length - sum;
  while (n < blockNum) {
   int limit = i + block[n].length - (length - sum);
   if (block[n].length > length - sum) {
    for (; i < limit; i++) {
     if (cells[i]->state == '-') {
      return -1;
     } else
     if (cells[i]->state == '?') {
      cells[i]->state = '#';
      ret++;
     }
    }
    i += length - sum;
   } else {
    i += line->block[n].length;
   }
   i++;
   n++;
  }
  return ret;
 }
 return 0;
}

canonical_original_code:
int stackline(struct _line *line, int length) {
 int sum = getMinSumOfBlocksAndBlanks(line, 0);
 int cap = getLengthOfLargestBlock(line);
 if (sum > length) {
  return -1;
 }
 struct _cell **cells = line->cells;
 struct _block *block = line->block;
 int blockNum = line->blockNum;
 int i; int ret = 0;
 if (sum == 0) {
  for (i = 0; i < length; i++) {
   if (cells[i]->state == '?') {
    cells[i]->state = '-';
    ret++;
   } else
   if (cells[i]->state == '#') {
    return -1;
   }
  }
  return ret;
 } else
 if (length == sum) {
  int i; int j; int l = 0;
  for (i = 0; i < blockNum; i++, l++) {
   for (j = 0; j < block[i].length; j++, l++) {
    if (cells[l]->state == '?') {
     cells[l]->state = '#';
     ret++;
    } else
    if (cells[l]->state == '-') {
     return -1;
    }
   }
   if (l < length) {
    if (cells[l]->state == '?') {
     cells[l]->state = '-';
     ret++;
    } else
    if (cells[l]->state == '#') {
     return -1;
    }
   }
  }
  return ret;
 } else
 if (length - sum < cap) {
  int n = 0;
  i = length - sum;
  while (n < blockNum) {
   int limit = i + block[n].length - (length - sum);
   if (block[n].length > length - sum) {
    for (; i < limit; i++) {
     if (cells[i]->state == '-') {
      return -1;
     } else
     if (cells[i]->state == '?') {
      cells[i]->state = '#';
      ret++;
     }
    }
    i += length - sum;
   } else {
    i += line->block[n].length;
   }
   i++;
   n++;
  }
  return ret;
 }
 return 0;
}

variable_types: length int

variable_types: sum int

variable_types: cap int

variable_types: struct _cell { char state; struct _line { struct _cell **cells; struct _block { int length; int min; int max; } *block; int blockNum; int unsolvedCells; } *row; struct _line *col; } **

variable_types: blockNum int

variable_types: ret int

variable_types: l int

variable_types: limit int


presolve

original_code:
int presolve(Puzzle* puzzle) {
 int unsolvedCellCount = puzzle->length[0] * puzzle->length[1];
 int i, x, buf;
 for (x = 0; x < 2; x++) {
  for (i = 0; i < puzzle->length[x]; i++) {
   if (unsolvedCellCount > 0) {
    buf = stackline(&puzzle->line[x][i], puzzle->length[!x]);
    unsolvedCellCount -= buf;
    puzzle->line[x][i].unsolvedCells -= buf;
   } else {
    return unsolvedCellCount;
   }
  }
 }
 return unsolvedCellCount;
}

canonical_original_code:
int presolve(struct _puzzle *puzzle) {
 int unsolvedCellCount = puzzle->length[0] * puzzle->length[1];
 int i; int x; int buf;
 for (x = 0; x < 2; x++) {
  for (i = 0; i < puzzle->length[x]; i++) {
   if (unsolvedCellCount > 0) {
    buf = stackline(&puzzle->line[x][i], puzzle->length[!x]);
    unsolvedCellCount -= buf;
    puzzle->line[x][i].unsolvedCells -= buf;
   } else {
    return unsolvedCellCount;
   }
  }
 }
 return unsolvedCellCount;
}

variable_types: unsolvedCellCount int

variable_types: buf int


main

repo: StanislavPodolsky/Alta-OS

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
printf(
"\nSIZE OF HOST SYSTEM TYPES:\nCHAR:\t%d\nSHORT:\t%d\nINT:\t%d\nFLOAT:\t%d\nDOUBLE:\t%d\n\n",
1LL,
2LL,
4LL,
4LL,
8LL);
return 0;
}

original_code:
int main(void) {
    printf("\nSIZE OF HOST SYSTEM TYPES:\n"
     "CHAR:\t%d\n"
     "SHORT:\t%d\n"
     "INT:\t%d\n"
     "FLOAT:\t%d\n"
     "DOUBLE:\t%d\n\n", sizeof(char), sizeof(short), sizeof(int), sizeof(float), sizeof(double));
return 0;
}

canonical_original_code:
int main() {
    printf("\nSIZE OF HOST SYSTEM TYPES:\n"
     "CHAR:\t%d\n"
     "SHORT:\t%d\n"
     "INT:\t%d\n"
     "FLOAT:\t%d\n"
     "DOUBLE:\t%d\n\n", sizeof(char), sizeof(short), sizeof(int), sizeof(float), sizeof(double));
return 0;
}


repo: StaticFiend/TestRL

decompiled_code:
__int64 __fastcall cave_walk(int a1, __int64 a2, __int64 a3)
{
unsigned __int8 v4; // al
unsigned __int8 v5; // al
unsigned __int8 v6; // al
unsigned __int8 v7; // al
__int64 result; // rax
unsigned __int8 v9; // dl

if ( a1 > 5 )
{
if ( (unsigned int)(a1 - 6) > 2 )
goto LABEL_14;
v5 = *(_BYTE *)(a3 + 4);
if ( v5 <= 0x4Cu )
*(_BYTE *)(a3 + 4) = v5 + 1;
}
else if ( a1 > 2 )
{
v7 = *(_BYTE *)(a3 + 4);
if ( v7 > 2u )
*(_BYTE *)(a3 + 4) = v7 - 1;
}
else
{
if ( a1 != 1 )
{
if ( a1 == 2 )
{
v4 = *(_BYTE *)(a3 + 5);
if ( v4 <= 0x24u )
*(_BYTE *)(a3 + 5) = v4 + 1;
goto LABEL_15;
}
LABEL_14:
puts("[Console] Invalid direction, how'd you manage this?");
printf(
"[Console] walker.x: %i walker.y: %i direction: %i\n",
*(unsigned __int8 *)(a3 + 4),
*(unsigned __int8 *)(a3 + 5),
(unsigned int)a1);
goto LABEL_15;
}
v6 = *(_BYTE *)(a3 + 5);
if ( v6 > 2u )
*(_BYTE *)(a3 + 5) = v6 - 1;
}
LABEL_15:
result = *(unsigned __int8 *)(a3 + 5);
if ( (unsigned __int8)(result - 2) <= 0x23u )
{
v9 = *(_BYTE *)(a3 + 4);
if ( (unsigned __int8)(v9 - 2) <= 0x4Bu )
{
result = (unsigned __int8)result;
*(_BYTE *)(80LL * (unsigned __int8)result + a2 + v9) = 46;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2, __int64 a3)
{
unsigned __int8 v4; // al
unsigned __int8 v5; // al
unsigned __int8 v6; // al
unsigned __int8 v7; // al
__int64 result; // rax
unsigned __int8 v9; // dl

if ( a1 > 5 )
{
if ( (unsigned int)(a1 - 6) > 2 )
goto LABEL_14;
v5 = *(_BYTE *)(a3 + 4);
if ( v5 <= 0x4Cu )
*(_BYTE *)(a3 + 4) = v5 + 1;
}
else if ( a1 > 2 )
{
v7 = *(_BYTE *)(a3 + 4);
if ( v7 > 2u )
*(_BYTE *)(a3 + 4) = v7 - 1;
}
else
{
if ( a1 != 1 )
{
if ( a1 == 2 )
{
v4 = *(_BYTE *)(a3 + 5);
if ( v4 <= 0x24u )
*(_BYTE *)(a3 + 5) = v4 + 1;
goto LABEL_15;
}
LABEL_14:
puts("[Console] Invalid direction, how'd you manage this?");
printf(
"[Console] walker.x: %i walker.y: %i direction: %i\n",
*(unsigned __int8 *)(a3 + 4),
*(unsigned __int8 *)(a3 + 5),
(unsigned int)a1);
goto LABEL_15;
}
v6 = *(_BYTE *)(a3 + 5);
if ( v6 > 2u )
*(_BYTE *)(a3 + 5) = v6 - 1;
}
LABEL_15:
result = *(unsigned __int8 *)(a3 + 5);
if ( (unsigned __int8)(result - 2) <= 0x23u )
{
v9 = *(_BYTE *)(a3 + 4);
if ( (unsigned __int8)(v9 - 2) <= 0x4Bu )
{
result = (unsigned __int8)result;
*(_BYTE *)(80LL * (unsigned __int8)result + a2 + v9) = 46;
}
}
return result;
}

original_code:
void cave_walk(int dir, char map[][80], tile_t *walker) {
 switch(dir) {
  case 1:
   if ((walker->y - 1) > 1)
    walker->y -= 1;
    break;
  case 2:
    if ((walker->y + 1) < (40 - 2))
    walker->y += 1;
    break;
  case 3:
  case 4:
  case 5:
    if ((walker->x - 1) > 1)
     walker->x -= 1;
    break;
  case 6:
  case 7:
  case 8:
    if ((walker->x + 1) < (80 - 2))
     walker->x += 1;
    break;
  default:
    printf("[Console] Invalid direction, how'd you manage this?\n");
    printf("[Console] walker.x: %i  walker.y: %i  direction: %i\n", walker->x, walker->y, dir);
    break;
 }
 if ((walker->y > 1) && (walker->y < 40 - 2) && (walker->x > 1) && (walker->x < 80 - 2))
  map[walker->y][walker->x] = 46;
}

canonical_original_code:
void cave_walk(int dir, char map[][80], struct tile_s *walker) {
 switch(dir) {
  case 1:
   if ((walker->y - 1) > 1)
    walker->y -= 1;
    break;
  case 2:
    if ((walker->y + 1) < (40 - 2))
    walker->y += 1;
    break;
  case 3:
  case 4:
  case 5:
    if ((walker->x - 1) > 1)
     walker->x -= 1;
    break;
  case 6:
  case 7:
  case 8:
    if ((walker->x + 1) < (80 - 2))
     walker->x += 1;
    break;
  default:
    printf("[Console] Invalid direction, how'd you manage this?\n");
    printf("[Console] walker.x: %i  walker.y: %i  direction: %i\n", walker->x, walker->y, dir);
    break;
 }
 if ((walker->y > 1) && (walker->y < 40 - 2) && (walker->x > 1) && (walker->x < 80 - 2))
  map[walker->y][walker->x] = 46;
}

variable_types: dir int

variable_types:
map
char [][80]

variable_types: struct tile_s { int index; unsigned char x; unsigned char y; } *


decompiled_code:
__int64 __fastcall cave_place_player(__int64 a1, unsigned __int8 *a2)
{
unsigned __int8 v2; // cl
__int64 result; // rax

do
{
*a2 = TCOD_random_get_int(0LL, 0LL, 79LL);
v2 = TCOD_random_get_int(0LL, 0LL, 39LL);
a2[1] = v2;
result = a1 + 80LL * v2;
}
while ( *(_BYTE *)(result + *a2) != 46 );
a2[1] = v2 + 5;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned __int8 *a2)
{
unsigned __int8 v2; // cl
__int64 result; // rax

do
{
*a2 = TCOD_random_get_int(0LL, 0LL, 79LL);
v2 = TCOD_random_get_int(0LL, 0LL, 39LL);
a2[1] = v2;
result = a1 + 80LL * v2;
}
while ( *(_BYTE *)(result + *a2) != 46 );
a2[1] = v2 + 5;
return result;
}

original_code:
void cave_place_player(char map[][80], object_t *player) {
 int player_placed = 0;
 while (player_placed == 0) {
  player->x = TCOD_random_get_int(((void *)0), 0, 80 - 1);
  player->y = TCOD_random_get_int(((void *)0), 0, 40 - 1);
  if (map[player->y][player->x] == 46)
   player_placed = 1;
 }
 player->y += 5;
}

canonical_original_code:
void cave_place_player(char map[][80], struct object_s *player) {
 int player_placed = 0;
 while (player_placed == 0) {
  player->x = TCOD_random_get_int(((void *)0), 0, 80 - 1);
  player->y = TCOD_random_get_int(((void *)0), 0, 40 - 1);
  if (map[player->y][player->x] == 46)
   player_placed = 1;
 }
 player->y += 5;
}

variable_types: struct object_s { unsigned char x; unsigned char y; unsigned char radius; unsigned char torch_life; unsigned char torch_lit; unsigned char currentHP; unsigned char currentMP; unsigned char maxHP; unsigned char maxMP; float hpPct; float mpPct; unsigned char color[3]; unsigned char symbol; unsigned char dlvl; unsigned char state; unsigned int turns; struct item_s { unsigned char x; unsigned char type; unsigned char sub_type; unsigned char quantity; unsigned char effect; unsigned char throwable; unsigned char min_dmg; unsigned char max_dmg; unsigned char plus_hit; unsigned char plus_dmg; unsigned char special_dmg; unsigned char ac; unsigned char currently_equipped; unsigned char discovered; } inventory[24]; } *

user_defined_types: struct object_s { unsigned char x; unsigned char y; unsigned char radius; unsigned char torch_life; unsigned char torch_lit; unsigned char currentHP; unsigned char currentMP; unsigned char maxHP; unsigned char maxMP; float hpPct; float mpPct; unsigned char color[3]; unsigned char symbol; unsigned char dlvl; unsigned char state; unsigned int turns; struct item_s inventory[24]; }


original_code:
void cave_place_stairs(char map[][80], object_t player, tile_t *stairs) {
 int stairs_placed = 0;
 int largest_x = 0, largest_y = 0;
 int cur_dist, largest_dist = 0;
 int times_run = 0;
 while (stairs_placed == 0) {
  stairs->x = TCOD_random_get_int(((void *)0), 0, 80 - 1);
  stairs->y = TCOD_random_get_int(((void *)0), 0, 40 - 1);
  if (map[stairs->y][stairs->x] != 46)
   continue;
  cur_dist = distance(player.x, player.y, stairs->x, stairs->y);
  times_run++;
  if (cur_dist > largest_dist) {
   largest_x = stairs->x;
   largest_y = stairs->y;
   largest_dist = cur_dist;
  }
  if (times_run == 20) {
   stairs->x = largest_x;
   stairs->y = largest_y;
   map[largest_y][largest_x] = 62;
   stairs_placed = 1;
  }
 }
}

canonical_original_code:
void cave_place_stairs(char map[][80], struct object_s player, struct tile_s *stairs) {
 int stairs_placed = 0;
 int largest_x = 0; int largest_y = 0;
 int cur_dist; int largest_dist = 0;
 int times_run = 0;
 while (stairs_placed == 0) {
  stairs->x = TCOD_random_get_int(((void *)0), 0, 80 - 1);
  stairs->y = TCOD_random_get_int(((void *)0), 0, 40 - 1);
  if (map[stairs->y][stairs->x] != 46)
   continue;
  cur_dist = distance(player.x, player.y, stairs->x, stairs->y);
  times_run++;
  if (cur_dist > largest_dist) {
   largest_x = stairs->x;
   largest_y = stairs->y;
   largest_dist = cur_dist;
  }
  if (times_run == 20) {
   stairs->x = largest_x;
   stairs->y = largest_y;
   map[largest_y][largest_x] = 62;
   stairs_placed = 1;
  }
 }
}

variable_types: struct object_s { unsigned char x; unsigned char y; unsigned char radius; unsigned char torch_life; unsigned char torch_lit; unsigned char currentHP; unsigned char currentMP; unsigned char maxHP; unsigned char maxMP; float hpPct; float mpPct; unsigned char color[3]; unsigned char symbol; unsigned char dlvl; unsigned char state; unsigned int turns; struct item_s { unsigned char x; unsigned char type; unsigned char sub_type; unsigned char quantity; unsigned char effect; unsigned char throwable; unsigned char min_dmg; unsigned char max_dmg; unsigned char plus_hit; unsigned char plus_dmg; unsigned char special_dmg; unsigned char ac; unsigned char currently_equipped; unsigned char discovered; } inventory[24]; }

user_defined_types: struct tile_s { int index; unsigned char x; unsigned char y; }


decompiled_code:
__int64 __fastcall generate_cave(__int64 a1, __int64 a2, unsigned __int8 *a3, __int64 a4)
{
int v6; // eax
int v7; // er12
int i; // ebx
int v9; // eax
__int64 v10; // rdx
__int64 v11; // r8
__int64 v12; // r9
__int16 v14[196]; // [rsp-190h] [rbp-1D8h] BYREF
char v15[4]; // [rsp+8h] [rbp-40h] BYREF
unsigned __int8 v16; // [rsp+Ch] [rbp-3Ch]
unsigned __int8 v17; // [rsp+Dh] [rbp-3Bh]

v16 = TCOD_random_get_int(0LL, 0LL, 79LL);
v17 = TCOD_random_get_int(0LL, 0LL, 39LL);
fill_map(a1, 35LL);
*(_BYTE *)(a1 + 80LL * v17 + v16) = 46;
v6 = TCOD_random_get_int(0LL, 4000LL, 6000LL);
if ( v6 > 0 )
{
v7 = v6;
for ( i = 0; i != v7; ++i )
{
v9 = TCOD_random_get_int(0LL, 1LL, 8LL);
cave_walk(v9, a1, (__int64)v15);
}
}
cave_place_player(a1, a3);
qmemcpy(v14, a3, sizeof(v14));
cave_place_stairs(a1, a4, v10, 0LL, v11, v12, v14[0]);
return random_get_colors(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, unsigned __int8 *a3, __int64 a4)
{
int v6; // eax
int v7; // er12
int i; // ebx
int v9; // eax
__int64 v10; // rdx
__int64 v11; // r8
__int64 v12; // r9
__int16 v14[196]; // [rsp-190h] [rbp-1D8h] BYREF
char v15[4]; // [rsp+8h] [rbp-40h] BYREF
unsigned __int8 v16; // [rsp+Ch] [rbp-3Ch]
unsigned __int8 v17; // [rsp+Dh] [rbp-3Bh]

v16 = TCOD_random_get_int(0LL, 0LL, 79LL);
v17 = TCOD_random_get_int(0LL, 0LL, 39LL);
fill_map(a1, 35LL);
*(_BYTE *)(a1 + 80LL * v17 + v16) = 46;
v6 = TCOD_random_get_int(0LL, 4000LL, 6000LL);
if ( v6 > 0 )
{
v7 = v6;
for ( i = 0; i != v7; ++i )
{
v9 = TCOD_random_get_int(0LL, 1LL, 8LL);
func0(v9, a1, (__int64)v15);
}
}
func1(a1, a3);
qmemcpy(v14, a3, sizeof(v14));
func2(a1, a4, v10, 0LL, v11, v12, v14[0]);
return random_get_colors(a1, a2);
}

original_code:
void generate_cave(char map[][80], TCOD_color_t color_map[][80],
  object_t *player, tile_t *stairs) {
 int count = 0, limit, direction = 0;
 tile_t walker;
 walker.x = TCOD_random_get_int(((void *)0), 0, 80 - 1);
 walker.y = TCOD_random_get_int(((void *)0), 0, 40 - 1);
 fill_map(map, 35);
 map[walker.y][walker.x] = 46;
 limit = TCOD_random_get_int(((void *)0), 4000, 6000);
 while (count < limit) {
  direction = TCOD_random_get_int(((void *)0), 1, 8);
  cave_walk(direction, map, &walker);
  count++;
 }
 cave_place_player(map, player);
 cave_place_stairs(map, *player, stairs);
 random_get_colors(map, color_map);
}

canonical_original_code:
void generate_cave(char map[][80], struct TCOD_color_t color_map[][80], struct object_s *player, struct tile_s *stairs) {
 int count = 0; int limit; int direction = 0;
 struct tile_s walker;
 walker.x = TCOD_random_get_int(((void *)0), 0, 80 - 1);
 walker.y = TCOD_random_get_int(((void *)0), 0, 40 - 1);
 fill_map(map, 35);
 map[walker.y][walker.x] = 46;
 limit = TCOD_random_get_int(((void *)0), 4000, 6000);
 while (count < limit) {
  direction = TCOD_random_get_int(((void *)0), 1, 8);
  cave_walk(direction, map, &walker);
  count++;
 }
 cave_place_player(map, player);
 cave_place_stairs(map, *player, stairs);
 random_get_colors(map, color_map);
}

variable_types: struct TCOD_color_t { unsigned char r; } [][80]

variable_types: count int

variable_types: direction int

variable_types: struct tile_s { int index; unsigned char x; unsigned char y; }

user_defined_types: struct item_s { unsigned char x; unsigned char type; unsigned char sub_type; unsigned char quantity; unsigned char effect; unsigned char throwable; unsigned char min_dmg; unsigned char max_dmg; unsigned char plus_hit; unsigned char plus_dmg; unsigned char special_dmg; unsigned char ac; unsigned char currently_equipped; unsigned char discovered; }


decompiled_code:
void __fastcall monster_change_state(__int64 a1, int a2, char a3)
{
*(_BYTE *)(392LL * a2 + a1 + 25) = a3;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1, int a2, char a3)
{
*(_BYTE *)(392LL * a2 + a1 + 25) = a3;
}

original_code:
void monster_change_state(object_t *monster, int index, uint8_t new_state) {
 monster[index].state = new_state;
}

canonical_original_code:
void monster_change_state(struct object_s *monster, int index, unsigned char new_state) {
 monster[index].state = new_state;
}

variable_types: index int


decompiled_code:
void __fastcall ai_move(unsigned __int8 *a1, int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int16 a7)
{
unsigned __int8 *i; // rbp
unsigned __int8 v8; // al
int v9; // eax
int v10; // ebx
unsigned __int8 v11; // dl
unsigned __int8 v12; // dl

if ( a2 > 0 )
{
for ( i = a1; i != &a1[392 * (a2 - 1) + 392]; i += 392 )
{
v8 = i[25];
if ( v8 == 3 )
{
do
{
v9 = TCOD_random_get_int(0LL, 0LL, 3LL);
v10 = v9;
}
while ( last_dir_0 == v9 );
if ( v9 )
{
if ( v9 == 1 )
{
if ( (unsigned __int8)TCOD_map_is_walkable(a3, (unsigned int)*i + 1, (unsigned int)i[1] - 5)
&& *i + 1 != (unsigned __int8)a7
&& i[1] != HIBYTE(a7) )
{
++*i;
}
}
else
{
if ( v9 != 2 )
goto LABEL_13;
if ( (unsigned __int8)TCOD_map_is_walkable(a3, *i, (unsigned int)i[1] - 4) )
{
v12 = i[1];
if ( v12 + 1 != HIBYTE(a7) && *i != (_BYTE)a7 )
i[1] = v12 + 1;
}
}
}
else
{
if ( (unsigned __int8)TCOD_map_is_walkable(a3, *i, (unsigned int)i[1] - 6) )
{
v11 = i[1];
if ( v11 - 1 != HIBYTE(a7) && *i != (_BYTE)a7 )
i[1] = v11 - 1;
}
LABEL_13:
if ( v10 == 3
&& (unsigned __int8)TCOD_map_is_walkable(a3, (unsigned int)*i - 1, (unsigned int)i[1] - 5)
&& *i - 1 != (unsigned __int8)a7
&& i[1] != HIBYTE(a7) )
{
--*i;
}
}
last_dir_0 = v10;
continue;
}
if ( v8 <= 3u )
{
if ( (unsigned __int8)(v8 - 1) > 1u )
goto LABEL_8;
}
else if ( v8 != 4 )
{
LABEL_8:
puts("[Console] ERROR: Unknown monster state, dunno how you managed this!");
continue;
}
}
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned __int8 *a1, int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int16 a7)
{
unsigned __int8 *i; // rbp
unsigned __int8 v8; // al
int v9; // eax
int v10; // ebx
unsigned __int8 v11; // dl
unsigned __int8 v12; // dl

if ( a2 > 0 )
{
for ( i = a1; i != &a1[392 * (a2 - 1) + 392]; i += 392 )
{
v8 = i[25];
if ( v8 == 3 )
{
do
{
v9 = TCOD_random_get_int(0LL, 0LL, 3LL);
v10 = v9;
}
while ( last_dir_0 == v9 );
if ( v9 )
{
if ( v9 == 1 )
{
if ( (unsigned __int8)TCOD_map_is_walkable(a3, (unsigned int)*i + 1, (unsigned int)i[1] - 5)
&& *i + 1 != (unsigned __int8)a7
&& i[1] != HIBYTE(a7) )
{
++*i;
}
}
else
{
if ( v9 != 2 )
goto LABEL_13;
if ( (unsigned __int8)TCOD_map_is_walkable(a3, *i, (unsigned int)i[1] - 4) )
{
v12 = i[1];
if ( v12 + 1 != HIBYTE(a7) && *i != (_BYTE)a7 )
i[1] = v12 + 1;
}
}
}
else
{
if ( (unsigned __int8)TCOD_map_is_walkable(a3, *i, (unsigned int)i[1] - 6) )
{
v11 = i[1];
if ( v11 - 1 != HIBYTE(a7) && *i != (_BYTE)a7 )
i[1] = v11 - 1;
}
LABEL_13:
if ( v10 == 3
&& (unsigned __int8)TCOD_map_is_walkable(a3, (unsigned int)*i - 1, (unsigned int)i[1] - 5)
&& *i - 1 != (unsigned __int8)a7
&& i[1] != HIBYTE(a7) )
{
--*i;
}
}
last_dir_0 = v10;
continue;
}
if ( v8 <= 3u )
{
if ( (unsigned __int8)(v8 - 1) > 1u )
goto LABEL_8;
}
else if ( v8 != 4 )
{
LABEL_8:
puts("[Console] ERROR: Unknown monster state, dunno how you managed this!");
continue;
}
}
}
}

original_code:
void ai_move(object_t *monster, int mon_num, TCOD_map_t fov_map, object_t player) {
 int i;
 int rand_dir = 0;
 static int last_dir;
 for (i = 0; i < mon_num; i++) {
  switch(monster[i].state) {
   case 1:
    break;
   case 3:
    do {
    rand_dir = TCOD_random_get_int(((void *)0), 0, 3);
    } while (rand_dir == last_dir);
    if (rand_dir == 0 && TCOD_map_is_walkable(fov_map, monster[i].x, monster[i].y - 6)) {
     if (monster[i].y - 1 != player.y && monster[i].x != player.x)
      monster[i].y -= 1;
    }
    if (rand_dir == 1 && TCOD_map_is_walkable(fov_map, monster[i].x + 1, monster[i].y - 5)) {
     if (monster[i].x + 1 != player.x && monster[i].y != player.y)
      monster[i].x += 1;
    }
    if (rand_dir == 2 && TCOD_map_is_walkable(fov_map, monster[i].x, monster[i].y - 4)) {
     if (monster[i].y + 1 != player.y && monster[i].x != player.x)
      monster[i].y += 1;
    }
    if (rand_dir == 3 && TCOD_map_is_walkable(fov_map, monster[i].x - 1, monster[i].y - 5)) {
     if (monster[i].x - 1 != player.x && monster[i].y != player.y)
      monster[i].x -= 1;
    }
    last_dir = rand_dir;
    break;
   case 2:
    break;
   case 4:
    break;
   default:
    printf("[Console] ERROR: Unknown monster state, dunno how you managed this!\n");
    break;
  }
 }
}

canonical_original_code:
void ai_move(struct object_s *monster, int mon_num, void *fov_map, struct object_s player) {
 int i;
 int rand_dir = 0;
 static int last_dir;
 for (i = 0; i < mon_num; i++) {
  switch(monster[i].state) {
   case 1:
    break;
   case 3:
    do {
    rand_dir = TCOD_random_get_int(((void *)0), 0, 3);
    } while (rand_dir == last_dir);
    if (rand_dir == 0 && TCOD_map_is_walkable(fov_map, monster[i].x, monster[i].y - 6)) {
     if (monster[i].y - 1 != player.y && monster[i].x != player.x)
      monster[i].y -= 1;
    }
    if (rand_dir == 1 && TCOD_map_is_walkable(fov_map, monster[i].x + 1, monster[i].y - 5)) {
     if (monster[i].x + 1 != player.x && monster[i].y != player.y)
      monster[i].x += 1;
    }
    if (rand_dir == 2 && TCOD_map_is_walkable(fov_map, monster[i].x, monster[i].y - 4)) {
     if (monster[i].y + 1 != player.y && monster[i].x != player.x)
      monster[i].y += 1;
    }
    if (rand_dir == 3 && TCOD_map_is_walkable(fov_map, monster[i].x - 1, monster[i].y - 5)) {
     if (monster[i].x - 1 != player.x && monster[i].y != player.y)
      monster[i].x -= 1;
    }
    last_dir = rand_dir;
    break;
   case 2:
    break;
   case 4:
    break;
   default:
    printf("[Console] ERROR: Unknown monster state, dunno how you managed this!\n");
    break;
  }
 }
}

variable_types:
player
struct object_s

variable_types: i int


distance

decompiled_code:
__int64 __fastcall distance(int a1, int a2, int a3, int a4)
{
double v4; // xmm0_8
__int64 result; // rax

v4 = (double)(a4 - a2) * (double)(a4 - a2) + (double)(a3 - a1) * (double)(a3 - a1);
if ( v4 < 0.0 )
result = (unsigned int)(int)sqrt(v4);
else
result = (unsigned int)(int)sqrt(v4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2, int a3, int a4)
{
double v4; // xmm0_8
__int64 result; // rax

v4 = (double)(a4 - a2) * (double)(a4 - a2) + (double)(a3 - a1) * (double)(a3 - a1);
if ( v4 < 0.0 )
result = (unsigned int)(int)sqrt(v4);
else
result = (unsigned int)(int)sqrt(v4);
return result;
}

original_code:
int distance(int x1, int y1, int x2, int y2) {
 return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}


createMonster

decompiled_code:
void __fastcall createMonster(unsigned __int8 *a1, int a2, __int64 a3)
{
unsigned __int8 *v4; // rbx
unsigned __int8 v5; // al

if ( a2 > 0 )
{
v4 = a1;
do
{
do
{
*v4 = TCOD_random_get_int(0LL, 0LL, 79LL);
v5 = TCOD_random_get_int(0LL, 0LL, 39LL);
v4[1] = v5;
}
while ( !(unsigned __int8)TCOD_map_is_walkable(a3, *v4, v5) );
if ( !(unsigned __int8)TCOD_map_is_walkable(a3, *v4, v4[1]) )
puts("[Console] Monster spawned out of bounds.");
v4[1] += 5;
v4[7] = 30;
v4[5] = 30;
v4[20] = -56;
v4[21] = 20;
v4[22] = 20;
v4[25] = 3;
v4[23] = 107;
v4 += 392;
}
while ( v4 != &a1[392 * (a2 - 1) + 392] );
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned __int8 *a1, int a2, __int64 a3)
{
unsigned __int8 *v4; // rbx
unsigned __int8 v5; // al

if ( a2 > 0 )
{
v4 = a1;
do
{
do
{
*v4 = TCOD_random_get_int(0LL, 0LL, 79LL);
v5 = TCOD_random_get_int(0LL, 0LL, 39LL);
v4[1] = v5;
}
while ( !(unsigned __int8)TCOD_map_is_walkable(a3, *v4, v5) );
if ( !(unsigned __int8)TCOD_map_is_walkable(a3, *v4, v4[1]) )
puts("[Console] Monster spawned out of bounds.");
v4[1] += 5;
v4[7] = 30;
v4[5] = 30;
v4[20] = -56;
v4[21] = 20;
v4[22] = 20;
v4[25] = 3;
v4[23] = 107;
v4 += 392;
}
while ( v4 != &a1[392 * (a2 - 1) + 392] );
}
}

original_code:
void createMonster(object_t *monster, int mon_num, TCOD_map_t map) {
 int i;
 for (i = 0; i < mon_num; i++) {
  do {
   monster[i].x = TCOD_random_get_int(((void *)0), 0, 79);
   monster[i].y = TCOD_random_get_int(((void *)0), 0, 39);
  } while (TCOD_map_is_walkable(map, monster[i].x, monster[i].y) == ((bool)0));
  if (TCOD_map_is_walkable(map, monster[i].x, monster[i].y) == ((bool)0)) {
   printf("[Console] Monster spawned out of bounds.\n");
  }
  monster[i].y += 5;
  monster[i].maxHP = 30;
  monster[i].currentHP = 30;
  monster[i].color[0] = 200;
  monster[i].color[1] = 20;
  monster[i].color[2] = 20;
  monster[i].state = 3;
  monster[i].symbol = 107;
 }
}

canonical_original_code:
void createMonster(struct object_s *monster, int mon_num, void *map) {
 int i;
 for (i = 0; i < mon_num; i++) {
  do {
   monster[i].x = TCOD_random_get_int(((void *)0), 0, 79);
   monster[i].y = TCOD_random_get_int(((void *)0), 0, 39);
  } while (TCOD_map_is_walkable(map, monster[i].x, monster[i].y) == ((unsigned char)0));
  if (TCOD_map_is_walkable(map, monster[i].x, monster[i].y) == ((unsigned char)0)) {
   printf("[Console] Monster spawned out of bounds.\n");
  }
  monster[i].y += 5;
  monster[i].maxHP = 30;
  monster[i].currentHP = 30;
  monster[i].color[0] = 200;
  monster[i].color[1] = 20;
  monster[i].color[2] = 20;
  monster[i].state = 3;
  monster[i].symbol = 107;
 }
}

variable_types:
map
void *