decompiled_code:
__int64 __fastcall Map_get_block(_QWORD *a1, int a2, int a3, int a4)
{
int v7; // esi
__int64 v8; // rax

v7 = a2 + 15;
if ( a2 >= 0 )
v7 = a2;
v8 = Map_get_chunk(a1, v7 >> 4, a4 / 16);
if ( v8 )
return Chunk_get_block(v8, a2 % 16, a3, a4 % 16);
logmsg(1LL, "Tried to get block that is outside of map!");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, int a2, int a3, int a4)
{
int v7; // esi
__int64 v8; // rax

v7 = a2 + 15;
if ( a2 >= 0 )
v7 = a2;
v8 = func5(a1, v7 >> 4, a4 / 16);
if ( v8 )
return func2(v8, a2 % 16, a3, a4 % 16);
logmsg(1LL, "Tried to get block that is outside of map!");
return 0LL;
}

original_code:
Block Map_get_block(Map *map, int x, int y, int z){
    ssize_t chunkx = x / 16;
    ssize_t chunkz = z / 16;
    Chunk *chunk = Map_get_chunk(map, chunkx, chunkz);
    if (chunk == ((void *)0)){
 logmsg(1, "Tried to get block that is outside of map!");
 return (Block) {.id = 0, .metadata = 0};
    }
    return Chunk_get_block(chunk, x%16, y, z%16);
}

canonical_original_code:
struct Block Map_get_block(struct Map *map, int x, int y, int z){
    long chunkx = x / 16;
    long chunkz = z / 16;
    struct Chunk *chunk = Map_get_chunk(map, chunkx, chunkz);
    if (chunk == ((void *)0)){
 logmsg(1, "Tried to get block that is outside of map!");
 return (struct Block) {.id = 0, .metadata = 0};
    }
    return Chunk_get_block(chunk, x%16, y, z%16);
}

variable_types: struct Map { unsigned long xchunks; unsigned long zchunks; struct Chunk { struct Block blocks[-1]; char biome_data[-1]; } **chunks; } *

variable_types: struct Chunk { struct Block { unsigned char id; unsigned char metadata; } blocks[-1]; char biome_data[-1]; } *


repo: SpenceSellers/microMC

decompiled_code:
__int64 __fastcall Map_set_below(_QWORD *a1, __int16 a2, int a3)
{
__int64 result; // rax
__int64 v5; // r15
__int64 v6; // r13
__int64 v7; // r14
__int64 v8; // rax
__int64 v9; // rax
int v10; // [rsp+4h] [rbp-44h]
__int64 v11; // [rsp+8h] [rbp-40h]

result = a1[1];
v10 = result;
if ( (int)*a1 > 0 )
{
v5 = 0LL;
v11 = (unsigned int)*a1 - 1;
v6 = (unsigned int)(result - 1);
while ( 1 )
{
v7 = 0LL;
if ( v10 > 0 )
{
do
{
v8 = Map_get_chunk(a1, v5, v7);
Chunk_set_below(v8, a2, a3);
v9 = v7++;
}
while ( v6 != v9 );
}
result = v5 + 1;
if ( v5 == v11 )
break;
++v5;
}
}
return result;
}

original_code:
void Map_set_below(Map *map, Block b, int level){
    int x = map->xchunks;
    int z = map->zchunks;
    int i;
    int j;
    for (i=0; i < x; i++){
 for (j=0; j < z; j++){
     Chunk_set_below(Map_get_chunk(map, i, j), b, level);
 }
    }
}

canonical_original_code:
void Map_set_below(struct Map *map, struct Block b, int level){
    int x = map->xchunks;
    int z = map->zchunks;
    int i;
    int j;
    for (i=0; i < x; i++){
 for (j=0; j < z; j++){
     Chunk_set_below(Map_get_chunk(map, i, j), b, level);
 }
    }
}

variable_types: 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; } *

variable_types:
b
struct Block

variable_types: level int

variable_types: x int

variable_types: z int

variable_types: i int

variable_types: j int

return_type: void

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

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


decompiled_code:
void __fastcall apply_face(char a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
switch ( a1 )
{
case 0:
--*a3;
break;
case 1:
++*a3;
break;
case 2:
--*a4;
break;
case 3:
++*a4;
break;
case 4:
--*a2;
break;
case 5:
++*a2;
break;
default:
return;
}
}

canonical_decompiled_code:
void __fastcall func11(char a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
switch ( a1 )
{
case 0:
--*a3;
break;
case 1:
++*a3;
break;
case 2:
--*a4;
break;
case 3:
++*a4;
break;
case 4:
--*a2;
break;
case 5:
++*a2;
break;
default:
return;
}
}

original_code:
void apply_face(char face, int *x, int *y, int *z){
    switch (face){
    case 0:
 *y -= 1;
 break;
    case 1:
 *y += 1;
 break;
    case 2:
 *z -= 1;
 break;
    case 3:
 *z += 1;
 break;
    case 4:
 *x -= 1;
 break;
    case 5:
 *x += 1;
 break;
    }
}

variable_types: face char

variable_types:
x
int *

variable_types:
y
int *

variable_types:
z
int *


decompiled_code:
int __fastcall handle_player_digging(__int64 a1, __int64 a2, __int64 a3)
{
int result; // eax

result = logfmt(3LL, "%s just broke a block.\n", *(const char **)(a2 + 56));
if ( *(_BYTE *)a1 == 2 )
{
pthread_rwlock_wrlock((pthread_rwlock_t *)(a3 + 168));
pthread_rwlock_wrlock((pthread_rwlock_t *)(a3 + 96));
pthread_rwlock_wrlock((pthread_rwlock_t *)a2);
Player_break_block(a2, a3, *(unsigned int *)(a1 + 4), (unsigned int)*(char *)(a1 + 8), *(unsigned int *)(a1 + 12));
pthread_rwlock_unlock((pthread_rwlock_t *)a2);
pthread_rwlock_unlock((pthread_rwlock_t *)(a3 + 168));
result = pthread_rwlock_unlock((pthread_rwlock_t *)(a3 + 96));
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
int result; // eax

result = logfmt(3LL, "%s just broke a block.\n", *(const char **)(a2 + 56));
if ( *(_BYTE *)a1 == 2 )
{
pthread_rwlock_wrlock((pthread_rwlock_t *)(a3 + 168));
pthread_rwlock_wrlock((pthread_rwlock_t *)(a3 + 96));
pthread_rwlock_wrlock((pthread_rwlock_t *)a2);
Player_break_block(a2, a3, *(unsigned int *)(a1 + 4), (unsigned int)*(char *)(a1 + 8), *(unsigned int *)(a1 + 12));
pthread_rwlock_unlock((pthread_rwlock_t *)a2);
pthread_rwlock_unlock((pthread_rwlock_t *)(a3 + 168));
result = pthread_rwlock_unlock((pthread_rwlock_t *)(a3 + 96));
}
return result;
}

original_code:
void handle_player_digging(Packet0EPlayerDigging *packet, Player *p, Server *s){
    logfmt(3, "%s just broke a block.\n", p->username);
    if (packet->action == 2){
 pthread_rwlock_wrlock(&s->map_lock);
 pthread_rwlock_wrlock(&s->players_lock);
 pthread_rwlock_wrlock(&p->lock);
 Player_break_block(p, s, packet->x, packet->y, packet->z);
 pthread_rwlock_unlock(&p->lock);
 pthread_rwlock_unlock(&s->map_lock);
 pthread_rwlock_unlock(&s->players_lock);
    } else {
    }
}

canonical_original_code:
void handle_player_digging(struct Packet0EPlayerDigging *packet, struct Player *p, struct Server *s){
    logfmt(3, "%s just broke a block.\n", p->username);
    if (packet->action == 2){
 pthread_rwlock_wrlock(&s->map_lock);
 pthread_rwlock_wrlock(&s->players_lock);
 pthread_rwlock_wrlock(&p->lock);
 Player_break_block(p, s, packet->x, packet->y, packet->z);
 pthread_rwlock_unlock(&p->lock);
 pthread_rwlock_unlock(&s->map_lock);
 pthread_rwlock_unlock(&s->players_lock);
    } else {
    }
}

variable_types: struct Packet0EPlayerDigging { char action; int x; char y; int z; char face; } *

variable_types: struct Player { 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; } 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; } *

variable_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 { 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; } *

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 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 Inventory { unsigned long size; struct Slot **slots; }


decompiled_code:
void __fastcall send_all_chunks(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 v3; // r12
unsigned __int64 i; // rbx
__int64 v5; // rdi
void *v6; // r15
size_t n[8]; // [rsp+8h] [rbp-40h] BYREF

v3 = 0LL;
logmsg(2LL, "Sending all chunks to a player!");
if ( *a2 )
{
do
{
for ( i = 0LL; a2[1] > i; ++i )
{
v5 = Map_get_chunk(a2, v3, i);
if ( v5 )
{
v6 = (void *)Packet33ChunkData_construct(v5, (unsigned int)v3, (unsigned int)i, n);
send(*(_DWORD *)(a1 + 68), v6, n[0], 0);
free(v6);
}
}
++v3;
}
while ( *a2 > v3 );
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 v3; // r12
unsigned __int64 i; // rbx
__int64 v5; // rdi
void *v6; // r15
size_t n[8]; // [rsp+8h] [rbp-40h] BYREF

v3 = 0LL;
logmsg(2LL, "Sending all chunks to a player!");
if ( *a2 )
{
do
{
for ( i = 0LL; a2[1] > i; ++i )
{
v5 = Map_get_chunk(a2, v3, i);
if ( v5 )
{
v6 = (void *)Packet33ChunkData_construct(v5, (unsigned int)v3, (unsigned int)i, n);
send(*(_DWORD *)(a1 + 68), v6, n[0], 0);
free(v6);
}
}
++v3;
}
while ( *a2 > v3 );
}
}

original_code:
void send_all_chunks(Player *p, Map *map){
    logmsg(2, "Sending all chunks to a player!");
    int i;
    int j;
    for (i=0; i < map->xchunks; i++){
        for (j=0; j < map->zchunks; j++){
     Chunk *c = Map_get_chunk(map, i, j);
     if (c == ((void *)0)) continue;
     size_t len;
     char *data = Packet33ChunkData_construct(c, i, j, &len);
     send(p->socket, data, len, 0);
     free(data);
 }
    }
}

canonical_original_code:
void send_all_chunks(struct Player *p, struct Map *map){
    logmsg(2, "Sending all chunks to a player!");
    int i;
    int j;
    for (i=0; i < map->xchunks; i++){
        for (j=0; j < map->zchunks; j++){
     struct Chunk *c = Map_get_chunk(map, i, j);
     if (c == ((void *)0)) continue;
     unsigned long len;
     char *data = Packet33ChunkData_construct(c, i, j, &len);
     send(p->socket, data, len, 0);
     free(data);
 }
    }
}

variable_types:
len
unsigned long

variable_types:
data
char *

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

user_defined_types: struct Block { unsigned char id; unsigned char metadata; }

user_defined_types: struct Slot { short id; char count; short damage; short nbt_len; char *nbt; }


decompiled_code:
int __fastcall send_all_players(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

pthread_rwlock_rdlock((pthread_rwlock_t *)(a2 + 96));
if ( *(int *)(a2 + 152) > 0 )
{
v2 = 0LL;
do
{
if ( *(_QWORD *)(*(_QWORD *)(a2 + 160) + 8 * v2) != a1 )
Player_send_new_player(a1);
++v2;
}
while ( *(_DWORD *)(a2 + 152) > (int)v2 );
}
return pthread_rwlock_unlock((pthread_rwlock_t *)(a2 + 96));
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

pthread_rwlock_rdlock((pthread_rwlock_t *)(a2 + 96));
if ( *(int *)(a2 + 152) > 0 )
{
v2 = 0LL;
do
{
if ( *(_QWORD *)(*(_QWORD *)(a2 + 160) + 8 * v2) != a1 )
Player_send_new_player(a1);
++v2;
}
while ( *(_DWORD *)(a2 + 152) > (int)v2 );
}
return pthread_rwlock_unlock((pthread_rwlock_t *)(a2 + 96));
}

original_code:
void send_all_players(Player *player, Server *server){
    pthread_rwlock_rdlock(&server->players_lock);
    int i;
    for (i=0; i < server->num_players; i++){
 if (player == server->players[i]) continue;
 Player_send_new_player(player, server->players[i]);
    }
    pthread_rwlock_unlock(&server->players_lock);
}

canonical_original_code:
void send_all_players(struct Player *player, struct Server *server){
    pthread_rwlock_rdlock(&server->players_lock);
    int i;
    for (i=0; i < server->num_players; i++){
 if (player == server->players[i]) continue;
 Player_send_new_player(player, server->players[i]);
    }
    pthread_rwlock_unlock(&server->players_lock);
}


decompiled_code:
int __fastcall handle_player_chat(const char **a1, __int64 a2, __int64 a3)
{
const char *v4; // r12
const char *v5; // rsi
char *v6; // rax
_WORD v8[140]; // [rsp+0h] [rbp-118h] BYREF

v4 = *a1;
if ( **a1 == 47 )
return handle_command(a2, a3, *a1);
v5 = *(const char **)(a2 + 56);
v8[0] = 91;
v6 = stpcpy((char *)v8 + 1, v5);
*(_WORD *)v6 = 8285;
strcpy(v6 + 2, v4);
pthread_rwlock_rdlock((pthread_rwlock_t *)(a3 + 96));
Server_tell_all(a3, v8);
return pthread_rwlock_unlock((pthread_rwlock_t *)(a3 + 96));
}

canonical_decompiled_code:
int __fastcall func3(const char **a1, __int64 a2, __int64 a3)
{
const char *v4; // r12
const char *v5; // rsi
char *v6; // rax
_WORD v8[140]; // [rsp+0h] [rbp-118h] BYREF

v4 = *a1;
if ( **a1 == 47 )
return handle_command(a2, a3, *a1);
v5 = *(const char **)(a2 + 56);
v8[0] = 91;
v6 = stpcpy((char *)v8 + 1, v5);
*(_WORD *)v6 = 8285;
strcpy(v6 + 2, v4);
pthread_rwlock_rdlock((pthread_rwlock_t *)(a3 + 96));
Server_tell_all(a3, v8);
return pthread_rwlock_unlock((pthread_rwlock_t *)(a3 + 96));
}

original_code:
void handle_player_chat(Packet03ChatMessage *packet, Player *p, Server *s){
    if (packet->str[0] == '/'){
 handle_command(p, s, packet->str);
 return;
    }
    char buffer[256];
    buffer[0] = 0;
    char *begin_name = "[";
    char *end_name = "] ";
    strcat(buffer, begin_name);
    strcat(buffer, p->username);
    strcat(buffer, end_name);
    strcat(buffer, packet->str);
    pthread_rwlock_rdlock(&s->players_lock);
    Server_tell_all(s, buffer);
    pthread_rwlock_unlock(&s->players_lock);
}

canonical_original_code:
void handle_player_chat(struct Packet03ChatMessage *packet, struct Player *p, struct Server *s){
    if (packet->str[0] == '/'){
 handle_command(p, s, packet->str);
 return;
    }
    char buffer[256];
    buffer[0] = 0;
    char *begin_name = "[";
    char *end_name = "] ";
    strcat(buffer, begin_name);
    strcat(buffer, p->username);
    strcat(buffer, end_name);
    strcat(buffer, packet->str);
    pthread_rwlock_rdlock(&s->players_lock);
    Server_tell_all(s, buffer);
    pthread_rwlock_unlock(&s->players_lock);
}

variable_types: struct Packet03ChatMessage { char *str; } *

variable_types:
buffer
char [256]


decompiled_code:
int __fastcall handle_player_position(double *a1, pthread_rwlock_t *a2)
{
pthread_rwlock_wrlock(a2);
Player_set_position(a2, *a1, a1[1], a1[3]);
return pthread_rwlock_unlock(a2);
}

canonical_decompiled_code:
int __fastcall func4(double *a1, pthread_rwlock_t *a2)
{
pthread_rwlock_wrlock(a2);
Player_set_position(a2, *a1, a1[1], a1[3]);
return pthread_rwlock_unlock(a2);
}

original_code:
void handle_player_position(Packet0BPlayerPosition *packet, Player *p, Server *s){
    pthread_rwlock_wrlock(&p->lock);
    Player_set_position(p, packet->x, packet->y, packet->z);
    pthread_rwlock_unlock(&p->lock);
}

canonical_original_code:
void handle_player_position(struct Packet0BPlayerPosition *packet, struct Player *p, struct Server *s){
    pthread_rwlock_wrlock(&p->lock);
    Player_set_position(p, packet->x, packet->y, packet->z);
    pthread_rwlock_unlock(&p->lock);
}

variable_types: struct Packet0BPlayerPosition { double x; double y; double stance; double z; char on_ground; } *


decompiled_code:
void handle_player_look()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void handle_player_look(Packet0CPlayerLook *packet, Player *p, Server *s){
}

canonical_original_code:
void handle_player_look(struct Packet0CPlayerLook *packet, struct Player *p, struct Server *s){
}

variable_types: struct Packet0CPlayerLook { float yaw; float pitch; } *


decompiled_code:
int __fastcall handle_block_placement(__int64 a1, __int64 a2, pthread_rwlock_t *a3)
{
pthread_rwlock_t *v4; // r13
__int64 v6; // rdi
unsigned int v8; // [rsp+4h] [rbp-34h] BYREF
unsigned int v9; // [rsp+8h] [rbp-30h] BYREF
unsigned int v10[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v4 = a3 + 3;
logfmt(3LL, "Player: %s is placing block!", *(const char **)(a2 + 56));
v6 = (unsigned int)*(char *)(a1 + 12);
v8 = *(_DWORD *)a1;
v9 = *(unsigned __int8 *)(a1 + 4);
v10[0] = *(_DWORD *)(a1 + 8);
apply_face(v6, &v8, &v9, v10);
pthread_rwlock_wrlock((pthread_rwlock_t *)a2);
pthread_rwlock_wrlock(v4);
Player_place_block(a2, a3, v8, v9, v10[0]);
pthread_rwlock_unlock(v4);
return pthread_rwlock_unlock((pthread_rwlock_t *)a2);
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1, __int64 a2, pthread_rwlock_t *a3)
{
pthread_rwlock_t *v4; // r13
__int64 v6; // rdi
unsigned int v8; // [rsp+4h] [rbp-34h] BYREF
unsigned int v9; // [rsp+8h] [rbp-30h] BYREF
unsigned int v10[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v4 = a3 + 3;
logfmt(3LL, "Player: %s is placing block!", *(const char **)(a2 + 56));
v6 = (unsigned int)*(char *)(a1 + 12);
v8 = *(_DWORD *)a1;
v9 = *(unsigned __int8 *)(a1 + 4);
v10[0] = *(_DWORD *)(a1 + 8);
apply_face(v6, &v8, &v9, v10);
pthread_rwlock_wrlock((pthread_rwlock_t *)a2);
pthread_rwlock_wrlock(v4);
Player_place_block(a2, a3, v8, v9, v10[0]);
pthread_rwlock_unlock(v4);
return pthread_rwlock_unlock((pthread_rwlock_t *)a2);
}

original_code:
void handle_block_placement(Packet0FPlayerBlockPlacement *packet,
       Player *p, Server *s){
    logfmt(3, "Player: %s is placing block!", p->username);
    int x = packet->x;
    int y = packet->y;
    int z = packet->z;
    apply_face(packet->direction, &x, &y, &z);
    pthread_rwlock_wrlock(&p->lock);
    pthread_rwlock_wrlock(&s->map_lock);
    Player_place_block(p, s, x,y,z);
    pthread_rwlock_unlock(&s->map_lock);
    pthread_rwlock_unlock(&p->lock);
}

canonical_original_code:
void handle_block_placement(struct Packet0FPlayerBlockPlacement *packet, struct Player *p, struct Server *s){
    logfmt(3, "Player: %s is placing block!", p->username);
    int x = packet->x;
    int y = packet->y;
    int z = packet->z;
    apply_face(packet->direction, &x, &y, &z);
    pthread_rwlock_wrlock(&p->lock);
    pthread_rwlock_wrlock(&s->map_lock);
    Player_place_block(p, s, x,y,z);
    pthread_rwlock_unlock(&s->map_lock);
    pthread_rwlock_unlock(&p->lock);
}

variable_types: struct Packet0FPlayerBlockPlacement { int x; unsigned char y; int z; char direction; struct Slot { short id; char count; short damage; short nbt_len; char *nbt; } *held_item; char c_posx; char c_posy; char c_posz; } *

variable_types: struct Player { 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; } lock; char *username; int entity_id; int socket; struct Inventory { unsigned long size; struct Slot **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; } *

variable_types: x int

variable_types: y int

user_defined_types: struct Packet0FPlayerBlockPlacement { int x; unsigned char y; int z; char direction; struct Slot *held_item; char c_posx; char c_posy; char c_posz; }


decompiled_code:
int __fastcall handle_item_change(__int16 *a1, pthread_rwlock_t *a2)
{
logfmt(3LL, "Player: is changing slot.", a2[1].__align);
pthread_rwlock_wrlock(a2);
a2[1].__writer = *a1;
return pthread_rwlock_unlock(a2);
}

canonical_decompiled_code:
int __fastcall func7(__int16 *a1, pthread_rwlock_t *a2)
{
logfmt(3LL, "Player: is changing slot.", a2[1].__align);
pthread_rwlock_wrlock(a2);
a2[1].__writer = *a1;
return pthread_rwlock_unlock(a2);
}

original_code:
void handle_item_change(Packet10HeldItemChange *packet, Player *p, Server *s){
    logfmt(3, "Player:  is changing slot.", p->username);
    pthread_rwlock_wrlock(&p->lock);
    p->held_slot_num = packet->slot_id;
    pthread_rwlock_unlock(&p->lock);
}

canonical_original_code:
void handle_item_change(struct Packet10HeldItemChange *packet, struct Player *p, struct Server *s){
    logfmt(3, "Player:  is changing slot.", p->username);
    pthread_rwlock_wrlock(&p->lock);
    p->held_slot_num = packet->slot_id;
    pthread_rwlock_unlock(&p->lock);
}

variable_types: struct Packet10HeldItemChange { short slot_id; } *


logmsg

decompiled_code:
int __fastcall logmsg(int a1, const char *a2)
{
const char *v2; // rbp
int result; // eax

if ( a1 <= 3 )
{
if ( (unsigned int)a1 <= 3 )
v2 = CSWTCH_1[a1];
pthread_mutex_lock(&log_mutex);
printf("%s %s \n", v2, a2);
result = pthread_mutex_unlock(&log_mutex);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1, const char *a2)
{
const char *v2; // rbp
int result; // eax

if ( a1 <= 3 )
{
if ( (unsigned int)a1 <= 3 )
v2 = CSWTCH_1[a1];
pthread_mutex_lock(&log_mutex);
printf("%s %s \n", v2, a2);
result = pthread_mutex_unlock(&log_mutex);
}
return result;
}

original_code:
void logmsg(int level, const char *message){
    if (level <= 3){
 char *level_string;
 switch (level){
 case 0:
     level_string = "[Error]";
     break;
 case 1:
     level_string = "[WARN]";
     break;
 case 2:
     level_string = "[INFO]";
     break;
 case 3:
     level_string = "[DEBUG]";
     break;
 }
 pthread_mutex_lock(&log_mutex);
 printf("%s %s \n", level_string, message);
 pthread_mutex_unlock(&log_mutex);
    }
}

canonical_original_code:
void logmsg(int level, char *message){
    if (level <= 3){
 char *level_string;
 switch (level){
 case 0:
     level_string = "[Error]";
     break;
 case 1:
     level_string = "[WARN]";
     break;
 case 2:
     level_string = "[INFO]";
     break;
 case 3:
     level_string = "[DEBUG]";
     break;
 }
 pthread_mutex_lock(&log_mutex);
 printf("%s %s \n", level_string, message);
 pthread_mutex_unlock(&log_mutex);
    }
}

variable_types: level int

variable_types:
message
char *


logfmt

decompiled_code:
int logfmt(int a1, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-2D0h] BYREF
char s[512]; // [rsp+20h] [rbp-2B8h] BYREF

va_start(arg, a2);
vsnprintf(s, 0x200uLL, a2, arg);
return logmsg(a1, s);
}

canonical_decompiled_code:
int func1(int a1, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-2D0h] BYREF
char s[512]; // [rsp+20h] [rbp-2B8h] BYREF

va_start(arg, a2);
vsnprintf(s, 0x200uLL, a2, arg);
return func0(a1, s);
}

original_code:
void logfmt(int level, const char *fmt, ...){
    char buffer[512];
    va_list args;
    __builtin_va_start(args,fmt);
    vsnprintf(buffer, 512, fmt, args);
    __builtin_va_end(args);
    logmsg(level, buffer);
}

canonical_original_code:
void logfmt(int level, char *fmt, ...){
    char buffer[512];
    __builtin_va_list args;
    __builtin_va_start(args,fmt);
    vsnprintf(buffer, 512, fmt, args);
    __builtin_va_end(args);
    logmsg(level, buffer);
}

variable_types:
fmt
char *

variable_types:
buffer
char [512]


decompiled_code:
int logging_init()
{
return pthread_mutex_init(&log_mutex, 0LL);
}

canonical_decompiled_code:
int func2()
{
return pthread_mutex_init(&log_mutex, 0LL);
}

original_code:
void logging_init(){
    pthread_mutex_init(&log_mutex, ((void *)0));
}


decompiled_code:
void __noreturn catch_sigint()
{
logmsg(1LL, "Shutting down due to quit signal!");
pthread_rwlock_wrlock((pthread_rwlock_t *)(sigint_server + 96));
Server_shutdown(sigint_server);
pthread_rwlock_unlock((pthread_rwlock_t *)(sigint_server + 96));
exit(0);
}

canonical_decompiled_code:
void __noreturn func0()
{
logmsg(1LL, "Shutting down due to quit signal!");
pthread_rwlock_wrlock((pthread_rwlock_t *)(sigint_server + 96));
Server_shutdown(sigint_server);
pthread_rwlock_unlock((pthread_rwlock_t *)(sigint_server + 96));
exit(0);
}

original_code:
static void catch_sigint(int signal){
    logmsg(1, "Shutting down due to quit signal!");
    pthread_rwlock_wrlock(&sigint_server->players_lock);
    Server_shutdown(sigint_server);
    pthread_rwlock_unlock(&sigint_server->players_lock);
    exit(0);
}

variable_types: signal int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
__int64 v4; // rcx
int v5; // er15
const char *v6; // r13
__int64 v7; // r8
__int64 v8; // rbx
const char *v9; // rax
__int64 v10; // rbp
__int64 v11; // rax
__int64 v12; // rbx
pthread_rwlock_t *v13; // rbp
bool v14; // zf
int v16; // [rsp+4h] [rbp-54h]
const char *v17; // [rsp+8h] [rbp-50h]
struct timespec requested_time; // [rsp+10h] [rbp-48h] BYREF

logging_init(argc, argv, envp);
logmsg(2LL, "Server started and logging started.");
if ( argc <= 0 )
{
v17 = 0LL;
LODWORD(v7) = 5;
v16 = 5;
goto LABEL_22;
}
v17 = 0LL;
v5 = 0;
v6 = 0LL;
v7 = 5LL;
v16 = 5;
do
{
while ( 1 )
{
while ( 1 )
{
v8 = v5;
v9 = argv[v8];
if ( *v9 == 45 )
break;
LABEL_9:
if ( argc <= ++v5 )
goto LABEL_10;
}
v4 = 115LL;
if ( v9[1] != 115 || v9[2] )
break;
v5 += 3;
v16 = atoi(argv[v8 + 1]);
v7 = (unsigned int)atoi(argv[v8 + 2]);
if ( argc <= v5 )
goto LABEL_10;
}
v3 = 102LL;
if ( v9[1] != 102 || v9[2] )
{
v3 = 111LL;
if ( v9[1] == 111 && !v9[2] )
v17 = argv[v8 + 1];
goto LABEL_9;
}
++v5;
v6 = argv[v8 + 1];
}
while ( argc > v5 );
LABEL_10:
if ( v6 )
{
v10 = Map_read(v6, "Server started and logging started.", v3, v4, v7);
goto LABEL_12;
}
LABEL_22:
v10 = Map_new_air(v16, (int)v7);
Map_set_below(v10, 1LL, 60LL);
v6 = v17;
***(_WORD ***)(v10 + 16) = 20;
LABEL_12:
v11 = Server_create(v10, 10LL);
*(_BYTE *)(v11 + 56) = 1;
v12 = v11;
*(_QWORD *)(v11 + 232) = v6;
v13 = (pthread_rwlock_t *)(v11 + 96);
sigint_server = v11;
signal(2, (__sighandler_t)catch_sigint);
pthread_create((pthread_t *)(v12 + 240), 0LL, (void *(*)(void *))&connection_distributor_thread, (void *)v12);
logmsg(2LL, "Distributor thread started.");
v14 = *(_BYTE *)(v12 + 56) == 0;
requested_time.tv_sec = 0LL;
requested_time.tv_nsec = 50000000LL;
if ( !v14 )
{
do
{
pthread_rwlock_wrlock((pthread_rwlock_t *)v12);
pthread_rwlock_wrlock(v13);
Server_tick(v12);
pthread_rwlock_unlock((pthread_rwlock_t *)v12);
pthread_rwlock_unlock(v13);
nanosleep(&requested_time, 0LL);
}
while ( *(_BYTE *)(v12 + 56) );
}
pthread_join(*(_QWORD *)(v12 + 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; }

return_type: int


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

logmsg(2LL, "Started new distributor thread.");
*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
*(_OWORD *)&req.ai_canonname = 0LL;
req.ai_socktype = 1;
req.ai_flags = 1;
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!");
v7 = 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
socklen_t addr_len; // [rsp+Ch] [rbp-12Ch] BYREF
struct addrinfo *pai; // [rsp+10h] [rbp-128h] BYREF
pthread_t newthread; // [rsp+18h] [rbp-120h] BYREF
int arg; // [rsp+20h] [rbp-118h] BYREF
__int64 v7; // [rsp+28h] [rbp-110h]
struct addrinfo req; // [rsp+30h] [rbp-108h] BYREF
pthread_attr_t attr; // [rsp+60h] [rbp-D8h] BYREF
struct sockaddr addr; // [rsp+A0h] [rbp-98h] BYREF

logmsg(2LL, "Started new distributor thread.");
*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
*(_OWORD *)&req.ai_canonname = 0LL;
req.ai_socktype = 1;
req.ai_flags = 1;
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!");
v7 = 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; }


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;
*(_DWORD *)&sops.sem_op = 268500991;
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;
*(_DWORD *)&sops.sem_op = 268500991;
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; }


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;
*(_DWORD *)&sops.sem_op = 268435457;
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;
*(_DWORD *)&sops.sem_op = 268435457;
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 *


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 func0()
{
;
}

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_strcat_setup()
{
dest[0] = -1LL;
dest[1] = -1LL;
dest[2] = -1LL;
dest[3] = -1LL;
dest[4] = -1LL;
dest[5] = -1LL;
dest[6] = -1LL;
dest[7] = -1LL;
}

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

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


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 func2(__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_CC6);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

result = mon_strlen(&unk_CC6);
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_CC6);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

result = mon_strcmp(&unk_CC6);
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 func6(__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 func7(__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 func8(__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 func9(__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 func10(__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_CC6, &unk_CC6, 0LL);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

result = mon_strncmp(&unk_CC6, &unk_CC6, 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_CC6, &unk_CC6, 6LL);
if ( !(_DWORD)result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

result = mon_strncmp(&unk_CC6, &unk_CC6, 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 func13(__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 func14(__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 func15(__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 func16(__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 func17(__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_CC6), "PREM") == 0;
result = !v1;
if ( v1 )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

strcpy((char *)dest, "PREM");
v1 = strcmp((const char *)mon_strcat(dest, &unk_CC6), "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 func19(__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 func20(__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 func21(__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_CC6, 67LL);
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

result = mon_strchr(&unk_CC6, 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_CC6, "CDEZ");
if ( !result )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

result = mon_strstr(&unk_CC6, "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_CC6);
if ( result == "0123456789" )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

result = (char *)mon_strstr("0123456789", &unk_CC6);
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 func27(__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 func28(__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 func29(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:
void mon_strstr_tear_down()
{
;
}

canonical_decompiled_code:
void func31()
{
;
}

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


decompiled_code:
void mon_strstr_setup()
{
;
}

canonical_decompiled_code:
void func32()
{
;
}

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


decompiled_code:
void mon_strchr_tear_down()
{
;
}

canonical_decompiled_code:
void func33()
{
;
}

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


decompiled_code:
void mon_strchr_setup()
{
;
}

canonical_decompiled_code:
void func34()
{
;
}

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


decompiled_code:
void mon_strcat_tear_down()
{
;
}

canonical_decompiled_code:
void func35()
{
;
}

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


decompiled_code:
void mon_strncmp_tear_down()
{
;
}

canonical_decompiled_code:
void func36()
{
;
}

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


decompiled_code:
void mon_strncmp_setup()
{
;
}

canonical_decompiled_code:
void func37()
{
;
}

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


decompiled_code:
void mon_strcmp_tear_down()
{
;
}

canonical_decompiled_code:
void func38()
{
;
}

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


decompiled_code:
void mon_strcmp_setup()
{
;
}

canonical_decompiled_code:
void func39()
{
;
}

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


decompiled_code:
void mon_strlen_tear_down()
{
;
}

canonical_decompiled_code:
void func40()
{
;
}

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


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

result = mon_strlen(&unk_D78);
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_D78);
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_constprop_0_isra_0(
(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_constprop_0_isra_0(
(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_constprop_0_isra_0(
(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_constprop_0_isra_0(
(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_constprop_0_isra_0(
(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_constprop_0_isra_0(
(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;
mu_run_test_suite_constprop_0_isra_0(
(void (__fastcall *)(_QWORD *))mon_strlen_setup,
(void (__fastcall *)(_QWORD *))mon_strlen_tear_down,
&mon_strlen_tests_array,
&v4,
v5);
func29("mon_strlen", &mon_strlen_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite_constprop_0_isra_0(
(void (__fastcall *)(_QWORD *))mon_strcmp_setup,
(void (__fastcall *)(_QWORD *))mon_strcmp_tear_down,
&mon_strcmp_tests_array,
&v4,
v5);
func29("mon_strcmp", &mon_strcmp_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite_constprop_0_isra_0(
(void (__fastcall *)(_QWORD *))mon_strncmp_setup,
(void (__fastcall *)(_QWORD *))mon_strncmp_tear_down,
&mon_strncmp_tests_array,
&v4,
v5);
func29("mon_strncmp", &mon_strncmp_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite_constprop_0_isra_0(
(void (__fastcall *)(_QWORD *))mon_strcat_setup,
(void (__fastcall *)(_QWORD *))mon_strcat_tear_down,
&mon_strcat_tests_array,
&v4,
v5);
func29("mon_strcat", &mon_strcat_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite_constprop_0_isra_0(
(void (__fastcall *)(_QWORD *))mon_strchr_setup,
(void (__fastcall *)(_QWORD *))mon_strchr_tear_down,
&mon_strchr_tests_array,
&v4,
v5);
func29("mon_strchr", &mon_strchr_tests_array, v4, v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite_constprop_0_isra_0(
(void (__fastcall *)(_QWORD *))mon_strstr_setup,
(void (__fastcall *)(_QWORD *))mon_strstr_tear_down,
&mon_strstr_tests_array,
&v4,
v5);
func29("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; // er8

if ( !*a1 )
return 0LL;
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; // er8

if ( !*a1 )
return 0LL;
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(char *a1, char *a2)
{
char v2; // al
char v3; // dl
int v4; // ecx
__int64 result; // rax
int v6; // er8
int v7; // edx

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

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

v2 = *a1;
v3 = *a2;
v4 = 0;
while ( v2 )
{
if ( v2 == v3 )
{
v2 = a1[++v4];
v3 = a2[v4];
}
else
{
LABEL_4:
if ( v2 > v3 )
return 1LL;
if ( v2 < v3 )
return 0xFFFFFFFFLL;
}
}
if ( v3 )
goto LABEL_4;
func0(a1);
v6 = func0(a2);
result = (unsigned int)-(v7 < v6);
if ( v7 > v6 )
result = 1LL;
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, __int64 a2, int a3)
{
char v4; // al
int v6; // ecx
__int64 v7; // rdx
_BYTE *v8; // r9
int v9; // edx
int v10; // ecx
__int64 result; // rax

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

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

v4 = *a1;
if ( a3 > 0 && v4 )
{
v6 = 0;
v7 = 0LL;
do
{
if ( *(_BYTE *)(a2 + v7) == v4 )
{
v7 = ++v6;
v4 = a1[v6];
if ( !v4 )
break;
}
else
{
if ( *(char *)(a2 + v7) < v4 )
return 1LL;
if ( *(char *)(a2 + v7) > v4 )
return 0xFFFFFFFFLL;
v7 = v6;
v4 = a1[v6];
if ( !v4 )
break;
}
}
while ( a3 > v6 );
}
func0(a1);
v10 = func0(v8);
if ( v9 < a3 || (result = 0LL, a3 > v10) )
{
result = (unsigned int)-(v9 < v10);
if ( v9 > v10 )
result = 1LL;
}
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:
__int64 __fastcall mon_strstr(_BYTE *a1, _BYTE *a2)
{
int v2; // eax
__int64 v3; // r11
int v4; // ebp
__int64 v5; // r10
int v6; // er13

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

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1, _BYTE *a2)
{
int v2; // eax
__int64 v3; // r11
int v4; // ebp
__int64 v5; // r10
int v6; // er13

v2 = func0(a2);
if ( v2 )
{
v4 = v2;
v6 = func0(a1) - v2;
while ( v6 > (int)v5 )
{
if ( !(unsigned int)func2(&a1[v5 + 1], (__int64)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

decompiled_code:
__int64 __fastcall getSumOfBlocks(__int64 a1)
{
unsigned int *v1; // rax
unsigned int v2; // er8
int v3; // edx
unsigned int *v4; // rcx
unsigned int v5; // edx

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

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
unsigned int *v1; // rax
unsigned int v2; // er8
int v3; // edx
unsigned int *v4; // rcx
unsigned int v5; // edx

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

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 func4(__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 = 0LL;
if ( a2 )
{
if ( a2 <= 0 )
{
result = (unsigned int)a2;
}
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 = 0LL;
if ( a2 )
{
if ( a2 <= 0 )
{
result = (unsigned int)a2;
}
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; // eax
int *v2; // rdx
unsigned int v3; // er8
__int64 v4; // rcx
int *v5; // rax
__int64 v6; // rcx
int v7; // edx

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

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