randomloss

decompiled_code:
_BOOL8 __fastcall randomloss(double a1)
{
int v2; // ebp

if ( a1 == 0.0 )
return 0LL;
v2 = rand();
return a1 > (double)(rand() % 10) / 10.0 + (double)(v2 % 100);
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(double a1)
{
int v2; // ebp

if ( a1 == 0.0 )
return 0LL;
v2 = rand();
return a1 > (double)(rand() % 10) / 10.0 + (double)(v2 % 100);
}

original_code:
int randomloss(double lossprob) {
 int loss = 0;
 double msb;
 double lsb;
 double tmp;
 if(lossprob == 0.0) {
  return loss;
 }
 msb = (double)(rand()%100);
 lsb = (double)(rand()%10);
 tmp = msb + (double)(lsb/(double)10);
 if(tmp < lossprob) {
  loss = 1;
 }
 return loss;
}

variable_types: lossprob double

variable_types: loss int

variable_types: msb double

variable_types: lsb double

variable_types: tmp double


original_code:
char *xor_fec_decode_src_block(trans_block_t *tr_block, unsigned long long *block_len,
          unsigned short es_len) {
  char *buf = ((void *)0);
  trans_unit_t *next_tu = ((void *)0);
  trans_unit_t *tu = ((void *)0);
  unsigned long long len = 0;
  unsigned long long tmp = 0;
    int last_esi = -1;
    int missing_esi = -1;
    char *missing_symb = ((void *)0);
    char *padded_symb = ((void *)0);
    trans_unit_t *missing_unit = ((void *)0);
    unsigned int j = 0;
    missing_symb = (char*)calloc(es_len, sizeof(char));
    padded_symb = (char*)calloc(es_len, sizeof(char));
    memset(missing_symb, 0, es_len);
    memset(padded_symb, 0, es_len);
    len = es_len*tr_block->k;
    if(!(buf = (char*)calloc((unsigned int)(len + 1), sizeof(char)))) {
        printf("Could not alloc memory for buf!\n");
        return ((void *)0);
    }
    tmp = 0;
 next_tu = tr_block->unit_list;
        while(next_tu != ((void *)0)) {
                tu = next_tu;
                next_tu = tu->next;
        }
        if(tu->esi == tr_block->k) {
  next_tu = tr_block->unit_list;
  while(next_tu != ((void *)0)) {
                 tu = next_tu;
   if((int)tu->esi != (last_esi + 1)) {
    missing_esi = (tu->esi - 1);
    break;
   }
                 next_tu = tu->next;
   last_esi = tu->esi;
         }
                next_tu = tr_block->unit_list;
                while(next_tu != ((void *)0)) {
                        tu = next_tu;
                 memset(padded_symb, 0, es_len);
   memcpy(padded_symb, tu->data, tu->len);
                        for(j = 0; j < es_len; j++) {
                                *(missing_symb + j) = *(missing_symb + j) ^ *(padded_symb + j);
                        }
                        next_tu = tu->next;
                }
  missing_unit = create_units(1);
  missing_unit->data = (char*)calloc(es_len, sizeof(char));
  missing_unit->esi = missing_esi;
  memcpy(missing_unit->data, missing_symb, es_len);
  missing_unit->len = es_len;
                next_tu = tr_block->unit_list;
                while(next_tu != ((void *)0)) {
                        tu = next_tu;
                        if(missing_esi == 0) {
    tr_block->unit_list = missing_unit;
    missing_unit->next = tu;
    tu->prev = missing_unit;
                                break;
                        }
   if((int)tu->esi > missing_esi) {
    tu->prev->next = missing_unit;
           missing_unit->prev = tu->prev;
    missing_unit->next = tu;
    tu->prev = missing_unit;
    break;
   }
                        next_tu = tu->next;
                }
  tu = tr_block->unit_list;
         for(j = 0; j < tr_block->k; j++) {
   if(tu->esi == (tr_block->k - 1)) {
                tu->next->used = 0;
    tu->next = ((void *)0);
    break;
   }
                 tu = tu->next;
         }
          next_tu = tr_block->unit_list;
 }
 next_tu = tr_block->unit_list;
 while(next_tu != ((void *)0)) {
         tu = next_tu;
         memcpy((buf+(unsigned int)tmp), tu->data, tu->len);
         tmp += tu->len;
         next_tu = tu->next;
 }
 *block_len = len;
        free(missing_symb);
        free(padded_symb);
 return buf;
}

canonical_original_code:
char *xor_fec_decode_src_block(struct trans_block *tr_block, unsigned long long *block_len, unsigned short es_len) {
  char *buf = ((void *)0);
  struct trans_unit *next_tu = ((void *)0);
  struct trans_unit *tu = ((void *)0);
  unsigned long long len = 0;
  unsigned long long tmp = 0;
    int last_esi = -1;
    int missing_esi = -1;
    char *missing_symb = ((void *)0);
    char *padded_symb = ((void *)0);
    struct trans_unit *missing_unit = ((void *)0);
    unsigned int j = 0;
    missing_symb = (char *)calloc(es_len, sizeof(char));
    padded_symb = (char *)calloc(es_len, sizeof(char));
    memset(missing_symb, 0, es_len);
    memset(padded_symb, 0, es_len);
    len = es_len*tr_block->k;
    if(!(buf = (char *)calloc((unsigned int)(len + 1), sizeof(char)))) {
        printf("Could not alloc memory for buf!\n");
        return ((void *)0);
    }
    tmp = 0;
 next_tu = tr_block->unit_list;
        while(next_tu != ((void *)0)) {
                tu = next_tu;
                next_tu = tu->next;
        }
        if(tu->esi == tr_block->k) {
  next_tu = tr_block->unit_list;
  while(next_tu != ((void *)0)) {
                 tu = next_tu;
   if((int)tu->esi != (last_esi + 1)) {
    missing_esi = (tu->esi - 1);
    break;
   }
                 next_tu = tu->next;
   last_esi = tu->esi;
         }
                next_tu = tr_block->unit_list;
                while(next_tu != ((void *)0)) {
                        tu = next_tu;
                 memset(padded_symb, 0, es_len);
   memcpy(padded_symb, tu->data, tu->len);
                        for(j = 0; j < es_len; j++) {
                                *(missing_symb + j) = *(missing_symb + j) ^ *(padded_symb + j);
                        }
                        next_tu = tu->next;
                }
  missing_unit = create_units(1);
  missing_unit->data = (char *)calloc(es_len, sizeof(char));
  missing_unit->esi = missing_esi;
  memcpy(missing_unit->data, missing_symb, es_len);
  missing_unit->len = es_len;
                next_tu = tr_block->unit_list;
                while(next_tu != ((void *)0)) {
                        tu = next_tu;
                        if(missing_esi == 0) {
    tr_block->unit_list = missing_unit;
    missing_unit->next = tu;
    tu->prev = missing_unit;
                                break;
                        }
   if((int)tu->esi > missing_esi) {
    tu->prev->next = missing_unit;
           missing_unit->prev = tu->prev;
    missing_unit->next = tu;
    tu->prev = missing_unit;
    break;
   }
                        next_tu = tu->next;
                }
  tu = tr_block->unit_list;
         for(j = 0; j < tr_block->k; j++) {
   if(tu->esi == (tr_block->k - 1)) {
                tu->next->used = 0;
    tu->next = ((void *)0);
    break;
   }
                 tu = tu->next;
         }
          next_tu = tr_block->unit_list;
 }
 next_tu = tr_block->unit_list;
 while(next_tu != ((void *)0)) {
         tu = next_tu;
         memcpy((buf+(unsigned int)tmp), tu->data, tu->len);
         tmp += tu->len;
         next_tu = tu->next;
 }
 *block_len = len;
        free(missing_symb);
        free(padded_symb);
 return buf;
}

variable_types: struct trans_block { unsigned int sbn; struct trans_unit { struct trans_unit *prev; struct trans_unit *next; unsigned int esi; unsigned short len; char *data; long offset; unsigned char used; } *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; } *

variable_types:
buf
char *

variable_types:
len
unsigned long long

variable_types:
tmp
unsigned long long

variable_types:
j
unsigned int

return_type: char *

user_defined_types: struct trans_block { unsigned int sbn; struct trans_unit *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; }


decompiled_code:
__int64 __fastcall compute_padding_length(unsigned __int64 a1, int a2, int a3)
{
int v3; // esi
unsigned __int64 v4; // rcx
unsigned int v5; // edx
unsigned int v6; // esi

v3 = a3 * a2;
v4 = v3;
v5 = 0;
if ( v3 < a1 )
{
v6 = v3 - a1 % v3;
v5 = 0;
if ( a1 % v4 )
v5 = v6;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1, int a2, int a3)
{
int v3; // esi
unsigned __int64 v4; // rcx
unsigned int v5; // edx
unsigned int v6; // esi

v3 = a3 * a2;
v4 = v3;
v5 = 0;
if ( v3 < a1 )
{
v6 = v3 - a1 % v3;
v5 = 0;
if ( a1 % v4 )
v5 = v6;
}
return v5;
}

original_code:
int compute_padding_length(unsigned long long f_size, int block_len, int es_len) {
  int p_length;
  if(f_size <= (block_len * es_len)) {
   p_length = 0;
  }
  else if(!(f_size % (block_len * es_len))) {
   p_length = 0;
  }
  else {
   p_length = (int)((block_len * es_len) - f_size % (block_len * es_len));
  }
  return p_length;
}

return_type: int


original_code:
int padding_decoder(char *file_name, unsigned long long content_length) {
  int fp_in;
  unsigned long long f_size;
  struct stat64 file_stats;
  char file_name_in[256] = "";
  char file_name_out[256] = "";
  char *ptr;
  int retval;
  strcpy(file_name_in, file_name);
  ptr = strstr(file_name_in, "~pad");
  memcpy(file_name_out, file_name_in, (ptr - file_name_in));
  fp_in = open64(file_name_in, 02 | 0100, (0400|0200|0100));
  if(fp_in == -1) {
    printf("open error: %s\n", file_name_in);
    return -1;
  }
  fstat64(fp_in, &file_stats);
  f_size = file_stats.st_size;
  if(f_size > content_length) {
   retval = ftruncate64(fp_in, content_length);
   if(retval != 0) {
    printf("Problem in padding decoding.\n" );
    close(fp_in);
    return -1;
   }
  }
  close(fp_in);
 if(rename(file_name_in, file_name_out) < 0) {
  if((*__errno_location ()) == 17) {
   retval = remove(file_name_out);
   if(retval == -1) {
    printf("errno: %i\n", (*__errno_location ()));
    fflush(stdout);
    close(fp_in);
    return -1;
   }
   if(rename(file_name_in, file_name_out) < 0) {
    printf("rename() error1: %s\n", file_name_in);
    fflush(stdout);
    close(fp_in);
    return -1;
   }
  }
  else {
   printf("rename() error2: %s\n", file_name_in);
   fflush(stdout);
   close(fp_in);
   return -1;
  }
 }
  return 0;
}

variable_types: struct stat64 { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }

variable_types:
ptr
char *

variable_types: retval int


decompiled_code:
void __fastcall free_query_str(void *ptr)
{
_QWORD *v2; // rbp
_QWORD *v3; // rbx
void *v4; // rdi
_QWORD *v5; // rbx

if ( *(_QWORD *)ptr )
free_uri();
v2 = (_QWORD *)*((_QWORD *)ptr + 1);
if ( v2 )
{
while ( 1 )
{
v3 = (_QWORD *)v2[2];
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)*v3;
free(v4);
}
v5 = (_QWORD *)*v2;
free(v2);
if ( !v5 )
break;
v2 = v5;
}
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
_QWORD *v2; // rbp
_QWORD *v3; // rbx
void *v4; // rdi
_QWORD *v5; // rbx

if ( *(_QWORD *)ptr )
free_uri();
v2 = (_QWORD *)*((_QWORD *)ptr + 1);
if ( v2 )
{
while ( 1 )
{
v3 = (_QWORD *)v2[2];
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)*v3;
free(v4);
}
v5 = (_QWORD *)*v2;
free(v2);
if ( !v5 )
break;
v2 = v5;
}
}
free(ptr);
}

original_code:
void free_query_str(query_str_t *qs) {
  qs_missing_block_t *mb;
  qs_missing_block_t *next_mb;
  qs_missing_symbol_t *ms;
  qs_missing_symbol_t *next_ms;
  if(qs->fileURI != ((void *)0)) {
    free_uri(qs->fileURI);
  }
  if(qs->block_list != ((void *)0)) {
    next_mb = qs->block_list;
    while(next_mb != ((void *)0)) {
      mb = next_mb;
      next_ms = mb->es_list;
      while(next_ms != ((void *)0)) {
 ms = next_ms;
 next_ms = ms->next;
 free(ms);
      }
      next_mb = mb->next;
      free(mb);
    }
  }
  if(qs != ((void *)0)) {
    free(qs);
  }
}

canonical_original_code:
void free_query_str(struct query_str *qs) {
  struct qs_missing_block *mb;
  struct qs_missing_block *next_mb;
  struct qs_missing_symbol *ms;
  struct qs_missing_symbol *next_ms;
  if(qs->fileURI != ((void *)0)) {
    free_uri(qs->fileURI);
  }
  if(qs->block_list != ((void *)0)) {
    next_mb = qs->block_list;
    while(next_mb != ((void *)0)) {
      mb = next_mb;
      next_ms = mb->es_list;
      while(next_ms != ((void *)0)) {
 ms = next_ms;
 next_ms = ms->next;
 free(ms);
      }
      next_mb = mb->next;
      free(mb);
    }
  }
  if(qs != ((void *)0)) {
    free(qs);
  }
}

variable_types: struct query_str { struct uri { char *scheme; char *host; char *port; char *path; char *params; char *query; char *frag; char *user; char *passwd; } *fileURI; struct qs_missing_block { struct qs_missing_block *next; unsigned int sbn; struct qs_missing_symbol { struct qs_missing_symbol *next; unsigned int esi; } *es_list; } *block_list; } *

return_type: void

user_defined_types: struct query_str { struct uri *fileURI; struct qs_missing_block *block_list; }

user_defined_types: struct qs_missing_block { struct qs_missing_block *next; unsigned int sbn; struct qs_missing_symbol *es_list; }


decompiled_code:
__int64 __fastcall list_init(_QWORD *a1)
{
_QWORD *v1; // rax
_QWORD *v2; // rbx
_QWORD *v3; // rax
__int64 result; // rax

v1 = malloc(0x18uLL);
*a1 = v1;
if ( v1 )
{
v2 = v1;
v3 = malloc(0x18uLL);
a1[1] = v3;
if ( v3 )
{
*v2 = v3;
v2[1] = 0LL;
*v3 = 0LL;
v3[1] = v2;
a1[2] = 0LL;
result = 0LL;
}
else
{
fwrite("error malloc tail\n", 1uLL, 0x12uLL, stderr);
result = 1LL;
}
}
else
{
fwrite("error malloc head\n", 1uLL, 0x12uLL, stderr);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
_QWORD *v1; // rax
_QWORD *v2; // rbx
_QWORD *v3; // rax
__int64 result; // rax

v1 = malloc(0x18uLL);
*a1 = v1;
if ( v1 )
{
v2 = v1;
v3 = malloc(0x18uLL);
a1[1] = v3;
if ( v3 )
{
*v2 = v3;
v2[1] = 0LL;
*v3 = 0LL;
v3[1] = v2;
a1[2] = 0LL;
result = 0LL;
}
else
{
fwrite("error malloc tail\n", 1uLL, 0x12uLL, stderr);
result = 1LL;
}
}
else
{
fwrite("error malloc head\n", 1uLL, 0x12uLL, stderr);
result = 1LL;
}
return result;
}

original_code:
err_code list_init(list* lst)
{
  lst->head = malloc(sizeof(struct _node));
  if (lst->head == ((void *)0)) {
    fprintf(stderr, "error malloc head\n");
    return 1;
  }
  lst->tail = malloc(sizeof(struct _node));
  if (lst->tail == ((void *)0)) {
    fprintf(stderr, "error malloc tail\n");
    return ERR_FAILURE;
  }
  lst->head->next = lst->tail;
  lst->head->previous = ((void *)0);
  lst->tail->next = ((void *)0);
  lst->tail->previous = lst->head;
  lst->size = 0;
  return ERR_SUCCESS;
}

canonical_original_code:
enum _config_error list_init(struct _list *lst)
{
  lst->head = malloc(sizeof(struct _node));
  if (lst->head == ((void *)0)) {
    fprintf(stderr, "error malloc head\n");
    return 1;
  }
  lst->tail = malloc(sizeof(struct _node));
  if (lst->tail == ((void *)0)) {
    fprintf(stderr, "error malloc tail\n");
    return ERR_FAILURE;
  }
  lst->head->next = lst->tail;
  lst->head->previous = ((void *)0);
  lst->tail->next = ((void *)0);
  lst->tail->previous = lst->head;
  lst->size = 0;
  return ERR_SUCCESS;
}

variable_types: struct _list { struct _node { struct _node *next; struct _node *previous; void *data; } *head; struct _node *tail; unsigned long size; } *

return_type: enum _config_error { ERR_SUCCESS=0, ERR_FAILURE=1 }

user_defined_types: struct _list { struct _node *head; struct _node *tail; unsigned long size; }


decompiled_code:
__int64 __fastcall list_begin(_QWORD *a1)
{
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x24u, "list_begin");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0x25u, "list_begin");
return *(_QWORD *)*a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x24u, "list_begin");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0x25u, "list_begin");
return *(_QWORD *)*a1;
}

original_code:
iterator list_begin(const list* lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 36, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 37, __extension__ __PRETTY_FUNCTION__));
  iterator it;
  it = lst->head->next;
  return it;
}

canonical_original_code:
struct _node *list_begin(struct _list *lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 36, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 37, __extension__ __PRETTY_FUNCTION__));
  struct _node *it;
  it = lst->head->next;
  return it;
}

variable_types: struct _list { struct _node *head; struct _node *tail; unsigned long size; } *

variable_types: struct _node { struct _node *next; struct _node *previous; void *data; } *


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

if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x31u, "list_end");
result = a1[1];
if ( !result )
_assert_fail("lst->tail != NULL", "list.c", 0x32u, "list_end");
return result;
}

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

if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x31u, "list_end");
result = a1[1];
if ( !result )
_assert_fail("lst->tail != NULL", "list.c", 0x32u, "list_end");
return result;
}

original_code:
iterator list_end(const list* lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 49, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 50, __extension__ __PRETTY_FUNCTION__));
  iterator it;
  it = lst->tail;
  return it;
}

canonical_original_code:
struct _node *list_end(struct _list *lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 49, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 50, __extension__ __PRETTY_FUNCTION__));
  struct _node *it;
  it = lst->tail;
  return it;
}

return_type: struct _node { struct _node *next; struct _node *previous; void *data; } *


decompiled_code:
__int64 __fastcall list_next(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
iterator list_next(iterator it)
{
  it = it->next;
  return it;
}

canonical_original_code:
struct _node *list_next(struct _node *it)
{
  it = it->next;
  return it;
}

variable_types:
it
struct _node *

user_defined_types: struct _node { struct _node *next; struct _node *previous; void *data; }


decompiled_code:
__int64 __fastcall list_insert(_QWORD *a1, _QWORD *a2, __int64 a3)
{
_QWORD *v4; // rax
_QWORD *v5; // rdx

if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x50u, "list_insert");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0x51u, "list_insert");
v4 = malloc(0x18uLL);
if ( !v4 )
return 1LL;
*v4 = *a2;
v5 = (_QWORD *)a2[1];
v4[1] = v5;
*v5 = v4;
*(_QWORD *)(*a2 + 8LL) = v4;
v4[2] = a3;
++a1[2];
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, _QWORD *a2, __int64 a3)
{
_QWORD *v4; // rax
_QWORD *v5; // rdx

if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x50u, "list_insert");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0x51u, "list_insert");
v4 = malloc(0x18uLL);
if ( !v4 )
return 1LL;
*v4 = *a2;
v5 = (_QWORD *)a2[1];
v4[1] = v5;
*v5 = v4;
*(_QWORD *)(*a2 + 8LL) = v4;
v4[2] = a3;
++a1[2];
return 0LL;
}

original_code:
err_code list_insert(list* lst, iterator it, const void* const data)
{
 ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 80, __extension__ __PRETTY_FUNCTION__));
 ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 81, __extension__ __PRETTY_FUNCTION__));
 struct _node* temp = malloc(sizeof(struct _node));
 if (temp == ((void *)0)) {
  return ERR_FAILURE;
 }
 else {
  temp->next = it->next;
  temp->previous = it->previous;
  it->previous->next = temp;
  it->next->previous = temp;
  temp->data = (void*)data;
  ++lst->size;
  return ERR_SUCCESS;
 }
}

canonical_original_code:
enum _config_error list_insert(struct _list *lst, struct _node *it, void *data)
{
 ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 80, __extension__ __PRETTY_FUNCTION__));
 ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 81, __extension__ __PRETTY_FUNCTION__));
 struct _node *temp = malloc(sizeof(struct _node));
 if (temp == ((void *)0)) {
  return ERR_FAILURE;
 }
 else {
  temp->next = it->next;
  temp->previous = it->previous;
  it->previous->next = temp;
  it->next->previous = temp;
  temp->data = (void *)data;
  ++lst->size;
  return ERR_SUCCESS;
 }
}

variable_types:
data
void *

user_defined_types: enum _config_error { ERR_SUCCESS=0, ERR_FAILURE=1 }


decompiled_code:
__int64 __fastcall list_get(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
void* list_get(const iterator it)
{
 return it->data;
}

canonical_original_code:
void *list_get(struct _node *it)
{
 return it->data;
}

return_type: void *


decompiled_code:
__int64 __fastcall list_erase(_QWORD *a1, __int64 a2)
{
__int64 v2; // r12
_QWORD *v3; // rdx
__int64 v4; // rax

if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0xD9u, "list_erase");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0xDAu, "list_erase");
v2 = list_next(a2);
v3 = *(_QWORD **)(a2 + 8);
v4 = *(_QWORD *)a2;
*v3 = *(_QWORD *)a2;
*(_QWORD *)(v4 + 8) = v3;
free(*(void **)(a2 + 16));
free((void *)a2);
--a1[2];
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, __int64 a2)
{
__int64 v2; // r12
_QWORD *v3; // rdx
__int64 v4; // rax

if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0xD9u, "list_erase");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0xDAu, "list_erase");
v2 = func3(a2);
v3 = *(_QWORD **)(a2 + 8);
v4 = *(_QWORD *)a2;
*v3 = *(_QWORD *)a2;
*(_QWORD *)(v4 + 8) = v3;
free(*(void **)(a2 + 16));
free((void *)a2);
--a1[2];
return v2;
}

original_code:
iterator list_erase(list* lst, iterator it)
{
 ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 217, __extension__ __PRETTY_FUNCTION__));
 ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 218, __extension__ __PRETTY_FUNCTION__));
 iterator new_it = list_next(it);
 struct _node* prev = it->previous;
 struct _node* nxt = it->next;
 prev->next = nxt;
 nxt->previous = prev;
 free(it->data);
 free(it);
 --lst->size;
 return new_it;
}

canonical_original_code:
struct _node *list_erase(struct _list *lst, struct _node *it)
{
 ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 217, __extension__ __PRETTY_FUNCTION__));
 ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 218, __extension__ __PRETTY_FUNCTION__));
 struct _node *new_it = list_next(it);
 struct _node *prev = it->previous;
 struct _node *nxt = it->next;
 prev->next = nxt;
 nxt->previous = prev;
 free(it->data);
 free(it);
 --lst->size;
 return new_it;
}


decompiled_code:
_BOOL8 __fastcall list_is_empty(_QWORD *a1)
{
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x10Bu, "list_is_empty");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0x10Cu, "list_is_empty");
return a1[2] == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(_QWORD *a1)
{
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x10Bu, "list_is_empty");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0x10Cu, "list_is_empty");
return a1[2] == 0LL;
}

original_code:
int list_is_empty(const list* lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 267, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 268, __extension__ __PRETTY_FUNCTION__));
  if (lst->size == 0) {
    return 1;
  }
  else {
    return 0;
  }
}

canonical_original_code:
int list_is_empty(struct _list *lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 267, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 268, __extension__ __PRETTY_FUNCTION__));
  if (lst->size == 0) {
    return 1;
  }
  else {
    return 0;
  }
}


decompiled_code:
__int64 __fastcall list_push_back(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // r13
__int64 v3; // r14
_QWORD *v4; // rax
_QWORD *v5; // rbp
_QWORD *v7; // rax
__int64 v8; // rax

v2 = (_QWORD *)*a1;
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x67u, "list_push_back");
v3 = a1[1];
if ( !v3 )
_assert_fail("lst->tail != NULL", "list.c", 0x68u, "list_push_back");
if ( !a2 )
_assert_fail("data != NULL", "list.c", 0x69u, "list_push_back");
v4 = malloc(0x18uLL);
v5 = v4;
if ( !v4 )
return 1LL;
v4[2] = a2;
if ( list_is_empty(a1) )
{
*v2 = v5;
*(_QWORD *)(a1[1] + 8LL) = v5;
v5[1] = *a1;
*v5 = a1[1];
}
else
{
v7 = *(_QWORD **)(v3 + 8);
v5[1] = v7;
*v7 = v5;
v8 = a1[1];
*v5 = v8;
*(_QWORD *)(v8 + 8) = v5;
}
++a1[2];
return 0LL;
}

original_code:
err_code list_push_back(list* lst, const void* const data)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 103, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 104, __extension__ __PRETTY_FUNCTION__));
  ((data != ((void *)0)) ? (void) (0) : __assert_fail ("data != NULL", "list.c", 105, __extension__ __PRETTY_FUNCTION__));
  node* n = malloc(sizeof(struct _node));
  if (n == ((void *)0)) {
   return ERR_FAILURE;
  }
  else {
   n->data = (void*)data;
  }
  if (list_is_empty(lst)) {
   lst->head->next = n;
   lst->tail->previous = n;
   n->previous = lst->head;
   n->next = lst->tail;
   ++lst->size;
   return ERR_SUCCESS;
  }
  else {
 n->previous = lst->tail->previous;
 lst->tail->previous->next = n;
 n->next = lst->tail;
 lst->tail->previous = n;
 ++lst->size;
 return ERR_SUCCESS;
  }
}

canonical_original_code:
enum _config_error list_push_back(struct _list *lst, void *data)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 103, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 104, __extension__ __PRETTY_FUNCTION__));
  ((data != ((void *)0)) ? (void) (0) : __assert_fail ("data != NULL", "list.c", 105, __extension__ __PRETTY_FUNCTION__));
  struct _node *n = malloc(sizeof(struct _node));
  if (n == ((void *)0)) {
   return ERR_FAILURE;
  }
  else {
   n->data = (void *)data;
  }
  if (list_is_empty(lst)) {
   lst->head->next = n;
   lst->tail->previous = n;
   n->previous = lst->head;
   n->next = lst->tail;
   ++lst->size;
   return ERR_SUCCESS;
  }
  else {
 n->previous = lst->tail->previous;
 lst->tail->previous->next = n;
 n->next = lst->tail;
 lst->tail->previous = n;
 ++lst->size;
 return ERR_SUCCESS;
  }
}


original_code:
err_code list_push_front(list* lst, const void* const data)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 139, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 140, __extension__ __PRETTY_FUNCTION__));;
  ((data != ((void *)0)) ? (void) (0) : __assert_fail ("data != NULL", "list.c", 141, __extension__ __PRETTY_FUNCTION__));
  struct _node* temp = malloc(sizeof(struct _node));
  if (temp == ((void *)0)) {
   return ERR_FAILURE;
  }
  else {
 temp->data = (void*)data;
  }
  if (list_is_empty(lst)) {
   lst->head->next = temp;
   temp->next = lst->tail;
   lst->tail->previous = temp;
   temp->previous = lst->head;
   ++lst->size;
   return ERR_SUCCESS;
  }
  else {
 node* t = lst->head->next;
 t->previous = temp;
    temp->next = t;
    temp->previous = lst->head;
    lst->head->next = temp;
    ++lst->size;
    return ERR_SUCCESS;
  }
}

canonical_original_code:
enum _config_error list_push_front(struct _list *lst, void *data)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 139, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 140, __extension__ __PRETTY_FUNCTION__));;
  ((data != ((void *)0)) ? (void) (0) : __assert_fail ("data != NULL", "list.c", 141, __extension__ __PRETTY_FUNCTION__));
  struct _node *temp = malloc(sizeof(struct _node));
  if (temp == ((void *)0)) {
   return ERR_FAILURE;
  }
  else {
 temp->data = (void *)data;
  }
  if (list_is_empty(lst)) {
   lst->head->next = temp;
   temp->next = lst->tail;
   lst->tail->previous = temp;
   temp->previous = lst->head;
   ++lst->size;
   return ERR_SUCCESS;
  }
  else {
 struct _node *t = lst->head->next;
 t->previous = temp;
    temp->next = t;
    temp->previous = lst->head;
    lst->head->next = temp;
    ++lst->size;
    return ERR_SUCCESS;
  }
}


decompiled_code:
__int64 __fastcall list_get_front(__int64 *a1)
{
__int64 v1; // rbx
_BOOL4 v2; // edx
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0xB9u, "list_get_front");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0xBAu, "list_get_front");
v2 = list_is_empty(a1);
result = 0LL;
if ( !v2 )
result = *(_QWORD *)(*(_QWORD *)v1 + 16LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 *a1)
{
__int64 v1; // rbx
_BOOL4 v2; // edx
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0xB9u, "list_get_front");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0xBAu, "list_get_front");
v2 = func9(a1);
result = 0LL;
if ( !v2 )
result = *(_QWORD *)(*(_QWORD *)v1 + 16LL);
return result;
}

original_code:
void* list_get_front(const list* lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 185, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 186, __extension__ __PRETTY_FUNCTION__));
  if (!list_is_empty(lst)) {
 node* n = lst->head->next;
 return n->data;
  }
  else {
    return ((void *)0);
  }
}

canonical_original_code:
void *list_get_front(struct _list *lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 185, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 186, __extension__ __PRETTY_FUNCTION__));
  if (!list_is_empty(lst)) {
 struct _node *n = lst->head->next;
 return n->data;
  }
  else {
    return ((void *)0);
  }
}


decompiled_code:
__int64 __fastcall list_get_rear(_QWORD *a1)
{
__int64 v1; // rbx
_BOOL4 v2; // edx
__int64 result; // rax

if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0xC7u, "list_get_rear");
v1 = a1[1];
if ( !v1 )
_assert_fail("lst->tail != NULL", "list.c", 0xC8u, "list_get_rear");
v2 = list_is_empty(a1);
result = 0LL;
if ( !v2 )
result = *(_QWORD *)(*(_QWORD *)(v1 + 8) + 16LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(_QWORD *a1)
{
__int64 v1; // rbx
_BOOL4 v2; // edx
__int64 result; // rax

if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0xC7u, "list_get_rear");
v1 = a1[1];
if ( !v1 )
_assert_fail("lst->tail != NULL", "list.c", 0xC8u, "list_get_rear");
v2 = func9(a1);
result = 0LL;
if ( !v2 )
result = *(_QWORD *)(*(_QWORD *)(v1 + 8) + 16LL);
return result;
}

original_code:
void* list_get_rear(const list* lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 199, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 200, __extension__ __PRETTY_FUNCTION__));
  if (!list_is_empty(lst)) {
    node* n = lst->tail->previous;
    return n->data;
  }
  else {
    return ((void *)0);
  }
}

canonical_original_code:
void *list_get_rear(struct _list *lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 199, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 200, __extension__ __PRETTY_FUNCTION__));
  if (!list_is_empty(lst)) {
    struct _node *n = lst->tail->previous;
    return n->data;
  }
  else {
    return ((void *)0);
  }
}


decompiled_code:
void __fastcall list_delete(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rax

if ( !*(_QWORD *)a1 )
_assert_fail("lst->head != NULL", "list.c", 0x118u, "list_delete");
if ( !*(_QWORD *)(a1 + 8) )
_assert_fail("lst->tail != NULL", "list.c", 0x119u, "list_delete");
v1 = list_end((_QWORD *)a1);
v2 = list_begin((_QWORD *)a1);
list_erase_between((_QWORD *)a1, v2, v1);
free(*(void **)a1);
free(*(void **)(a1 + 8));
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 8) = 0LL;
}

canonical_decompiled_code:
void __fastcall func14(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rax

if ( !*(_QWORD *)a1 )
_assert_fail("lst->head != NULL", "list.c", 0x118u, "list_delete");
if ( !*(_QWORD *)(a1 + 8) )
_assert_fail("lst->tail != NULL", "list.c", 0x119u, "list_delete");
v1 = func2((_QWORD *)a1);
v2 = func1((_QWORD *)a1);
func7((_QWORD *)a1, v2, v1);
free(*(void **)a1);
free(*(void **)(a1 + 8));
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 8) = 0LL;
}

original_code:
void list_delete(list* lst)
{
 ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 280, __extension__ __PRETTY_FUNCTION__));
 ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 281, __extension__ __PRETTY_FUNCTION__));
 list_erase_between(lst, list_begin(lst), list_end(lst));
 free(lst->head);
 free(lst->tail);
 lst->head = ((void *)0);
 lst->tail = ((void *)0);
}

canonical_original_code:
void list_delete(struct _list *lst)
{
 ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 280, __extension__ __PRETTY_FUNCTION__));
 ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 281, __extension__ __PRETTY_FUNCTION__));
 list_erase_between(lst, list_begin(lst), list_end(lst));
 free(lst->head);
 free(lst->tail);
 lst->head = ((void *)0);
 lst->tail = ((void *)0);
}


decompiled_code:
__int64 __fastcall list_size(_QWORD *a1)
{
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x125u, "list_size");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0x126u, "list_size");
return a1[2];
}

canonical_decompiled_code:
__int64 __fastcall func15(_QWORD *a1)
{
if ( !*a1 )
_assert_fail("lst->head != NULL", "list.c", 0x125u, "list_size");
if ( !a1[1] )
_assert_fail("lst->tail != NULL", "list.c", 0x126u, "list_size");
return a1[2];
}

original_code:
size_t list_size(const list* lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 293, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 294, __extension__ __PRETTY_FUNCTION__));
  return lst->size;
}

canonical_original_code:
unsigned long list_size(struct _list *lst)
{
  ((lst->head != ((void *)0)) ? (void) (0) : __assert_fail ("lst->head != NULL", "list.c", 293, __extension__ __PRETTY_FUNCTION__));
  ((lst->tail != ((void *)0)) ? (void) (0) : __assert_fail ("lst->tail != NULL", "list.c", 294, __extension__ __PRETTY_FUNCTION__));
  return lst->size;
}

return_type: unsigned long


decompiled_code:
int __fastcall dbg_print_list(_QWORD *a1)
{
__int64 v1; // rax
__int64 i; // rbx
char *v3; // rax

puts("List Dump");
if ( *a1 && a1[1] )
{
if ( list_is_empty(a1) )
{
LODWORD(v1) = puts("List is empty.");
}
else
{
for ( i = list_begin(a1); ; i = list_next(i) )
{
v1 = list_end(a1);
if ( i == v1 )
break;
v3 = (char *)list_get(i);
printf("%c\n", (unsigned int)*v3);
}
}
}
else
{
LODWORD(v1) = puts("No list found.");
}
return v1;
}

canonical_decompiled_code:
int __fastcall func16(_QWORD *a1)
{
__int64 v1; // rax
__int64 i; // rbx
char *v3; // rax

puts("List Dump");
if ( *a1 && a1[1] )
{
if ( func9(a1) )
{
LODWORD(v1) = puts("List is empty.");
}
else
{
for ( i = func1(a1); ; i = func3(i) )
{
v1 = func2(a1);
if ( i == v1 )
break;
v3 = (char *)func5(i);
printf("%c\n", (unsigned int)*v3);
}
}
}
else
{
LODWORD(v1) = puts("No list found.");
}
return v1;
}

original_code:
void dbg_print_list(list* lst) {
 printf("List Dump\n");
 if (lst->head == ((void *)0) || lst->tail == ((void *)0)) {
  printf("No list found.\n");
 }
 else if (list_is_empty(lst)) {
  printf("List is empty.\n");
 }
 else{
  for (iterator it = list_begin(lst); it != list_end(lst); it = list_next(it)) {
   printf("%c\n", *(char*)list_get(it));
  }
 }
}

canonical_original_code:
void dbg_print_list(struct _list *lst) {
 printf("List Dump\n");
 if (lst->head == ((void *)0) || lst->tail == ((void *)0)) {
  printf("No list found.\n");
 }
 else if (list_is_empty(lst)) {
  printf("List is empty.\n");
 }
 else{
  for (struct _node *it = list_begin(lst); it != list_end(lst); it = list_next(it)) {
   printf("%c\n", *(char *)list_get(it));
  }
 }
}


decompiled_code:
__int64 __fastcall helper_push_queue(__int64 a1, char a2)
{
_BYTE *v2; // rax

v2 = malloc(1uLL);
*v2 = a2;
return queue_push(a1, v2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, char a2)
{
_BYTE *v2; // rax

v2 = malloc(1uLL);
*v2 = a2;
return queue_push(a1, v2);
}

original_code:
void helper_push_queue(queue* que, char c) {
 char* mem;
 mem = malloc(sizeof(char));
 *mem = c;
 queue_push(que, mem);
}

canonical_original_code:
void helper_push_queue(struct _queue *que, char c) {
 char *mem;
 mem = malloc(sizeof(char));
 *mem = c;
 queue_push(que, mem);
}

variable_types: struct _queue { struct _list { struct _node { struct _node *next; struct _node *previous; void *data; } *head; struct _node *tail; unsigned long size; } lst_queue; } *

variable_types: c char

variable_types:
mem
char *

user_defined_types: struct _queue { struct _list lst_queue; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
_BYTE *v4; // rax
_BYTE *v5; // rax
_BYTE *v6; // rax
_BYTE *v7; // rax
__int64 v8; // rax
__int64 v9; // rax
_BYTE *v10; // rax
_BYTE *v11; // rax
__int64 v12; // rax
__int64 v13; // rax
char *v14; // rbx
char *v15; // rax
_BYTE v17[32]; // [rsp+0h] [rbp-48h] BYREF
char v18[40]; // [rsp+20h] [rbp-28h] BYREF

list_init(v18, argv, envp);
v3 = list_size(v18);
printf("size: %d\n", v3);
v4 = malloc(1uLL);
*v4 = 121;
list_push_front(v18, v4);
v5 = malloc(1uLL);
*v5 = 97;
list_push_front(v18, v5);
v6 = malloc(1uLL);
*v6 = 114;
list_push_front(v18, v6);
v7 = malloc(1uLL);
*v7 = 103;
list_push_front(v18, v7);
v8 = list_begin(v18);
list_advance(v8, 2LL);
dbg_print_list(v18);
list_clear(v18);
v9 = list_size(v18);
printf("size: %d\n", v9);
dbg_print_list(v18);
v10 = malloc(1uLL);
*v10 = 120;
list_push_front(v18, v10);
v11 = malloc(1uLL);
*v11 = 122;
list_push_back(v18, v11);
v12 = list_size(v18);
printf("size: %d\n", v12);
dbg_print_list(v18);
list_delete(v18);
dbg_print_list(v18);
queue_init(v17);
helper_push_queue((__int64)v17, 100);
helper_push_queue((__int64)v17, 97);
helper_push_queue((__int64)v17, 116);
helper_push_queue((__int64)v17, 97);
v13 = queue_size(v17);
printf("queue size: %d\n", v13);
v14 = (char *)queue_front(v17);
v15 = (char *)queue_back(v17);
printf("%c, %c\n", (unsigned int)*v14, (unsigned int)*v15);
dbg_print_queue(v17);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
_BYTE *v4; // rax
_BYTE *v5; // rax
_BYTE *v6; // rax
_BYTE *v7; // rax
__int64 v8; // rax
__int64 v9; // rax
_BYTE *v10; // rax
_BYTE *v11; // rax
__int64 v12; // rax
__int64 v13; // rax
char *v14; // rbx
char *v15; // rax
_BYTE v17[32]; // [rsp+0h] [rbp-48h] BYREF
char v18[40]; // [rsp+20h] [rbp-28h] BYREF

list_init(v18, argv, envp);
v3 = list_size(v18);
printf("size: %d\n", v3);
v4 = malloc(1uLL);
*v4 = 121;
list_push_front(v18, v4);
v5 = malloc(1uLL);
*v5 = 97;
list_push_front(v18, v5);
v6 = malloc(1uLL);
*v6 = 114;
list_push_front(v18, v6);
v7 = malloc(1uLL);
*v7 = 103;
list_push_front(v18, v7);
v8 = list_begin(v18);
list_advance(v8, 2LL);
dbg_print_list(v18);
list_clear(v18);
v9 = list_size(v18);
printf("size: %d\n", v9);
dbg_print_list(v18);
v10 = malloc(1uLL);
*v10 = 120;
list_push_front(v18, v10);
v11 = malloc(1uLL);
*v11 = 122;
list_push_back(v18, v11);
v12 = list_size(v18);
printf("size: %d\n", v12);
dbg_print_list(v18);
list_delete(v18);
dbg_print_list(v18);
queue_init(v17);
func0((__int64)v17, 100);
func0((__int64)v17, 97);
func0((__int64)v17, 116);
func0((__int64)v17, 97);
v13 = queue_size(v17);
printf("queue size: %d\n", v13);
v14 = (char *)queue_front(v17);
v15 = (char *)queue_back(v17);
printf("%c, %c\n", (unsigned int)*v14, (unsigned int)*v15);
dbg_print_queue(v17);
return 0;
}

original_code:
int main()
{
 list lst;
 list_init(&lst);
 printf("size: %d\n", (int)list_size(&lst));
 char* c;
 c = malloc(sizeof(char));
 *c = 'y';
 list_push_front(&lst, c);
 c = malloc(sizeof(char));
 *c = 'a';
 list_push_front(&lst, c);
 c = malloc(sizeof(char));
 *c = 'r';
 list_push_front(&lst, c);
 c = malloc(sizeof(char));
 *c = 'g';
 list_push_front(&lst, c);
 iterator it;
 it = list_begin(&lst);
 it = list_advance(it, 2);
 dbg_print_list(&lst);
 list_clear(&lst);
 printf("size: %d\n", (int)list_size(&lst));
 dbg_print_list(&lst);
 char* chr = malloc(sizeof(char));
 *chr = 'x';
 list_push_front(&lst, chr);
 chr = malloc(sizeof(char));
 *chr = 'z';
 list_push_back(&lst, chr);
 printf("size: %d\n", (int)list_size(&lst));
 dbg_print_list(&lst);
 list_delete(&lst);
 dbg_print_list(&lst);
 queue q;
 queue_init(&q);
 helper_push_queue(&q, 'd');
 helper_push_queue(&q, 'a');
 helper_push_queue(&q, 't');
 helper_push_queue(&q, 'a');
 printf("queue size: %d\n", (int)queue_size(&q));
 char* c1 = (char*)queue_front(&q);
 char* c2 = (char*)queue_back(&q);
 printf("%c, %c\n", *c1, *c2);
 dbg_print_queue(&q);
 return 0;
}

canonical_original_code:
int main()
{
 struct _list lst;
 list_init(&lst);
 printf("size: %d\n", (int)list_size(&lst));
 char *c;
 c = malloc(sizeof(char));
 *c = 'y';
 list_push_front(&lst, c);
 c = malloc(sizeof(char));
 *c = 'a';
 list_push_front(&lst, c);
 c = malloc(sizeof(char));
 *c = 'r';
 list_push_front(&lst, c);
 c = malloc(sizeof(char));
 *c = 'g';
 list_push_front(&lst, c);
 struct _node *it;
 it = list_begin(&lst);
 it = list_advance(it, 2);
 dbg_print_list(&lst);
 list_clear(&lst);
 printf("size: %d\n", (int)list_size(&lst));
 dbg_print_list(&lst);
 char *chr = malloc(sizeof(char));
 *chr = 'x';
 list_push_front(&lst, chr);
 chr = malloc(sizeof(char));
 *chr = 'z';
 list_push_back(&lst, chr);
 printf("size: %d\n", (int)list_size(&lst));
 dbg_print_list(&lst);
 list_delete(&lst);
 dbg_print_list(&lst);
 struct _queue q;
 queue_init(&q);
 helper_push_queue(&q, 'd');
 helper_push_queue(&q, 'a');
 helper_push_queue(&q, 't');
 helper_push_queue(&q, 'a');
 printf("queue size: %d\n", (int)queue_size(&q));
 char *c1 = (char*)queue_front(&q);
 char *c2 = (char*)queue_back(&q);
 printf("%c, %c\n", *c1, *c2);
 dbg_print_queue(&q);
 return 0;
}

variable_types:
c
char *

variable_types:
chr
char *

variable_types: struct _queue { struct _list { struct _node { struct _node *next; struct _node *previous; void *data; } *head; struct _node *tail; unsigned long size; } lst_queue; }


decompiled_code:
__int64 __fastcall queue_init(__m128i *a1)
{
__int64 result; // rax
__m128i v2; // [rsp+0h] [rbp-28h] BYREF
__int64 v3; // [rsp+10h] [rbp-18h]

result = list_init(&v2);
if ( (_DWORD)result != 1 )
{
*a1 = _mm_loadu_si128(&v2);
a1[1].m128i_i64[0] = v3;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__m128i *a1)
{
__int64 result; // rax
__m128i v2; // [rsp+0h] [rbp-28h] BYREF
__int64 v3; // [rsp+10h] [rbp-18h]

result = list_init(&v2);
if ( (_DWORD)result != 1 )
{
*a1 = _mm_loadu_si128(&v2);
a1[1].m128i_i64[0] = v3;
result = 0LL;
}
return result;
}

original_code:
err_code queue_init(queue* q) {
 list lst;
 if (list_init(&lst) == 1) {
  return 1;
 }
 else {
  q->lst_queue = lst;
  return 0;
 }
}

canonical_original_code:
enum _config_error queue_init(struct _queue *q) {
 struct _list lst;
 if (list_init(&lst) == 1) {
  return 1;
 }
 else {
  q->lst_queue = lst;
  return 0;
 }
}

variable_types: struct _list { struct _node { struct _node *next; struct _node *previous; void *data; } *head; struct _node *tail; unsigned long size; }


decompiled_code:
__int64 queue_front()
{
return list_get_front();
}

canonical_decompiled_code:
__int64 func1()
{
return list_get_front();
}

original_code:
void* queue_front(const queue* q) {
 return list_get_front(&q->lst_queue);
}

canonical_original_code:
void *queue_front(struct _queue *q) {
 return list_get_front(&q->lst_queue);
}


decompiled_code:
__int64 queue_back()
{
return list_get_rear();
}

canonical_decompiled_code:
__int64 func2()
{
return list_get_rear();
}

original_code:
void* queue_back(const queue* q) {
 return list_get_rear(&q->lst_queue);
}

canonical_original_code:
void *queue_back(struct _queue *q) {
 return list_get_rear(&q->lst_queue);
}


decompiled_code:
__int64 queue_push()
{
return list_push_back();
}

canonical_decompiled_code:
__int64 func3()
{
return list_push_back();
}

original_code:
err_code queue_push(queue* q, const void* const data) {
 return list_push_back(&q->lst_queue, data);
}

canonical_original_code:
enum _config_error queue_push(struct _queue *q, void *data) {
 return list_push_back(&q->lst_queue, data);
}


decompiled_code:
__int64 __fastcall queue_pop(__int64 a1)
{
__int64 v1; // rax

list_get_front();
v1 = list_begin(a1);
return list_erase(a1, v1);
}

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

list_get_front();
v1 = list_begin(a1);
return list_erase(a1, v1);
}

original_code:
void queue_pop(queue* q) {
 list_get_front(&q->lst_queue);
 list_erase(&q->lst_queue, list_begin(&q->lst_queue));
}

canonical_original_code:
void queue_pop(struct _queue *q) {
 list_get_front(&q->lst_queue);
 list_erase(&q->lst_queue, list_begin(&q->lst_queue));
}


decompiled_code:
_BOOL8 queue_is_empty()
{
return (unsigned int)list_is_empty() != 0;
}

canonical_decompiled_code:
_BOOL8 func5()
{
return (unsigned int)list_is_empty() != 0;
}

original_code:
int queue_is_empty(queue* q) {
 if (list_is_empty(&q->lst_queue)) {
  return 1;
 }
 else {
  return 0;
 }
}

canonical_original_code:
int queue_is_empty(struct _queue *q) {
 if (list_is_empty(&q->lst_queue)) {
  return 1;
 }
 else {
  return 0;
 }
}


decompiled_code:
__int64 __fastcall queue_size(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
size_t queue_size(const queue* const q) {
 return q->lst_queue.size;
}

canonical_original_code:
unsigned long queue_size(struct _queue *q) {
 return q->lst_queue.size;
}


decompiled_code:
__int64 dbg_print_queue()
{
return dbg_print_list();
}

canonical_decompiled_code:
__int64 func7()
{
return dbg_print_list();
}

original_code:
void dbg_print_queue(queue*q) {
 dbg_print_list(&q->lst_queue);
}

canonical_original_code:
void dbg_print_queue(struct _queue *q) {
 dbg_print_list(&q->lst_queue);
}


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

*a1 = 0;
result = SDL_GetTicks();
a1[1] = result;
return result;
}

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

*a1 = 0;
result = SDL_GetTicks();
a1[1] = result;
return result;
}

original_code:
void init_timer(timer* timer)
{
  timer->DT = 0;
  timer->last = SDL_GetTicks();
}

canonical_original_code:
void init_timer(struct _timer *timer)
{
  timer->DT = 0;
  timer->last = SDL_GetTicks();
}

variable_types: struct _timer { unsigned int DT; unsigned int last; } *


decompiled_code:
__int64 __fastcall set_delay_timer(_DWORD *a1, unsigned __int8 a2)
{
__int64 result; // rax

*a1 = a2;
result = SDL_GetTicks();
a1[1] = result;
return result;
}

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

*a1 = a2;
result = SDL_GetTicks();
a1[1] = result;
return result;
}

original_code:
void set_delay_timer(timer* timer, unsigned char delay)
{
  timer->DT = delay;
  timer->last = SDL_GetTicks();
}

canonical_original_code:
void set_delay_timer(struct _timer *timer, unsigned char delay)
{
  timer->DT = delay;
  timer->last = SDL_GetTicks();
}

variable_types:
delay
unsigned char

user_defined_types: struct _timer { unsigned int DT; unsigned int last; }


decompiled_code:
__int64 __fastcall get_delay_timer(unsigned int *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1)
{
return *a1;
}

original_code:
unsigned char get_delay_timer(timer* timer)
{
  return timer->DT;
}

canonical_original_code:
unsigned char get_delay_timer(struct _timer *timer)
{
  return timer->DT;
}

return_type: unsigned char


decompiled_code:
void __fastcall update_timer(_DWORD *a1)
{
if ( *a1 )
{
if ( (float)(int)(SDL_GetTicks() - a1[1]) > 16.666666 )
{
--*a1;
a1[1] = SDL_GetTicks();
}
}
}

canonical_decompiled_code:
void __fastcall func3(_DWORD *a1)
{
if ( *a1 )
{
if ( (float)(int)(SDL_GetTicks() - a1[1]) > 16.666666 )
{
--*a1;
a1[1] = SDL_GetTicks();
}
}
}

original_code:
void update_timer(timer* timer)
{
  if (timer->DT > 0) {
    if ((SDL_GetTicks() - timer->last) > (1000.0f / 60.0f)) {
      timer->DT -= 1;
      timer->last = SDL_GetTicks();
    }
  }
}

canonical_original_code:
void update_timer(struct _timer *timer)
{
  if (timer->DT > 0) {
    if ((SDL_GetTicks() - timer->last) > (1000.0f / 60.0f)) {
      timer->DT -= 1;
      timer->last = SDL_GetTicks();
    }
  }
}


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

*a1 = 0;
result = SDL_GetTicks();
a1[1] = result;
return result;
}

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

*a1 = 0;
result = SDL_GetTicks();
a1[1] = result;
return result;
}

original_code:
void init_sound_timer(sound_timer* timer)
{
  timer->ST = 0;
  timer->last = SDL_GetTicks();
}

canonical_original_code:
void init_sound_timer(struct _sound_timer *timer)
{
  timer->ST = 0;
  timer->last = SDL_GetTicks();
}

variable_types: struct _sound_timer { unsigned int ST; unsigned int last; } *


decompiled_code:
__int64 __fastcall set_sound_timer(_DWORD *a1, unsigned __int8 a2)
{
__int64 result; // rax

*a1 = a2;
result = SDL_GetTicks();
a1[1] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1, unsigned __int8 a2)
{
__int64 result; // rax

*a1 = a2;
result = SDL_GetTicks();
a1[1] = result;
return result;
}

original_code:
void set_sound_timer(sound_timer* timer, unsigned char sound_for)
{
  timer->ST = sound_for;
  timer->last = SDL_GetTicks();
}

canonical_original_code:
void set_sound_timer(struct _sound_timer *timer, unsigned char sound_for)
{
  timer->ST = sound_for;
  timer->last = SDL_GetTicks();
}

user_defined_types: struct _sound_timer { unsigned int ST; unsigned int last; }


decompiled_code:
void __fastcall update_sound_timer(_DWORD *a1)
{
if ( *a1 )
{
if ( (float)(int)(SDL_GetTicks() - a1[1]) > 16.666666 )
{
--*a1;
a1[1] = SDL_GetTicks();
}
}
}

canonical_decompiled_code:
void __fastcall func6(_DWORD *a1)
{
if ( *a1 )
{
if ( (float)(int)(SDL_GetTicks() - a1[1]) > 16.666666 )
{
--*a1;
a1[1] = SDL_GetTicks();
}
}
}

original_code:
void update_sound_timer(sound_timer* timer)
{
  if (timer->ST > 0) {
    if ((SDL_GetTicks() - timer->last) > (1000.0f / 60.0f)) {
      timer->ST -= 1;
      timer->last = SDL_GetTicks();
    }
  }
}

canonical_original_code:
void update_sound_timer(struct _sound_timer *timer)
{
  if (timer->ST > 0) {
    if ((SDL_GetTicks() - timer->last) > (1000.0f / 60.0f)) {
      timer->ST -= 1;
      timer->last = SDL_GetTicks();
    }
  }
}


decompiled_code:
__int64 __fastcall get_sprite_at(int a1)
{
return (unsigned int)(40 * a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
return (unsigned int)(40 * a1);
}

original_code:
unsigned char get_sprite_at(unsigned char vx) {
  unsigned char sprite_width = 8 * 5;
  return sprite_width * vx;
}

variable_types:
vx
unsigned char


initVars

repo: greenlsi/randmem

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

runTime = LC0;
numexecs = 1;
integer = 1;
serial = 1;
usermemsize = 0LL;
result = LC2;
blockmemsize = LC2;
read = 1;
return result;
}

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

runTime = LC0;
numexecs = 1;
integer = 1;
serial = 1;
usermemsize = 0LL;
result = LC2;
blockmemsize = LC2;
read = 1;
return result;
}

original_code:
void initVars(void)
{
    runTime = 0.1;
    numexecs = 1;
    integer=1;
    serial=1;
    usermemsize=0;
    blockmemsize=( 2.0 * 1024 * 1024 * 1024 / 4 );
    read=1;
}

canonical_original_code:
void initVars()
{
    runTime = 0.1;
    numexecs = 1;
    integer=1;
    serial=1;
    usermemsize=0;
    blockmemsize=( 2.0 * 1024 * 1024 * 1024 / 4 );
    read=1;
}


parseArguments

decompiled_code:
__int64 __fastcall parseArguments(int a1, const char **a2)
{
const char **v3; // rbx
__int64 v4; // rbp
const char *v5; // rdx
bool v6; // al
bool v7; // cf
bool v8; // zf
const char *v9; // rdi
__int64 v10; // rcx
const char *v11; // rsi

if ( a1 <= 1 )
return 0LL;
v3 = a2 + 1;
v4 = (__int64)&a2[(unsigned int)(a1 - 2) + 2];
do
{
v5 = *v3;
if ( !strcmp(*v3, "--help") )
{
printf(
"Usage: %s --pattern=<pattern type> --data=<data type> --access=<read/write access> --memsize=<mem size in GB> --"
"blocksize=<memory block size (KB)> --runtime=<runtime in secs> --numexecs=<number of executions>\n",
*a2);
puts(" - pattern: test to run, can be 'serial' or 'random'");
puts(" - data: type of data to run, can be 'integer' or 'intfp'");
puts(" - access: type of access to memory, can be 'r' or 'rw'");
puts(" - memsize: memory size in GB to use");
puts(" - blocksize: maximum size of each memory block (in KB)");
puts(" - runtime: minimum time to run benchmark (in secs) ");
puts(" - numexecs: Number of times the benchmark is executed ");
exit(0);
}
if ( !strcmp(*v3, "--pattern=random") )
{
serial = 0;
}
else if ( !strcmp(*v3, "--pattern=serial") )
{
serial = 1;
}
else if ( !strcmp(*v3, "--access=rw") )
{
read = 0;
}
else if ( !strcmp(*v3, "--data=integer") )
{
integer = 1;
}
else if ( !strcmp(*v3, "--data=intfp") )
{
integer = 0;
}
else if ( !memcmp(*v3, "--memsize=", 0xAuLL) )
{
usermemsize = atof(v5 + 10);
}
else if ( !memcmp(*v3, "--blocksize=", 0xCuLL) )
{
blockmemsize = atof(v5 + 12);
}
else
{
v6 = memcmp(*v3, "--runtime=", 0xAuLL) != 0;
v7 = 0;
v8 = !v6;
if ( v6 )
{
v9 = "--numexecs=";
v10 = 11LL;
v11 = *v3;
do
{
if ( !v10 )
break;
v7 = *v11 < (unsigned int)*v9;
v8 = *v11++ == *v9++;
--v10;
}
while ( v8 );
if ( (!v7 && !v8) != v7 )
{
printf((const char *)stderr, "unrecognised argument %s\n", v5, v10);
return 0xFFFFFFFFLL;
}
numexecs = atoi(v5 + 11);
}
else
{
runTime = atof(v5 + 10);
}
}
++v3;
}
while ( v3 != (const char **)v4 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, const char **a2)
{
const char **v3; // rbx
__int64 v4; // rbp
const char *v5; // rdx
bool v6; // al
bool v7; // cf
bool v8; // zf
const char *v9; // rdi
__int64 v10; // rcx
const char *v11; // rsi

if ( a1 <= 1 )
return 0LL;
v3 = a2 + 1;
v4 = (__int64)&a2[(unsigned int)(a1 - 2) + 2];
do
{
v5 = *v3;
if ( !strcmp(*v3, "--help") )
{
printf(
"Usage: %s --pattern=<pattern type> --data=<data type> --access=<read/write access> --memsize=<mem size in GB> --"
"blocksize=<memory block size (KB)> --runtime=<runtime in secs> --numexecs=<number of executions>\n",
*a2);
puts(" - pattern: test to run, can be 'serial' or 'random'");
puts(" - data: type of data to run, can be 'integer' or 'intfp'");
puts(" - access: type of access to memory, can be 'r' or 'rw'");
puts(" - memsize: memory size in GB to use");
puts(" - blocksize: maximum size of each memory block (in KB)");
puts(" - runtime: minimum time to run benchmark (in secs) ");
puts(" - numexecs: Number of times the benchmark is executed ");
exit(0);
}
if ( !strcmp(*v3, "--pattern=random") )
{
serial = 0;
}
else if ( !strcmp(*v3, "--pattern=serial") )
{
serial = 1;
}
else if ( !strcmp(*v3, "--access=rw") )
{
read = 0;
}
else if ( !strcmp(*v3, "--data=integer") )
{
integer = 1;
}
else if ( !strcmp(*v3, "--data=intfp") )
{
integer = 0;
}
else if ( !memcmp(*v3, "--memsize=", 0xAuLL) )
{
usermemsize = atof(v5 + 10);
}
else if ( !memcmp(*v3, "--blocksize=", 0xCuLL) )
{
blockmemsize = atof(v5 + 12);
}
else
{
v6 = memcmp(*v3, "--runtime=", 0xAuLL) != 0;
v7 = 0;
v8 = !v6;
if ( v6 )
{
v9 = "--numexecs=";
v10 = 11LL;
v11 = *v3;
do
{
if ( !v10 )
break;
v7 = *v11 < (unsigned int)*v9;
v8 = *v11++ == *v9++;
--v10;
}
while ( v8 );
if ( (!v7 && !v8) != v7 )
{
printf((const char *)stderr, "unrecognised argument %s\n", v5, v10);
return 0xFFFFFFFFLL;
}
numexecs = atoi(v5 + 11);
}
else
{
runTime = atof(v5 + 10);
}
}
++v3;
}
while ( v3 != (const char **)v4 );
return 0LL;
}

original_code:
int parseArguments (int argc, char **argv)
{
     int i;
     for(i=1; i < argc; i++) {
         if (strcmp(argv[i], "--help") == 0) {
            printf("Usage: %s --pattern=<pattern type> --data=<data type> --access=<read/write access> --memsize=<mem size in GB> --blocksize=<memory block size (KB)> --runtime=<runtime in secs> --numexecs=<number of executions>\n", argv[0]);
            printf("    - pattern: test to run, can be 'serial' or 'random'\n");
            printf("    - data: type of data to run, can be 'integer' or 'intfp'\n");
            printf("    - access: type of access to memory, can be 'r' or 'rw'\n");
            printf("    - memsize: memory size in GB to use\n");
            printf("    - blocksize: maximum size of each memory block (in KB)\n");
            printf("    - runtime: minimum time to run benchmark (in secs) \n");
            printf("    - numexecs: Number of times the benchmark is executed \n");
            exit(0);
         }
         else if (strcmp(argv[i], "--pattern=random") == 0) {
            serial=0;
         }
         else if (strcmp(argv[i], "--pattern=serial") == 0) {
            serial=1;
         }
         else if (strcmp(argv[i], "--access=rw") == 0) {
            read=0;
         }
         else if (strcmp(argv[i], "--data=integer") == 0) {
            integer=1;
         }
         else if (strcmp(argv[i], "--data=intfp") == 0) {
            integer=0;
         }
         else if (! strncmp(argv[i], "--memsize=", 10) ) {
            usermemsize = atof(argv[i]+10);
         }
         else if (! strncmp(argv[i], "--blocksize=", 12) ) {
            blockmemsize = atof(argv[i]+12);
         }
         else if (! strncmp(argv[i], "--runtime=", 10) ) {
            runTime = atof(argv[i]+10);
         }
         else if (! strncmp(argv[i], "--numexecs=", 11) ) {
            numexecs = atoi(argv[i]+11);
         }
         else {
             printf(stderr, "unrecognised argument %s\n", argv[i]);
             return -1;
         }
    }
    return 0;
}

canonical_original_code:
int parseArguments(int argc, char **argv)
{
     int i;
     for(i=1; i < argc; i++) {
         if (strcmp(argv[i], "--help") == 0) {
            printf("Usage: %s --pattern=<pattern type> --data=<data type> --access=<read/write access> --memsize=<mem size in GB> --blocksize=<memory block size (KB)> --runtime=<runtime in secs> --numexecs=<number of executions>\n", argv[0]);
            printf("    - pattern: test to run, can be 'serial' or 'random'\n");
            printf("    - data: type of data to run, can be 'integer' or 'intfp'\n");
            printf("    - access: type of access to memory, can be 'r' or 'rw'\n");
            printf("    - memsize: memory size in GB to use\n");
            printf("    - blocksize: maximum size of each memory block (in KB)\n");
            printf("    - runtime: minimum time to run benchmark (in secs) \n");
            printf("    - numexecs: Number of times the benchmark is executed \n");
            exit(0);
         }
         else if (strcmp(argv[i], "--pattern=random") == 0) {
            serial=0;
         }
         else if (strcmp(argv[i], "--pattern=serial") == 0) {
            serial=1;
         }
         else if (strcmp(argv[i], "--access=rw") == 0) {
            read=0;
         }
         else if (strcmp(argv[i], "--data=integer") == 0) {
            integer=1;
         }
         else if (strcmp(argv[i], "--data=intfp") == 0) {
            integer=0;
         }
         else if (! strncmp(argv[i], "--memsize=", 10) ) {
            usermemsize = atof(argv[i]+10);
         }
         else if (! strncmp(argv[i], "--blocksize=", 12) ) {
            blockmemsize = atof(argv[i]+12);
         }
         else if (! strncmp(argv[i], "--runtime=", 10) ) {
            runTime = atof(argv[i]+10);
         }
         else if (! strncmp(argv[i], "--numexecs=", 11) ) {
            numexecs = atoi(argv[i]+11);
         }
         else {
             printf(stderr, "unrecognised argument %s\n", argv[i]);
             return -1;
         }
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int


decompiled_code:
int print_output_header()
{
const char *v0; // rbx

v0 = (const char *)(unsigned int)((_DWORD)&configdata + 200);
do
{
puts(v0);
v0 += 200;
}
while ( v0 != (const char *)(unsigned int)((_DWORD)&configdata + 1400) );
putchar(10);
puts(" #####################################################");
local_time();
printf("\n Random/Serial Memory Test %s %s \n", "Solaris Bit Version 3", (const char *)&timeday);
printf("\n Benchmark runtime: %f \n", *(double *)&runTime);
return printf("\n Number of executions : %d \n", (unsigned int)numexecs);
}

canonical_decompiled_code:
int func2()
{
const char *v0; // rbx

v0 = (const char *)(unsigned int)((_DWORD)&configdata + 200);
do
{
puts(v0);
v0 += 200;
}
while ( v0 != (const char *)(unsigned int)((_DWORD)&configdata + 1400) );
putchar(10);
puts(" #####################################################");
local_time();
printf("\n Random/Serial Memory Test %s %s \n", "Solaris Bit Version 3", (const char *)&timeday);
printf("\n Benchmark runtime: %f \n", *(double *)&runTime);
return printf("\n Number of executions : %d \n", (unsigned int)numexecs);
}

original_code:
void print_output_header( void )
{
    int i, g;
    for (i=1; i<7; i++) {
        printf("%s\n", configdata[i]);
    }
    printf("\n");
    printf(" #####################################################\n");
    local_time();
    printf("\n   Random/Serial Memory Test %s %s \n", "Solaris Bit Version 3", timeday);
    printf("\n   Benchmark runtime: %f \n", runTime);
    printf("\n   Number of executions : %d \n", numexecs);
}

canonical_original_code:
void print_output_header()
{
    int i; int g;
    for (i=1; i<7; i++) {
        printf("%s\n", configdata[i]);
    }
    printf("\n");
    printf(" #####################################################\n");
    local_time();
    printf("\n   Random/Serial Memory Test %s %s \n", "Solaris Bit Version 3", timeday);
    printf("\n   Benchmark runtime: %f \n", runTime);
    printf("\n   Number of executions : %d \n", numexecs);
}

variable_types: g int


decompiled_code:
int print_benchmark_params()
{
if ( integer )
puts(" Integer");
else
puts(" Double/Integer");
if ( serial )
puts(" Serial........");
else
puts(" Random........");
if ( read )
puts(" Exec Pass RAM Read ");
else
puts(" Exec Pass RAM Rd/Wrt ");
return puts(" KB MB/Sec \n");
}

canonical_decompiled_code:
int func3()
{
if ( integer )
puts(" Integer");
else
puts(" Double/Integer");
if ( serial )
puts(" Serial........");
else
puts(" Random........");
if ( read )
puts(" Exec Pass RAM Read ");
else
puts(" Exec Pass RAM Rd/Wrt ");
return puts(" KB MB/Sec \n");
}

original_code:
void print_benchmark_params( void )
{
    if (integer){
        printf("             Integer\n");
    }
    else {
       printf("                 Double/Integer\n");
    }
    if(serial){
        printf("             Serial........\n");
    }
    else{
        printf("            Random........\n");
    }
    if (read){
        printf("   Exec   Pass      RAM   Read   \n");
        printf("                KB  MB/Sec  \n\n");
    }
    else {
        printf("   Exec   Pass    RAM   Rd/Wrt   \n");
        printf("                KB  MB/Sec  \n\n");
    }
}

canonical_original_code:
void print_benchmark_params()
{
    if (integer){
        printf("             Integer\n");
    }
    else {
       printf("                 Double/Integer\n");
    }
    if(serial){
        printf("             Serial........\n");
    }
    else{
        printf("            Random........\n");
    }
    if (read){
        printf("   Exec   Pass      RAM   Read   \n");
        printf("                KB  MB/Sec  \n\n");
    }
    else {
        printf("   Exec   Pass    RAM   Rd/Wrt   \n");
        printf("                KB  MB/Sec  \n\n");
    }
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er15
int v4; // ebx
double v5; // xmm0_8
__int64 v6; // rdx
__m128d v8; // xmm0
void *v9; // rax
void *v10; // r12
void *v11; // rax
int v12; // er13
int v13; // er15
__int64 v14; // rbp
__int64 i; // rbx
__int64 j; // rbx
int v17; // [rsp+4h] [rbp-814h]
int v18; // [rsp+8h] [rbp-810h]
void *v19[257]; // [rsp+10h] [rbp-808h]

initVars(argc, argv, envp);
parseArguments(argc, argv);
putchar(10);
getDetails();
if ( *(double *)&usermemsize == 0.0 )
{
if ( ramGB <= 2.0 )
{
usermemsize = ramGB;
printf(" User did not define memory size. Defaulting to %f \n", ramGB);
}
else
{
usermemsize = LC39;
printf(" User did not define memory size. Memory size exceeds maximum. Defaulting to %f \n", *(double *)&LC39);
}
}
else if ( *(double *)&usermemsize > ramGB )
{
*(_QWORD *)&v8.m128d_f64[0] = LC39;
v8.m128d_f64[0] = _mm_cmplt_sd(v8, (__m128d)ramGB).m128d_f64[0];
usermemsize = LC39 & *(_QWORD *)&v8.m128d_f64[0] | ~*(_QWORD *)&v8.m128d_f64[0] & ramGB;
printf("Memory required by user exceeds maximum of %f.\n Defaultint to %f GB", *(double *)&LC39, ramGB);
}
print_output_header();
v3 = (int)(*(double *)&usermemsize * 1024.0 * 1024.0 * 1024.0 * 0.25);
v18 = v3;
v4 = (int)(*(double *)&blockmemsize * 1024.0 * 1024.0 * 0.25);
v5 = *(double *)&usermemsize;
printf(
" Total memory to allocate %f and size of memory blocks %f \n",
*(double *)&usermemsize,
*(double *)&blockmemsize);
if ( v3 <= v4 )
{
printf(" Number of blocks to allocate: %d and remainder memory: %d \n", 0LL, (unsigned int)v3);
puts(" Trying to allocate desired memory space ");
v17 = 0;
}
else
{
v6 = (unsigned int)(v3 >> 31);
LODWORD(v6) = v3 % v4;
v17 = v3 / v4;
v18 = v3 % v4;
printf(" Number of blocks to allocate: %d and remainder memory: %d \n", (unsigned int)(v3 / v4), v6);
puts(" Trying to allocate desired memory space ");
if ( v3 / v4 < 0 )
{
puts("\n");
puts(" #####################################################\n");
printf(" Running benchmark \n\n ");
print_benchmark_params();
LABEL_7:
putchar(10);
fflush(stdout);
goto LABEL_8;
}
}
v12 = 0;
v13 = 0;
do
{
if ( v13 == v17 )
{
if ( !v18 )
break;
v4 = v18;
}
if ( integer )
{
while ( 1 )
{
printf(" Trying %d contiguous KB... ", (unsigned int)(4 * (v4 / 0x100000)));
v9 = calloc(v4 + 2, 4uLL);
v19[v12 + 100] = v9;
if ( v9 )
break;
puts(" Cannot allocate ");
v4 /= 2;
}
}
else
{
while ( 1 )
{
printf(" Trying %7d contiguous KB... ", (unsigned int)(v4 / 256));
v10 = malloc(4 * (v4 / 3) + 8);
v19[v12 + 100] = v10;
v11 = malloc(8 * (v4 / 3) + 8);
v19[v12] = v11;
if ( v11 )
{
if ( v10 )
break;
}
puts(" Cannot allocate ");
if ( v4 <= 0 )
{
puts(" All memory used. Cannot allocate anymore");
goto LABEL_22;
}
v4 /= 2;
}
}
puts(" Allocation OK ");
*((_DWORD *)&v19[200] + v12++) = v4;
LABEL_22:
++v13;
}
while ( v13 <= v17 );
puts("\n");
puts(" #####################################################\n");
printf(" Running benchmark \n\n ");
print_benchmark_params();
if ( v12 <= 0 )
goto LABEL_7;
v14 = (unsigned int)(v12 - 1);
for ( i = 0LL; ; ++i )
{
if ( integer )
execute_integer_benchmark(*((unsigned int *)&v19[200] + i), v19[i + 100], (unsigned int)numexecs);
else
execute_intfp_benchmark(*((unsigned int *)&v19[200] + i), v19[i + 100], v19[i], (unsigned int)numexecs);
printf(" %d %d %7.0f \n", 0LL, (unsigned int)i, v5);
fflush(stdout);
if ( v14 == i )
break;
}
putchar(10);
fflush(stdout);
for ( j = 0LL; ; ++j )
{
if ( integer )
{
free(v19[j + 100]);
}
else
{
free(v19[j + 100]);
free(v19[j]);
}
if ( v14 == j )
break;
}
LABEL_8:
local_time();
putchar(10);
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er15
int v4; // ebx
double v5; // xmm0_8
__int64 v6; // rdx
__m128d v8; // xmm0
void *v9; // rax
void *v10; // r12
void *v11; // rax
int v12; // er13
int v13; // er15
__int64 v14; // rbp
__int64 i; // rbx
__int64 j; // rbx
int v17; // [rsp+4h] [rbp-814h]
int v18; // [rsp+8h] [rbp-810h]
void *v19[257]; // [rsp+10h] [rbp-808h]

func0(argc, argv, envp);
func1(argc, argv);
putchar(10);
getDetails();
if ( *(double *)&usermemsize == 0.0 )
{
if ( ramGB <= 2.0 )
{
usermemsize = ramGB;
printf(" User did not define memory size. Defaulting to %f \n", ramGB);
}
else
{
usermemsize = LC39;
printf(" User did not define memory size. Memory size exceeds maximum. Defaulting to %f \n", *(double *)&LC39);
}
}
else if ( *(double *)&usermemsize > ramGB )
{
*(_QWORD *)&v8.m128d_f64[0] = LC39;
v8.m128d_f64[0] = _mm_cmplt_sd(v8, (__m128d)ramGB).m128d_f64[0];
usermemsize = LC39 & *(_QWORD *)&v8.m128d_f64[0] | ~*(_QWORD *)&v8.m128d_f64[0] & ramGB;
printf("Memory required by user exceeds maximum of %f.\n Defaultint to %f GB", *(double *)&LC39, ramGB);
}
func2();
v3 = (int)(*(double *)&usermemsize * 1024.0 * 1024.0 * 1024.0 * 0.25);
v18 = v3;
v4 = (int)(*(double *)&blockmemsize * 1024.0 * 1024.0 * 0.25);
v5 = *(double *)&usermemsize;
printf(
" Total memory to allocate %f and size of memory blocks %f \n",
*(double *)&usermemsize,
*(double *)&blockmemsize);
if ( v3 <= v4 )
{
printf(" Number of blocks to allocate: %d and remainder memory: %d \n", 0LL, (unsigned int)v3);
puts(" Trying to allocate desired memory space ");
v17 = 0;
}
else
{
v6 = (unsigned int)(v3 >> 31);
LODWORD(v6) = v3 % v4;
v17 = v3 / v4;
v18 = v3 % v4;
printf(" Number of blocks to allocate: %d and remainder memory: %d \n", (unsigned int)(v3 / v4), v6);
puts(" Trying to allocate desired memory space ");
if ( v3 / v4 < 0 )
{
puts("\n");
puts(" #####################################################\n");
printf(" Running benchmark \n\n ");
func3();
LABEL_7:
putchar(10);
fflush(stdout);
goto LABEL_8;
}
}
v12 = 0;
v13 = 0;
do
{
if ( v13 == v17 )
{
if ( !v18 )
break;
v4 = v18;
}
if ( integer )
{
while ( 1 )
{
printf(" Trying %d contiguous KB... ", (unsigned int)(4 * (v4 / 0x100000)));
v9 = calloc(v4 + 2, 4uLL);
v19[v12 + 100] = v9;
if ( v9 )
break;
puts(" Cannot allocate ");
v4 /= 2;
}
}
else
{
while ( 1 )
{
printf(" Trying %7d contiguous KB... ", (unsigned int)(v4 / 256));
v10 = malloc(4 * (v4 / 3) + 8);
v19[v12 + 100] = v10;
v11 = malloc(8 * (v4 / 3) + 8);
v19[v12] = v11;
if ( v11 )
{
if ( v10 )
break;
}
puts(" Cannot allocate ");
if ( v4 <= 0 )
{
puts(" All memory used. Cannot allocate anymore");
goto LABEL_22;
}
v4 /= 2;
}
}
puts(" Allocation OK ");
*((_DWORD *)&v19[200] + v12++) = v4;
LABEL_22:
++v13;
}
while ( v13 <= v17 );
puts("\n");
puts(" #####################################################\n");
printf(" Running benchmark \n\n ");
func3();
if ( v12 <= 0 )
goto LABEL_7;
v14 = (unsigned int)(v12 - 1);
for ( i = 0LL; ; ++i )
{
if ( integer )
execute_integer_benchmark(*((unsigned int *)&v19[200] + i), v19[i + 100], (unsigned int)numexecs);
else
execute_intfp_benchmark(*((unsigned int *)&v19[200] + i), v19[i + 100], v19[i], (unsigned int)numexecs);
printf(" %d %d %7.0f \n", 0LL, (unsigned int)i, v5);
fflush(stdout);
if ( v14 == i )
break;
}
putchar(10);
fflush(stdout);
for ( j = 0LL; ; ++j )
{
if ( integer )
{
free(v19[j + 100]);
}
else
{
free(v19[j + 100]);
free(v19[j]);
}
if ( v14 == j )
break;
}
LABEL_8:
local_time();
putchar(10);
return 1;
}

original_code:
int main( int argc, char *argv[] )
{
    int i,j, g, m, k;
    double results;
    int num_malloc=0, malloc_size[100], malloc_flag=0;
    int *xi[100];
    double *xd[100];
    int arraymax , darraymax;
    int arraymodule=0, arrayrem=0, blockarraysize, dbarraysize;
    struct rlimit limit ;
    initVars();
    parseArguments(argc, argv);
    printf("\n");
    getDetails();
    if (usermemsize == 0){
        if ( ramGB > 2.0 ){
            usermemsize= 2.0 ;
            printf("  User did not define memory size. Memory size exceeds maximum. Defaulting to %f \n", 2.0);
        }
        else {
            usermemsize=ramGB;
            printf("  User did not define memory size. Defaulting to %f \n", usermemsize);
        }
    }
    else if (usermemsize > ramGB) {
        if ( ramGB > 2.0 ){
            usermemsize= 2.0 ;
        }
        else {
            usermemsize=ramGB;
        }
        printf("Memory required by user exceeds maximum of %f.\n Defaultint to %f GB", (double) 2.0, ramGB);
    }
    print_output_header( );
    results = 0;
    arraymax = usermemsize * 1024 * 1024 * 1024 / 4 ;
    blockarraysize = blockmemsize * 1024 * 1024 / 4 ;
    printf("   Total memory to allocate %f and size of memory blocks %f \n", usermemsize, blockmemsize );
    if (blockarraysize < arraymax){
        arraymodule = arraymax / blockarraysize ;
        arrayrem = arraymax % blockarraysize ;
    }
    else {
        arrayrem=arraymax;
    }
    printf("   Number of blocks to allocate: %d and remainder memory: %d \n", arraymodule, arrayrem);
    printf("   Trying to allocate desired memory space \n");
    for (m=0 ; m<= arraymodule ; m++){
        if ( m == arraymodule ) {
            if (arrayrem){
                blockarraysize=arrayrem ;
            }
            else{
                break;
            }
        }
        if (integer){
            malloc_flag=0;
            do{
                printf("      Trying %d contiguous KB... ", (int) (blockarraysize / 1024 / 1024 * 4) );
                xi[num_malloc] = (int *) calloc (blockarraysize + 2 , 4 );
                if (xi[num_malloc] == ((void *)0)) {
                   printf(" Cannot allocate \n");
                   blockarraysize/=2;
                }
                else {
                   printf(" Allocation OK \n");
                   malloc_flag=1;
                   malloc_size[num_malloc]=blockarraysize;
                   num_malloc++;
                }
            } while (!malloc_flag);
        }
        else {
            malloc_flag=0;
            do{
                printf("      Trying %7d contiguous KB... ", blockarraysize * 4 / 1024);
                dbarraysize = blockarraysize / 3;
                xi[num_malloc] = (int *)malloc(dbarraysize * 4 + 8);
                xd[num_malloc] = (double *)malloc(dbarraysize * 8 + 8);
                if ( (xi[num_malloc] == ((void *)0)) || (xd[num_malloc] == ((void *)0)) ) {
                   printf(" Cannot allocate \n");
                   if (blockarraysize > 0) {
                        blockarraysize/=2;
                   }
                   else {
                       printf(" All memory used. Cannot allocate anymore\n");
                       break;
                   }
                }
                else {
                   printf(" Allocation OK \n");
                   malloc_flag=1;
                   malloc_size[num_malloc]=blockarraysize;
                   num_malloc++;
                }
            } while (!malloc_flag);
        }
    }
    printf("\n\n");
    printf(" #####################################################\n\n");
    printf("  Running benchmark \n\n ");
    print_benchmark_params();
    for (m=0 ; m< num_malloc ; m++){
        if (integer) {
            results = execute_integer_benchmark( malloc_size[m], xi[m], numexecs );
        }
        else {
            results = execute_intfp_benchmark( malloc_size[m], xi[m], xd[m], numexecs );
        }
        printf("     %d     %d    %7.0f \n", k, m, results);
        fflush(stdout);
    }
    printf("\n");
    fflush(stdout);
    for (m=0 ; m< num_malloc ; m++){
        if (integer){
            free(xi[m]);
        }
        else {
            free(xi[m]);
            free(xd[m]);
        }
    }
    local_time();
    printf("\n");
    return 1;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int i; int j; int g; int m; int k;
    double results;
    int num_malloc = 0; int malloc_size[100]; int malloc_flag = 0;
    int *xi[100];
    double *xd[100];
    int arraymax; int darraymax;
    int arraymodule = 0; int arrayrem = 0; int blockarraysize; int dbarraysize;
    struct rlimit limit;
    initVars();
    parseArguments(argc, argv);
    printf("\n");
    getDetails();
    if (usermemsize == 0){
        if ( ramGB > 2.0 ){
            usermemsize= 2.0 ;
            printf("  User did not define memory size. Memory size exceeds maximum. Defaulting to %f \n", 2.0);
        }
        else {
            usermemsize=ramGB;
            printf("  User did not define memory size. Defaulting to %f \n", usermemsize);
        }
    }
    else if (usermemsize > ramGB) {
        if ( ramGB > 2.0 ){
            usermemsize= 2.0 ;
        }
        else {
            usermemsize=ramGB;
        }
        printf("Memory required by user exceeds maximum of %f.\n Defaultint to %f GB", (double) 2.0, ramGB);
    }
    print_output_header( );
    results = 0;
    arraymax = usermemsize * 1024 * 1024 * 1024 / 4 ;
    blockarraysize = blockmemsize * 1024 * 1024 / 4 ;
    printf("   Total memory to allocate %f and size of memory blocks %f \n", usermemsize, blockmemsize );
    if (blockarraysize < arraymax){
        arraymodule = arraymax / blockarraysize ;
        arrayrem = arraymax % blockarraysize ;
    }
    else {
        arrayrem=arraymax;
    }
    printf("   Number of blocks to allocate: %d and remainder memory: %d \n", arraymodule, arrayrem);
    printf("   Trying to allocate desired memory space \n");
    for (m=0 ; m<= arraymodule ; m++){
        if ( m == arraymodule ) {
            if (arrayrem){
                blockarraysize=arrayrem ;
            }
            else{
                break;
            }
        }
        if (integer){
            malloc_flag=0;
            do{
                printf("      Trying %d contiguous KB... ", (int) (blockarraysize / 1024 / 1024 * 4) );
                xi[num_malloc] = (int *) calloc (blockarraysize + 2 , 4 );
                if (xi[num_malloc] == ((void *)0)) {
                   printf(" Cannot allocate \n");
                   blockarraysize/=2;
                }
                else {
                   printf(" Allocation OK \n");
                   malloc_flag=1;
                   malloc_size[num_malloc]=blockarraysize;
                   num_malloc++;
                }
            } while (!malloc_flag);
        }
        else {
            malloc_flag=0;
            do{
                printf("      Trying %7d contiguous KB... ", blockarraysize * 4 / 1024);
                dbarraysize = blockarraysize / 3;
                xi[num_malloc] = (int *)malloc(dbarraysize * 4 + 8);
                xd[num_malloc] = (double *)malloc(dbarraysize * 8 + 8);
                if ( (xi[num_malloc] == ((void *)0)) || (xd[num_malloc] == ((void *)0)) ) {
                   printf(" Cannot allocate \n");
                   if (blockarraysize > 0) {
                        blockarraysize/=2;
                   }
                   else {
                       printf(" All memory used. Cannot allocate anymore\n");
                       break;
                   }
                }
                else {
                   printf(" Allocation OK \n");
                   malloc_flag=1;
                   malloc_size[num_malloc]=blockarraysize;
                   num_malloc++;
                }
            } while (!malloc_flag);
        }
    }
    printf("\n\n");
    printf(" #####################################################\n\n");
    printf("  Running benchmark \n\n ");
    print_benchmark_params();
    for (m=0 ; m< num_malloc ; m++){
        if (integer) {
            results = execute_integer_benchmark( malloc_size[m], xi[m], numexecs );
        }
        else {
            results = execute_intfp_benchmark( malloc_size[m], xi[m], xd[m], numexecs );
        }
        printf("     %d     %d    %7.0f \n", k, m, results);
        fflush(stdout);
    }
    printf("\n");
    fflush(stdout);
    for (m=0 ; m< num_malloc ; m++){
        if (integer){
            free(xi[m]);
        }
        else {
            free(xi[m]);
            free(xd[m]);
        }
    }
    local_time();
    printf("\n");
    return 1;
}

variable_types:
argv
char *[]

variable_types: j int

variable_types: m int

variable_types: k int

variable_types: results double

variable_types:
xd
double *[100]

variable_types: arraymax int

variable_types: darraymax int

variable_types: arraymodule int

variable_types: arrayrem int

variable_types: blockarraysize int

variable_types: dbarraysize int

variable_types: struct rlimit { unsigned long rlim_cur; unsigned long rlim_max; }


decompiled_code:
char *local_time()
{
struct tm *v0; // rax
char *v1; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
v1 = asctime(v0);
return strcpy(timeday, v1);
}

canonical_decompiled_code:
char *func0()
{
struct tm *v0; // rax
char *v1; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
v1 = asctime(v0);
return strcpy(timeday, v1);
}

original_code:
void local_time()
  {
     time_t t;
     t = time(((void *)0));
     sprintf(timeday, "%s", asctime(localtime(&t)));
     return;
  }

canonical_original_code:
void local_time()
  {
     long t;
     t = time(((void *)0));
     sprintf(timeday, "%s", asctime(localtime(&t)));
     return;
  }

variable_types: t long


getSecs

decompiled_code:
int getSecs()
{
int result; // eax

result = clock_gettime(0, &tp1);
*(double *)&theseSecs = (double)(int)tp1.tv_nsec / 1000000000.0 + (double)SLODWORD(tp1.tv_sec);
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax

result = clock_gettime(0, &tp1);
*(double *)&theseSecs = (double)(int)tp1.tv_nsec / 1000000000.0 + (double)SLODWORD(tp1.tv_sec);
return result;
}

original_code:
void getSecs()
  {
     clock_gettime(0, &tp1);
     theseSecs = tp1.tv_sec + tp1.tv_nsec / 1e9;
     return;
  }


decompiled_code:
int start_time()
{
int result; // eax

result = getSecs();
startSecs = theseSecs;
return result;
}

canonical_decompiled_code:
int func2()
{
int result; // eax

result = func1();
startSecs = theseSecs;
return result;
}

original_code:
void start_time()
  {
      getSecs();
      startSecs = theseSecs;
      return;
  }


decompiled_code:
__int64 end_time()
{
double v0; // xmm0_8
__int64 result; // rax

getSecs();
*(double *)&secs = *(double *)&theseSecs - *(double *)&startSecs;
v0 = (*(double *)&theseSecs - *(double *)&startSecs) * 1000.0;
result = (unsigned int)(int)v0;
millisecs = (int)v0;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
double v0; // xmm0_8
__int64 result; // rax

func1();
*(double *)&secs = *(double *)&theseSecs - *(double *)&startSecs;
v0 = (*(double *)&theseSecs - *(double *)&startSecs) * 1000.0;
result = (unsigned int)(int)v0;
millisecs = (int)v0;
return result;
}

original_code:
void end_time()
  {
      getSecs();
      secs = theseSecs - startSecs;
      millisecs = (int)(1000.0 * secs);
      return;
  }


decompiled_code:
__int64 func_b()
{
__int64 v0; // rbx

v0 = memleak_alloc(256LL, "memleak_test.c", 16LL);
memleak_alloc(128LL, "memleak_test.c", 17LL);
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbx

v0 = memleak_alloc(256LL, "memleak_test.c", 16LL);
memleak_alloc(128LL, "memleak_test.c", 17LL);
return v0;
}

original_code:
void *func_b()
{
    void *ptr_a;
    void *ptr_b;
    ptr_a = (void *)memleak_alloc(256, "memleak_test.c", 16);
    ptr_b = (void *)memleak_alloc(128, "memleak_test.c", 17);
    return ptr_a;
}


decompiled_code:
__int64 func_a()
{
__int64 v0; // rax

memleak_alloc(64LL, "memleak_test.c", 24LL);
v0 = func_b();
return memleak_free(v0, "memleak_test.c", 25LL);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rax

memleak_alloc(64LL, "memleak_test.c", 24LL);
v0 = func0();
return memleak_free(v0, "memleak_test.c", 25LL);
}

original_code:
void func_a()
{
    void *ptr;
    ptr = (void *)memleak_alloc(64, "memleak_test.c", 24);
    memleak_free(func_b(), "memleak_test.c", 25);
}

variable_types:
ptr
void *


decompiled_code:
__int64 basic_test()
{
__int64 v0; // rbp
__int64 v1; // rbx
__int64 v2; // rax
char v4[32]; // [rsp+8h] [rbp-20h] BYREF

memleak_alloc(2LL, "memleak_test.c", 37LL);
memleak_start();
v0 = memleak_calloc(0LL, 1LL, "memleak_test.c", 41LL);
v1 = memleak_alloc(8LL, "memleak_test.c", 42LL);
v2 = memleak_alloc(4LL, "memleak_test.c", 43LL);
memleak_realloc(v2, 96LL);
memleak_posix_memalign(v4, 512LL, 512LL, "memleak_test.c", 46LL);
func_a();
memleak_free(v0, "memleak_test.c", 50LL);
memleak_free(v1, "memleak_test.c", 51LL);
return memleak_end();
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbp
__int64 v1; // rbx
__int64 v2; // rax
char v4[32]; // [rsp+8h] [rbp-20h] BYREF

memleak_alloc(2LL, "memleak_test.c", 37LL);
memleak_start();
v0 = memleak_calloc(0LL, 1LL, "memleak_test.c", 41LL);
v1 = memleak_alloc(8LL, "memleak_test.c", 42LL);
v2 = memleak_alloc(4LL, "memleak_test.c", 43LL);
memleak_realloc(v2, 96LL);
memleak_posix_memalign(v4, 512LL, 512LL, "memleak_test.c", 46LL);
func1();
memleak_free(v0, "memleak_test.c", 50LL);
memleak_free(v1, "memleak_test.c", 51LL);
return memleak_end();
}

original_code:
void basic_test()
{
    uint8_t *a;
    uint64_t *b;
    uint32_t *c;
    uint16_t *d;
    void *str;
    int ret;
    d = memleak_alloc(sizeof(uint16_t), "memleak_test.c", 37);
    memleak_start();
    a = (uint8_t*)memleak_calloc(0, sizeof(uint8_t), "memleak_test.c", 41);
    b = (uint64_t*)memleak_alloc(sizeof(uint64_t), "memleak_test.c", 42);
    c = (uint32_t*)memleak_alloc(sizeof(uint32_t), "memleak_test.c", 43);
    c = (uint32_t*)memleak_realloc(c, sizeof(uint32_t)*24);;
    ret = memleak_posix_memalign(&str, 512, 512, "memleak_test.c", 46);
    func_a();
    memleak_free(a, "memleak_test.c", 50);
    memleak_free(b, "memleak_test.c", 51);
    memleak_end();
}

canonical_original_code:
void basic_test()
{
    unsigned char *a;
    unsigned long *b;
    unsigned int *c;
    unsigned short *d;
    void *str;
    int ret;
    d = memleak_alloc(sizeof(unsigned short), "memleak_test.c", 37);
    memleak_start();
    a = (unsigned char *)memleak_calloc(0, sizeof(unsigned char), "memleak_test.c", 41);
    b = (unsigned long *)memleak_alloc(sizeof(unsigned long), "memleak_test.c", 42);
    c = (unsigned int *)memleak_alloc(sizeof(unsigned int), "memleak_test.c", 43);
    c = (unsigned int *)memleak_realloc(c, sizeof(unsigned int)*24);;
    ret = memleak_posix_memalign(&str, 512, 512, "memleak_test.c", 46);
    func_a();
    memleak_free(a, "memleak_test.c", 50);
    memleak_free(b, "memleak_test.c", 51);
    memleak_end();
}

variable_types:
a
unsigned char *

variable_types:
b
unsigned long *

variable_types:
c
unsigned int *

variable_types:
d
unsigned short *

variable_types:
str
void *

variable_types: ret int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
basic_test(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func2(argc, argv, envp);
return 0;
}

original_code:
int main()
{
    basic_test();
    return 0;
}

canonical_original_code:
int main()
{
    basic_test();
    return 0;
}


decompiled_code:
__int64 __fastcall avl_first(__int64 *a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = *a1;
if ( !*a1 )
return 0LL;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = *a1;
if ( !*a1 )
return 0LL;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
return v2;
}

original_code:
struct avl_node* avl_first(struct avl_tree *tree)
{
    struct avl_node *p = ((void *)0);
    struct avl_node *node = tree->root;
    while(node) {
        p = node;
        node = node->left;
    }
    return p;
}

canonical_original_code:
struct avl_node *avl_first(struct avl_tree *tree)
{
    struct avl_node *p = ((void *)0);
    struct avl_node *node = tree->root;
    while(node) {
        p = node;
        node = node->left;
    }
    return p;
}

variable_types: struct avl_tree { struct avl_node *root; void *aux; } *

variable_types: struct avl_node { struct avl_node *parent; } *


decompiled_code:
__int64 __fastcall avl_last(__int64 *a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = *a1;
if ( !*a1 )
return 0LL;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
return v2;
}

original_code:
struct avl_node* avl_last(struct avl_tree *tree)
{
    struct avl_node *p = ((void *)0);
    struct avl_node *node = tree->root;
    while(node) {
        p = node;
        node = node->right;
    }
    return p;
}

canonical_original_code:
struct avl_node *avl_last(struct avl_tree *tree)
{
    struct avl_node *p = ((void *)0);
    struct avl_node *node = tree->root;
    while(node) {
        p = node;
        node = node->right;
    }
    return p;
}

return_type: struct avl_node { struct avl_node *parent; } *

user_defined_types: struct avl_tree { struct avl_node *root; void *aux; }


original_code:
struct avl_node* avl_search(struct avl_tree *tree,
                            struct avl_node *node,
                            avl_cmp_func *func)
{
    struct avl_node *p = tree->root;
    int cmp;
    while(p)
    {
        cmp = func(p, node, tree->aux);
        if (cmp > 0) {
            p = p->left;
        }else if (cmp < 0){
            p = p->right;
        }else {
            return p;
        }
    }
    return ((void *)0);
}

canonical_original_code:
struct avl_node *avl_search(struct avl_tree *tree, struct avl_node *node, int (*func)(struct avl_node *a, struct avl_node *b, void *aux))
{
    struct avl_node *p = tree->root;
    int cmp;
    while(p)
    {
        cmp = func(p, node, tree->aux);
        if (cmp > 0) {
            p = p->left;
        }else if (cmp < 0){
            p = p->right;
        }else {
            return p;
        }
    }
    return ((void *)0);
}

variable_types:
node
struct avl_node *

variable_types: int (*)(struct avl_node *a, struct avl_node *b, void *aux)

variable_types: cmp int

user_defined_types: struct avl_node { struct avl_node *parent; }


original_code:
void avl_remove(struct avl_tree *tree,
                struct avl_node *node)
{
    ;
    if (node == ((void *)0)) return;
    struct avl_tree right_subtree;
    struct avl_node *p=((void *)0),*cur, *next=((void *)0);
    int bf = 0, bf_old;
    right_subtree.root = node->right;
    next = avl_first(&right_subtree);
    if (next) {
        if (((struct avl_node *)((unsigned long)(next)->parent & ~0x3))) {
            if (((struct avl_node *)((unsigned long)(next)->parent & ~0x3)) != node) {
                ((struct avl_node *)((unsigned long)(next)->parent & ~0x3))->left = next->right;
                if (next->right)
                    avl_set_parent(next->right, ((struct avl_node *)((unsigned long)(next)->parent & ~0x3)));
            }
        }
        if (((struct avl_node *)((unsigned long)(node)->parent & ~0x3))) {
            if (((struct avl_node *)((unsigned long)(node)->parent & ~0x3))->left == node) {
                ((struct avl_node *)((unsigned long)(node)->parent & ~0x3))->left = next;
            } else {
                ((struct avl_node *)((unsigned long)(node)->parent & ~0x3))->right = next;
            }
        }
        if (node->right != next) {
            next->right = node->right;
            if (node->right) avl_set_parent(node->right, next);
            cur = ((struct avl_node *)((unsigned long)(next)->parent & ~0x3));
            bf = 1;
        }else{
            cur = next;
            bf = -1;
        }
        next->left = node->left;
        if (node->left) avl_set_parent(node->left, next);
        avl_set_parent(next, ((struct avl_node *)((unsigned long)(node)->parent & ~0x3)));
        avl_set_bf(next, (((int)((unsigned long)(node)->parent & 0x3)) - 1));
    } else {
        p = ((struct avl_node *)((unsigned long)(node)->parent & ~0x3));
        if (p) {
            if (p->left == node) {
                p->left = node->left;
                bf = 1;
            } else {
                p->right = node->left;
                bf = -1;
            }
        }
        if (node->left)
            avl_set_parent(node->left, p);
        cur = ((struct avl_node *)((unsigned long)(node)->parent & ~0x3));
    }
    if (tree->root == node) {
        tree->root = next;
        if (next == ((void *)0)) {
            if (node->left) tree->root = node->left;
        }
    }
    while(cur) {
        p = ((struct avl_node *)((unsigned long)(cur)->parent & ~0x3));
        if (p) {
            bf_old = (((int)((unsigned long)(cur)->parent & 0x3)) - 1);
            if (p->right == cur) {
                cur = _balance_tree(cur, bf);
                p->right = cur;
            }else {
                cur = _balance_tree(cur, bf);
                p->left = cur;
            }
            if (cur->left == ((void *)0) && cur->right == ((void *)0)) {
                if (p->left == cur) bf = 1;
                else bf = -1;
            } else {
                bf = 0;
                if (_abs(bf_old) > _abs((((int)((unsigned long)(cur)->parent & 0x3)) - 1))) {
                    if (p->left == cur) bf = 1;
                    else bf = -1;
                }
            }
        } else if(cur == tree->root){
            tree->root = _balance_tree(tree->root, bf);
            break;
        }
        if (bf == 0) break;
        cur = p;
    }
    ;
}

canonical_original_code:
void avl_remove(struct avl_tree *tree, struct avl_node *node)
{
    ;
    if (node == ((void *)0)) return;
    struct avl_tree right_subtree;
    struct avl_node *p = ((void *)0); struct avl_node *cur; struct avl_node *next = ((void *)0);
    int bf = 0; int bf_old;
    right_subtree.root = node->right;
    next = avl_first(&right_subtree);
    if (next) {
        if (((struct avl_node *)((unsigned long)(next)->parent & ~0x3))) {
            if (((struct avl_node *)((unsigned long)(next)->parent & ~0x3)) != node) {
                ((struct avl_node *)((unsigned long)(next)->parent & ~0x3))->left = next->right;
                if (next->right)
                    avl_set_parent(next->right, ((struct avl_node *)((unsigned long)(next)->parent & ~0x3)));
            }
        }
        if (((struct avl_node *)((unsigned long)(node)->parent & ~0x3))) {
            if (((struct avl_node *)((unsigned long)(node)->parent & ~0x3))->left == node) {
                ((struct avl_node *)((unsigned long)(node)->parent & ~0x3))->left = next;
            } else {
                ((struct avl_node *)((unsigned long)(node)->parent & ~0x3))->right = next;
            }
        }
        if (node->right != next) {
            next->right = node->right;
            if (node->right) avl_set_parent(node->right, next);
            cur = ((struct avl_node *)((unsigned long)(next)->parent & ~0x3));
            bf = 1;
        }else{
            cur = next;
            bf = -1;
        }
        next->left = node->left;
        if (node->left) avl_set_parent(node->left, next);
        avl_set_parent(next, ((struct avl_node *)((unsigned long)(node)->parent & ~0x3)));
        avl_set_bf(next, (((int)((unsigned long)(node)->parent & 0x3)) - 1));
    } else {
        p = ((struct avl_node *)((unsigned long)(node)->parent & ~0x3));
        if (p) {
            if (p->left == node) {
                p->left = node->left;
                bf = 1;
            } else {
                p->right = node->left;
                bf = -1;
            }
        }
        if (node->left)
            avl_set_parent(node->left, p);
        cur = ((struct avl_node *)((unsigned long)(node)->parent & ~0x3));
    }
    if (tree->root == node) {
        tree->root = next;
        if (next == ((void *)0)) {
            if (node->left) tree->root = node->left;
        }
    }
    while(cur) {
        p = ((struct avl_node *)((unsigned long)(cur)->parent & ~0x3));
        if (p) {
            bf_old = (((int)((unsigned long)(cur)->parent & 0x3)) - 1);
            if (p->right == cur) {
                cur = _balance_tree(cur, bf);
                p->right = cur;
            }else {
                cur = _balance_tree(cur, bf);
                p->left = cur;
            }
            if (cur->left == ((void *)0) && cur->right == ((void *)0)) {
                if (p->left == cur) bf = 1;
                else bf = -1;
            } else {
                bf = 0;
                if (_abs(bf_old) > _abs((((int)((unsigned long)(cur)->parent & 0x3)) - 1))) {
                    if (p->left == cur) bf = 1;
                    else bf = -1;
                }
            }
        } else if(cur == tree->root){
            tree->root = _balance_tree(tree->root, bf);
            break;
        }
        if (bf == 0) break;
        cur = p;
    }
    ;
}

variable_types: struct avl_tree { struct avl_node { struct avl_node *parent; } *root; void *aux; } *

variable_types: bf int


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

lock = 1;
result = avl_init(&tree_index, 0LL);
start_sw = 1;
return result;
}

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

lock = 1;
result = avl_init(&tree_index, 0LL);
start_sw = 1;
return result;
}

original_code:
void memleak_start()
{
    lock = (pthread_spinlock_t)(1);
    avl_init(&tree_index, ((void *)0));
    start_sw = 1;
}