main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // eax
int v5; // ebp
int v6; // eax
const char *v7; // rdi
__int16 v8; // ax
socklen_t v9; // edx
__int64 v10; // rbx
size_t v11; // rax
int fd; // [rsp+0h] [rbp-458h] BYREF
socklen_t addr_len; // [rsp+4h] [rbp-454h] BYREF
__int64 v14; // [rsp+8h] [rbp-450h] BYREF
pthread_t newthread; // [rsp+10h] [rbp-448h] BYREF
pthread_t v16; // [rsp+18h] [rbp-440h] BYREF
char buf[10]; // [rsp+26h] [rbp-432h] BYREF
struct sockaddr v18; // [rsp+30h] [rbp-428h] BYREF
struct sockaddr addr; // [rsp+40h] [rbp-418h] BYREF
char s[1032]; // [rsp+50h] [rbp-408h] BYREF

if ( argc == 2 )
{
v14 = 0LL;
client_list = (__int64)&v14;
initialize_hue(argc, argv, envp);
v4 = socket(2, 2, 0);
v18 = 0LL;
v5 = v4;
fd = v4;
v18.sa_family = 2;
v6 = _bswap_32_constprop_0();
v7 = argv[1];
*(_DWORD *)&v18.sa_data[2] = v6;
v8 = atoi(v7);
*(_WORD *)v18.sa_data = _bswap_16(v8);
bind(v5, &v18, v9);
pthread_create(&newthread, 0LL, (void *(*)(void *))&loop_check_timeouts, 0LL);
pthread_create(&v16, 0LL, (void *(*)(void *))&loop_ping_clients, 0LL);
while ( 1 )
{
addr_len = 16;
v10 = (int)recvfrom(fd, buf, 0xAuLL, 0, &addr, &addr_len);
process_recvfrom(client_list, buf, &addr, &addr_len, &fd, s);
printf("From main() reply: %s\n", s);
v11 = strlen(s);
sendto(fd, s, v11, 0, &addr, 0x10u);
puts("-------------------------------------------------------");
buf[v10] = 0;
printf("Received the following:\n%s", buf);
puts("-------------------------------------------------------");
}
}
printf("usage: %s <port>\n", *argv);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // eax
int v5; // ebp
int v6; // eax
const char *v7; // rdi
__int16 v8; // ax
socklen_t v9; // edx
__int64 v10; // rbx
size_t v11; // rax
int fd; // [rsp+0h] [rbp-458h] BYREF
socklen_t addr_len; // [rsp+4h] [rbp-454h] BYREF
__int64 v14; // [rsp+8h] [rbp-450h] BYREF
pthread_t newthread; // [rsp+10h] [rbp-448h] BYREF
pthread_t v16; // [rsp+18h] [rbp-440h] BYREF
char buf[10]; // [rsp+26h] [rbp-432h] BYREF
struct sockaddr v18; // [rsp+30h] [rbp-428h] BYREF
struct sockaddr addr; // [rsp+40h] [rbp-418h] BYREF
char s[1032]; // [rsp+50h] [rbp-408h] BYREF

if ( argc == 2 )
{
v14 = 0LL;
client_list = (__int64)&v14;
initialize_hue(argc, argv, envp);
v4 = socket(2, 2, 0);
v18 = 0LL;
v5 = v4;
fd = v4;
v18.sa_family = 2;
v6 = func1();
v7 = argv[1];
*(_DWORD *)&v18.sa_data[2] = v6;
v8 = atoi(v7);
*(_WORD *)v18.sa_data = func0(v8);
bind(v5, &v18, v9);
pthread_create(&newthread, 0LL, (void *(*)(void *))&loop_check_timeouts, 0LL);
pthread_create(&v16, 0LL, (void *(*)(void *))&loop_ping_clients, 0LL);
while ( 1 )
{
addr_len = 16;
v10 = (int)recvfrom(fd, buf, 0xAuLL, 0, &addr, &addr_len);
process_recvfrom(client_list, buf, &addr, &addr_len, &fd, s);
printf("From main() reply: %s\n", s);
v11 = strlen(s);
sendto(fd, s, v11, 0, &addr, 0x10u);
puts("-------------------------------------------------------");
buf[v10] = 0;
printf("Received the following:\n%s", buf);
puts("-------------------------------------------------------");
}
}
printf("usage: %s <port>\n", *argv);
return 0;
}

original_code:
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("usage: %s <port>\n", argv[0]);
  } else {
  int sockfd, n;
  struct sockaddr_in servaddr, client_address;
  socklen_t len;
  char mesg[10], reply[1000];
  list *end = ((void *)0);
  client_list = &end;
  pthread_t timeout_thread;
  pthread_t ping_client_thread;
  initialize_hue();
  sockfd = socket(2, SOCK_DGRAM, 0);
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = 2;
  servaddr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
  servaddr.sin_port = htons(atoi(argv[1]));
  bind(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr));
  pthread_create(&timeout_thread, ((void *)0), loop_check_timeouts, ((void *)0));
  pthread_create(&ping_client_thread, ((void *)0), loop_ping_clients, ((void *)0));
  while (1) {
    len = sizeof(client_address);
    n = recvfrom(sockfd, mesg, 10, 0, (struct sockaddr *) &client_address, &len);
    process_recvfrom(client_list, mesg, &client_address, &len, &sockfd, reply);
    printf("From main() reply: %s\n", reply);
    sendto(sockfd, reply, strlen(reply), 0, (struct sockaddr *) &client_address, sizeof(client_address));
    printf("-------------------------------------------------------\n");
    mesg[n] = 0;
    printf("Received the following:\n%s", mesg);
    printf("-------------------------------------------------------\n");
  }}
}

canonical_original_code:
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("usage: %s <port>\n", argv[0]);
  } else {
  int sockfd; int n;
  struct sockaddr_in servaddr; struct sockaddr_in client_address;
  unsigned int len;
  char mesg[10]; char reply[1000];
  struct list *end = ((void *)0);
  client_list = &end;
  unsigned long timeout_thread;
  unsigned long ping_client_thread;
  initialize_hue();
  sockfd = socket(2, SOCK_DGRAM, 0);
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = 2;
  servaddr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
  servaddr.sin_port = htons(atoi(argv[1]));
  bind(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr));
  pthread_create(&timeout_thread, ((void *)0), loop_check_timeouts, ((void *)0));
  pthread_create(&ping_client_thread, ((void *)0), loop_ping_clients, ((void *)0));
  while (1) {
    len = sizeof(client_address);
    n = recvfrom(sockfd, mesg, 10, 0, (struct sockaddr *) &client_address, &len);
    process_recvfrom(client_list, mesg, &client_address, &len, &sockfd, reply);
    printf("From main() reply: %s\n", reply);
    sendto(sockfd, reply, strlen(reply), 0, (struct sockaddr *) &client_address, sizeof(client_address));
    printf("-------------------------------------------------------\n");
    mesg[n] = 0;
    printf("Received the following:\n%s", mesg);
    printf("-------------------------------------------------------\n");
  }}
}

variable_types: argc int

variable_types:
argv
char **

variable_types: sockfd int

variable_types: n int

variable_types:
len
unsigned int

variable_types:
mesg
char [10]

variable_types:
reply
char [1000]

variable_types: struct list { struct player_struct { struct pixel_struct { unsigned short *red; unsigned short *green; unsigned short *blue; unsigned short *x; unsigned short *y; } *pixel; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *clientaddr; unsigned int *clientaddr_len; long *last_pong; int *socket; } *player; struct list *next; } *

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

user_defined_types: struct list { struct player_struct *player; struct list *next; }

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

user_defined_types: struct player_struct { struct pixel_struct *pixel; struct sockaddr_in *clientaddr; unsigned int *clientaddr_len; long *last_pong; int *socket; }


decompiled_code:
int __fastcall move_player(__int64 *a1, char a2)
{
__int64 v2; // rbp
_WORD *v3; // rax
unsigned __int16 *v4; // rdx
unsigned __int16 v5; // ax
__int64 v6; // rsi
__int64 v7; // rdx

v2 = *a1;
LODWORD(v3) = printf(
"\tOld X: %.2hu\n\tOld Y: %.2hu\n",
**(unsigned __int16 **)(v2 + 24),
**(unsigned __int16 **)(v2 + 32));
switch ( a2 )
{
case 'N':
v3 = *(_WORD **)(v2 + 32);
if ( !*v3 )
return (int)v3;
LOWORD(v7) = *v3 - 1;
*v3 = v7;
v7 = (unsigned __int16)v7;
v6 = **(unsigned __int16 **)(v2 + 24);
goto LABEL_14;
case 'S':
v3 = *(_WORD **)(v2 + 32);
if ( *v3 > 0x30u )
return (int)v3;
LOWORD(v7) = *v3 + 1;
*v3 = v7;
v7 = (unsigned __int16)v7;
v6 = **(unsigned __int16 **)(v2 + 24);
goto LABEL_14;
case 'W':
v4 = *(unsigned __int16 **)(v2 + 24);
LODWORD(v3) = *v4;
if ( !(_WORD)v3 )
return (int)v3;
v5 = (_WORD)v3 - 1;
goto LABEL_6;
case 'E':
v4 = *(unsigned __int16 **)(v2 + 24);
LODWORD(v3) = *v4;
if ( (unsigned __int16)v3 <= 0x30u )
{
v5 = (_WORD)v3 + 1;
LABEL_6:
*v4 = v5;
v6 = v5;
v7 = **(unsigned __int16 **)(v2 + 32);
LABEL_14:
LODWORD(v3) = printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", v6, v7);
return (int)v3;
}
break;
}
return (int)v3;
}

canonical_decompiled_code:
int __fastcall func0(__int64 *a1, char a2)
{
__int64 v2; // rbp
_WORD *v3; // rax
unsigned __int16 *v4; // rdx
unsigned __int16 v5; // ax
__int64 v6; // rsi
__int64 v7; // rdx

v2 = *a1;
LODWORD(v3) = printf(
"\tOld X: %.2hu\n\tOld Y: %.2hu\n",
**(unsigned __int16 **)(v2 + 24),
**(unsigned __int16 **)(v2 + 32));
switch ( a2 )
{
case 'N':
v3 = *(_WORD **)(v2 + 32);
if ( !*v3 )
return (int)v3;
LOWORD(v7) = *v3 - 1;
*v3 = v7;
v7 = (unsigned __int16)v7;
v6 = **(unsigned __int16 **)(v2 + 24);
goto LABEL_14;
case 'S':
v3 = *(_WORD **)(v2 + 32);
if ( *v3 > 0x30u )
return (int)v3;
LOWORD(v7) = *v3 + 1;
*v3 = v7;
v7 = (unsigned __int16)v7;
v6 = **(unsigned __int16 **)(v2 + 24);
goto LABEL_14;
case 'W':
v4 = *(unsigned __int16 **)(v2 + 24);
LODWORD(v3) = *v4;
if ( !(_WORD)v3 )
return (int)v3;
v5 = (_WORD)v3 - 1;
goto LABEL_6;
case 'E':
v4 = *(unsigned __int16 **)(v2 + 24);
LODWORD(v3) = *v4;
if ( (unsigned __int16)v3 <= 0x30u )
{
v5 = (_WORD)v3 + 1;
LABEL_6:
*v4 = v5;
v6 = v5;
v7 = **(unsigned __int16 **)(v2 + 32);
LABEL_14:
LODWORD(v3) = printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", v6, v7);
return (int)v3;
}
break;
}
return (int)v3;
}

original_code:
void move_player(player_struct *player, char direction) {
  struct pixel_struct *current_pixel;
  current_pixel = player->pixel;
  printf("\tOld X: %.2hu\n\tOld Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
  if (direction == 'N' && *current_pixel->y > 0) {
    *current_pixel->y -= 1;
    printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
    return;
  }
  if (direction == 'S' && *current_pixel->y < 49) {
    *current_pixel->y += 1;
    printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
    return;
  }
  if (direction == 'W' && *current_pixel->x > 0) {
    *current_pixel->x -= 1;
    printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
    return;
  }
  if (direction == 'E' && *current_pixel->x < 49) {
    *current_pixel->x += 1;
    printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
    return;
  }
}

canonical_original_code:
void move_player(struct player_struct *player, char direction) {
  struct pixel_struct *current_pixel;
  current_pixel = player->pixel;
  printf("\tOld X: %.2hu\n\tOld Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
  if (direction == 'N' && *current_pixel->y > 0) {
    *current_pixel->y -= 1;
    printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
    return;
  }
  if (direction == 'S' && *current_pixel->y < 49) {
    *current_pixel->y += 1;
    printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
    return;
  }
  if (direction == 'W' && *current_pixel->x > 0) {
    *current_pixel->x -= 1;
    printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
    return;
  }
  if (direction == 'E' && *current_pixel->x < 49) {
    *current_pixel->x += 1;
    printf("\tNew X: %.2hu\n\tNew Y: %.2hu\n", *(current_pixel->x), *(current_pixel->y));
    return;
  }
}

variable_types: struct player_struct { struct pixel_struct { unsigned short *red; unsigned short *green; unsigned short *blue; unsigned short *x; unsigned short *y; } *pixel; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *clientaddr; unsigned int *clientaddr_len; long *last_pong; int *socket; } *

variable_types: direction char

return_type: void


decompiled_code:
time_t __fastcall update_timeout(__int64 a1)
{
time_t *v1; // rbx
time_t result; // rax

puts("update_timeout called!");
v1 = *(time_t **)(a1 + 24);
result = time(0LL);
*v1 = result;
return result;
}

canonical_decompiled_code:
time_t __fastcall func1(__int64 a1)
{
time_t *v1; // rbx
time_t result; // rax

puts("update_timeout called!");
v1 = *(time_t **)(a1 + 24);
result = time(0LL);
*v1 = result;
return result;
}

original_code:
void update_timeout(player_struct *player) {
  printf("update_timeout called!\n");
  *(player->last_pong) = time(((void *)0));
}

canonical_original_code:
void update_timeout(struct player_struct *player) {
  printf("update_timeout called!\n");
  *(player->last_pong) = time(((void *)0));
}

user_defined_types: struct pixel_struct { unsigned short *red; unsigned short *green; unsigned short *blue; unsigned short *x; unsigned short *y; }


decompiled_code:
__int64 __fastcall add_player(__int64 a1, const __m128i *a2, int *a3, unsigned int *a4)
{
unsigned __int16 **v6; // rbx
_QWORD *v7; // rax
_QWORD *v8; // rbp
_OWORD *v9; // rax
__m128i v10; // xmm0
_DWORD *v11; // rax
int v12; // edx
_QWORD *v13; // rbx
_DWORD *v14; // rax
__int64 v15; // rsi

puts("Adding a player..");
v6 = (unsigned __int16 **)malloc(0x28uLL);
initialize_pixel(v6);
generate_pos(v6[3], v6[4]);
generate_rgb(*v6, v6[1], v6[2]);
printf("\tRed: %.3hu\n\tGreen: %.3hu\n\tBlue: %.3hu\n", **v6, *v6[1], *v6[2]);
printf("\n\tX: %.2hu\n\tY: %.2hu\n", *v6[3], *v6[4]);
v7 = malloc(0x28uLL);
*v7 = v6;
v8 = v7;
v9 = malloc(0x10uLL);
v10 = _mm_loadu_si128(a2);
v8[1] = v9;
*v9 = v10;
v11 = malloc(4uLL);
v12 = *a3;
v8[2] = v11;
*v11 = v12;
v13 = malloc(8uLL);
v8[3] = v13;
*v13 = time(0LL);
v14 = malloc(4uLL);
v15 = *a4;
v8[4] = v14;
*v14 = v15;
printf("Socket: %d\n", v15);
return insert_list(a1, v8);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const __m128i *a2, int *a3, unsigned int *a4)
{
unsigned __int16 **v6; // rbx
_QWORD *v7; // rax
_QWORD *v8; // rbp
_OWORD *v9; // rax
__m128i v10; // xmm0
_DWORD *v11; // rax
int v12; // edx
_QWORD *v13; // rbx
_DWORD *v14; // rax
__int64 v15; // rsi

puts("Adding a player..");
v6 = (unsigned __int16 **)malloc(0x28uLL);
initialize_pixel(v6);
func2(v6[3], v6[4]);
generate_rgb(*v6, v6[1], v6[2]);
printf("\tRed: %.3hu\n\tGreen: %.3hu\n\tBlue: %.3hu\n", **v6, *v6[1], *v6[2]);
printf("\n\tX: %.2hu\n\tY: %.2hu\n", *v6[3], *v6[4]);
v7 = malloc(0x28uLL);
*v7 = v6;
v8 = v7;
v9 = malloc(0x10uLL);
v10 = _mm_loadu_si128(a2);
v8[1] = v9;
*v9 = v10;
v11 = malloc(4uLL);
v12 = *a3;
v8[2] = v11;
*v11 = v12;
v13 = malloc(8uLL);
v8[3] = v13;
*v13 = time(0LL);
v14 = malloc(4uLL);
v15 = *a4;
v8[4] = v14;
*v14 = v15;
printf("Socket: %d\n", v15);
return insert_list(a1, v8);
}

original_code:
void add_player(list **players, struct sockaddr_in *client_address, socklen_t *client_address_len, int *client_socket) {
  struct pixel_struct *new_pixel;
  player_struct *new_player;
  printf("Adding a player..\n");
  new_pixel = malloc(sizeof(struct pixel_struct));
  initialize_pixel(new_pixel);
  generate_pos(new_pixel->x, new_pixel->y);
  generate_rgb(new_pixel->red, new_pixel->green, new_pixel->blue);
  printf("\tRed: %.3hu\n\tGreen: %.3hu\n\tBlue: %.3hu\n", *(new_pixel->red), *(new_pixel->green), *(new_pixel->blue));
  printf("\n\tX: %.2hu\n\tY: %.2hu\n", *(new_pixel->x), *(new_pixel->y));
  new_player = malloc(sizeof(player_struct));
  new_player->pixel = new_pixel;
  new_player->clientaddr = malloc(sizeof(struct sockaddr_in));
  *(new_player->clientaddr) = *client_address;
  new_player->clientaddr_len = malloc(sizeof(socklen_t));
  *(new_player->clientaddr_len) = *client_address_len;
  new_player->last_pong = malloc(sizeof(time_t));
  *(new_player->last_pong) = time(((void *)0));
  new_player->socket = malloc(sizeof(int));
  *(new_player->socket) = *client_socket;
  printf("Socket: %d\n", *new_player->socket);
  insert_list(players, new_player);
}

canonical_original_code:
void add_player(struct list **players, struct sockaddr_in *client_address, unsigned int *client_address_len, int *client_socket) {
  struct pixel_struct *new_pixel;
  struct player_struct *new_player;
  printf("Adding a player..\n");
  new_pixel = malloc(sizeof(struct pixel_struct));
  initialize_pixel(new_pixel);
  generate_pos(new_pixel->x, new_pixel->y);
  generate_rgb(new_pixel->red, new_pixel->green, new_pixel->blue);
  printf("\tRed: %.3hu\n\tGreen: %.3hu\n\tBlue: %.3hu\n", *(new_pixel->red), *(new_pixel->green), *(new_pixel->blue));
  printf("\n\tX: %.2hu\n\tY: %.2hu\n", *(new_pixel->x), *(new_pixel->y));
  new_player = malloc(sizeof(player_struct));
  new_player->pixel = new_pixel;
  new_player->clientaddr = malloc(sizeof(struct sockaddr_in));
  *(new_player->clientaddr) = *client_address;
  new_player->clientaddr_len = malloc(sizeof(socklen_t));
  *(new_player->clientaddr_len) = *client_address_len;
  new_player->last_pong = malloc(sizeof(time_t));
  *(new_player->last_pong) = time(((void *)0));
  new_player->socket = malloc(sizeof(int));
  *(new_player->socket) = *client_socket;
  printf("Socket: %d\n", *new_player->socket);
  insert_list(players, new_player);
}

variable_types: struct list { struct player_struct { struct pixel_struct { unsigned short *red; unsigned short *green; unsigned short *blue; unsigned short *x; unsigned short *y; } *pixel; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *clientaddr; unsigned int *clientaddr_len; long *last_pong; int *socket; } *player; struct list *next; } **


decompiled_code:
void __fastcall check_timeouts(__int64 **a1, _QWORD *a2)
{
__int64 v2; // r12
time_t v3; // rax
__int64 *i; // rbx
__int64 v5; // r13
size_t v6; // rax
double v7; // [rsp+0h] [rbp-70h]
char s[104]; // [rsp+8h] [rbp-68h] BYREF

if ( a2 )
{
v2 = a2[1];
v3 = time(0LL);
v7 = difftime(v3, **(_QWORD **)(*a2 + 24LL));
printf("Time since last PONG by client: %.2f\n", v7);
if ( v7 > 20.0 )
{
puts("deleting player from list, timed out");
removal_message(*a2, s);
delete_list(a1, *a2);
for ( i = *a1; i; i = (__int64 *)i[1] )
{
v5 = *i;
v6 = strlen(s);
sendto(**(_DWORD **)(v5 + 32), s, v6, 0, *(const struct sockaddr **)(v5 + 8), 0x10u);
}
}
check_timeouts(a1, v2);
}
}

canonical_decompiled_code:
void __fastcall func0(__int64 **a1, _QWORD *a2)
{
__int64 v2; // r12
time_t v3; // rax
__int64 *i; // rbx
__int64 v5; // r13
size_t v6; // rax
double v7; // [rsp+0h] [rbp-70h]
char s[104]; // [rsp+8h] [rbp-68h] BYREF

if ( a2 )
{
v2 = a2[1];
v3 = time(0LL);
v7 = difftime(v3, **(_QWORD **)(*a2 + 24LL));
printf("Time since last PONG by client: %.2f\n", v7);
if ( v7 > 20.0 )
{
puts("deleting player from list, timed out");
removal_message(*a2, s);
delete_list(a1, *a2);
for ( i = *a1; i; i = (__int64 *)i[1] )
{
v5 = *i;
v6 = strlen(s);
sendto(**(_DWORD **)(v5 + 32), s, v6, 0, *(const struct sockaddr **)(v5 + 8), 0x10u);
}
}
func0(a1, v2);
}
}

original_code:
void check_timeouts(list **original_players, list *players) {
  time_t current_time;
  double delta;
  list *next_ptr, *p;
  int timeout = 20;
  char reply_buffer[50];
  if (players == ((void *)0))
    return;
  next_ptr = players->next;
  current_time = time(((void *)0));
  delta = difftime(current_time, *((players->player)->last_pong));
  printf("Time since last PONG by client: %.2f\n", delta);
  if (delta > timeout) {
    printf("deleting player from list, timed out\n");
    removal_message(players->player, reply_buffer);
    delete_list(original_players, players->player);
    p = *original_players;
    while (p != ((void *)0)) {
      sendto(*p->player->socket, reply_buffer, strlen(reply_buffer), 0, (struct sockaddr *) p->player->clientaddr, sizeof(*p->player->clientaddr));
      p = p->next;
    }
  }
  check_timeouts(original_players, next_ptr);
}

canonical_original_code:
void check_timeouts(struct list **original_players, struct list *players) {
  long current_time;
  double delta;
  struct list *next_ptr; struct list *p;
  int timeout = 20;
  char reply_buffer[50];
  if (players == ((void *)0))
    return;
  next_ptr = players->next;
  current_time = time(((void *)0));
  delta = difftime(current_time, *((players->player)->last_pong));
  printf("Time since last PONG by client: %.2f\n", delta);
  if (delta > timeout) {
    printf("deleting player from list, timed out\n");
    removal_message(players->player, reply_buffer);
    delete_list(original_players, players->player);
    p = *original_players;
    while (p != ((void *)0)) {
      sendto(*p->player->socket, reply_buffer, strlen(reply_buffer), 0, (struct sockaddr *) p->player->clientaddr, sizeof(*p->player->clientaddr));
      p = p->next;
    }
  }
  check_timeouts(original_players, next_ptr);
}

variable_types:
players
struct list *

variable_types: delta double

variable_types: timeout int


decompiled_code:
void __noreturn loop_check_timeouts()
{
while ( 1 )
{
sleep(0x1Eu);
puts("Checking for timeouts...");
check_timeouts(client_list, (_QWORD *)*client_list);
}
}

canonical_decompiled_code:
void __noreturn func1()
{
while ( 1 )
{
sleep(0x1Eu);
puts("Checking for timeouts...");
func0(client_list, (_QWORD *)*client_list);
}
}

original_code:
void *loop_check_timeouts(void *arg) {
  while (1) {
    sleep(30);
    printf("Checking for timeouts...\n");
    check_timeouts(client_list, *client_list);
  }
}

variable_types:
arg
void *

return_type: void *


decompiled_code:
_BOOL8 __fastcall pong_response(const void *a1)
{
return memcmp("PONG", a1, 4uLL) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(const void *a1)
{
return memcmp("PONG", a1, 4uLL) == 0;
}

original_code:
int pong_response(char message[]) {
  return 0 == strncmp("PONG", message, 4);
}

variable_types:
message
char []

return_type: int


decompiled_code:
_BOOL8 __fastcall move_request(const void *a1)
{
_BOOL8 result; // rax

if ( !memcmp("MOVEN", a1, 5uLL) || !memcmp("MOVES", a1, 5uLL) || !memcmp("MOVEW", a1, 5uLL) )
result = 1LL;
else
result = memcmp("MOVEE", a1, 5uLL) == 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(const void *a1)
{
_BOOL8 result; // rax

if ( !memcmp("MOVEN", a1, 5uLL) || !memcmp("MOVES", a1, 5uLL) || !memcmp("MOVEW", a1, 5uLL) )
result = 1LL;
else
result = memcmp("MOVEE", a1, 5uLL) == 0;
return result;
}

original_code:
int move_request(char message[]) {
  return (0 == strncmp("MOVEN", message, 5) ||
          0 == strncmp("MOVES", message, 5) ||
          0 == strncmp("MOVEW", message, 5) ||
          0 == strncmp("MOVEE", message, 5));
}


decompiled_code:
_BOOL8 __fastcall client_connecting(const void *a1)
{
return memcmp("HELLO", a1, 5uLL) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(const void *a1)
{
return memcmp("HELLO", a1, 5uLL) == 0;
}

original_code:
int client_connecting(char message[]) {
  return 0 == strncmp("HELLO", message, 5);
}


decompiled_code:
__int64 __fastcall check_address(_QWORD *a1, __int64 a2, _DWORD *a3, _QWORD *a4)
{
_QWORD *v6; // rbx
char *v7; // r14
char *v8; // rax
__int16 v9; // ax
__int64 v10; // rcx
__int16 v11; // dx

if ( !a1 )
return 0LL;
v6 = a1;
do
{
v7 = inet_ntoa(*(struct in_addr *)(a2 + 4));
v8 = inet_ntoa(*(struct in_addr *)(*(_QWORD *)(*v6 + 8LL) + 4LL));
if ( !strcmp(v8, v7) )
{
_bswap_16(*(_WORD *)(*(_QWORD *)(*v6 + 8LL) + 2LL));
v9 = _bswap_16(*(_WORD *)(a2 + 2));
if ( v11 == v9 && **(_DWORD **)(v10 + 16) == *a3 )
{
*a4 = v10;
return 1LL;
}
}
v6 = (_QWORD *)v6[1];
}
while ( v6 );
return 0LL;
}

original_code:
int check_address(list *players, struct sockaddr_in *client_addr, socklen_t *client_addr_len, player_struct **player) {
  if (players == ((void *)0))
    return 0;
  if (!strcmp(inet_ntoa(((players->player)->clientaddr)->sin_addr), inet_ntoa(client_addr->sin_addr)) &&
      ntohs(((players->player)->clientaddr)->sin_port) == ntohs(client_addr->sin_port) &&
      *((players->player)->clientaddr_len) == *client_addr_len) {
    *player = players->player;
    return 1;
  }
  return check_address(players->next, client_addr, client_addr_len, player);
}

canonical_original_code:
int check_address(struct list *players, struct sockaddr_in *client_addr, unsigned int *client_addr_len, struct player_struct **player) {
  if (players == ((void *)0))
    return 0;
  if (!strcmp(inet_ntoa(((players->player)->clientaddr)->sin_addr), inet_ntoa(client_addr->sin_addr)) &&
      ntohs(((players->player)->clientaddr)->sin_port) == ntohs(client_addr->sin_port) &&
      *((players->player)->clientaddr_len) == *client_addr_len) {
    *player = players->player;
    return 1;
  }
  return check_address(players->next, client_addr, client_addr_len, player);
}

variable_types:
player
struct player_struct **


decompiled_code:
_BOOL8 __fastcall process_recvfrom(__int64 **a1, char *a2, __int64 a3, _DWORD *a4, __int64 a5, __int64 a6)
{
__int64 v9; // r8
__int64 v10; // r15
_BOOL4 v11; // ebp
unsigned __int16 v12; // bx
char *v13; // rax
__int64 v15[8]; // [rsp+8h] [rbp-40h] BYREF

if ( pong_response(a2) )
{
puts("Caught a pong!");
if ( (unsigned int)check_address(*a1, a3, a4, v15) )
{
v11 = 1;
update_timeout(v15[0]);
pong_message(a6);
return v11;
}
goto LABEL_9;
}
v10 = v9;
if ( move_request(a2) )
{
puts("Caught a move request!");
if ( (unsigned int)check_address(*a1, a3, a4, v15) )
{
move_player(v15[0], (unsigned int)a2[4]);
v11 = 1;
move_message((unsigned int)a2[4], a6);
send_updates();
puts("post grid_message");
return v11;
}
goto LABEL_9;
}
v11 = client_connecting(a2);
if ( v11 )
{
puts("Caught a connection request!");
if ( !(unsigned int)check_address(*a1, a3, a4, v15) )
{
add_player(a1, a3, a4, v10);
v11 = 1;
v15[0] = **a1;
welcome_message(v15[0], a6);
send_updates();
return v11;
}
LABEL_9:
v11 = 1;
error_message(a6);
return v11;
}
v12 = _bswap_16(*(_WORD *)(a3 + 2));
v13 = inet_ntoa(*(struct in_addr *)(a3 + 4));
printf("[Error]: Unresolved udp message from %s:%d.\n", v13, v12);
error_message(a6);
return v11;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 **a1, char *a2, __int64 a3, _DWORD *a4, __int64 a5, __int64 a6)
{
__int64 v9; // r8
__int64 v10; // r15
_BOOL4 v11; // ebp
unsigned __int16 v12; // bx
char *v13; // rax
__int64 v15[8]; // [rsp+8h] [rbp-40h] BYREF

if ( func1(a2) )
{
puts("Caught a pong!");
if ( (unsigned int)func4(*a1, a3, a4, v15) )
{
v11 = 1;
update_timeout(v15[0]);
pong_message(a6);
return v11;
}
goto LABEL_9;
}
v10 = v9;
if ( func2(a2) )
{
puts("Caught a move request!");
if ( (unsigned int)func4(*a1, a3, a4, v15) )
{
move_player(v15[0], (unsigned int)a2[4]);
v11 = 1;
move_message((unsigned int)a2[4], a6);
send_updates();
puts("post grid_message");
return v11;
}
goto LABEL_9;
}
v11 = func3(a2);
if ( v11 )
{
puts("Caught a connection request!");
if ( !(unsigned int)func4(*a1, a3, a4, v15) )
{
add_player(a1, a3, a4, v10);
v11 = 1;
v15[0] = **a1;
welcome_message(v15[0], a6);
send_updates();
return v11;
}
LABEL_9:
v11 = 1;
error_message(a6);
return v11;
}
v12 = func0(*(_WORD *)(a3 + 2));
v13 = inet_ntoa(*(struct in_addr *)(a3 + 4));
printf("[Error]: Unresolved udp message from %s:%d.\n", v13, v12);
error_message(a6);
return v11;
}

original_code:
int process_recvfrom( list **players,
                      char message[],
                      struct sockaddr_in *client_addr_ptr,
                      socklen_t *len_ptr,
                      int *socket_ptr,
                      char reply[]) {
  player_struct *client;
  if (pong_response(message)) {
    printf("Caught a pong!\n");
    if (check_address(*players, client_addr_ptr, len_ptr, &client)) {
      update_timeout(client);
      pong_message(reply);
    } else
        error_message(reply);
    return 1;
  }
  if (move_request(message)) {
    printf("Caught a move request!\n");
    if (check_address(*players, client_addr_ptr, len_ptr, &client)) {
      move_player(client, message[4]);
      move_message(message[4], reply);
      send_updates();
      printf("post grid_message\n");
    } else
        error_message(reply);
    return 1;
  }
  if (client_connecting(message)) {
    printf("Caught a connection request!\n");
    if (!check_address(*players, client_addr_ptr, len_ptr, &client)) {
      add_player(players, client_addr_ptr, len_ptr, socket_ptr);
      client = (*players)->player;
      welcome_message(client, reply);
      send_updates();
    } else
        error_message(reply);
    return 1;
  }
  printf("[Error]: Unresolved udp message from %s:%d.\n", inet_ntoa(client_addr_ptr->sin_addr), ntohs(client_addr_ptr->sin_port));
  error_message(reply);
  return 0;
}

canonical_original_code:
int process_recvfrom(struct list **players, char message[], struct sockaddr_in *client_addr_ptr, unsigned int *len_ptr, int *socket_ptr, char reply[]) {
  struct player_struct *client;
  if (pong_response(message)) {
    printf("Caught a pong!\n");
    if (check_address(*players, client_addr_ptr, len_ptr, &client)) {
      update_timeout(client);
      pong_message(reply);
    } else
        error_message(reply);
    return 1;
  }
  if (move_request(message)) {
    printf("Caught a move request!\n");
    if (check_address(*players, client_addr_ptr, len_ptr, &client)) {
      move_player(client, message[4]);
      move_message(message[4], reply);
      send_updates();
      printf("post grid_message\n");
    } else
        error_message(reply);
    return 1;
  }
  if (client_connecting(message)) {
    printf("Caught a connection request!\n");
    if (!check_address(*players, client_addr_ptr, len_ptr, &client)) {
      add_player(players, client_addr_ptr, len_ptr, socket_ptr);
      client = (*players)->player;
      welcome_message(client, reply);
      send_updates();
    } else
        error_message(reply);
    return 1;
  }
  printf("[Error]: Unresolved udp message from %s:%d.\n", inet_ntoa(client_addr_ptr->sin_addr), ntohs(client_addr_ptr->sin_port));
  error_message(reply);
  return 0;
}

variable_types:
reply
char []


decompiled_code:
int __fastcall grid_message(__int64 *a1)
{
__int64 *v1; // rbx
unsigned __int16 ****v2; // rbp
unsigned __int16 **v3; // rax
size_t v4; // rax
__int64 v5; // rbp
size_t v6; // rax
int result; // eax
char v8[1008]; // [rsp+0h] [rbp-7F8h] BYREF
char s[1032]; // [rsp+3F0h] [rbp-408h] BYREF

v8[0] = 0;
if ( !a1 )
return snprintf(s, 0x3E8uLL, "%s", v8);
v1 = a1;
v2 = (unsigned __int16 ****)a1;
do
{
v3 = **v2;
snprintf(s, 0x28uLL, "#%hu,%hu,%hu,%hu,%hu$\n", *v3[3], *v3[4], **v3, *v3[1], *v3[2]);
v4 = strlen(v8);
strcpy(&v8[v4], s);
v2 = (unsigned __int16 ****)v2[1];
}
while ( v2 );
snprintf(s, 0x3E8uLL, "%s", v8);
do
{
v5 = *v1;
v6 = strlen(s);
result = sendto(**(_DWORD **)(v5 + 32), s, v6, 0, *(const struct sockaddr **)(v5 + 8), 0x10u);
v1 = (__int64 *)v1[1];
}
while ( v1 );
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 *a1)
{
__int64 *v1; // rbx
unsigned __int16 ****v2; // rbp
unsigned __int16 **v3; // rax
size_t v4; // rax
__int64 v5; // rbp
size_t v6; // rax
int result; // eax
char v8[1008]; // [rsp+0h] [rbp-7F8h] BYREF
char s[1032]; // [rsp+3F0h] [rbp-408h] BYREF

v8[0] = 0;
if ( !a1 )
return snprintf(s, 0x3E8uLL, "%s", v8);
v1 = a1;
v2 = (unsigned __int16 ****)a1;
do
{
v3 = **v2;
snprintf(s, 0x28uLL, "#%hu,%hu,%hu,%hu,%hu$\n", *v3[3], *v3[4], **v3, *v3[1], *v3[2]);
v4 = strlen(v8);
strcpy(&v8[v4], s);
v2 = (unsigned __int16 ****)v2[1];
}
while ( v2 );
snprintf(s, 0x3E8uLL, "%s", v8);
do
{
v5 = *v1;
v6 = strlen(s);
result = sendto(**(_DWORD **)(v5 + 32), s, v6, 0, *(const struct sockaddr **)(v5 + 8), 0x10u);
v1 = (__int64 *)v1[1];
}
while ( v1 );
return result;
}

original_code:
void grid_message(list *players) {
  unsigned short x, y, r, g, b;
  list *p = players;
  char temp[1000];
  char str_ptr[1000];
  strcpy(temp, "");
  while (p != ((void *)0)) {
    x = *p->player->pixel->x;
    y = *p->player->pixel->y;
    r = *p->player->pixel->red;
    g = *p->player->pixel->green;
    b = *p->player->pixel->blue;
    snprintf(str_ptr, 40, "#%hu,%hu,%hu,%hu,%hu$\n", x, y, r, g, b);
    strcat(temp, str_ptr);
    p = p->next;
  }
  snprintf(str_ptr, 1000, "%s", temp);
  p = players;
  while (p != ((void *)0)) {
    sendto(*p->player->socket, str_ptr, strlen(str_ptr), 0, (struct sockaddr *) p->player->clientaddr, sizeof(*p->player->clientaddr));
    p = p->next;
  }
}

canonical_original_code:
void grid_message(struct list *players) {
  unsigned short x; unsigned short y; unsigned short r; unsigned short g; unsigned short b;
  struct list *p = players;
  char temp[1000];
  char str_ptr[1000];
  strcpy(temp, "");
  while (p != ((void *)0)) {
    x = *p->player->pixel->x;
    y = *p->player->pixel->y;
    r = *p->player->pixel->red;
    g = *p->player->pixel->green;
    b = *p->player->pixel->blue;
    snprintf(str_ptr, 40, "#%hu,%hu,%hu,%hu,%hu$\n", x, y, r, g, b);
    strcat(temp, str_ptr);
    p = p->next;
  }
  snprintf(str_ptr, 1000, "%s", temp);
  p = players;
  while (p != ((void *)0)) {
    sendto(*p->player->socket, str_ptr, strlen(str_ptr), 0, (struct sockaddr *) p->player->clientaddr, sizeof(*p->player->clientaddr));
    p = p->next;
  }
}

variable_types:
x
unsigned short

variable_types:
y
unsigned short

variable_types:
r
unsigned short

variable_types:
g
unsigned short

variable_types:
b
unsigned short

variable_types:
temp
char [1000]


decompiled_code:
void __noreturn loop_ping_clients()
{
while ( 1 )
{
sleep(0xFu);
puts("Sending out pings...");
ping_clients((_QWORD *)*client_list);
}
}

canonical_decompiled_code:
void __noreturn func2()
{
while ( 1 )
{
sleep(0xFu);
puts("Sending out pings...");
func0((_QWORD *)*client_list);
}
}

original_code:
void *loop_ping_clients(void *arg) {
  while (1) {
    sleep(15);
    printf("Sending out pings...\n");
    ping_clients(*client_list);
  }
}


decompiled_code:
int send_updates()
{
return grid_message((__int64 *)*client_list);
}

canonical_decompiled_code:
int func3()
{
return func1((__int64 *)*client_list);
}

original_code:
void send_updates(void) {
  grid_message(*client_list);
}

canonical_original_code:
void send_updates() {
  grid_message(*client_list);
}


decompiled_code:
void __fastcall free_pixel(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(ptr);
}

original_code:
void free_pixel(struct pixel_struct *pixel) {
  free(pixel->red);
  free(pixel->green);
  free(pixel->blue);
  free(pixel->x);
  free(pixel->y);
  free(pixel);
}

variable_types: struct pixel_struct { unsigned short *red; unsigned short *green; unsigned short *blue; unsigned short *x; unsigned short *y; } *


decompiled_code:
void __fastcall free_player(void *ptr)
{
free_pixel(*(void **)ptr);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
func0(*(void **)ptr);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(ptr);
}

original_code:
void free_player(player_struct *player) {
  free_pixel(player->pixel);
  free(player->clientaddr);
  free(player->clientaddr_len);
  free(player->last_pong);
  free(player->socket);
  free(player);
}

canonical_original_code:
void free_player(struct player_struct *player) {
  free_pixel(player->pixel);
  free(player->clientaddr);
  free(player->clientaddr_len);
  free(player->last_pong);
  free(player->socket);
  free(player);
}

variable_types: struct player_struct { struct pixel_struct { unsigned short *red; unsigned short *green; unsigned short *blue; unsigned short *x; unsigned short *y; } *pixel; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *clientaddr; unsigned int *clientaddr_len; long *last_pong; int *socket; } *


decompiled_code:
void *__fastcall initialize_pixel(void **a1)
{
void *result; // rax

*a1 = malloc(2uLL);
a1[1] = malloc(2uLL);
a1[2] = malloc(2uLL);
a1[3] = malloc(2uLL);
result = malloc(2uLL);
a1[4] = result;
return result;
}

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

*a1 = malloc(2uLL);
a1[1] = malloc(2uLL);
a1[2] = malloc(2uLL);
a1[3] = malloc(2uLL);
result = malloc(2uLL);
a1[4] = result;
return result;
}

original_code:
void initialize_pixel(struct pixel_struct *pixel) {
  pixel->red = malloc(sizeof(unsigned short));
  pixel->green = malloc(sizeof(unsigned short));
  pixel->blue = malloc(sizeof(unsigned short));
  pixel->x = malloc(sizeof(unsigned short));
  pixel->y = malloc(sizeof(unsigned short));
}


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

result = 2642LL;
strcpy(a1, "ERROR\n");
return result;
}

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

result = 2642LL;
strcpy(a1, "ERROR\n");
return result;
}

original_code:
void error_message(char *str_ptr) {
  snprintf(str_ptr, 40, "ERROR\n");
}


decompiled_code:
__int64 __fastcall move_message(char a1, char *a2)
{
__int64 result; // rax

if ( a1 == 83 )
{
*(__m128i *)a2 = _mm_load_si128((const __m128i *)&LC1);
}
else if ( a1 > 83 )
{
if ( a1 == 87 )
{
strcpy(a2, "ACK MOVE WEST\n");
result = 2644LL;
}
}
else if ( a1 == 69 )
{
result = 0x45564F4D204B4341LL;
strcpy(a2, "ACK MOVE EAST\n");
}
else if ( a1 == 78 )
{
*(__m128i *)a2 = _mm_load_si128((const __m128i *)&LC0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1, char *a2)
{
__int64 result; // rax

if ( a1 == 83 )
{
*(__m128i *)a2 = _mm_load_si128((const __m128i *)&LC1);
}
else if ( a1 > 83 )
{
if ( a1 == 87 )
{
strcpy(a2, "ACK MOVE WEST\n");
result = 2644LL;
}
}
else if ( a1 == 69 )
{
result = 0x45564F4D204B4341LL;
strcpy(a2, "ACK MOVE EAST\n");
}
else if ( a1 == 78 )
{
*(__m128i *)a2 = _mm_load_si128((const __m128i *)&LC0);
}
return result;
}

original_code:
void move_message(char direction, char *str_ptr) {
  switch (direction) {
    case 'N':
      snprintf(str_ptr, 40, "ACK MOVE NORTH\n");
      break;
    case 'S':
      snprintf(str_ptr, 40, "ACK MOVE SOUTH\n");
      break;
    case 'E':
      snprintf(str_ptr, 40, "ACK MOVE EAST\n");
      break;
    case 'W':
      snprintf(str_ptr, 40, "ACK MOVE WEST\n");
      break;
  }
}

variable_types: direction char


decompiled_code:
__int64 __fastcall pong_message(char *a1)
{
strcpy(a1, "PONG ACK\n");
return 10LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1)
{
strcpy(a1, "PONG ACK\n");
return 10LL;
}

original_code:
void pong_message(char *str_ptr) {
  snprintf(str_ptr, 40, "PONG ACK\n");
}


decompiled_code:
int __fastcall removal_message(unsigned __int16 ***a1, char *a2)
{
return snprintf(
a2,
0x28uLL,
"REMOVING: x:%hu,y:%hu,r:%hu,g:%hu,b:%hu\n",
*(*a1)[3],
*(*a1)[4],
***a1,
*(*a1)[1],
*(*a1)[2]);
}

original_code:
void removal_message(player_struct *player, char *str_ptr) {
  unsigned short x, y, r, g, b;
  x = *player->pixel->x;
  y = *player->pixel->y;
  r = *player->pixel->red;
  g = *player->pixel->green;
  b = *player->pixel->blue;
  snprintf(str_ptr, 40, "REMOVING: x:%hu,y:%hu,r:%hu,g:%hu,b:%hu\n", x, y, r, g, b);
  return ;
}

canonical_original_code:
void removal_message(struct player_struct *player, char *str_ptr) {
  unsigned short x; unsigned short y; unsigned short r; unsigned short g; unsigned short b;
  x = *player->pixel->x;
  y = *player->pixel->y;
  r = *player->pixel->red;
  g = *player->pixel->green;
  b = *player->pixel->blue;
  snprintf(str_ptr, 40, "REMOVING: x:%hu,y:%hu,r:%hu,g:%hu,b:%hu\n", x, y, r, g, b);
  return ;
}


decompiled_code:
int __fastcall welcome_message(unsigned __int16 ***a1, char *a2)
{
return snprintf(
a2,
0x28uLL,
"WELCOME: x:%hu,y:%hu,r:%hu,g:%hu,b:%hu\n",
*(*a1)[3],
*(*a1)[4],
***a1,
*(*a1)[1],
*(*a1)[2]);
}

original_code:
void welcome_message(player_struct *player, char *str_ptr) {
  unsigned short x, y, r, g, b;
  x = *player->pixel->x;
  y = *player->pixel->y;
  r = *player->pixel->red;
  g = *player->pixel->green;
  b = *player->pixel->blue;
  snprintf(str_ptr, 40, "WELCOME: x:%hu,y:%hu,r:%hu,g:%hu,b:%hu\n", x, y, r, g, b);
  return ;
}

canonical_original_code:
void welcome_message(struct player_struct *player, char *str_ptr) {
  unsigned short x; unsigned short y; unsigned short r; unsigned short g; unsigned short b;
  x = *player->pixel->x;
  y = *player->pixel->y;
  r = *player->pixel->red;
  g = *player->pixel->green;
  b = *player->pixel->blue;
  snprintf(str_ptr, 40, "WELCOME: x:%hu,y:%hu,r:%hu,g:%hu,b:%hu\n", x, y, r, g, b);
  return ;
}


decompiled_code:
void __fastcall delete_list(_QWORD **a1, __int64 a2)
{
_QWORD *v2; // rax
__int64 v3; // r8
_QWORD *v4; // rbp
__int64 v5; // rax
_QWORD *v6; // rdx
__int64 v7; // rcx

v2 = search_list(*a1, a2);
if ( v2 )
{
v4 = v2;
v5 = predecessor_list(v3, a2);
v7 = v4[1];
if ( v5 )
*(_QWORD *)(v5 + 8) = v7;
else
*v6 = v7;
free_player(*v4);
free(v4);
}
}

canonical_decompiled_code:
void __fastcall func1(_QWORD **a1, __int64 a2)
{
_QWORD *v2; // rax
__int64 v3; // r8
_QWORD *v4; // rbp
__int64 v5; // rax
_QWORD *v6; // rdx
__int64 v7; // rcx

v2 = search_list(*a1, a2);
if ( v2 )
{
v4 = v2;
v5 = func0(v3, a2);
v7 = v4[1];
if ( v5 )
*(_QWORD *)(v5 + 8) = v7;
else
*v6 = v7;
free_player(*v4);
free(v4);
}
}

original_code:
void delete_list(list **l, player_struct *x) {
  list *p, *pred;
  list *search_list(), *predecessor_list();
  p = search_list(*l, x);
  if (p != ((void *)0)) {
    pred = predecessor_list(*l, x);
    if (pred == ((void *)0))
      *l = p->next;
    else
      pred->next = p->next;
    free_player(p->player);
    free(p);
  }
}

canonical_original_code:
void delete_list(struct list **l, struct player_struct *x) {
  struct list *p; struct list *pred;
  struct list *search_list(); struct list *predecessor_list();
  p = search_list(*l, x);
  if (p != ((void *)0)) {
    pred = predecessor_list(*l, x);
    if (pred == ((void *)0))
      *l = p->next;
    else
      pred->next = p->next;
    free_player(p->player);
    free(p);
  }
}

variable_types: struct list { struct player_struct { struct pixel_struct { unsigned short *red; unsigned short *green; unsigned short *blue; unsigned short *x; unsigned short *y; } *pixel; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *clientaddr; unsigned int *clientaddr_len; long *last_pong; int *socket; } *player; struct list *next; } **

variable_types:
x
struct player_struct *

variable_types: struct list { struct player_struct { struct pixel_struct { unsigned short *red; unsigned short *green; unsigned short *blue; unsigned short *x; unsigned short *y; } *pixel; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *clientaddr; unsigned int *clientaddr_len; long *last_pong; int *socket; } *player; struct list *next; } *()


writeEdgeDeletedPlanarCodeChar

repo: nvcleemp/graphtools

decompiled_code:
int writeEdgeDeletedPlanarCodeChar()
{
int result; // eax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx

fputc(nv, stdout);
result = nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
v2 = firstedge[v1];
v3 = v2;
do
{
while ( *(_DWORD *)(v3 + 40) >= markvalue )
{
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_7;
}
fputc(*(_DWORD *)(v3 + 4) + 1, stdout);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_7:
++v1;
result = fputc(0, stdout);
}
while ( nv > (int)v1 );
}
return result;
}

canonical_decompiled_code:
int func7()
{
int result; // eax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx

fputc(nv, stdout);
result = nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
v2 = firstedge[v1];
v3 = v2;
do
{
while ( *(_DWORD *)(v3 + 40) >= markvalue )
{
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_7;
}
fputc(*(_DWORD *)(v3 + 4) + 1, stdout);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_7:
++v1;
result = fputc(0, stdout);
}
while ( nv > (int)v1 );
}
return result;
}

original_code:
void writeEdgeDeletedPlanarCodeChar(){
    int i;
    EDGE *e, *elast;
    fputc(nv, stdout);
    for(i=0; i<nv; i++){
        e = elast = firstedge[i];
        do {
            if(!((e)->mark >= markvalue)){
                fputc(e->end + 1, stdout);
            }
            e = e->next;
        } while (e != elast);
        fputc(0, stdout);
    }
}

canonical_original_code:
void writeEdgeDeletedPlanarCodeChar(){
    int i;
    struct e *e; struct e *elast;
    fputc(nv, stdout);
    for(i=0; i<nv; i++){
        e = elast = firstedge[i];
        do {
            if(!((e)->mark >= markvalue)){
                fputc(e->end + 1, stdout);
            }
            e = e->next;
        } while (e != elast);
        fputc(0, stdout);
    }
}

variable_types: i int

variable_types: struct e { int start; int end; int rightface; struct e *prev; struct e *next; struct e *inverse; int mark; } *


writeShort

decompiled_code:
size_t __fastcall writeShort(__int16 a1)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, stdout);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func8(__int16 a1)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, stdout);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}

original_code:
void writeShort(unsigned short value){
    if (fwrite(&value, sizeof (unsigned short), 1, stdout) != 1) {
        fprintf(stderr, "fwrite() failed -- exiting!\n");
        exit(-1);
    }
}

variable_types:
value
unsigned short


writeEdgeDeletedPlanarCodeShort

decompiled_code:
size_t writeEdgeDeletedPlanarCodeShort()
{
size_t result; // rax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx

fputc(0, stdout);
writeShort(nv);
result = (unsigned int)nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
v2 = firstedge[v1];
v3 = v2;
do
{
while ( *(_DWORD *)(v3 + 40) >= markvalue )
{
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_7;
}
writeShort(*(_WORD *)(v3 + 4) + 1);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_7:
++v1;
result = writeShort(0);
}
while ( nv > (int)v1 );
}
return result;
}

canonical_decompiled_code:
size_t func9()
{
size_t result; // rax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx

fputc(0, stdout);
func8(nv);
result = (unsigned int)nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
v2 = firstedge[v1];
v3 = v2;
do
{
while ( *(_DWORD *)(v3 + 40) >= markvalue )
{
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_7;
}
func8(*(_WORD *)(v3 + 4) + 1);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_7:
++v1;
result = func8(0);
}
while ( nv > (int)v1 );
}
return result;
}

original_code:
void writeEdgeDeletedPlanarCodeShort(){
    int i;
    EDGE *e, *elast;
    fputc(0, stdout);
    writeShort(nv);
    for(i=0; i<nv; i++){
        e = elast = firstedge[i];
        do {
            if(!((e)->mark >= markvalue)){
                writeShort(e->end + 1);
            }
            e = e->next;
        } while (e != elast);
        writeShort(0);
    }
}

canonical_original_code:
void writeEdgeDeletedPlanarCodeShort(){
    int i;
    struct e *e; struct e *elast;
    fputc(0, stdout);
    writeShort(nv);
    for(i=0; i<nv; i++){
        e = elast = firstedge[i];
        do {
            if(!((e)->mark >= markvalue)){
                writeShort(e->end + 1);
            }
            e = e->next;
        } while (e != elast);
        writeShort(0);
    }
}

user_defined_types: struct e { int start; int end; int rightface; struct e *prev; struct e *next; struct e *inverse; int mark; }


writeEdgeDeletedPlanarCode

decompiled_code:
int writeEdgeDeletedPlanarCode()
{
int v0; // eax

if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
v0 = nv;
if ( nv > 254 )
goto LABEL_3;
return writeEdgeDeletedPlanarCodeChar();
}
v0 = nv;
if ( nv <= 254 )
return writeEdgeDeletedPlanarCodeChar();
LABEL_3:
if ( v0 > 65534 )
{
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return writeEdgeDeletedPlanarCodeShort();
}

canonical_decompiled_code:
int func10()
{
int v0; // eax

if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
v0 = nv;
if ( nv > 254 )
goto LABEL_3;
return func7();
}
v0 = nv;
if ( nv <= 254 )
return func7();
LABEL_3:
if ( v0 > 65534 )
{
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return func9();
}

original_code:
void writeEdgeDeletedPlanarCode(){
    static int first = 1;
    if(first){
        first = 0;
        fprintf(stdout, ">>planar_code<<");
    }
    if (nv + 1 <= 255) {
        writeEdgeDeletedPlanarCodeChar();
    } else if (nv + 1 <= 65535) {
        writeEdgeDeletedPlanarCodeShort();
    } else {
        fprintf(stderr, "Graphs of that size are currently not supported -- exiting!\n");
        exit(-1);
    }
}

variable_types: first int


writeSubdividedPlanarCodeChar

decompiled_code:
int writeSubdividedPlanarCodeChar()
{
__int64 v0; // r12
__int64 v1; // rbp
__int64 v2; // rbx
int result; // eax
__int64 v4; // r12
__int64 v5; // rbp
__int64 v6; // rbx

fputc(nv + nf, stdout);
if ( nv > 0 )
{
v0 = 0LL;
do
{
v1 = firstedge[v0];
v2 = v1;
do
{
fputc(*(_DWORD *)(v2 + 4) + 1, stdout);
fputc(*(_DWORD *)(v2 + 8) + nv + 1, stdout);
v2 = *(_QWORD *)(v2 + 24);
}
while ( v1 != v2 );
++v0;
fputc(0, stdout);
}
while ( nv > (int)v0 );
}
result = nf;
if ( nf > 0 )
{
v4 = 0LL;
do
{
v5 = facestart[v4];
v6 = v5;
do
{
fputc(*(_DWORD *)v6 + 1, stdout);
v6 = *(_QWORD *)(*(_QWORD *)(v6 + 32) + 16LL);
}
while ( v5 != v6 );
++v4;
result = fputc(0, stdout);
}
while ( nf > (int)v4 );
}
return result;
}

canonical_decompiled_code:
int func7()
{
__int64 v0; // r12
__int64 v1; // rbp
__int64 v2; // rbx
int result; // eax
__int64 v4; // r12
__int64 v5; // rbp
__int64 v6; // rbx

fputc(nv + nf, stdout);
if ( nv > 0 )
{
v0 = 0LL;
do
{
v1 = firstedge[v0];
v2 = v1;
do
{
fputc(*(_DWORD *)(v2 + 4) + 1, stdout);
fputc(*(_DWORD *)(v2 + 8) + nv + 1, stdout);
v2 = *(_QWORD *)(v2 + 24);
}
while ( v1 != v2 );
++v0;
fputc(0, stdout);
}
while ( nv > (int)v0 );
}
result = nf;
if ( nf > 0 )
{
v4 = 0LL;
do
{
v5 = facestart[v4];
v6 = v5;
do
{
fputc(*(_DWORD *)v6 + 1, stdout);
v6 = *(_QWORD *)(*(_QWORD *)(v6 + 32) + 16LL);
}
while ( v5 != v6 );
++v4;
result = fputc(0, stdout);
}
while ( nf > (int)v4 );
}
return result;
}

original_code:
void writeSubdividedPlanarCodeChar(){
    int i;
    EDGE *e, *elast;
    fputc(nv + nf, stdout);
    for(i=0; i<nv; i++){
        e = elast = firstedge[i];
        do {
            fputc(e->end + 1, stdout);
            fputc(nv + e->rightface + 1, stdout);
            e = e->next;
        } while (e != elast);
        fputc(0, stdout);
    }
    for(i=0; i<nf; i++){
        e = elast = facestart[i];
        do {
            fputc(e->start + 1, stdout);
            e = e->inverse->prev;
        } while (e != elast);
        fputc(0, stdout);
    }
}

canonical_original_code:
void writeSubdividedPlanarCodeChar(){
    int i;
    struct e *e; struct e *elast;
    fputc(nv + nf, stdout);
    for(i=0; i<nv; i++){
        e = elast = firstedge[i];
        do {
            fputc(e->end + 1, stdout);
            fputc(nv + e->rightface + 1, stdout);
            e = e->next;
        } while (e != elast);
        fputc(0, stdout);
    }
    for(i=0; i<nf; i++){
        e = elast = facestart[i];
        do {
            fputc(e->start + 1, stdout);
            e = e->inverse->prev;
        } while (e != elast);
        fputc(0, stdout);
    }
}


writeSubdividedPlanarCodeShort

decompiled_code:
void __noreturn writeSubdividedPlanarCodeShort()
{
fwrite("Graphs of this size are not yet supported\n", 1uLL, 0x2AuLL, stderr);
exit(-1);
}

canonical_decompiled_code:
void __noreturn func8()
{
fwrite("Graphs of this size are not yet supported\n", 1uLL, 0x2AuLL, stderr);
exit(-1);
}

original_code:
void writeSubdividedPlanarCodeShort(){
    fprintf(stderr, "Graphs of this size are not yet supported\n");
    exit(-1);
}


writeSubdividedPlanarCode

decompiled_code:
int writeSubdividedPlanarCode()
{
if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
}
if ( nv + nf > 254 )
{
if ( nv + nf <= 65534 )
writeSubdividedPlanarCodeShort();
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return writeSubdividedPlanarCodeChar();
}

canonical_decompiled_code:
int func9()
{
if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
}
if ( nv + nf > 254 )
{
if ( nv + nf <= 65534 )
func8();
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return func7();
}

original_code:
void writeSubdividedPlanarCode(){
    static int first = 1;
    if(first){
        first = 0;
        fprintf(stdout, ">>planar_code<<");
    }
    if (nv + nf + 1 <= 255) {
        writeSubdividedPlanarCodeChar();
    } else if (nv + nf + 1 <= 65535) {
        writeSubdividedPlanarCodeShort();
    } else {
        fprintf(stderr, "Graphs of that size are currently not supported -- exiting!\n");
        exit(-1);
    }
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r12
unsigned int v4; // eax
const char *v5; // rdi
int v6; // er12
char *v8; // rcx
const char *v9; // rdi
int longind; // [rsp+8h] [rbp-390h] BYREF
char ptr[904]; // [rsp+10h] [rbp-388h] BYREF

v3 = *argv;
longind = 0;
while ( 1 )
{
v4 = getopt_long(argc, (char *const *)argv, "h", &long_options_0, &longind);
if ( v4 == -1 )
break;
if ( v4 == 63 )
goto LABEL_7;
if ( v4 == 104 )
{
v9 = v3;
v6 = 0;
help(v9);
return v6;
}
if ( v4 )
{
fprintf(stderr, "Illegal option %c.\n", v4);
LABEL_7:
v5 = v3;
v6 = 1;
usage(v5);
return v6;
}
}
while ( 1 )
{
v6 = readPlanarCode(ptr);
if ( !v6 )
break;
decodePlanarCode(ptr);
writeSubdividedPlanarCode();
++numberOfGraphs;
}
v8 = "";
if ( numberOfGraphs != 1 )
v8 = "s";
fprintf(stderr, "Output subdivision of %d graph%s.\n", (unsigned int)numberOfGraphs, v8);
return v6;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r12
unsigned int v4; // eax
const char *v5; // rdi
int v6; // er12
char *v8; // rcx
const char *v9; // rdi
int longind; // [rsp+8h] [rbp-390h] BYREF
char ptr[904]; // [rsp+10h] [rbp-388h] BYREF

v3 = *argv;
longind = 0;
while ( 1 )
{
v4 = getopt_long(argc, (char *const *)argv, "h", &long_options_0, &longind);
if ( v4 == -1 )
break;
if ( v4 == 63 )
goto LABEL_7;
if ( v4 == 104 )
{
v9 = v3;
v6 = 0;
func14(v9);
return v6;
}
if ( v4 )
{
fprintf(stderr, "Illegal option %c.\n", v4);
LABEL_7:
v5 = v3;
v6 = 1;
func15(v5);
return v6;
}
}
while ( 1 )
{
v6 = func13(ptr);
if ( !v6 )
break;
func12(ptr);
func9();
++numberOfGraphs;
}
v8 = "";
if ( numberOfGraphs != 1 )
v8 = "s";
fprintf(stderr, "Output subdivision of %d graph%s.\n", (unsigned int)numberOfGraphs, v8);
return v6;
}

original_code:
int main(int argc, char *argv[]) {
    int c;
    char *name = argv[0];
    static struct option long_options[] = {
        {"help", 0, ((void *)0), 'h'}
    };
    int option_index = 0;
    while ((c = getopt_long(argc, argv, "h", long_options, &option_index)) != -1) {
        switch (c) {
            case 0:
                break;
            case 'h':
                help(name);
                return 0;
            case '?':
                usage(name);
                return 1;
            default:
                fprintf(stderr, "Illegal option %c.\n", c);
                usage(name);
                return 1;
        }
    }
    unsigned short code[(64 +(6*64 -12)+3)];
    int length;
    while (readPlanarCode(code, &length, stdin)) {
        decodePlanarCode(code);
        writeSubdividedPlanarCode();
        numberOfGraphs++;
    }
    fprintf(stderr, "Output subdivision of %d graph%s.\n", numberOfGraphs,
                numberOfGraphs==1 ? "" : "s");
}

canonical_original_code:
int main(int argc, char *argv[]) {
    int c;
    char *name = argv[0];
    static struct option long_options[] = {
        {"help", 0, ((void *)0), 'h'}
    };
    int option_index = 0;
    while ((c = getopt_long(argc, argv, "h", long_options, &option_index)) != -1) {
        switch (c) {
            case 0:
                break;
            case 'h':
                help(name);
                return 0;
            case '?':
                usage(name);
                return 1;
            default:
                fprintf(stderr, "Illegal option %c.\n", c);
                usage(name);
                return 1;
        }
    }
    unsigned short code[-1];
    int length;
    while (readPlanarCode(code, &length, stdin)) {
        decodePlanarCode(code);
        writeSubdividedPlanarCode();
        numberOfGraphs++;
    }
    fprintf(stderr, "Output subdivision of %d graph%s.\n", numberOfGraphs,
                numberOfGraphs==1 ? "" : "s");
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: c int

variable_types:
name
char *

variable_types: struct option { char *name; int has_arg; int *flag; int val; } []

variable_types:
code
unsigned short [-1]

variable_types: length int


findEdge

decompiled_code:
__int64 __fastcall findEdge(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

result = firstedge[a1];
while ( *(_DWORD *)(result + 4) != a2 )
{
result = *(_QWORD *)(result + 24);
if ( firstedge[a1] == result )
{
fprintf(stderr, "error while looking for edge from %d to %d.\n", a1, a2);
exit(0);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

result = firstedge[a1];
while ( *(_DWORD *)(result + 4) != a2 )
{
result = *(_QWORD *)(result + 24);
if ( firstedge[a1] == result )
{
fprintf(stderr, "error while looking for edge from %d to %d.\n", a1, a2);
exit(0);
}
}
return result;
}

original_code:
EDGE *findEdge(int from, int to) {
    EDGE *e, *elast;
    e = elast = firstedge[from];
    do {
        if (e->end == to) {
            return e;
        }
        e = e->next;
    } while (e != elast);
    fprintf(stderr, "error while looking for edge from %d to %d.\n", from, to);
    exit(0);
}

canonical_original_code:
struct e *findEdge(int from, int to) {
    struct e *e; struct e *elast;
    e = elast = firstedge[from];
    do {
        if (e->end == to) {
            return e;
        }
        e = e->next;
    } while (e != elast);
    fprintf(stderr, "error while looking for edge from %d to %d.\n", from, to);
    exit(0);
}

variable_types: from int

variable_types: to int

return_type: struct e { int start; int end; int rightface; struct e *prev; struct e *next; struct e *inverse; int mark; } *


makeDual

decompiled_code:
__int64 makeDual()
{
__int64 result; // rax
__int64 v1; // r11
int v2; // edi
__int64 v3; // r10
int v4; // esi
__int64 v5; // r9
__int64 v6; // rdx
__int64 v7; // rax
int v8; // ecx

result = (unsigned int)(markvalue + 2);
if ( (int)result > 30000 )
{
markvalue = 2;
result = (__int64)&unk_404148;
do
{
*(_DWORD *)result = 0;
result += 48LL;
}
while ( (_UNKNOWN *)result != &unk_408708 );
}
else
{
markvalue += 2;
}
v1 = nv;
nf = 0;
if ( nv > 0 )
{
v2 = markvalue;
v3 = 0LL;
result = 0LL;
v4 = 0;
do
{
v5 = firstedge[v3];
v6 = v5;
do
{
while ( *(_DWORD *)(v6 + 40) == v2 )
{
v6 = *(_QWORD *)(v6 + 24);
if ( v5 == v6 )
goto LABEL_11;
}
v7 = v6;
v8 = 0;
facestart[v4] = v6;
do
{
*(_DWORD *)(v7 + 8) = v4;
++v8;
*(_DWORD *)(v7 + 40) = v2;
v7 = *(_QWORD *)(*(_QWORD *)(v7 + 32) + 16LL);
}
while ( v6 != v7 );
v6 = *(_QWORD *)(v6 + 24);
faceSize[v4++] = v8;
result = 1LL;
}
while ( v5 != v6 );
LABEL_11:
++v3;
}
while ( v1 != v3 );
if ( (_BYTE)result )
nf = v4;
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 result; // rax
__int64 v1; // r11
int v2; // edi
__int64 v3; // r10
int v4; // esi
__int64 v5; // r9
__int64 v6; // rdx
__int64 v7; // rax
int v8; // ecx

result = (unsigned int)(markvalue + 2);
if ( (int)result > 30000 )
{
markvalue = 2;
result = (__int64)&unk_404148;
do
{
*(_DWORD *)result = 0;
result += 48LL;
}
while ( (_UNKNOWN *)result != &unk_408708 );
}
else
{
markvalue += 2;
}
v1 = nv;
nf = 0;
if ( nv > 0 )
{
v2 = markvalue;
v3 = 0LL;
result = 0LL;
v4 = 0;
do
{
v5 = firstedge[v3];
v6 = v5;
do
{
while ( *(_DWORD *)(v6 + 40) == v2 )
{
v6 = *(_QWORD *)(v6 + 24);
if ( v5 == v6 )
goto LABEL_11;
}
v7 = v6;
v8 = 0;
facestart[v4] = v6;
do
{
*(_DWORD *)(v7 + 8) = v4;
++v8;
*(_DWORD *)(v7 + 40) = v2;
v7 = *(_QWORD *)(*(_QWORD *)(v7 + 32) + 16LL);
}
while ( v6 != v7 );
v6 = *(_QWORD *)(v6 + 24);
faceSize[v4++] = v8;
result = 1LL;
}
while ( v5 != v6 );
LABEL_11:
++v3;
}
while ( v1 != v3 );
if ( (_BYTE)result )
nf = v4;
}
return result;
}

original_code:
void makeDual() {
    register int i, sz;
    register EDGE *e, *ex, *ef, *efx;
    {int mki; if ((markvalue += 2) > 30000) { markvalue = 2; for (mki=0;mki<(6*64 -12);++mki) edges[mki].mark=0;}};
    nf = 0;
    for (i = 0; i < nv; ++i) {
        e = ex = firstedge[i];
        do {
            if (!((e)->mark == markvalue)) {
                facestart[nf] = ef = efx = e;
                sz = 0;
                do {
                    ef->rightface = nf;
                    (ef)->mark = markvalue;
                    ef = ef->inverse->prev;
                    ++sz;
                } while (ef != efx);
                faceSize[nf] = sz;
                ++nf;
            }
            e = e->next;
        } while (e != ex);
    }
}

canonical_original_code:
void makeDual() {
    register int i; register int sz;
    register struct e *e; register struct e *ex; register struct e *ef; register struct e *efx;
    {int mki; if ((markvalue += 2) > 30000) { markvalue = 2; for (mki=0;mki<(6*64 -12);++mki) edges[mki].mark=0;}};
    nf = 0;
    for (i = 0; i < nv; ++i) {
        e = ex = firstedge[i];
        do {
            if (!((e)->mark == markvalue)) {
                facestart[nf] = ef = efx = e;
                sz = 0;
                do {
                    ef->rightface = nf;
                    (ef)->mark = markvalue;
                    ef = ef->inverse->prev;
                    ++sz;
                } while (ef != efx);
                faceSize[nf] = sz;
                ++nf;
            }
            e = e->next;
        } while (e != ex);
    }
}

variable_types: sz int

variable_types: mki int


decodePlanarCode

original_code:
void decodePlanarCode(unsigned short* code) {
    int i, j, codePosition;
    int edgeCounter = 0;
    EDGE *inverse;
    nv = code[0];
    codePosition = 1;
    for (i = 0; i < nv; i++) {
        degree[i] = 0;
        firstedge[i] = edges + edgeCounter;
        edges[edgeCounter].start = i;
        edges[edgeCounter].end = code[codePosition] - 1;
        edges[edgeCounter].next = edges + edgeCounter + 1;
        if (code[codePosition] - 1 < i) {
            inverse = findEdge(code[codePosition] - 1, i);
            edges[edgeCounter].inverse = inverse;
            inverse->inverse = edges + edgeCounter;
        } else {
            edges[edgeCounter].inverse = ((void *)0);
        }
        edgeCounter++;
        codePosition++;
        for (j = 1; code[codePosition]; j++, codePosition++) {
            if (j == (64 -1)) {
                fprintf(stderr, "MAXVAL too small: %d\n", (64 -1));
                exit(0);
            }
            edges[edgeCounter].start = i;
            edges[edgeCounter].end = code[codePosition] - 1;
            edges[edgeCounter].prev = edges + edgeCounter - 1;
            edges[edgeCounter].next = edges + edgeCounter + 1;
            if (code[codePosition] - 1 < i) {
                inverse = findEdge(code[codePosition] - 1, i);
                edges[edgeCounter].inverse = inverse;
                inverse->inverse = edges + edgeCounter;
            } else {
                edges[edgeCounter].inverse = ((void *)0);
            }
            edgeCounter++;
        }
        firstedge[i]->prev = edges + edgeCounter - 1;
        edges[edgeCounter - 1].next = firstedge[i];
        degree[i] = j;
        codePosition++;
    }
    ne = edgeCounter;
    makeDual();
}

canonical_original_code:
void decodePlanarCode(unsigned short *code) {
    int i; int j; int codePosition;
    int edgeCounter = 0;
    struct e *inverse;
    nv = code[0];
    codePosition = 1;
    for (i = 0; i < nv; i++) {
        degree[i] = 0;
        firstedge[i] = edges + edgeCounter;
        edges[edgeCounter].start = i;
        edges[edgeCounter].end = code[codePosition] - 1;
        edges[edgeCounter].next = edges + edgeCounter + 1;
        if (code[codePosition] - 1 < i) {
            inverse = findEdge(code[codePosition] - 1, i);
            edges[edgeCounter].inverse = inverse;
            inverse->inverse = edges + edgeCounter;
        } else {
            edges[edgeCounter].inverse = ((void *)0);
        }
        edgeCounter++;
        codePosition++;
        for (j = 1; code[codePosition]; j++, codePosition++) {
            if (j == (64 -1)) {
                fprintf(stderr, "MAXVAL too small: %d\n", (64 -1));
                exit(0);
            }
            edges[edgeCounter].start = i;
            edges[edgeCounter].end = code[codePosition] - 1;
            edges[edgeCounter].prev = edges + edgeCounter - 1;
            edges[edgeCounter].next = edges + edgeCounter + 1;
            if (code[codePosition] - 1 < i) {
                inverse = findEdge(code[codePosition] - 1, i);
                edges[edgeCounter].inverse = inverse;
                inverse->inverse = edges + edgeCounter;
            } else {
                edges[edgeCounter].inverse = ((void *)0);
            }
            edgeCounter++;
        }
        firstedge[i]->prev = edges + edgeCounter - 1;
        edges[edgeCounter - 1].next = firstedge[i];
        degree[i] = j;
        codePosition++;
    }
    ne = edgeCounter;
    makeDual();
}

variable_types:
code
unsigned short *

variable_types: j int

variable_types: codePosition int

variable_types: edgeCounter int


help

decompiled_code:
size_t __fastcall help(const char *a1)
{
fprintf(stderr, "The program %s reads planar graphs from standard in and\n", a1);
fwrite("subdivides each face with one vertex.\n\n", 1uLL, 0x27uLL, stderr);
fwrite("Usage\n=====\n", 1uLL, 0xCuLL, stderr);
fprintf(stderr, " %s [options]\n\n", a1);
fprintf(stderr, "\nThis program can handle graphs up to %d vertices. Recompile if you need larger\n", 64LL);
fwrite("graphs.\n\n", 1uLL, 9uLL, stderr);
fwrite("Valid options\n=============\n", 1uLL, 0x1CuLL, stderr);
fwrite(" -h, --help\n", 1uLL, 0xFuLL, stderr);
return fwrite(" Print this help and return.\n", 1uLL, 0x23uLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func14(const char *a1)
{
fprintf(stderr, "The program %s reads planar graphs from standard in and\n", a1);
fwrite("subdivides each face with one vertex.\n\n", 1uLL, 0x27uLL, stderr);
fwrite("Usage\n=====\n", 1uLL, 0xCuLL, stderr);
fprintf(stderr, " %s [options]\n\n", a1);
fprintf(stderr, "\nThis program can handle graphs up to %d vertices. Recompile if you need larger\n", 64LL);
fwrite("graphs.\n\n", 1uLL, 9uLL, stderr);
fwrite("Valid options\n=============\n", 1uLL, 0x1CuLL, stderr);
fwrite(" -h, --help\n", 1uLL, 0xFuLL, stderr);
return fwrite(" Print this help and return.\n", 1uLL, 0x23uLL, stderr);
}

original_code:
void help(char *name) {
    fprintf(stderr, "The program %s reads planar graphs from standard in and\n", name);
    fprintf(stderr, "subdivides each face with one vertex.\n\n");
    fprintf(stderr, "Usage\n=====\n");
    fprintf(stderr, " %s [options]\n\n", name);
    fprintf(stderr, "\nThis program can handle graphs up to %d vertices. Recompile if you need larger\n", 64);
    fprintf(stderr, "graphs.\n\n");
    fprintf(stderr, "Valid options\n=============\n");
    fprintf(stderr, "    -h, --help\n");
    fprintf(stderr, "       Print this help and return.\n");
}


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
fprintf(stderr, "Usage: %s [options]\n", a1);
return fprintf(stderr, "For more information type: %s -h \n\n", a1);
}

canonical_decompiled_code:
int __fastcall func15(const char *a1)
{
fprintf(stderr, "Usage: %s [options]\n", a1);
return fprintf(stderr, "For more information type: %s -h \n\n", a1);
}

original_code:
void usage(char *name) {
    fprintf(stderr, "Usage: %s [options]\n", name);
    fprintf(stderr, "For more information type: %s -h \n\n", name);
}


writeVertexDeletedPlanarCodeChar

decompiled_code:
int writeVertexDeletedPlanarCodeChar()
{
int result; // eax
__int64 v1; // rbp
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // rax

result = fputc(newNv, stdout);
if ( nv > 0 )
{
v1 = 0LL;
do
{
while ( deleted[v1] )
{
if ( nv <= (int)++v1 )
return result;
}
v2 = firstedge[v1];
v3 = v2;
do
{
while ( 1 )
{
v4 = *(int *)(v3 + 4);
if ( !deleted[v4] )
break;
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_9;
}
fputc(newLabels[v4] + 1, stdout);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_9:
++v1;
result = fputc(0, stdout);
}
while ( nv > (int)v1 );
}
return result;
}

canonical_decompiled_code:
int func8()
{
int result; // eax
__int64 v1; // rbp
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // rax

result = fputc(newNv, stdout);
if ( nv > 0 )
{
v1 = 0LL;
do
{
while ( deleted[v1] )
{
if ( nv <= (int)++v1 )
return result;
}
v2 = firstedge[v1];
v3 = v2;
do
{
while ( 1 )
{
v4 = *(int *)(v3 + 4);
if ( !deleted[v4] )
break;
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_9;
}
fputc(newLabels[v4] + 1, stdout);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_9:
++v1;
result = fputc(0, stdout);
}
while ( nv > (int)v1 );
}
return result;
}

original_code:
void writeVertexDeletedPlanarCodeChar(){
    int i;
    EDGE *e, *elast;
    fputc(newNv, stdout);
    for(i=0; i<nv; i++){
        if(!deleted[i]){
            e = elast = firstedge[i];
            do {
                if(!deleted[e->end]){
                    fputc(newLabels[e->end] + 1, stdout);
                }
                e = e->next;
            } while (e != elast);
            fputc(0, stdout);
        }
    }
}

canonical_original_code:
void writeVertexDeletedPlanarCodeChar(){
    int i;
    struct e *e; struct e *elast;
    fputc(newNv, stdout);
    for(i=0; i<nv; i++){
        if(!deleted[i]){
            e = elast = firstedge[i];
            do {
                if(!deleted[e->end]){
                    fputc(newLabels[e->end] + 1, stdout);
                }
                e = e->next;
            } while (e != elast);
            fputc(0, stdout);
        }
    }
}

variable_types: i int

variable_types: struct e { int start; int end; int rightface; struct e *prev; struct e *next; struct e *inverse; int mark; } *


writeShort

canonical_decompiled_code:
size_t __fastcall func9(__int16 a1)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, stdout);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}

canonical_original_code:
void writeShort(unsigned short value){
    if (fwrite(&value, sizeof (unsigned short), 1, stdout) != 1) {
        fprintf(stderr, "fwrite() failed -- exiting!\n");
        exit(-1);
    }
}

variable_types:
value
unsigned short


writeVertexDeletedPlanarCodeShort

decompiled_code:
size_t writeVertexDeletedPlanarCodeShort()
{
size_t result; // rax
__int64 v1; // rbp
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // rax

fputc(0, stdout);
result = writeShort(newNv);
if ( nv > 0 )
{
v1 = 0LL;
do
{
while ( deleted[v1] )
{
if ( nv <= (int)++v1 )
return result;
}
v2 = firstedge[v1];
v3 = v2;
do
{
while ( 1 )
{
v4 = *(int *)(v3 + 4);
if ( !deleted[v4] )
break;
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_9;
}
writeShort(newLabels[v4] + 1);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_9:
++v1;
result = writeShort(0);
}
while ( nv > (int)v1 );
}
return result;
}

canonical_decompiled_code:
size_t func10()
{
size_t result; // rax
__int64 v1; // rbp
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // rax

fputc(0, stdout);
result = func9(newNv);
if ( nv > 0 )
{
v1 = 0LL;
do
{
while ( deleted[v1] )
{
if ( nv <= (int)++v1 )
return result;
}
v2 = firstedge[v1];
v3 = v2;
do
{
while ( 1 )
{
v4 = *(int *)(v3 + 4);
if ( !deleted[v4] )
break;
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_9;
}
func9(newLabels[v4] + 1);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_9:
++v1;
result = func9(0);
}
while ( nv > (int)v1 );
}
return result;
}

original_code:
void writeVertexDeletedPlanarCodeShort(){
    int i;
    EDGE *e, *elast;
    fputc(0, stdout);
    writeShort(newNv);
    for(i=0; i<nv; i++){
        if(!deleted[i]){
            e = elast = firstedge[i];
            do {
                if(!deleted[e->end]){
                    writeShort(newLabels[e->end] + 1);
                }
                e = e->next;
            } while (e != elast);
            writeShort(0);
        }
    }
}

canonical_original_code:
void writeVertexDeletedPlanarCodeShort(){
    int i;
    struct e *e; struct e *elast;
    fputc(0, stdout);
    writeShort(newNv);
    for(i=0; i<nv; i++){
        if(!deleted[i]){
            e = elast = firstedge[i];
            do {
                if(!deleted[e->end]){
                    writeShort(newLabels[e->end] + 1);
                }
                e = e->next;
            } while (e != elast);
            writeShort(0);
        }
    }
}


writeVertexDeletedPlanarCode

decompiled_code:
int writeVertexDeletedPlanarCode()
{
int v0; // eax

if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
v0 = newNv;
if ( newNv > 254 )
goto LABEL_3;
return writeVertexDeletedPlanarCodeChar();
}
v0 = newNv;
if ( newNv <= 254 )
return writeVertexDeletedPlanarCodeChar();
LABEL_3:
if ( v0 > 65534 )
{
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return writeVertexDeletedPlanarCodeShort();
}

canonical_decompiled_code:
int func11()
{
int v0; // eax

if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
v0 = newNv;
if ( newNv > 254 )
goto LABEL_3;
return func8();
}
v0 = newNv;
if ( newNv <= 254 )
return func8();
LABEL_3:
if ( v0 > 65534 )
{
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return func10();
}

original_code:
void writeVertexDeletedPlanarCode(){
    static int first = 1;
    if(first){
        first = 0;
        fprintf(stdout, ">>planar_code<<");
    }
    if (newNv + 1 <= 255) {
        writeVertexDeletedPlanarCodeChar();
    } else if (newNv + 1 <= 65535) {
        writeVertexDeletedPlanarCodeShort();
    } else {
        fprintf(stderr, "Graphs of that size are currently not supported -- exiting!\n");
        exit(-1);
    }
}

variable_types: first int


validateGraph

decompiled_code:
void validateGraph()
{
__int64 v0; // rsi
__int64 v1; // rax

if ( nv > 0 )
{
v0 = 0LL;
do
{
if ( degree[v0] != 2 )
{
v1 = firstedge[v0];
do
{
if ( degree[*(int *)(v1 + 4)] == 2 )
{
fwrite("Neighbouring vertices of degree 2 are not supported -- exiting!\n", 1uLL, 0x40uLL, stderr);
exit(1);
}
v1 = *(_QWORD *)(v1 + 24);
}
while ( firstedge[v0] != v1 );
}
++v0;
}
while ( v0 != nv );
}
}

canonical_decompiled_code:
void func7()
{
__int64 v0; // rsi
__int64 v1; // rax

if ( nv > 0 )
{
v0 = 0LL;
do
{
if ( degree[v0] != 2 )
{
v1 = firstedge[v0];
do
{
if ( degree[*(int *)(v1 + 4)] == 2 )
{
fwrite("Neighbouring vertices of degree 2 are not supported -- exiting!\n", 1uLL, 0x40uLL, stderr);
exit(1);
}
v1 = *(_QWORD *)(v1 + 24);
}
while ( firstedge[v0] != v1 );
}
++v0;
}
while ( v0 != nv );
}
}

original_code:
void validateGraph(){
    int i;
    EDGE *e, *elast;
    for(i = 0; i < nv; i++){
        if(degree[i]!=2){
            e = elast = firstedge[i];
            do {
                if(degree[e->end]==2){
                    fprintf(stderr, "Neighbouring vertices of degree 2 are not supported -- exiting!\n");
                    exit(1);
                }
                e = e->next;
            } while (e != elast);
        }
    }
}

canonical_original_code:
void validateGraph(){
    int i;
    struct e *e; struct e *elast;
    for(i = 0; i < nv; i++){
        if(degree[i]!=2){
            e = elast = firstedge[i];
            do {
                if(degree[e->end]==2){
                    fprintf(stderr, "Neighbouring vertices of degree 2 are not supported -- exiting!\n");
                    exit(1);
                }
                e = e->next;
            } while (e != elast);
        }
    }
}


writeSuppressedPlanarCodeChar

decompiled_code:
int writeSuppressedPlanarCodeChar()
{
int result; // eax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx
__int64 v4; // rax

fputc(newNv, stdout);
result = nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
while ( degree[v1] == 2 )
{
if ( nv <= (int)++v1 )
return result;
}
v2 = firstedge[v1];
v3 = v2;
do
{
while ( 1 )
{
v4 = *(int *)(v3 + 4);
if ( degree[v4] == 2 )
break;
fputc(newLabels[v4] + 1, stdout);
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_9;
}
fputc(newLabels[*(int *)(*(_QWORD *)(*(_QWORD *)(v3 + 32) + 24LL) + 4LL)] + 1, stdout);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_9:
++v1;
result = fputc(0, stdout);
}
while ( nv > (int)v1 );
}
return result;
}

canonical_decompiled_code:
int func9()
{
int result; // eax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx
__int64 v4; // rax

fputc(newNv, stdout);
result = nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
while ( degree[v1] == 2 )
{
if ( nv <= (int)++v1 )
return result;
}
v2 = firstedge[v1];
v3 = v2;
do
{
while ( 1 )
{
v4 = *(int *)(v3 + 4);
if ( degree[v4] == 2 )
break;
fputc(newLabels[v4] + 1, stdout);
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_9;
}
fputc(newLabels[*(int *)(*(_QWORD *)(*(_QWORD *)(v3 + 32) + 24LL) + 4LL)] + 1, stdout);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_9:
++v1;
result = fputc(0, stdout);
}
while ( nv > (int)v1 );
}
return result;
}

original_code:
void writeSuppressedPlanarCodeChar(){
    int i;
    EDGE *e, *elast;
    fputc(newNv, stdout);
    for(i=0; i<nv; i++){
        if(degree[i]!=2){
            e = elast = firstedge[i];
            do {
                if(degree[e->end]==2){
                    fputc(newLabels[e->inverse->next->end] + 1, stdout);
                } else {
                    fputc(newLabels[e->end] + 1, stdout);
                }
                e = e->next;
            } while (e != elast);
            fputc(0, stdout);
        }
    }
}

canonical_original_code:
void writeSuppressedPlanarCodeChar(){
    int i;
    struct e *e; struct e *elast;
    fputc(newNv, stdout);
    for(i=0; i<nv; i++){
        if(degree[i]!=2){
            e = elast = firstedge[i];
            do {
                if(degree[e->end]==2){
                    fputc(newLabels[e->inverse->next->end] + 1, stdout);
                } else {
                    fputc(newLabels[e->end] + 1, stdout);
                }
                e = e->next;
            } while (e != elast);
            fputc(0, stdout);
        }
    }
}


writeShort

canonical_decompiled_code:
size_t __fastcall func10(__int16 a1)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, stdout);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}

original_code:
void writeShort(unsigned short value){
    if (fwrite(&value, sizeof (unsigned short), 1, stdout) != 1) {
        fprintf(stderr, "fwrite() failed -- exiting!\n");
        exit(-1);
    }
}


writeSuppressedPlanarCodeShort

decompiled_code:
size_t writeSuppressedPlanarCodeShort()
{
size_t result; // rax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx
__int64 v4; // rax

fputc(0, stdout);
writeShort(newNv);
result = (unsigned int)nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
while ( degree[v1] == 2 )
{
if ( nv <= (int)++v1 )
return result;
}
v2 = firstedge[v1];
v3 = v2;
do
{
while ( 1 )
{
v4 = *(int *)(v3 + 4);
if ( degree[v4] == 2 )
break;
writeShort(newLabels[v4] + 1);
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_9;
}
writeShort(newLabels[*(int *)(*(_QWORD *)(*(_QWORD *)(v3 + 32) + 24LL) + 4LL)] + 1);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_9:
++v1;
result = writeShort(0);
}
while ( nv > (int)v1 );
}
return result;
}

canonical_decompiled_code:
size_t func11()
{
size_t result; // rax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx
__int64 v4; // rax

fputc(0, stdout);
func10(newNv);
result = (unsigned int)nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
while ( degree[v1] == 2 )
{
if ( nv <= (int)++v1 )
return result;
}
v2 = firstedge[v1];
v3 = v2;
do
{
while ( 1 )
{
v4 = *(int *)(v3 + 4);
if ( degree[v4] == 2 )
break;
func10(newLabels[v4] + 1);
v3 = *(_QWORD *)(v3 + 24);
if ( v2 == v3 )
goto LABEL_9;
}
func10(newLabels[*(int *)(*(_QWORD *)(*(_QWORD *)(v3 + 32) + 24LL) + 4LL)] + 1);
v3 = *(_QWORD *)(v3 + 24);
}
while ( v2 != v3 );
LABEL_9:
++v1;
result = func10(0);
}
while ( nv > (int)v1 );
}
return result;
}

original_code:
void writeSuppressedPlanarCodeShort(){
    int i;
    EDGE *e, *elast;
    fputc(0, stdout);
    writeShort(newNv);
    for(i=0; i<nv; i++){
        if(degree[i]!=2){
            e = elast = firstedge[i];
            do {
                if(degree[e->end]==2){
                    writeShort(newLabels[e->inverse->next->end] + 1);
                } else {
                    writeShort(newLabels[e->end] + 1);
                }
                e = e->next;
            } while (e != elast);
            writeShort(0);
        }
    }
}

canonical_original_code:
void writeSuppressedPlanarCodeShort(){
    int i;
    struct e *e; struct e *elast;
    fputc(0, stdout);
    writeShort(newNv);
    for(i=0; i<nv; i++){
        if(degree[i]!=2){
            e = elast = firstedge[i];
            do {
                if(degree[e->end]==2){
                    writeShort(newLabels[e->inverse->next->end] + 1);
                } else {
                    writeShort(newLabels[e->end] + 1);
                }
                e = e->next;
            } while (e != elast);
            writeShort(0);
        }
    }
}


writeSuppressedPlanarCode

decompiled_code:
int writeSuppressedPlanarCode()
{
int v0; // eax

if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
v0 = newNv;
if ( newNv > 254 )
goto LABEL_3;
return writeSuppressedPlanarCodeChar();
}
v0 = newNv;
if ( newNv <= 254 )
return writeSuppressedPlanarCodeChar();
LABEL_3:
if ( v0 > 65534 )
{
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return writeSuppressedPlanarCodeShort();
}

canonical_decompiled_code:
int func12()
{
int v0; // eax

if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
v0 = newNv;
if ( newNv > 254 )
goto LABEL_3;
return func9();
}
v0 = newNv;
if ( newNv <= 254 )
return func9();
LABEL_3:
if ( v0 > 65534 )
{
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return func11();
}

original_code:
void writeSuppressedPlanarCode(){
    static int first = 1;
    if(first){
        first = 0;
        fprintf(stdout, ">>planar_code<<");
    }
    if (newNv + 1 <= 255) {
        writeSuppressedPlanarCodeChar();
    } else if (newNv + 1 <= 65535) {
        writeSuppressedPlanarCodeShort();
    } else {
        fprintf(stderr, "Graphs of that size are currently not supported -- exiting!\n");
        exit(-1);
    }
}


writePlanarCodeChar

decompiled_code:
int writePlanarCodeChar()
{
int result; // eax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx

fputc(nv, stdout);
result = nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
v2 = firstedge[v1];
v3 = v2;
do
{
fputc(*(_DWORD *)(v3 + 4) + 1, stdout);
v3 = *(_QWORD *)(v3 + 16);
}
while ( v2 != v3 );
++v1;
result = fputc(0, stdout);
}
while ( nv > (int)v1 );
}
return result;
}

canonical_decompiled_code:
int func7()
{
int result; // eax
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rbx

fputc(nv, stdout);
result = nv;
if ( nv > 0 )
{
v1 = 0LL;
do
{
v2 = firstedge[v1];
v3 = v2;
do
{
fputc(*(_DWORD *)(v3 + 4) + 1, stdout);
v3 = *(_QWORD *)(v3 + 16);
}
while ( v2 != v3 );
++v1;
result = fputc(0, stdout);
}
while ( nv > (int)v1 );
}
return result;
}

original_code:
void writePlanarCodeChar(){
    int i;
    EDGE *e, *elast;
    fputc(nv, stdout);
    for(i=0; i<nv; i++){
        e = elast = firstedge[i];
        do {
            fputc(e->end + 1, stdout);
            e = e->next;
        } while (e != elast);
        fputc(0, stdout);
    }
}

canonical_original_code:
void writePlanarCodeChar(){
    int i;
    struct e *e; struct e *elast;
    fputc(nv, stdout);
    for(i=0; i<nv; i++){
        e = elast = firstedge[i];
        do {
            fputc(e->end + 1, stdout);
            e = e->next;
        } while (e != elast);
        fputc(0, stdout);
    }
}


writeShort

decompiled_code:
size_t __fastcall writeShort(__int16 a1)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, stdout);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func8(__int16 a1)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, stdout);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}


writePlanarCode

decompiled_code:
int writePlanarCode()
{
int v0; // eax

if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
v0 = nv;
if ( nv > 254 )
goto LABEL_3;
return writePlanarCodeChar();
}
v0 = nv;
if ( nv <= 254 )
return writePlanarCodeChar();
LABEL_3:
if ( v0 > 65534 )
{
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return writePlanarCodeShort();
}

canonical_decompiled_code:
int func10()
{
int v0; // eax

if ( first_2 )
{
first_2 = 0;
fwrite(">>planar_code<<", 1uLL, 0xFuLL, stdout);
v0 = nv;
if ( nv > 254 )
goto LABEL_3;
return func7();
}
v0 = nv;
if ( nv <= 254 )
return func7();
LABEL_3:
if ( v0 > 65534 )
{
fwrite("Graphs of that size are currently not supported -- exiting!\n", 1uLL, 0x3CuLL, stderr);
exit(-1);
}
return func9();
}

original_code:
void writePlanarCode(){
    static int first = 1;
    if(first){
        first = 0;
        fprintf(stdout, ">>planar_code<<");
    }
    if (nv + 1 <= 255) {
        writePlanarCodeChar();
    } else if (nv + 1 <= 65535) {
        writePlanarCodeShort();
    } else {
        fprintf(stderr, "Graphs of that size are currently not supported -- exiting!\n");
        exit(-1);
    }
}


writeShort

decompiled_code:
size_t __fastcall writeShort(__int16 a1, FILE *a2)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, a2);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func15(__int16 a1, FILE *a2)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, a2);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}


canonical_decompiled_code:
size_t __fastcall func14(__int16 a1, FILE *a2)
{
size_t result; // rax
__int16 ptr[6]; // [rsp+Ch] [rbp-Ch] BYREF

ptr[0] = a1;
result = fwrite(ptr, 2uLL, 1uLL, a2);
if ( result != 1 )
{
fwrite("fwrite() failed -- exiting!\n", 1uLL, 0x1CuLL, stderr);
exit(-1);
}
return result;
}


original_code:
static void Arr_sort_dtlmaopao(int * piar, int len){
 int i, j, m;
 for (i=0; i< len; i++){
  for (j=i+1; j< len; j++){
   if (piar[i] > piar[j]){
    m =piar[i];
    piar[i] = piar[j];
    piar[j] = m;
   }
  }
 }
}

canonical_original_code:
static void Arr_sort_dtlmaopao(int *piar, int len){
 int i; int j; int m;
 for (i=0; i< len; i++){
  for (j=i+1; j< len; j++){
   if (piar[i] > piar[j]){
    m =piar[i];
    piar[i] = piar[j];
    piar[j] = m;
   }
  }
 }
}

variable_types:
piar
int *

variable_types: len int

variable_types: m int


decompiled_code:
void __fastcall __noreturn Arr_error(char *a1)
{
char *v1; // rbx
int i; // edi

v1 = a1;
for ( i = *a1; (_BYTE)i; ++v1 )
{
putchar(i);
i = v1[1];
}
putchar(10);
exit(-1);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(char *a1)
{
char *v1; // rbx
int i; // edi

v1 = a1;
for ( i = *a1; (_BYTE)i; ++v1 )
{
putchar(i);
i = v1[1];
}
putchar(10);
exit(-1);
}

original_code:
static void Arr_error(char * pstr){
 while (*pstr != '\0'){
  printf("%c",*pstr);
  pstr++;
 }
 printf("\n");
 exit(-1);
}

canonical_original_code:
static void Arr_error(char *pstr){
 while (*pstr != '\0'){
  printf("%c",*pstr);
  pstr++;
 }
 printf("\n");
 exit(-1);
}

variable_types:
pstr
char *


decompiled_code:
__int64 __fastcall Arr_extend(__int64 a1, int a2)
{
void *v2; // rax

v2 = realloc(*(void **)a1, 4LL * (*(_DWORD *)(a1 + 12) + a2));
*(_QWORD *)a1 = v2;
if ( !v2 )
return 48LL;
*(_DWORD *)(a1 + 8) += a2;
return 49LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
void *v2; // rax

v2 = realloc(*(void **)a1, 4LL * (*(_DWORD *)(a1 + 12) + a2));
*(_QWORD *)a1 = v2;
if ( !v2 )
return 48LL;
*(_DWORD *)(a1 + 8) += a2;
return 49LL;
}

original_code:
static char Arr_extend(struct Arrlist * pArr, int increment){
 pArr->paddr = (int *)realloc(pArr->paddr, sizeof(int) * (pArr->cur_len + increment));
 if (((void *)0) == pArr->paddr){
  return '0';
 }
 pArr->len += increment;
 return '1';
}

canonical_original_code:
static char Arr_extend(struct Arrlist *pArr, int increment){
 pArr->paddr = (int *)realloc(pArr->paddr, sizeof(int) * (pArr->cur_len + increment));
 if (((void *)0) == pArr->paddr){
  return '0';
 }
 pArr->len += increment;
 return '1';
}

variable_types: struct Arrlist { int *paddr; int len; int cur_len; int increment; char is_inited; } *

variable_types: increment int

return_type: char


decompiled_code:
__int64 __fastcall Arr_init(__int64 a1, int a2)
{
void *v2; // rax
__int64 result; // rax

v2 = malloc(4LL * a2);
*(_QWORD *)a1 = v2;
if ( !v2 )
Arr_error("fail to assign memory!!");
result = 0xA00000000LL;
*(_DWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 12) = 0xA00000000LL;
*(_BYTE *)(a1 + 20) = 49;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
void *v2; // rax
__int64 result; // rax

v2 = malloc(4LL * a2);
*(_QWORD *)a1 = v2;
if ( !v2 )
func1("fail to assign memory!!");
result = 0xA00000000LL;
*(_DWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 12) = 0xA00000000LL;
*(_BYTE *)(a1 + 20) = 49;
return result;
}

original_code:
void Arr_init(struct Arrlist * pArr, int length){
 pArr->paddr = (int *)malloc(sizeof(int) * length);
 if (((void *)0) == pArr->paddr){
  Arr_error("fail to assign memory!!");
 }
 pArr->len = length;
 pArr->cur_len = 0;
 pArr->increment = 10;
 pArr->is_inited = '1';
 return;
}

canonical_original_code:
void Arr_init(struct Arrlist *pArr, int length){
 pArr->paddr = (int *)malloc(sizeof(int) * length);
 if (((void *)0) == pArr->paddr){
  Arr_error("fail to assign memory!!");
 }
 pArr->len = length;
 pArr->cur_len = 0;
 pArr->increment = 10;
 pArr->is_inited = '1';
 return;
}

variable_types: length int

user_defined_types: struct Arrlist { int *paddr; int len; int cur_len; int increment; char is_inited; }


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

result = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)result != 49 )
Arr_error("Array is not inited yet!!");
if ( *(_DWORD *)(a1 + 12) )
result = 48LL;
return result;
}

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

result = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)result != 49 )
func1("Array is not inited yet!!");
if ( *(_DWORD *)(a1 + 12) )
result = 48LL;
return result;
}

original_code:
char Arr_is_empty(struct Arrlist * pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if (0 == pArr->cur_len){
  return '1';
 }
 return '0';
}

canonical_original_code:
char Arr_is_empty(struct Arrlist *pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if (0 == pArr->cur_len){
  return '1';
 }
 return '0';
}


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

result = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)result != 49 )
Arr_error("Array is not inited yet!!");
if ( *(_DWORD *)(a1 + 8) != *(_DWORD *)(a1 + 12) )
result = 48LL;
return result;
}

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

result = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)result != 49 )
func1("Array is not inited yet!!");
if ( *(_DWORD *)(a1 + 8) != *(_DWORD *)(a1 + 12) )
result = 48LL;
return result;
}

original_code:
char Arr_is_full(struct Arrlist * pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if (pArr->len == pArr->cur_len){
  return '1';
 }
 return '0';
}

canonical_original_code:
char Arr_is_full(struct Arrlist *pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if (pArr->len == pArr->cur_len){
  return '1';
 }
 return '0';
}


decompiled_code:
int __fastcall Arr_show(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rsi

if ( *(_BYTE *)(a1 + 20) != 49 )
Arr_error("Array is not inited yet!!");
if ( (unsigned __int8)Arr_is_empty(a1) == 49 )
return puts("It's an empty Arrlist");
v1 = *(int *)(a1 + 12);
v2 = 0LL;
if ( (int)v1 > 1 )
{
do
{
v3 = *(unsigned int *)(*(_QWORD *)a1 + 4 * v2++);
printf("%d, ", v3);
v1 = *(int *)(a1 + 12);
}
while ( (int)v1 - 1 > (int)v2 );
}
return printf("%d\n", *(unsigned int *)(*(_QWORD *)a1 + 4 * v1 - 4));
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rsi

if ( *(_BYTE *)(a1 + 20) != 49 )
func1("Array is not inited yet!!");
if ( (unsigned __int8)func4(a1) == 49 )
return puts("It's an empty Arrlist");
v1 = *(int *)(a1 + 12);
v2 = 0LL;
if ( (int)v1 > 1 )
{
do
{
v3 = *(unsigned int *)(*(_QWORD *)a1 + 4 * v2++);
printf("%d, ", v3);
v1 = *(int *)(a1 + 12);
}
while ( (int)v1 - 1 > (int)v2 );
}
return printf("%d\n", *(unsigned int *)(*(_QWORD *)a1 + 4 * v1 - 4));
}

original_code:
void Arr_show(struct Arrlist * pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if ('1' == Arr_is_empty(pArr)){
  printf("It's an empty Arrlist\n");
  return;
 }
 int i;
 for (i=0; i < (pArr->cur_len - 1); i++){
   printf("%d, ", pArr->paddr[i]);
 }
 printf("%d\n", pArr->paddr[pArr->cur_len -1]);
 return;
}

canonical_original_code:
void Arr_show(struct Arrlist *pArr){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if ('1' == Arr_is_empty(pArr)){
  printf("It's an empty Arrlist\n");
  return;
 }
 int i;
 for (i=0; i < (pArr->cur_len - 1); i++){
   printf("%d, ", pArr->paddr[i]);
 }
 printf("%d\n", pArr->paddr[pArr->cur_len -1]);
 return;
}


decompiled_code:
__int64 __fastcall Arr_add(__int64 a1, int a2)
{
unsigned int v2; // er12

v2 = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)v2 != 49 )
Arr_error("Array is not inited yet!!");
if ( (unsigned __int8)Arr_is_full(a1) == 49 && (unsigned __int8)Arr_extend(a1, *(_DWORD *)(a1 + 16)) == 48 )
return 48;
*(_DWORD *)(*(_QWORD *)a1 + 4LL * (int)(*(_DWORD *)(a1 + 12))++) = a2;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
unsigned int v2; // er12

v2 = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)v2 != 49 )
func1("Array is not inited yet!!");
if ( (unsigned __int8)func5(a1) == 49 && (unsigned __int8)func2(a1, *(_DWORD *)(a1 + 16)) == 48 )
return 48;
*(_DWORD *)(*(_QWORD *)a1 + 4LL * (int)(*(_DWORD *)(a1 + 12))++) = a2;
return v2;
}

original_code:
char Arr_add(struct Arrlist * pArr, int val){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if ('1' == Arr_is_full(pArr)){
  if ('0' == Arr_extend(pArr, pArr->increment)){
   return '0';
  }
 }
 pArr->paddr[pArr->cur_len] = val;
 pArr->cur_len++;
 return '1';
}

canonical_original_code:
char Arr_add(struct Arrlist *pArr, int val){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if ('1' == Arr_is_full(pArr)){
  if ('0' == Arr_extend(pArr, pArr->increment)){
   return '0';
  }
 }
 pArr->paddr[pArr->cur_len] = val;
 pArr->cur_len++;
 return '1';
}

variable_types: val int


decompiled_code:
__int64 __fastcall Arr_set(__int64 a1, int a2, int a3)
{
__int64 result; // rax

result = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)result != 49 )
Arr_error("Array is not inited yet!!");
if ( a2 < 0 || *(_DWORD *)(a1 + 12) <= a2 )
{
puts("the element is not existed yet");
result = 48LL;
}
else
{
*(_DWORD *)(*(_QWORD *)a1 + 4LL * a2) = a3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2, int a3)
{
__int64 result; // rax

result = *(unsigned __int8 *)(a1 + 20);
if ( (_BYTE)result != 49 )
func1("Array is not inited yet!!");
if ( a2 < 0 || *(_DWORD *)(a1 + 12) <= a2 )
{
puts("the element is not existed yet");
result = 48LL;
}
else
{
*(_DWORD *)(*(_QWORD *)a1 + 4LL * a2) = a3;
}
return result;
}

original_code:
char Arr_set(struct Arrlist * pArr, int index, int val){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if((index < 0) || (index >= pArr->cur_len)){
  printf("the element is not existed yet\n");
  return '0';
 }
 pArr->paddr[index] = val;
 return '1';
}

canonical_original_code:
char Arr_set(struct Arrlist *pArr, int index, int val){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if((index < 0) || (index >= pArr->cur_len)){
  printf("the element is not existed yet\n");
  return '0';
 }
 pArr->paddr[index] = val;
 return '1';
}

variable_types: index int


decompiled_code:
__int64 __fastcall Arr_get(__int64 a1, int a2)
{
if ( *(_BYTE *)(a1 + 20) != 49 )
Arr_error("Array is not inited yet!!");
if ( a2 >= 0 && *(_DWORD *)(a1 + 12) > a2 )
return *(unsigned int *)(*(_QWORD *)a1 + 4LL * a2);
puts("the element is not existed yet");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
if ( *(_BYTE *)(a1 + 20) != 49 )
func1("Array is not inited yet!!");
if ( a2 >= 0 && *(_DWORD *)(a1 + 12) > a2 )
return *(unsigned int *)(*(_QWORD *)a1 + 4LL * a2);
puts("the element is not existed yet");
return 0LL;
}

original_code:
int Arr_get(struct Arrlist * pArr, int index){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if((index < 0) || (index >= pArr->cur_len)){
  printf("the element is not existed yet\n");
  return 0;
 }
 return pArr->paddr[index];
}

canonical_original_code:
int Arr_get(struct Arrlist *pArr, int index){
 if ('1' != pArr->is_inited){
  Arr_error("Array is not inited yet!!");
 }
 if((index < 0) || (index >= pArr->cur_len)){
  printf("the element is not existed yet\n");
  return 0;
 }
 return pArr->paddr[index];
}