decompiled_code:
char *__fastcall fasta_title(const char *a1)
{
return strchr(a1, 10) + 1;
}

canonical_decompiled_code:
char *__fastcall func2(const char *a1)
{
return strchr(a1, 10) + 1;
}

original_code:
char *
fasta_title (char *full)
{
  char *ptr;
  ptr = strchr (full, '\n');
  return ptr + 1;
}

canonical_original_code:
char *fasta_title(char *full)
{
  char *ptr;
  ptr = strchr (full, '\n');
  return ptr + 1;
}

variable_types:
full
char *

variable_types:
ptr
char *


repo: tzcoolman/FACS-OLD

original_code:
void
fastq_add (bloom * bl, char *position)
{
  char *key = (char *) malloc (bl->k_mer * sizeof (char) + 1);
  while (position[0] != '\0')
    {
      position = strchr (position, '\n') + 1;
      while (position[bl->k_mer - 1] != '\n') {
       memcpy (key, position, sizeof (char) * bl->k_mer);
       key[bl->k_mer] = '\0';
       bloom_add (bl, key);
       position++;
      }
      position += bl->k_mer;
      position = strchr (position, '\n') + 1;
      char *v = strchr (position, '\n');
      if (!v) break;
      else position = v + 1;
    }
  free (key);
}

canonical_original_code:
void fastq_add(struct bloom *bl, char *position)
{
  char *key = (char *) malloc (bl->k_mer * sizeof (char) + 1);
  while (position[0] != '\0')
    {
      position = strchr (position, '\n') + 1;
      while (position[bl->k_mer - 1] != '\n') {
       memcpy (key, position, sizeof (char) * bl->k_mer);
       key[bl->k_mer] = '\0';
       bloom_add (bl, key);
       position++;
      }
      position += bl->k_mer;
      position = strchr (position, '\n') + 1;
      char *v = strchr (position, '\n');
      if (!v) break;
      else position = v + 1;
    }
  free (key);
}

variable_types: struct bloom { char *vector; unsigned long long (*hash)(char *str); unsigned long long inserts; struct bloomstat { unsigned long long elements; int ideal_hashes; unsigned long long capacity; double e; } stat; int k_mer; int dx; float mcf; } *

variable_types:
position
char *

variable_types:
key
char *

variable_types:
v
char *

return_type: void

user_defined_types: struct bloom { char *vector; unsigned long long (*hash)(char *str); unsigned long long inserts; struct bloomstat stat; int k_mer; int dx; float mcf; }


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

for ( result = (unsigned __int8)*a2; (_BYTE)result; result = (unsigned __int8)*a2 )
{
if ( (_BYTE)result == 62 )
a2 = fasta_title(a2);
else
a2 = fasta_data(a1, a2);
}
return result;
}

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

for ( result = (unsigned __int8)*a2; (_BYTE)result; result = (unsigned __int8)*a2 )
{
if ( (_BYTE)result == 62 )
a2 = func2(a2);
else
a2 = func4(a1, a2);
}
return result;
}

original_code:
void
fasta_add (bloom * bl, char *position)
{
  while (*position != '\0')
    {
      if (*position == '>')
       position = fasta_title (position);
      else
       position = fasta_data (bl, position);
    }
}

canonical_original_code:
void fasta_add(struct bloom *bl, char *position)
{
  while (*position != '\0')
    {
      if (*position == '>')
       position = fasta_title (position);
      else
       position = fasta_data (bl, position);
    }
}

user_defined_types: struct bloomstat { unsigned long long elements; int ideal_hashes; unsigned long long capacity; double e; }


decompiled_code:
void __fastcall ref_add(__int64 a1, char *a2)
{
if ( *a2 == 62 )
{
fasta_add(a1, a2);
}
else
{
if ( *a2 != 64 )
{
perror("wrong format\n");
exit(-1);
}
fastq_add(a1, a2);
}
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1, char *a2)
{
if ( *a2 == 62 )
{
func5(a1, a2);
}
else
{
if ( *a2 != 64 )
{
perror("wrong format\n");
exit(-1);
}
func3(a1, a2);
}
}

original_code:
void ref_add (bloom * bl, char *position)
{
    if (*position == '>')
        fasta_add (bl, position);
    else if (*position == '@')
        fastq_add (bl, position);
    else
    {
        perror ("wrong format\n");
        exit (-1);
    }
}

canonical_original_code:
void ref_add(struct bloom *bl, char *position)
{
    if (*position == '>')
        fasta_add (bl, position);
    else if (*position == '@')
        fastq_add (bl, position);
    else
    {
        perror ("wrong format\n");
        exit (-1);
    }
}


build

decompiled_code:
__int64 __fastcall build(__int64 a1, __int64 a2, int a3, double a4)
{
char *v5; // r12
_DWORD *v6; // rax
__int64 v7; // rbx
__int64 v9; // rax

v5 = (char *)mmaping();
v6 = malloc(0x48uLL);
v7 = (__int64)v6;
if ( a3 )
{
v6[14] = a3;
}
else
{
v9 = get_size(a1);
*(_DWORD *)(v7 + 56) = kmer_suggestion(v9);
}
printf("k_mer->%d\n", *(unsigned int *)(v7 + 56));
*(double *)(v7 + 48) = a4;
*(_DWORD *)(v7 + 60) = dx_add(*(unsigned int *)(v7 + 56));
*(_QWORD *)(v7 + 40) = strlen(v5);
get_rec(v7 + 24);
bloom_init(v7, *(_QWORD *)(v7 + 24), *(_QWORD *)(v7 + 40), *(unsigned int *)(v7 + 32), 0LL, 3LL, *(double *)(v7 + 48));
ref_add(v7, v5);
save_bloom(a1, v7, 0LL, a2);
return 0LL;
}

original_code:
int
build(char *ref_name, char *target_path, int k_mer, double error_rate, char *prefix)
{
  char *position = mmaping (ref_name);
  bloom *bl = (bloom *) malloc(sizeof(bloom));
  if (k_mer!=0)
      bl->k_mer = k_mer;
  else
      bl->k_mer = kmer_suggestion(get_size(ref_name));
  printf ("k_mer->%d\n",bl->k_mer);
  bl->stat.e = error_rate;
  bl->dx = dx_add (bl->k_mer);
  bl->stat.capacity = strlen (position);
  get_rec (&bl->stat);
  bloom_init (bl, bl->stat.elements, bl->stat.capacity, bl->stat.e,
       bl->stat.ideal_hashes, ((void *)0), 3);
  ref_add (bl, position);
  save_bloom (ref_name, bl, ((void *)0), target_path);
  return 0;
}

canonical_original_code:
int build(char *ref_name, char *target_path, int k_mer, double error_rate, char *prefix)
{
  char *position = mmaping (ref_name);
  struct bloom *bl = (bloom *) malloc(sizeof(bloom));
  if (k_mer!=0)
      bl->k_mer = k_mer;
  else
      bl->k_mer = kmer_suggestion(get_size(ref_name));
  printf ("k_mer->%d\n",bl->k_mer);
  bl->stat.e = error_rate;
  bl->dx = dx_add (bl->k_mer);
  bl->stat.capacity = strlen (position);
  get_rec (&bl->stat);
  bloom_init (bl, bl->stat.elements, bl->stat.capacity, bl->stat.e,
       bl->stat.ideal_hashes, ((void *)0), 3);
  ref_add (bl, position);
  save_bloom (ref_name, bl, ((void *)0), target_path);
  return 0;
}

variable_types:
prefix
char *

return_type: int


decompiled_code:
__int64 __fastcall build_main(const char *argc, char **argv)
{
char *v2; // r15
char *v3; // r13
char *v4; // r14
unsigned int v5; // er12
int v6; // eax
__int64 result; // rax
float v8; // xmm2_4
__int64 v9; // rsi
void *v10; // rbx
_QWORD *v11; // rbp
__int64 *v12; // r14
__int64 v13; // rsi
size_t v14; // rsi
const char *v15; // rax
char *v16; // rbp
float v17; // [rsp+Ch] [rbp-3Ch]

if ( (int)argc <= 1 )
return build_usage(argc, argv);
printf("1st command->%s\n", *argv);
v2 = 0LL;
v3 = 0LL;
v4 = 0LL;
v17 = *(float *)&LC6;
v5 = 0;
while ( 2 )
{
v6 = getopt((int)argc, argv, "ek:o:r:lh");
if ( v6 == -1 )
{
printf("LIST IS %s\n", v4);
if ( v4 )
{
v10 = malloc(0x48uLL);
v11 = malloc(0x20uLL);
v11[3] = malloc(0x20uLL);
v12 = (__int64 *)make_list(v2, v4);
if ( v12 )
{
do
{
v15 = (const char *)mmaping(*v12);
v16 = (char *)v15;
if ( *v15 == 62 )
v13 = strlen(v15);
else
v13 = strlen(v15) >> 1;
init_bloom((__int64)v10, v17, v13, v5, *v12);
ref_add((__int64)v10, v16);
save_bloom(*v12, v10, 0LL, v3);
bloom_destroy(v10);
v14 = strlen(v16);
munmap(v16, v14);
v12 = (__int64 *)v12[6];
}
while ( v12 );
result = 0LL;
}
else
{
result = 0LL;
}
}
else
{
build((__int64)v2, (__int64)v3, v5, v17);
result = 0LL;
}
}
else
{
switch ( v6 )
{
case '?':
v9 = (unsigned int)(char)optopt;
printf("Unknown option: -%c\n", v9);
result = build_usage("Unknown option: -%c\n", v9);
break;
case 'e':
if ( optarg )
{
v8 = atof(optarg);
v17 = v8;
}
continue;
case 'h':
result = build_usage((const char *)(unsigned int)argc);
break;
case 'k':
if ( optarg )
v5 = atoi(optarg);
printf("k_mer->%d\n", v5);
continue;
case 'l':
if ( optarg )
v4 = optarg;
continue;
case 'o':
if ( optarg )
v3 = optarg;
continue;
case 'r':
if ( optarg )
v2 = optarg;
continue;
default:
continue;
}
}
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *argc, char **argv)
{
char *v2; // r15
char *v3; // r13
char *v4; // r14
unsigned int v5; // er12
int v6; // eax
__int64 result; // rax
float v8; // xmm2_4
__int64 v9; // rsi
void *v10; // rbx
_QWORD *v11; // rbp
__int64 *v12; // r14
__int64 v13; // rsi
size_t v14; // rsi
const char *v15; // rax
char *v16; // rbp
float v17; // [rsp+Ch] [rbp-3Ch]

if ( (int)argc <= 1 )
return func0(argc, argv);
printf("1st command->%s\n", *argv);
v2 = 0LL;
v3 = 0LL;
v4 = 0LL;
v17 = *(float *)&LC6;
v5 = 0;
while ( 2 )
{
v6 = getopt((int)argc, argv, "ek:o:r:lh");
if ( v6 == -1 )
{
printf("LIST IS %s\n", v4);
if ( v4 )
{
v10 = malloc(0x48uLL);
v11 = malloc(0x20uLL);
v11[3] = malloc(0x20uLL);
v12 = (__int64 *)make_list(v2, v4);
if ( v12 )
{
do
{
v15 = (const char *)mmaping(*v12);
v16 = (char *)v15;
if ( *v15 == 62 )
v13 = strlen(v15);
else
v13 = strlen(v15) >> 1;
func1((__int64)v10, v17, v13, v5, *v12);
func6((__int64)v10, v16);
save_bloom(*v12, v10, 0LL, v3);
bloom_destroy(v10);
v14 = strlen(v16);
munmap(v16, v14);
v12 = (__int64 *)v12[6];
}
while ( v12 );
result = 0LL;
}
else
{
result = 0LL;
}
}
else
{
func7((__int64)v2, (__int64)v3, v5, v17);
result = 0LL;
}
}
else
{
switch ( v6 )
{
case '?':
v9 = (unsigned int)(char)optopt;
printf("Unknown option: -%c\n", v9);
result = func0("Unknown option: -%c\n", v9);
break;
case 'e':
if ( optarg )
{
v8 = atof(optarg);
v17 = v8;
}
continue;
case 'h':
result = func0((const char *)(unsigned int)argc);
break;
case 'k':
if ( optarg )
v5 = atoi(optarg);
printf("k_mer->%d\n", v5);
continue;
case 'l':
if ( optarg )
v4 = optarg;
continue;
case 'o':
if ( optarg )
v3 = optarg;
continue;
case 'r':
if ( optarg )
v2 = optarg;
continue;
default:
continue;
}
}
break;
}
return result;
}

original_code:
int
build_main (int argc, char **argv)
{
  if (argc < 2) return build_usage();
  char *position;
  unsigned long long capacity;
  int opt;
  int k_mer = 0;
  float error_rate = 0.0005;
  char* list = ((void *)0);
  char* prefix = ((void *)0);
  char* target_path = ((void *)0);
  char* source = ((void *)0);
  printf ("1st command->%s\n",argv[0]);
  while ((opt = getopt (argc, argv, "ek:o:r:lh")) != -1) {
      switch (opt) {
          case 'e':
              (optarg) && ((error_rate = atof (optarg)), 1);
              break;
          case 'k':
              (optarg) && ((k_mer = atoi (optarg)), 1);
              printf ("k_mer->%d\n",k_mer);
              break;
          case 'o':
              (optarg) && ((target_path = optarg), 1);
              break;
          case 'r':
              (optarg) && (source = optarg, 1);
              break;
          case 'l':
              (optarg) && (list = optarg, 1);
              break;
          case 'h':
              return build_usage();
          case '?':
              printf ("Unknown option: -%c\n", (char) optopt);
              return build_usage();
      }
  }
  printf("LIST IS %s\n", list);
  if (!list) {
    build(source, target_path, k_mer, error_rate, ((void *)0));
  } else {
      bloom *bl_2 = (bloom *) malloc(sizeof(bloom));
      Queue *head = (Queue *) malloc(sizeof(Queue));
      Queue *tail = (Queue *) malloc(sizeof(Queue));
      head->next = tail;
      F_set *File_head = (F_set *) malloc(sizeof(F_set));
      File_head = make_list (source, list);
      while (File_head) {
          position = mmaping (File_head->filename);
          if (*position == '>')
            capacity = strlen (position);
          else
            capacity = strlen (position) / 2;
          init_bloom (bl_2, capacity, error_rate, k_mer, File_head->filename);
          ref_add (bl_2, position);
          save_bloom (File_head->filename, bl_2, prefix,target_path);
          bloom_destroy (bl_2);
          munmap (position, strlen (position));
          File_head = File_head->next;
    }
  }
  return 0;
}

canonical_original_code:
int build_main(int argc, char **argv)
{
  if (argc < 2) return build_usage();
  char *position;
  unsigned long long capacity;
  int opt;
  int k_mer = 0;
  float error_rate = 0.0005;
  char *list = ((void *)0);
  char *prefix = ((void *)0);
  char *target_path = ((void *)0);
  char *source = ((void *)0);
  printf ("1st command->%s\n",argv[0]);
  while ((opt = getopt (argc, argv, "ek:o:r:lh")) != -1) {
      switch (opt) {
          case 'e':
              (optarg) && ((error_rate = atof (optarg)), 1);
              break;
          case 'k':
              (optarg) && ((k_mer = atoi (optarg)), 1);
              printf ("k_mer->%d\n",k_mer);
              break;
          case 'o':
              (optarg) && ((target_path = optarg), 1);
              break;
          case 'r':
              (optarg) && (source = optarg, 1);
              break;
          case 'l':
              (optarg) && (list = optarg, 1);
              break;
          case 'h':
              return build_usage();
          case '?':
              printf ("Unknown option: -%c\n", (char) optopt);
              return build_usage();
      }
  }
  printf("LIST IS %s\n", list);
  if (!list) {
    build(source, target_path, k_mer, error_rate, ((void *)0));
  } else {
      struct bloom *bl_2 = (bloom *) malloc(sizeof(bloom));
      struct info *head = (Queue *) malloc(sizeof(Queue));
      struct info *tail = (Queue *) malloc(sizeof(Queue));
      head->next = tail;
      struct file_list *File_head = (F_set *) malloc(sizeof(F_set));
      File_head = make_list (source, list);
      while (File_head) {
          position = mmaping (File_head->filename);
          if (*position == '>')
            capacity = strlen (position);
          else
            capacity = strlen (position) / 2;
          init_bloom (bl_2, capacity, error_rate, k_mer, File_head->filename);
          ref_add (bl_2, position);
          save_bloom (File_head->filename, bl_2, prefix,target_path);
          bloom_destroy (bl_2);
          munmap (position, strlen (position));
          File_head = File_head->next;
    }
  }
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
capacity
unsigned long long

variable_types: opt int

variable_types:
list
char *

variable_types:
source
char *

variable_types: struct info { char *location; short *score; short *number; struct info *next; } *

variable_types: struct file_list { char *filename; short number; long long reads_num; long long reads_contam; long long hits; long long all_k; struct file_list *next; } *


decompiled_code:
void __fastcall fastq_process(__int64 a1, __int64 a2, char **a3, __int64 a4, float a5, float a6)
{
char *v6; // rbx
char **v8; // rax
char *v9; // r12
const char *v10; // rbx
char *v11; // rax
char *v12; // rax
char *v13; // rax
const char *v14; // rax

v6 = *(char **)a2;
if ( **(_BYTE **)a2 == 64 )
{
v8 = *(char ***)(a2 + 24);
if ( v8 == a3 || (v9 = *v8) == 0LL )
v9 = &v6[strlen(*(const char **)a2)];
while ( v6 != v9 )
{
v14 = (const char *)jump(v6, 2LL, a5);
if ( v6 == v14 )
{
_InterlockedAdd64((volatile signed __int64 *)(a4 + 16), 1uLL);
v10 = strchr(v14, 10) + 1;
v11 = strchr(v10, 10);
if ( (int)fastq_read_check(v10, v11 - v10, 110LL, a1, a4, a6) > 0 )
_InterlockedAdd64((volatile signed __int64 *)(a4 + 24), 1uLL);
v12 = strchr(v10, 10);
v13 = strchr(v12 + 1, 10);
v6 = strchr(v13 + 1, 10) + 1;
}
else
{
v6 = (char *)v14;
}
}
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, __int64 a2, char **a3, __int64 a4, float a5, float a6)
{
char *v6; // rbx
char **v8; // rax
char *v9; // r12
const char *v10; // rbx
char *v11; // rax
char *v12; // rax
char *v13; // rax
const char *v14; // rax

v6 = *(char **)a2;
if ( **(_BYTE **)a2 == 64 )
{
v8 = *(char ***)(a2 + 24);
if ( v8 == a3 || (v9 = *v8) == 0LL )
v9 = &v6[strlen(*(const char **)a2)];
while ( v6 != v9 )
{
v14 = (const char *)jump(v6, 2LL, a5);
if ( v6 == v14 )
{
_InterlockedAdd64((volatile signed __int64 *)(a4 + 16), 1uLL);
v10 = strchr(v14, 10) + 1;
v11 = strchr(v10, 10);
if ( (int)fastq_read_check(v10, v11 - v10, 110LL, a1, a4, a6) > 0 )
_InterlockedAdd64((volatile signed __int64 *)(a4 + 24), 1uLL);
v12 = strchr(v10, 10);
v13 = strchr(v12 + 1, 10);
v6 = strchr(v13 + 1, 10) + 1;
}
else
{
v6 = (char *)v14;
}
}
}
}

original_code:
void
fastq_process (bloom * bl, Queue * info, Queue *tail, F_set * File_head,
        float sampling_rate, float tole_rate)
{
  char *p = info->location;
  char *next = ((void *)0), *temp = ((void *)0), *temp_piece = ((void *)0);
  if (info->location[0] != '@') {
    return;
  } else if (info->next != tail && info->next->location!=((void *)0)) {
    next = info->next->location;
  } else {
    next = strchr (p, '\0');
  }
  while (p != next)
    {
      temp = jump (p, 2, sampling_rate);
      if (p != temp)
 {
   p = temp;
   continue;
 }

#pragma omp atomic
      File_head->reads_num++;
      p = strchr (p, '\n') + 1;
      if (fastq_read_check (p, strchr (p, '\n') - p, 'n', bl, tole_rate, File_head)> 0) {

#pragma omp atomic
 File_head->reads_contam++;
      }
      p = strchr (p, '\n') + 1;
      p = strchr (p, '\n') + 1;
      p = strchr (p, '\n') + 1;
    }
  if (temp_piece)
    free (temp_piece);
}

canonical_original_code:
void fastq_process(struct bloom *bl, struct info *info, struct info *tail, struct file_list *File_head, float sampling_rate, float tole_rate)
{
  char *p = info->location;
  char *next = ((void *)0); char *temp = ((void *)0); char *temp_piece = ((void *)0);
  if (info->location[0] != '@') {
    return;
  } else if (info->next != tail && info->next->location!=((void *)0)) {
    next = info->next->location;
  } else {
    next = strchr (p, '\0');
  }
  while (p != next)
    {
      temp = jump (p, 2, sampling_rate);
      if (p != temp)
 {
   p = temp;
   continue;
 }

#pragma omp atomic
      File_head->reads_num++;
      p = strchr (p, '\n') + 1;
      if (fastq_read_check (p, strchr (p, '\n') - p, 'n', bl, tole_rate, File_head)> 0) {

#pragma omp atomic
 File_head->reads_contam++;
      }
      p = strchr (p, '\n') + 1;
      p = strchr (p, '\n') + 1;
      p = strchr (p, '\n') + 1;
    }
  if (temp_piece)
    free (temp_piece);
}

variable_types:
tail
struct info *

variable_types:
p
char *

variable_types:
next
char *

variable_types:
temp
char *

user_defined_types: struct info { char *location; short *score; short *number; struct info *next; }

user_defined_types: struct file_list { char *filename; short number; long long reads_num; long long reads_contam; long long hits; long long all_k; struct file_list *next; }


decompiled_code:
void __fastcall fasta_process(__int64 a1, char **a2, char **a3, __int64 a4, float a5, float a6)
{
char *v6; // rbx
char **v8; // rax
char *v9; // r12
__int64 v10; // rax
__int64 v11; // rbp

v6 = *a2;
if ( *a2 )
{
v8 = (char **)a2[3];
if ( v8 == a3 )
v9 = &v6[strlen(*a2)];
else
v9 = *v8;
while ( v9 != v6 )
{
v10 = jump(v6, 1LL, a5);
v11 = v10;
if ( v6 == (char *)v10 )
{
_InterlockedAdd64((volatile signed __int64 *)(a4 + 16), 1uLL);
v6 = strchr((const char *)(v10 + 1), 62);
if ( !v6 )
v6 = v9;
if ( (int)fasta_read_check(v11, v6, 110LL, a1, a4, a6) > 0 )
_InterlockedAdd64((volatile signed __int64 *)(a4 + 24), 1uLL);
}
else
{
v6 = (char *)v10;
}
}
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, char **a2, char **a3, __int64 a4, float a5, float a6)
{
char *v6; // rbx
char **v8; // rax
char *v9; // r12
__int64 v10; // rax
__int64 v11; // rbp

v6 = *a2;
if ( *a2 )
{
v8 = (char **)a2[3];
if ( v8 == a3 )
v9 = &v6[strlen(*a2)];
else
v9 = *v8;
while ( v9 != v6 )
{
v10 = jump(v6, 1LL, a5);
v11 = v10;
if ( v6 == (char *)v10 )
{
_InterlockedAdd64((volatile signed __int64 *)(a4 + 16), 1uLL);
v6 = strchr((const char *)(v10 + 1), 62);
if ( !v6 )
v6 = v9;
if ( (int)fasta_read_check(v11, v6, 110LL, a1, a4, a6) > 0 )
_InterlockedAdd64((volatile signed __int64 *)(a4 + 24), 1uLL);
}
else
{
v6 = (char *)v10;
}
}
}
}

original_code:
void
fasta_process (bloom * bl, Queue * info, Queue * tail, F_set * File_head,
        float sampling_rate, float tole_rate)
{
  char *temp_next, *next, *temp;
  if (info->location == ((void *)0))
    return;
  else if (info->next != tail)
    next = info->next->location;
  else
    next = strchr (info->location, '\0');
  char *p = info->location;
  while (p != next)
    {
      temp = jump (p, 1, sampling_rate);
      if (p != temp)
 {
   p = temp;
   continue;
 }

#pragma omp atomic
      File_head->reads_num++;
      temp_next = strchr (p + 1, '>');
      if (!temp_next)
 temp_next = next;
      if (fasta_read_check (p, temp_next, 'n', bl, tole_rate, File_head) > 0)
 {

#pragma omp atomic
   File_head->reads_contam++;
 }
      p = temp_next;
    }
}

canonical_original_code:
void fasta_process(struct bloom *bl, struct info *info, struct info *tail, struct file_list *File_head, float sampling_rate, float tole_rate)
{
  char *temp_next; char *next; char *temp;
  if (info->location == ((void *)0))
    return;
  else if (info->next != tail)
    next = info->next->location;
  else
    next = strchr (info->location, '\0');
  char *p = info->location;
  while (p != next)
    {
      temp = jump (p, 1, sampling_rate);
      if (p != temp)
 {
   p = temp;
   continue;
 }

#pragma omp atomic
      File_head->reads_num++;
      temp_next = strchr (p + 1, '>');
      if (!temp_next)
 temp_next = next;
      if (fasta_read_check (p, temp_next, 'n', bl, tole_rate, File_head) > 0)
 {

#pragma omp atomic
   File_head->reads_contam++;
 }
      p = temp_next;
    }
}

variable_types: struct bloom { char *vector; unsigned long long (*hash)(char *str); unsigned long long inserts; struct bloomstat { unsigned long long elements; int ideal_hashes; unsigned long long capacity; double e; } stat; int k_mer; int dx; float mcf; } *


evaluate

original_code:
void
evaluate (char *detail, char *filename, F_set * File_head)
{
  char buffer[200] = { 0 };
  float contamination_rate =
    (float) (File_head->reads_contam) / (float) (File_head->reads_num);
  printf("{\n");
  printf ("\t\"total_read_count\": %lld,\n", File_head->reads_num);
  printf ("\t\"contaminated_reads\": %lld,\n", File_head->reads_contam);
  printf ("\t\"total_hits\": %lld,\n", File_head->hits);
  printf ("\t\"contamination_rate\": %f,\n", contamination_rate);
  printf ("\t\"bloom_filename\":\"%s\"\n", filename);
  printf("}\n");
  sprintf (buffer, "  %lld\t%lld\t%f\n", File_head->reads_num,
    File_head->reads_contam, contamination_rate);
  strcat (detail, buffer);
}

canonical_original_code:
void evaluate(char *detail, char *filename, struct file_list *File_head)
{
  char buffer[200] = { 0 };
  float contamination_rate = (float) (File_head->reads_contam) / (float) (File_head->reads_num);
  printf("{\n");
  printf ("\t\"total_read_count\": %lld,\n", File_head->reads_num);
  printf ("\t\"contaminated_reads\": %lld,\n", File_head->reads_contam);
  printf ("\t\"total_hits\": %lld,\n", File_head->hits);
  printf ("\t\"contamination_rate\": %f,\n", contamination_rate);
  printf ("\t\"bloom_filename\":\"%s\"\n", filename);
  printf("}\n");
  sprintf (buffer, "  %lld\t%lld\t%f\n", File_head->reads_num,
    File_head->reads_contam, contamination_rate);
  strcat (detail, buffer);
}

variable_types:
detail
char *

variable_types:
filename
char *

variable_types:
buffer
char [200]


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

v2 = (_BYTE *)prefix_make(a2, 0LL);
v3 = &v2[*v2 == 47];
strcat(v3, ".info");
return write_result(v3, a1);
}

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

v2 = (_BYTE *)prefix_make(a2, 0LL);
v3 = &v2[*v2 == 47];
strcat(v3, ".info");
return write_result(v3, a1);
}

original_code:
void
statistic_save (char *detail, char *filename, char *prefix)
{
  char *save_file = ((void *)0);
  save_file = prefix_make (filename, ((void *)0), prefix);
  if (save_file[0]=='/')
      save_file++;
  strcat (save_file,".info");
  write_result (save_file, detail);
}

canonical_original_code:
void statistic_save(char *detail, char *filename, char *prefix)
{
  char *save_file = ((void *)0);
  save_file = prefix_make (filename, ((void *)0), prefix);
  if (save_file[0]=='/')
      save_file++;
  strcat (save_file,".info");
  write_result (save_file, detail);
}

variable_types:
prefix
char *


decompiled_code:
__int64 __fastcall check_all(__int64 a1, __int64 a2, __int64 a3, double a4, double a5)
{
void *v6; // r13
_QWORD *v7; // r12
void *v8; // r14
unsigned int *v9; // rbp
_QWORD *v10; // rbx
int v11; // er15
size_t v12; // rax
unsigned __int64 v14; // [rsp+0h] [rbp-88h]
char *s; // [rsp+10h] [rbp-78h]
__int64 v16[5]; // [rsp+20h] [rbp-68h] BYREF
int v17; // [rsp+48h] [rbp-40h]

v14 = __PAIR64__(LODWORD(a5), LODWORD(a4));
v6 = malloc(0xF4240uLL);
memset(v6, 0, 0xF4240uLL);
v7 = malloc(0x20uLL);
v8 = malloc(0x20uLL);
v9 = (unsigned int *)malloc(0x48uLL);
*v7 = 0LL;
v7[3] = v8;
v10 = (_QWORD *)make_list(a2, a3);
s = (char *)mmaping(a1);
v11 = get_parainfo(s, v7);
while ( v10 )
{
load_bloom(*v10, v9);
if ( *(float *)&v14 == 0.0 )
{
*(float *)&a4 = mco_suggestion(v9[14], a4, a5, *(float *)&v14, 0.0);
LODWORD(v14) = LODWORD(a4);
}
v16[3] = (__int64)v10;
v16[2] = (__int64)v9;
v16[1] = (__int64)v8;
v17 = v11;
v16[4] = v14;
v16[0] = (__int64)v7;
GOMP_parallel(check_all__omp_fn_0, v16, 0LL, 0LL);
evaluate((char *)v6, (const char *)*v10, v10);
v10 = (_QWORD *)v10[6];
bloom_destroy(v9);
}
statistic_save((__int64)v6, a1);
v12 = strlen(s);
munmap(s, v12);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3, double a4, double a5)
{
void *v6; // r13
_QWORD *v7; // r12
void *v8; // r14
unsigned int *v9; // rbp
_QWORD *v10; // rbx
int v11; // er15
size_t v12; // rax
unsigned __int64 v14; // [rsp+0h] [rbp-88h]
char *s; // [rsp+10h] [rbp-78h]
__int64 v16[5]; // [rsp+20h] [rbp-68h] BYREF
int v17; // [rsp+48h] [rbp-40h]

v14 = __PAIR64__(LODWORD(a5), LODWORD(a4));
v6 = malloc(0xF4240uLL);
memset(v6, 0, 0xF4240uLL);
v7 = malloc(0x20uLL);
v8 = malloc(0x20uLL);
v9 = (unsigned int *)malloc(0x48uLL);
*v7 = 0LL;
v7[3] = v8;
v10 = (_QWORD *)make_list(a2, a3);
s = (char *)mmaping(a1);
v11 = get_parainfo(s, v7);
while ( v10 )
{
load_bloom(*v10, v9);
if ( *(float *)&v14 == 0.0 )
{
*(float *)&a4 = mco_suggestion(v9[14], a4, a5, *(float *)&v14, 0.0);
LODWORD(v14) = LODWORD(a4);
}
v16[3] = (__int64)v10;
v16[2] = (__int64)v9;
v16[1] = (__int64)v8;
v17 = v11;
v16[4] = v14;
v16[0] = (__int64)v7;
GOMP_parallel(check_all__omp_fn_0, v16, 0LL, 0LL);
func4((char *)v6, (const char *)*v10, v10);
v10 = (_QWORD *)v10[6];
bloom_destroy(v9);
}
func5((__int64)v6, a1);
v12 = strlen(s);
munmap(s, v12);
return 1LL;
}

original_code:
int check_all (char *source, char *ref, float tole_rate, float sampling_rate, char *list, char *prefix)
{
  char *position;
  char *detail = (char *) malloc (1000 * 1000 * sizeof (char));
  memset (detail, 0, 1000 * 1000);
  int type = 0;
  Queue *head = (Queue *) malloc(sizeof(Queue));
  Queue *tail = (Queue *) malloc(sizeof(Queue));
  bloom *bl_2 = (bloom *) malloc(sizeof(bloom));
  Queue *head2;
  head->location=((void *)0);
  head2 = head;
  head->next = tail;
  F_set *File_head = (F_set *) malloc(sizeof(F_set));
  File_head = make_list (ref, list);
  position = mmaping (source);
  type = get_parainfo (position,head);
  while (File_head!=((void *)0))
    {
      load_bloom (File_head->filename, bl_2);
      if (tole_rate==0)
          tole_rate = mco_suggestion(bl_2->k_mer);

#pragma omp parallel
      {

#pragma omp single nowait
 {
   while (head != tail) {

#pragma omp task firstprivate(head)
       {
  if (head->location!=((void *)0))
                  {
    if (type == 1)
      fasta_process (bl_2, head, tail, File_head, sampling_rate,
       tole_rate);
    else
      fastq_process (bl_2, head, tail, File_head, sampling_rate,
         tole_rate);
    }
       }
       head = head->next;
     }
 }
      }
      evaluate (detail, File_head->filename, File_head);
      File_head = File_head->next;
      head = head2;
      bloom_destroy (bl_2);
    }
  statistic_save (detail, source, prefix);
  munmap (position, strlen (position));
  return 1;
}

canonical_original_code:
int check_all(char *source, char *ref, float tole_rate, float sampling_rate, char *list, char *prefix)
{
  char *position;
  char *detail = (char *) malloc (1000 * 1000 * sizeof (char));
  memset (detail, 0, 1000 * 1000);
  int type = 0;
  struct info *head = (Queue *) malloc(sizeof(Queue));
  struct info *tail = (Queue *) malloc(sizeof(Queue));
  struct bloom *bl_2 = (bloom *) malloc(sizeof(bloom));
  struct info *head2;
  head->location=((void *)0);
  head2 = head;
  head->next = tail;
  struct file_list *File_head = (F_set *) malloc(sizeof(F_set));
  File_head = make_list (ref, list);
  position = mmaping (source);
  type = get_parainfo (position,head);
  while (File_head!=((void *)0))
    {
      load_bloom (File_head->filename, bl_2);
      if (tole_rate==0)
          tole_rate = mco_suggestion(bl_2->k_mer);

#pragma omp parallel
      {

#pragma omp single nowait
 {
   while (head != tail) {

#pragma omp task firstprivate(head)
       {
  if (head->location!=((void *)0))
                  {
    if (type == 1)
      fasta_process (bl_2, head, tail, File_head, sampling_rate,
       tole_rate);
    else
      fastq_process (bl_2, head, tail, File_head, sampling_rate,
         tole_rate);
    }
       }
       head = head->next;
     }
 }
      }
      evaluate (detail, File_head->filename, File_head);
      File_head = File_head->next;
      head = head2;
      bloom_destroy (bl_2);
    }
  statistic_save (detail, source, prefix);
  munmap (position, strlen (position));
  return 1;
}

variable_types:
ref
char *

variable_types:
position
char *

variable_types: type int


decompiled_code:
__int64 __fastcall check_main(int argc, char **argv)
{
char *v2; // r12
char *v3; // r14
char *v4; // r13
float v5; // xmm4_4
int v6; // xmm5_4
int v7; // eax
int v9; // [rsp+8h] [rbp-40h]
float v10; // [rsp+Ch] [rbp-3Ch]

if ( argc <= 1 )
check_help();
v2 = 0LL;
v3 = 0LL;
v4 = 0LL;
v9 = LC9;
v10 = 0.0;
while ( 1 )
{
v7 = getopt(argc, argv, "s:t:r:o:q:l:h");
if ( v7 == -1 )
return check_all(
(__int64)v2,
(__int64)v4,
(__int64)v3,
COERCE_DOUBLE((unsigned __int64)LODWORD(v10)),
COERCE_DOUBLE((unsigned __int64)v9));
switch ( v7 )
{
case '?':
goto LABEL_18;
case 'h':
check_help();
LABEL_18:
printf("Unknown option: -%c\n", (unsigned int)(char)optopt);
check_help();
break;
case 'l':
if ( optarg )
v3 = optarg;
break;
case 'q':
if ( optarg )
v2 = optarg;
break;
case 'r':
if ( optarg )
v4 = optarg;
break;
case 's':
if ( optarg )
{
*(float *)&v6 = atof(optarg);
v9 = v6;
}
break;
case 't':
if ( optarg )
{
v5 = atof(optarg);
v10 = v5;
}
break;
default:
continue;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func7(int argc, char **argv)
{
char *v2; // r12
char *v3; // r14
char *v4; // r13
float v5; // xmm4_4
int v6; // xmm5_4
int v7; // eax
int v9; // [rsp+8h] [rbp-40h]
float v10; // [rsp+Ch] [rbp-3Ch]

if ( argc <= 1 )
check_help();
v2 = 0LL;
v3 = 0LL;
v4 = 0LL;
v9 = LC9;
v10 = 0.0;
while ( 1 )
{
v7 = getopt(argc, argv, "s:t:r:o:q:l:h");
if ( v7 == -1 )
return func6(
(__int64)v2,
(__int64)v4,
(__int64)v3,
COERCE_DOUBLE((unsigned __int64)LODWORD(v10)),
COERCE_DOUBLE((unsigned __int64)v9));
switch ( v7 )
{
case '?':
goto LABEL_18;
case 'h':
check_help();
LABEL_18:
printf("Unknown option: -%c\n", (unsigned int)(char)optopt);
check_help();
break;
case 'l':
if ( optarg )
v3 = optarg;
break;
case 'q':
if ( optarg )
v2 = optarg;
break;
case 'r':
if ( optarg )
v4 = optarg;
break;
case 's':
if ( optarg )
{
*(float *)&v6 = atof(optarg);
v9 = v6;
}
break;
case 't':
if ( optarg )
{
v5 = atof(optarg);
v10 = v5;
}
break;
default:
continue;
}
}
}

original_code:
int check_main (int argc, char **argv)
{
   if (argc<2) check_help();
  int opt;
  float tole_rate = 0;
  float sampling_rate = 1;
  char* ref = ((void *)0);
  char* list = ((void *)0);
  char* target_path = ((void *)0);
  char* source = ((void *)0);
  while ((opt = getopt (argc, argv, "s:t:r:o:q:l:h")) != -1) {
      switch (opt) {
          case 't':
              (optarg) && ((tole_rate = atof(optarg)), 1);
              break;
          case 's':
              (optarg) && ((sampling_rate = atof(optarg)), 1);
              break;
          case 'o':
              (optarg) && ((target_path = optarg), 1);
              break;
          case 'q':
              (optarg) && (source = optarg, 1);
              break;
          case 'r':
              (optarg) && (ref = optarg, 1);
              break;
          case 'l':
              (optarg) && (list = optarg, 1);
              break;
          case 'h':
              check_help();
          case '?':
              printf ("Unknown option: -%c\n", (char) optopt);
              check_help();
      }
  }
  return check_all (source, ref, tole_rate, sampling_rate, list, target_path);
}

canonical_original_code:
int check_main(int argc, char **argv)
{
   if (argc<2) check_help();
  int opt;
  float tole_rate = 0;
  float sampling_rate = 1;
  char *ref = ((void *)0);
  char *list = ((void *)0);
  char *target_path = ((void *)0);
  char *source = ((void *)0);
  while ((opt = getopt (argc, argv, "s:t:r:o:q:l:h")) != -1) {
      switch (opt) {
          case 't':
              (optarg) && ((tole_rate = atof(optarg)), 1);
              break;
          case 's':
              (optarg) && ((sampling_rate = atof(optarg)), 1);
              break;
          case 'o':
              (optarg) && ((target_path = optarg), 1);
              break;
          case 'q':
              (optarg) && (source = optarg, 1);
              break;
          case 'r':
              (optarg) && (ref = optarg, 1);
              break;
          case 'l':
              (optarg) && (list = optarg, 1);
              break;
          case 'h':
              check_help();
          case '?':
              printf ("Unknown option: -%c\n", (char) optopt);
              check_help();
      }
  }
  return check_all (source, ref, tole_rate, sampling_rate, list, target_path);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int


printtext

repo: tzwaan/datastructuren

decompiled_code:
int __fastcall printtext(char *a1, int a2)
{
char *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
putchar(*v2++);
while ( v2 != &a1[a2 - 1 + 1] );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func0(char *a1, int a2)
{
char *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
putchar(*v2++);
while ( v2 != &a1[a2 - 1 + 1] );
}
return putchar(10);
}

original_code:
void printtext(char *array, int counter){
   for(int i = 0; i<counter; i++){
      printf("%c", array[i]);
   }
   printf("\n");
}

variable_types:
array
char *

variable_types: counter int

variable_types: i int


decompiled_code:
__int64 __fastcall input_to_freqtable(__int64 a1, __int64 a2)
{
__int64 i; // rdx
__int64 result; // rax

for ( i = 0LL; i != 26; ++i )
{
result = *(char *)(a1 + i) - 97;
freqtable[result] = *(_QWORD *)(a2 + 8 * i);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 i; // rdx
__int64 result; // rax

for ( i = 0LL; i != 26; ++i )
{
result = *(char *)(a1 + i) - 97;
freqtable[result] = *(_QWORD *)(a2 + 8 * i);
}
return result;
}

original_code:
void input_to_freqtable(char *letters, double *freq){
   for(int i=0; i<26; i++){
      freqtable[letters[i]-97] = freq[i];
   }
}

canonical_original_code:
void input_to_freqtable(char *letters, double *freq){
   for(int i = 0; i<26; i++){
      freqtable[letters[i]-97] = freq[i];
   }
}

variable_types:
letters
char *

variable_types:
freq
double *


printfreqtable

decompiled_code:
int __fastcall printfreqtable(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = 0LL; i != 26; ++i )
result = printf("%c = %2.3f\n", (unsigned int)(i + 97), *(double *)(a1 + 8 * i));
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = 0LL; i != 26; ++i )
result = printf("%c = %2.3f\n", (unsigned int)(i + 97), *(double *)(a1 + 8 * i));
return result;
}

original_code:
void printfreqtable(double *table){
   for(int i=0; i<26; i++){
      printf("%c = %2.3f\n", i+97, table[i]);
   }
}

canonical_original_code:
void printfreqtable(double *table){
   for(int i = 0; i<26; i++){
      printf("%c = %2.3f\n", i+97, table[i]);
   }
}

variable_types:
table
double *


decompiled_code:
int __fastcall printfreqtable2(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = 0LL; i != 26; ++i )
result = printf("%c = %d\n", (unsigned int)(i + 97), *(unsigned int *)(a1 + 4 * i));
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = 0LL; i != 26; ++i )
result = printf("%c = %d\n", (unsigned int)(i + 97), *(unsigned int *)(a1 + 4 * i));
return result;
}

original_code:
void printfreqtable2(int *table){
   for(int i=0; i<26; i++){
      printf("%c = %d\n", i+97, table[i]);
   }
}

canonical_original_code:
void printfreqtable2(int *table){
   for(int i = 0; i<26; i++){
      printf("%c = %d\n", i+97, table[i]);
   }
}

variable_types:
table
int *


pythagoras

decompiled_code:
double __fastcall pythagoras(double a1, double a2)
{
return a1 * a1 + a2 * a2;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2)
{
return a1 * a1 + a2 * a2;
}

original_code:
double pythagoras(double x, double y){
   return((x*x) + (y*y));
}

variable_types: x double

variable_types: y double

return_type: double


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er13
int v4; // ebp
int v5; // er12
int v6; // ebx
int v7; // eax

if ( argc <= 1 )
{
puts("no argument given\n");
}
else
{
v3 = atoi(argv[1]);
srand(1u);
if ( v3 )
{
v4 = v3;
v5 = 0;
do
{
v6 = rand();
v7 = rand();
v5 += pythagoras((double)v6 / 2147483647.0, (double)v7 / 2147483647.0) < 1.0;
--v4;
}
while ( v4 );
}
else
{
v5 = 0;
}
printf("total points: %i\npoints in circle: %i\n", (unsigned int)v3, (unsigned int)v5);
printf("pi: %f \n", (double)v5 / (double)v3 * 4.0);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er13
int v4; // ebp
int v5; // er12
int v6; // ebx
int v7; // eax

if ( argc <= 1 )
{
puts("no argument given\n");
}
else
{
v3 = atoi(argv[1]);
srand(1u);
if ( v3 )
{
v4 = v3;
v5 = 0;
do
{
v6 = rand();
v7 = rand();
v5 += func0((double)v6 / 2147483647.0, (double)v7 / 2147483647.0) < 1.0;
--v4;
}
while ( v4 );
}
else
{
v5 = 0;
}
printf("total points: %i\npoints in circle: %i\n", (unsigned int)v3, (unsigned int)v5);
printf("pi: %f \n", (double)v5 / (double)v3 * 4.0);
}
return 0;
}

original_code:
int main(int argc, char *argv[]){
   if(argc<=1){
      printf("no argument given\n\n");
      return(0);
   }
   int input = atoi(argv[1]);
   int i=input, inCircle=0;
   double pi, x, y, z;
   srand(1);
   for (; i; i--) {
      x = (double)rand()/(double)2147483647;
      y = (double)rand()/(double)2147483647;
      z = pythagoras(x,y);
      if(z<1)
         inCircle++;
   }
 printf("total points: %i\npoints in circle: %i\n", input, inCircle);
 pi = (inCircle/(double)input) * 4;
 printf("pi: %f \n", pi);
 return(0);
}

canonical_original_code:
int main(int argc, char *argv[]){
   if(argc<=1){
      printf("no argument given\n\n");
      return(0);
   }
   int input = atoi(argv[1]);
   int i = input; int inCircle = 0;
   double pi; double x; double y; double z;
   srand(1);
   for (; i; i--) {
      x = (double)rand()/(double)2147483647;
      y = (double)rand()/(double)2147483647;
      z = pythagoras(x,y);
      if(z<1)
         inCircle++;
   }
 printf("total points: %i\npoints in circle: %i\n", input, inCircle);
 pi = (inCircle/(double)input) * 4;
 printf("pi: %f \n", pi);
 return(0);
}

variable_types:
argv
char *[]

variable_types: input int

variable_types: inCircle int

variable_types: pi double

variable_types: z double


decompiled_code:
int __fastcall print_maze(unsigned int *a1, unsigned int *a2)
{
int result; // eax
__int64 i; // r13
__int64 j; // rbx

result = printf("length:%d\nwidth:%d\nrow:%d\ncollum:%d\n", *a1, a1[1], *a2, a2[1]);
for ( i = 0LL; (int)*a1 > (int)i; ++i )
{
for ( j = 0LL; (int)a1[1] > (int)j; ++j )
{
if ( *a2 == (_DWORD)i && a2[1] == (_DWORD)j )
putchar(88);
else
putchar(*(char *)(*(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * i) + j));
}
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(unsigned int *a1, unsigned int *a2)
{
int result; // eax
__int64 i; // r13
__int64 j; // rbx

result = printf("length:%d\nwidth:%d\nrow:%d\ncollum:%d\n", *a1, a1[1], *a2, a2[1]);
for ( i = 0LL; (int)*a1 > (int)i; ++i )
{
for ( j = 0LL; (int)a1[1] > (int)j; ++j )
{
if ( *a2 == (_DWORD)i && a2[1] == (_DWORD)j )
putchar(88);
else
putchar(*(char *)(*(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * i) + j));
}
result = putchar(10);
}
return result;
}

original_code:
void print_maze(maze_t *maze, walker_t *walker) {
   int i, j;
   printf("length:%d\nwidth:%d\nrow:%d\ncollum:%d\n",
           maze->length, maze->width, walker->row, walker->col);
   for(i=0; i<maze->length; i++) {
      for(j=0; j<maze->width; j++) {
         if((i == walker->row) && (j == walker->col)) {
            printf("X");
         }
         else {
            printf("%c", maze->maze[i][j]);
         }
      }
      printf("\n");
   }
}

canonical_original_code:
void print_maze(struct maze_t *maze, struct walker_t *walker) {
   int i; int j;
   printf("length:%d\nwidth:%d\nrow:%d\ncollum:%d\n",
           maze->length, maze->width, walker->row, walker->col);
   for(i=0; i<maze->length; i++) {
      for(j=0; j<maze->width; j++) {
         if((i == walker->row) && (j == walker->col)) {
            printf("X");
         }
         else {
            printf("%c", maze->maze[i][j]);
         }
      }
      printf("\n");
   }
}

variable_types: struct maze_t { int length; char **maze; } *

variable_types:
walker
struct walker_t { int row; } *

variable_types: j int


decompiled_code:
void __fastcall cleanup_maze(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func8(void *a1)
{
free(a1);
}

original_code:
void cleanup_maze (maze_t *maze) {
   free(maze);
   maze = ((void *)0);
}

canonical_original_code:
void cleanup_maze(struct maze_t *maze) {
   free(maze);
   maze = ((void *)0);
}

user_defined_types: struct maze_t { int length; char **maze; }


decompiled_code:
__int64 __fastcall random_solver(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx

do
v2 = rand() % 4;
while ( !(unsigned int)move_walker(a1, a2, v2) );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx

do
v2 = rand() % 4;
while ( !(unsigned int)func16(a1, a2, v2) );
return v2;
}

original_code:
int random_solver(maze_t *maze, walker_t *walker) {
   int dir = (rand() % 4);
   while(!move_walker(maze, walker, dir)) {
      dir = (rand() % 4);
   }
   return dir;
}

canonical_original_code:
int random_solver(struct maze_t *maze, struct walker_t *walker) {
   int dir = (rand() % 4);
   while(!move_walker(maze, walker, dir)) {
      dir = (rand() % 4);
   }
   return dir;
}

variable_types: dir int


decompiled_code:
__int64 __fastcall wall_follower_right(__int64 a1, __int64 a2, int a3)
{
unsigned int i; // ebx

for ( i = (a3 + 1) % 4; !(unsigned int)move_walker(a1, a2, i); i = (int)(i + 3) % 4 )
;
return i;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, int a3)
{
unsigned int i; // ebx

for ( i = (a3 + 1) % 4; !(unsigned int)func16(a1, a2, i); i = (int)(i + 3) % 4 )
;
return i;
}

original_code:
int wall_follower_right(maze_t *maze, walker_t *walker, int dir) {
   dir = ((dir+1) % 4);
   while(!move_walker(maze, walker, dir)) {
      dir = ((dir+3) % 4);
   }
   return dir;
}

canonical_original_code:
int wall_follower_right(struct maze_t *maze, struct walker_t *walker, int dir) {
   dir = ((dir+1) % 4);
   while(!move_walker(maze, walker, dir)) {
      dir = ((dir+3) % 4);
   }
   return dir;
}


decompiled_code:
__int64 __fastcall wall_follower_left(__int64 a1, __int64 a2, int a3)
{
unsigned int i; // ebx

for ( i = (a3 + 3) % 4; !(unsigned int)move_walker(a1, a2, i); i = (int)(i + 1) % 4 )
;
return i;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, int a3)
{
unsigned int i; // ebx

for ( i = (a3 + 3) % 4; !(unsigned int)func16(a1, a2, i); i = (int)(i + 1) % 4 )
;
return i;
}

original_code:
int wall_follower_left(maze_t *maze, walker_t *walker, int dir) {
   dir = ((dir+3) % 4);
   while(!move_walker(maze, walker, dir)) {
      dir = ((dir+1) % 4);
   }
   return dir;
}

canonical_original_code:
int wall_follower_left(struct maze_t *maze, struct walker_t *walker, int dir) {
   dir = ((dir+3) % 4);
   while(!move_walker(maze, walker, dir)) {
      dir = ((dir+1) % 4);
   }
   return dir;
}


decompiled_code:
__int64 __fastcall tremaux_solver(__int64 a1, int *a2, unsigned int a3)
{
unsigned int v3; // ebx
char v4; // al
signed int v5; // ebp
unsigned int v6; // er14
bool v7; // al
bool v9; // [rsp+Bh] [rbp-3Dh]

v3 = a3;
printf("start_dir:%d\n", a3);
v4 = *(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * *a2) + a2[1]);
v9 = v4 == 83 || v4 == 32;
v5 = v3;
v6 = 0;
do
{
v6 -= ((unsigned int)check_clear_move(a1, a2, (unsigned int)(v5 % 4)) == 0) - 1;
++v5;
}
while ( v5 != v3 + 4 );
printf("counter:%d\n", v6);
if ( !v6 && v9 )
{
v3 = (int)(v3 + 2) % 4;
lay_breadcrumb(a1, a2);
lay_breadcrumb(a1, a2);
move_walker(a1, a2, v3);
return v3;
}
if ( v6 | v9 )
{
v7 = v6 != 0;
if ( v9 && v6 )
{
lay_breadcrumb(a1, a2);
while ( !(unsigned int)clear_move_walker(a1, a2, v3) )
v3 = (int)(v3 + 1) % 4;
return v3;
}
}
else
{
lay_breadcrumb(a1, a2);
while ( !(unsigned int)move_walker(a1, a2, v3) )
v3 = (int)(v3 + 1) % 4;
v7 = v6 != 0;
}
if ( !v9 && v7 )
{
while ( !(unsigned int)clear_move_walker(a1, a2, v3) )
v3 = (int)(v3 + 1) % 4;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, int *a2, unsigned int a3)
{
unsigned int v3; // ebx
char v4; // al
signed int v5; // ebp
unsigned int v6; // er14
bool v7; // al
bool v9; // [rsp+Bh] [rbp-3Dh]

v3 = a3;
printf("start_dir:%d\n", a3);
v4 = *(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * *a2) + a2[1]);
v9 = v4 == 83 || v4 == 32;
v5 = v3;
v6 = 0;
do
{
v6 -= ((unsigned int)func14(a1, a2, (unsigned int)(v5 % 4)) == 0) - 1;
++v5;
}
while ( v5 != v3 + 4 );
printf("counter:%d\n", v6);
if ( !v6 && v9 )
{
v3 = (int)(v3 + 2) % 4;
lay_breadcrumb(a1, a2);
lay_breadcrumb(a1, a2);
func16(a1, a2, v3);
return v3;
}
if ( v6 | v9 )
{
v7 = v6 != 0;
if ( v9 && v6 )
{
lay_breadcrumb(a1, a2);
while ( !(unsigned int)func17(a1, a2, v3) )
v3 = (int)(v3 + 1) % 4;
return v3;
}
}
else
{
lay_breadcrumb(a1, a2);
while ( !(unsigned int)func16(a1, a2, v3) )
v3 = (int)(v3 + 1) % 4;
v7 = v6 != 0;
}
if ( !v9 && v7 )
{
while ( !(unsigned int)func17(a1, a2, v3) )
v3 = (int)(v3 + 1) % 4;
}
return v3;
}

original_code:
int tremaux_solver(maze_t *maze, walker_t *walker, int dir) {
   int counter=0, i, new_path=0;
   printf("start_dir:%d\n", dir);
   if(maze->maze[walker->row][walker->col] == 32 ||
      maze->maze[walker->row][walker->col] == 83)
      new_path = 1;
   else
      new_path = 0;
   for(i=0; i<4; i++) {
      if(check_clear_move(maze, walker, ((dir + i) % 4))) {
         counter++;
      }
   }
   printf("counter:%d\n", counter);
   if(!counter && new_path) {
      dir = ((dir + 2) % 4);
      lay_breadcrumb(maze, walker);
      lay_breadcrumb(maze, walker);
      move_walker(maze, walker, dir);
      return dir;
   }
   if(!counter && !new_path) {
      lay_breadcrumb(maze, walker);
      while(!move_walker(maze, walker, dir))
         dir = ((dir + 1) % 4);
   }
   if(counter && new_path) {
      lay_breadcrumb(maze, walker);
      while(!clear_move_walker(maze, walker, dir))
         dir = ((dir + 1) % 4);
      return dir;
   }
   if(counter && !new_path) {
      while(!clear_move_walker(maze, walker, dir))
         dir = ((dir + 1) % 4);
      return dir;
   }
   return dir;
}

canonical_original_code:
int tremaux_solver(struct maze_t *maze, struct walker_t *walker, int dir) {
   int counter = 0; int i; int new_path = 0;
   printf("start_dir:%d\n", dir);
   if(maze->maze[walker->row][walker->col] == 32 ||
      maze->maze[walker->row][walker->col] == 83)
      new_path = 1;
   else
      new_path = 0;
   for(i=0; i<4; i++) {
      if(check_clear_move(maze, walker, ((dir + i) % 4))) {
         counter++;
      }
   }
   printf("counter:%d\n", counter);
   if(!counter && new_path) {
      dir = ((dir + 2) % 4);
      lay_breadcrumb(maze, walker);
      lay_breadcrumb(maze, walker);
      move_walker(maze, walker, dir);
      return dir;
   }
   if(!counter && !new_path) {
      lay_breadcrumb(maze, walker);
      while(!move_walker(maze, walker, dir))
         dir = ((dir + 1) % 4);
   }
   if(counter && new_path) {
      lay_breadcrumb(maze, walker);
      while(!clear_move_walker(maze, walker, dir))
         dir = ((dir + 1) % 4);
      return dir;
   }
   if(counter && !new_path) {
      while(!clear_move_walker(maze, walker, dir))
         dir = ((dir + 1) % 4);
      return dir;
   }
   return dir;
}

variable_types: counter int


original_code:
int check_move(maze_t *maze, walker_t *walker, int dir) {
   switch(dir) {
      case 0 : if(maze->maze[walker->row - 1][walker->col] != 35) {return 1;};
               break;
      case 1 : if(maze->maze[walker->row][walker->col + 1] != 35) {return 1;};
               break;
      case 2 : if(maze->maze[walker->row + 1][walker->col] != 35) {return 1;};
               break;
      case 3 : if(maze->maze[walker->row][walker->col - 1] != 35) {return 1;};
               break;
      default: return 0;
   }
   return 0;
}

canonical_original_code:
int check_move(struct maze_t *maze, struct walker_t *walker, int dir) {
   switch(dir) {
      case 0 : if(maze->maze[walker->row - 1][walker->col] != 35) {return 1;};
               break;
      case 1 : if(maze->maze[walker->row][walker->col + 1] != 35) {return 1;};
               break;
      case 2 : if(maze->maze[walker->row + 1][walker->col] != 35) {return 1;};
               break;
      case 3 : if(maze->maze[walker->row][walker->col - 1] != 35) {return 1;};
               break;
      default: return 0;
   }
   return 0;
}


original_code:
int check_clear_move(maze_t *maze, walker_t *walker, int dir) {
   switch(dir) {
      case 0 : if(maze->maze[walker->row - 1][walker->col] != 35 &&
                  maze->maze[walker->row - 1][walker->col] != 46) {return 1;};
               break;
      case 1 : if(maze->maze[walker->row][walker->col + 1] != 35 &&
                  maze->maze[walker->row][walker->col + 1] != 46) {return 1;};
               break;
      case 2 : if(maze->maze[walker->row + 1][walker->col] != 35 &&
                  maze->maze[walker->row + 1][walker->col] != 46) {return 1;};
               break;
      case 3 : if(maze->maze[walker->row][walker->col - 1] != 35 &&
                  maze->maze[walker->row][walker->col - 1] != 46) {return 1;};
               break;
      default: return 0;
   }
   return 0;
}

canonical_original_code:
int check_clear_move(struct maze_t *maze, struct walker_t *walker, int dir) {
   switch(dir) {
      case 0 : if(maze->maze[walker->row - 1][walker->col] != 35 &&
                  maze->maze[walker->row - 1][walker->col] != 46) {return 1;};
               break;
      case 1 : if(maze->maze[walker->row][walker->col + 1] != 35 &&
                  maze->maze[walker->row][walker->col + 1] != 46) {return 1;};
               break;
      case 2 : if(maze->maze[walker->row + 1][walker->col] != 35 &&
                  maze->maze[walker->row + 1][walker->col] != 46) {return 1;};
               break;
      case 3 : if(maze->maze[walker->row][walker->col - 1] != 35 &&
                  maze->maze[walker->row][walker->col - 1] != 46) {return 1;};
               break;
      default: return 0;
   }
   return 0;
}


original_code:
int at_exit(maze_t *maze, walker_t *walker) {
   if(maze->maze[walker->row][walker->col] == 69)
      return 1;
   return 0;
}

canonical_original_code:
int at_exit(struct maze_t *maze, struct walker_t *walker) {
   if(maze->maze[walker->row][walker->col] == 69)
      return 1;
   return 0;
}


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

result = check_move(a1, a2, a3);
if ( result )
{
if ( a3 == 2 )
{
++*a2;
result = 1LL;
}
else if ( a3 > 2 )
{
result = 0LL;
if ( a3 == 3 )
{
--a2[1];
result = 1LL;
}
}
else if ( a3 )
{
if ( a3 == 1 )
{
++a2[1];
result = 1LL;
}
else
{
result = 0LL;
}
}
else
{
--*a2;
result = 1LL;
}
}
return result;
}

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

result = func13(a1, a2, a3);
if ( result )
{
if ( a3 == 2 )
{
++*a2;
result = 1LL;
}
else if ( a3 > 2 )
{
result = 0LL;
if ( a3 == 3 )
{
--a2[1];
result = 1LL;
}
}
else if ( a3 )
{
if ( a3 == 1 )
{
++a2[1];
result = 1LL;
}
else
{
result = 0LL;
}
}
else
{
--*a2;
result = 1LL;
}
}
return result;
}

original_code:
int move_walker(maze_t *maze, walker_t *walker, int dir) {
   if(check_move(maze, walker, dir)) {
      switch(dir) {
         case 0 : walker->row--; return 1;
         case 1 : walker->col++; return 1;
         case 2 : walker->row++; return 1;
         case 3 : walker->col--; return 1;
         default: break;
      }
   }
   return 0;
}

canonical_original_code:
int move_walker(struct maze_t *maze, struct walker_t *walker, int dir) {
   if(check_move(maze, walker, dir)) {
      switch(dir) {
         case 0 : walker->row--; return 1;
         case 1 : walker->col++; return 1;
         case 2 : walker->row++; return 1;
         case 3 : walker->col--; return 1;
         default: break;
      }
   }
   return 0;
}


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

result = check_clear_move(a1, a2, a3);
if ( (_DWORD)result )
{
if ( a3 == 2 )
{
++*a2;
result = 1LL;
}
else if ( a3 > 2 )
{
result = 0LL;
if ( a3 == 3 )
{
--a2[1];
result = 1LL;
}
}
else if ( a3 )
{
if ( a3 == 1 )
{
++a2[1];
result = 1LL;
}
else
{
result = 0LL;
}
}
else
{
--*a2;
result = 1LL;
}
}
return result;
}

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

result = func14(a1, a2, a3);
if ( (_DWORD)result )
{
if ( a3 == 2 )
{
++*a2;
result = 1LL;
}
else if ( a3 > 2 )
{
result = 0LL;
if ( a3 == 3 )
{
--a2[1];
result = 1LL;
}
}
else if ( a3 )
{
if ( a3 == 1 )
{
++a2[1];
result = 1LL;
}
else
{
result = 0LL;
}
}
else
{
--*a2;
result = 1LL;
}
}
return result;
}

original_code:
int clear_move_walker(maze_t *maze, walker_t *walker, int dir) {
   if(check_clear_move(maze, walker, dir)) {
      switch(dir) {
         case 0 : walker->row--; return 1;
         case 1 : walker->col++; return 1;
         case 2 : walker->row++; return 1;
         case 3 : walker->col--; return 1;
         default: break;
      }
   }
   return 0;
}

canonical_original_code:
int clear_move_walker(struct maze_t *maze, struct walker_t *walker, int dir) {
   if(check_clear_move(maze, walker, dir)) {
      switch(dir) {
         case 0 : walker->row--; return 1;
         case 1 : walker->col++; return 1;
         case 2 : walker->row++; return 1;
         case 3 : walker->col--; return 1;
         default: break;
      }
   }
   return 0;
}


decompiled_code:
void __fastcall cleanup_walker(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func18(void *a1)
{
free(a1);
}

original_code:
void cleanup_walker(walker_t *walker) {
   free(walker);
   walker = ((void *)0);
}

canonical_original_code:
void cleanup_walker(struct walker_t *walker) {
   free(walker);
   walker = ((void *)0);
}


decompiled_code:
_QWORD *maak_loods3()
{
_QWORD *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
*v0 = maak_loods();
v0[1] = maak_loods();
return v0;
}

canonical_decompiled_code:
_QWORD *func8()
{
_QWORD *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
*v0 = func7();
v0[1] = func7();
return v0;
}

original_code:
loods3 *maak_loods3(void) {
 loods3 *loods = calloc(1, sizeof(loods3));
 loods->loods1 = maak_loods();
 loods->loods2 = maak_loods();
 return loods;
}

canonical_original_code:
struct loods3 *maak_loods3() {
 struct loods3 *loods = calloc(1, sizeof(loods3));
 loods->loods1 = maak_loods();
 loods->loods2 = maak_loods();
 return loods;
}

variable_types: struct loods3 { struct loods2 { struct container { struct container *next; char *content; } *begin; } *loods1; struct loods2 *loods2; } *

user_defined_types: struct loods3 { struct loods2 *loods1; struct loods2 *loods2; }

user_defined_types: struct loods2 { struct container *begin; }


decompiled_code:
void *maak_container()
{
return calloc(1uLL, 8uLL);
}

canonical_decompiled_code:
void *func9()
{
return calloc(1uLL, 8uLL);
}

original_code:
container *maak_container(void) {
 container *container = calloc(1, sizeof(container));
 return container;
}

canonical_original_code:
struct container *maak_container() {
 struct container *container = calloc(1, sizeof(container));
 return container;
}

variable_types: struct container { struct container *next; char *content; } *


decompiled_code:
char *__fastcall opslaan_oud(_QWORD *a1, const char *a2)
{
_QWORD *v2; // rbx
size_t v3; // rax
char *v4; // rax

v2 = maak_container();
*v2 = *a1;
*a1 = v2;
v3 = strlen(a2);
v4 = (char *)malloc(v3);
v2[1] = v4;
return strcpy(v4, a2);
}

canonical_decompiled_code:
char *__fastcall func12(_QWORD *a1, const char *a2)
{
_QWORD *v2; // rbx
size_t v3; // rax
char *v4; // rax

v2 = func9();
*v2 = *a1;
*a1 = v2;
v3 = strlen(a2);
v4 = (char *)malloc(v3);
v2[1] = v4;
return strcpy(v4, a2);
}

original_code:
void opslaan_oud(loods2 *loods, char *content) {
 container *container = maak_container();
 container->next = loods->begin;
 loods->begin = container;
 container->content = malloc(strlen(content) * sizeof(char));
 strcpy(container->content, content);
}

canonical_original_code:
void opslaan_oud(struct loods2 *loods, char *content) {
 struct container *container = maak_container();
 container->next = loods->begin;
 loods->begin = container;
 container->content = malloc(strlen(content) * sizeof(char));
 strcpy(container->content, content);
}

variable_types: struct loods2 { struct container { struct container *next; char *content; } *begin; } *

variable_types:
content
char *


decompiled_code:
__int64 __fastcall leveren_oud(_QWORD *a1)
{
__int64 v2; // rbp
void *v3; // rdi

v2 = 0LL;
if ( !leeg(a1) )
{
v3 = (void *)*a1;
v2 = *(_QWORD *)(*a1 + 8LL);
*a1 = *(_QWORD *)*a1;
free(v3);
}
return v2;
}

original_code:
char *leveren_oud(loods2 *loods) {
 if (leeg(loods))
  return ((void *)0);
 container *container = loods->begin;
 char *content = loods->begin->content;
 loods->begin = container->next;
 free(container);
 return content;
}

canonical_original_code:
char *leveren_oud(struct loods2 *loods) {
 if (leeg(loods))
  return ((void *)0);
 struct container *container = loods->begin;
 char *content = loods->begin->content;
 loods->begin = container->next;
 free(container);
 return content;
}

return_type: char *

user_defined_types: struct container { struct container *next; char *content; }


decompiled_code:
_BOOL8 __fastcall verplaats_alles(_QWORD **a1)
{
_BOOL8 result; // rax

while ( 1 )
{
result = leeg(*a1);
if ( result )
break;
verplaatsen(a1);
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func15(_QWORD **a1)
{
_BOOL8 result; // rax

while ( 1 )
{
result = func10(*a1);
if ( result )
break;
func14(a1);
}
return result;
}

original_code:
void verplaats_alles(loods3 *loods) {
 while (!leeg(loods->loods1)) {
  verplaatsen(loods);
 }
}

canonical_original_code:
void verplaats_alles(struct loods3 *loods) {
 while (!leeg(loods->loods1)) {
  verplaatsen(loods);
 }
}


decompiled_code:
__int64 __fastcall hash_int(_DWORD *a1, unsigned int a2)
{
return *a1 % a2;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1, unsigned int a2)
{
return *a1 % a2;
}

original_code:
unsigned int hash_int(void *value, unsigned int hash_table_size){
 return *((int*)value) % hash_table_size;
}

canonical_original_code:
unsigned int hash_int(void *value, unsigned int hash_table_size){
 return *((int *)value) % hash_table_size;
}

variable_types:
value
void *

return_type: unsigned int


decompiled_code:
__int64 __fastcall hash_char(char *a1, unsigned int a2)
{
char v2; // dl
char *v3; // rdi
unsigned int v4; // eax

v2 = *a1;
if ( *a1 )
{
v3 = a1 + 1;
v4 = 0;
do
{
v4 = (11 * v4) ^ v2;
v2 = *v3++;
}
while ( v2 );
}
else
{
v4 = 0;
}
return v4 % a2;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, unsigned int a2)
{
char v2; // dl
char *v3; // rdi
unsigned int v4; // eax

v2 = *a1;
if ( *a1 )
{
v3 = a1 + 1;
v4 = 0;
do
{
v4 = (11 * v4) ^ v2;
v2 = *v3++;
}
while ( v2 );
}
else
{
v4 = 0;
}
return v4 % a2;
}

original_code:
unsigned int hash_char(void *value, unsigned int hash_table_size){
 unsigned hash_value = 0;
    int i = 0;
    char c;
    while((c = ((char*)value)[i++]) != 0){
     hash_value = c ^ 11 * hash_value;
    }
    return (hash_value % hash_table_size);
}

canonical_original_code:
unsigned int hash_char(void *value, unsigned int hash_table_size){
 unsigned int hash_value = 0;
    int i = 0;
    char c;
    while((c = ((char *)value)[i++]) != 0){
     hash_value = c ^ 11 * hash_value;
    }
    return (hash_value % hash_table_size);
}

variable_types: i int

variable_types: c char


decompiled_code:
_BOOL8 __fastcall compare_int(_DWORD *a1, _DWORD *a2)
{
return *a1 == *a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(_DWORD *a1, _DWORD *a2)
{
return *a1 == *a2;
}

original_code:
int compare_int(void *a, void *b){
 if(*((int *)a) == *((int *)b)){
  return 1;
 }
 return 0;
}

variable_types:
a
void *

variable_types:
b
void *


decompiled_code:
_BOOL8 __fastcall compare_char(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

original_code:
int compare_char(void *a, void *b){
 if(strcmp((char *)a,(char *)b) == 0) return 1;
 return 0;
}


decompiled_code:
__int64 __fastcall gcds_calc(unsigned int *a1, int a2)
{
__int64 result; // rax
__int64 v3; // rbx
int v4; // esi

if ( a2 == 1 )
return *a1;
result = 1LL;
if ( a2 > 0 )
{
result = gcd(a1[a2 - 1], a1[a2 - 2]);
LODWORD(v3) = a2 - 3;
if ( a2 - 3 >= 0 )
{
v3 = (int)v3;
while ( 1 )
{
v4 = a1[v3];
if ( v4 < 0 )
break;
result = gcd(result, v4);
if ( (int)--v3 < 0 )
return result;
}
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int *a1, int a2)
{
__int64 result; // rax
__int64 v3; // rbx
int v4; // esi

if ( a2 == 1 )
return *a1;
result = 1LL;
if ( a2 > 0 )
{
result = func0(a1[a2 - 1], a1[a2 - 2]);
LODWORD(v3) = a2 - 3;
if ( a2 - 3 >= 0 )
{
v3 = (int)v3;
while ( 1 )
{
v4 = a1[v3];
if ( v4 < 0 )
break;
result = func0(result, v4);
if ( (int)--v3 < 0 )
return result;
}
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int gcds_calc(int *ngram, int dist_count){
 int i, tmp;
 if(dist_count == 1 ) {
  return ngram[0];
 }else if(dist_count < 1){
  return 1;
 }
 tmp = gcd(ngram[dist_count-1],ngram[dist_count-2]);
 for (i = dist_count-3; i >= 0; --i) {
  if(ngram[i] < 0){
   return -1;
  }
  tmp = gcd(tmp,ngram[i]);
 }
 return tmp;
}

canonical_original_code:
int gcds_calc(int *ngram, int dist_count){
 int i; int tmp;
 if(dist_count == 1 ) {
  return ngram[0];
 }else if(dist_count < 1){
  return 1;
 }
 tmp = gcd(ngram[dist_count-1],ngram[dist_count-2]);
 for (i = dist_count-3; i >= 0; --i) {
  if(ngram[i] < 0){
   return -1;
  }
  tmp = gcd(tmp,ngram[i]);
 }
 return tmp;
}

variable_types:
ngram
int *

variable_types: tmp int


decompiled_code:
__int64 __fastcall letter_freqs(unsigned __int8 *a1, __int64 a2)
{
__int64 result; // rax
unsigned __int8 *v3; // rdi

result = *a1;
if ( (_BYTE)result )
{
v3 = a1 + 1;
do
{
*(double *)(a2 + 8LL * (char)result - 776) = *(double *)(a2 + 8LL * (char)result - 776) + 1.0;
result = *v3++;
}
while ( (_BYTE)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int8 *a1, __int64 a2)
{
__int64 result; // rax
unsigned __int8 *v3; // rdi

result = *a1;
if ( (_BYTE)result )
{
v3 = a1 + 1;
do
{
*(double *)(a2 + 8LL * (char)result - 776) = *(double *)(a2 + 8LL * (char)result - 776) + 1.0;
result = *v3++;
}
while ( (_BYTE)result );
}
return result;
}

original_code:
void letter_freqs(char *input, double freqs[]){
 char c;
 unsigned long i = 0;
 while((c = input[i++]) != 0){
  freqs[c - 'a']++;
 }
}

variable_types:
input
char *

variable_types:
freqs
double []

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall hash_char_2(char *a1, unsigned int a2)
{
unsigned int v2; // eax
char v3; // dl
char *v4; // rdi

v2 = *a1;
v3 = a1[1];
if ( v3 )
{
v4 = a1 + 2;
do
{
v2 = v3 + 16 * v2;
v3 = *v4++;
}
while ( v3 );
}
return v2 % a2;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1, unsigned int a2)
{
unsigned int v2; // eax
char v3; // dl
char *v4; // rdi

v2 = *a1;
v3 = a1[1];
if ( v3 )
{
v4 = a1 + 2;
do
{
v2 = v3 + 16 * v2;
v3 = *v4++;
}
while ( v3 );
}
return v2 % a2;
}

original_code:
unsigned int hash_char_2(void *value, unsigned int hash_table_size){
 char *data = (char*)value;
 unsigned h = data[0];
 int i;
 for (i = 1; data[i] != 0; ++i){
  h = (h << 4) + data[ i ];
 }
 return h % hash_table_size;
}

canonical_original_code:
unsigned int hash_char_2(void *value, unsigned int hash_table_size){
 char *data = (char*)value;
 unsigned int h = data[0];
 int i;
 for (i = 1; data[i] != 0; ++i){
  h = (h << 4) + data[ i ];
 }
 return h % hash_table_size;
}

variable_types:
data
char *

variable_types:
h
unsigned int


decompiled_code:
__int64 __fastcall q_compare_ngram(const void *a1, const void *a2)
{
return (unsigned int)(*((_DWORD *)a2 + 5) - *((_DWORD *)a1 + 5));
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
return (unsigned int)(*((_DWORD *)a2 + 5) - *((_DWORD *)a1 + 5));
}

original_code:
int q_compare_ngram(const void * a, const void * b){
 return (*((kasiski_node_t *)b)).count - (*((kasiski_node_t *)a)).count;
}

canonical_original_code:
int q_compare_ngram(void *a, void *b){
 return (*((struct _kasiski_node *)b)).count - (*((struct _kasiski_node *)a)).count;
}

user_defined_types: struct _kasiski_node { struct _kasiski_node *next; int *positions; unsigned int _ngram_max_pos; int count; unsigned int len; int *distances; int gcd; }


decompiled_code:
__int64 __fastcall q_compare_gcd(const void *a1, const void *a2)
{
return (unsigned int)(**((_DWORD **)a2 + 2) - **((_DWORD **)a1 + 2));
}

canonical_decompiled_code:
__int64 __fastcall func1(const void *a1, const void *a2)
{
return (unsigned int)(**((_DWORD **)a2 + 2) - **((_DWORD **)a1 + 2));
}

original_code:
int q_compare_gcd(const void * a, const void * b){
 hash_table_node_t h_a = *((hash_table_node_t *)a);
 hash_table_node_t h_b = *((hash_table_node_t *)b);
 return (*((int*)h_b.value)) - (*((int*)h_a.value));
}

canonical_original_code:
int q_compare_gcd(void *a, void *b){
 struct _hash_table_node h_a = *((hash_table_node_t *)a);
 struct _hash_table_node h_b = *((hash_table_node_t *)b);
 return (*((int *)h_b.value)) - (*((int *)h_a.value));
}

variable_types: struct _hash_table_node { struct _hash_table_node *next; void *key; void *value; }


decompiled_code:
_QWORD *create_default_ngram_node()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = malloc(0x30uLL);
if ( !v0 )
{
perror("node mallock failed\n");
exit(1);
}
v1 = v0;
v0[1] = malloc(0x320uLL);
v1[4] = malloc(0x320uLL);
*((_DWORD *)v1 + 5) = 0;
*((_DWORD *)v1 + 4) = 200;
return v1;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = malloc(0x30uLL);
if ( !v0 )
{
perror("node mallock failed\n");
exit(1);
}
v1 = v0;
v0[1] = malloc(0x320uLL);
v1[4] = malloc(0x320uLL);
*((_DWORD *)v1 + 5) = 0;
*((_DWORD *)v1 + 4) = 200;
return v1;
}

original_code:
kasiski_node_t *create_default_ngram_node(){
 kasiski_node_t *new_node = (kasiski_node_t *) malloc(sizeof(kasiski_node_t));
 if(new_node == ((void *)0)){
  perror("node mallock failed\n");
  exit(1);
 }
 new_node->positions = (int *) malloc(200 * sizeof(int));
 new_node->distances = (int *) malloc(200 * sizeof(int));
 new_node->count = 0;
 new_node->_ngram_max_pos = 200;
 return new_node;
}

canonical_original_code:
struct _kasiski_node *create_default_ngram_node(){
 struct _kasiski_node *new_node = (kasiski_node_t *) malloc(sizeof(kasiski_node_t));
 if(new_node == ((void *)0)){
  perror("node mallock failed\n");
  exit(1);
 }
 new_node->positions = (int *) malloc(200 * sizeof(int));
 new_node->distances = (int *) malloc(200 * sizeof(int));
 new_node->count = 0;
 new_node->_ngram_max_pos = 200;
 return new_node;
}

variable_types: struct _kasiski_node { struct _kasiski_node *next; int *positions; unsigned int _ngram_max_pos; int count; unsigned int len; int *distances; int gcd; } *


decompiled_code:
__int64 __fastcall add_position(__int64 a1, int a2, __int64 a3, _DWORD *a4)
{
int v6; // esi
__int64 result; // rax
int v8; // eax
unsigned int v9; // eax
unsigned int v10; // esi
void *v11; // rax

v6 = *(_DWORD *)(a1 + 16);
if ( *(_DWORD *)(a1 + 20) >= (unsigned int)(v6 - 1) )
{
v10 = 2 * v6;
*(_DWORD *)(a1 + 16) = v10;
*(_QWORD *)(a1 + 8) = realloc(*(void **)(a1 + 8), 4LL * v10);
v11 = realloc(*(void **)(a1 + 32), 4LL * *(unsigned int *)(a1 + 16));
*(_QWORD *)(a1 + 32) = v11;
if ( !*(_QWORD *)(a1 + 8) || !v11 )
{
perror("ngram->position | distances allocation\n");
exit(1);
}
}
LODWORD(result) = *(_DWORD *)(a1 + 20) + 1;
*(_DWORD *)(a1 + 20) = result;
result = (int)result;
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 4LL * (int)result - 4) = a2;
if ( *(int *)(a1 + 20) > 1 )
{
v8 = all_pos_max;
if ( *a4 >= (unsigned int)(all_pos_max - 1) )
{
all_pos_max *= 2;
all_pos = realloc(all_pos, 8LL * v8);
}
v9 = (*a4)++;
*((_DWORD *)all_pos + v9) = a2;
result = 4LL * *(int *)(a1 + 20);
*(_DWORD *)(*(_QWORD *)(a1 + 32) + result - 8) = *(_DWORD *)(*(_QWORD *)(a1 + 8) + result - 4)
- **(_DWORD **)(a1 + 8);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, __int64 a3, _DWORD *a4)
{
int v6; // esi
__int64 result; // rax
int v8; // eax
unsigned int v9; // eax
unsigned int v10; // esi
void *v11; // rax

v6 = *(_DWORD *)(a1 + 16);
if ( *(_DWORD *)(a1 + 20) >= (unsigned int)(v6 - 1) )
{
v10 = 2 * v6;
*(_DWORD *)(a1 + 16) = v10;
*(_QWORD *)(a1 + 8) = realloc(*(void **)(a1 + 8), 4LL * v10);
v11 = realloc(*(void **)(a1 + 32), 4LL * *(unsigned int *)(a1 + 16));
*(_QWORD *)(a1 + 32) = v11;
if ( !*(_QWORD *)(a1 + 8) || !v11 )
{
perror("ngram->position | distances allocation\n");
exit(1);
}
}
LODWORD(result) = *(_DWORD *)(a1 + 20) + 1;
*(_DWORD *)(a1 + 20) = result;
result = (int)result;
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 4LL * (int)result - 4) = a2;
if ( *(int *)(a1 + 20) > 1 )
{
v8 = all_pos_max;
if ( *a4 >= (unsigned int)(all_pos_max - 1) )
{
all_pos_max *= 2;
all_pos = realloc(all_pos, 8LL * v8);
}
v9 = (*a4)++;
*((_DWORD *)all_pos + v9) = a2;
result = 4LL * *(int *)(a1 + 20);
*(_DWORD *)(*(_QWORD *)(a1 + 32) + result - 8) = *(_DWORD *)(*(_QWORD *)(a1 + 8) + result - 4)
- **(_DWORD **)(a1 + 8);
}
return result;
}

original_code:
void add_position(kasiski_node_t *ngram, int position, int ngram_len, unsigned int *all_pos_counter){
 if(ngram->count >= ngram->_ngram_max_pos - 1){
  ngram->_ngram_max_pos *= 2;
  ngram->positions = (int *) realloc(ngram->positions,ngram->_ngram_max_pos * sizeof(int));
  ngram->distances = (int *) realloc(ngram->distances,ngram->_ngram_max_pos * sizeof(int));
  if(ngram->positions == ((void *)0) || ngram->distances == ((void *)0)){
   perror("ngram->position | distances allocation\n");
   exit(1);
  }
 }
 ngram->count++;
 ngram->positions[ngram->count - 1] = position;
 if(ngram->count < 2) return;
 if(*all_pos_counter >= all_pos_max - 1){
  all_pos_max *= 2;
  all_pos = (int *)realloc(all_pos,all_pos_max * sizeof(int));
 }
 all_pos[(*all_pos_counter)++] = position;
 ngram->distances[ngram->count - 2] = ngram->positions[ngram->count - 1] - ngram->positions[0];
}

canonical_original_code:
void add_position(struct _kasiski_node *ngram, int position, int ngram_len, unsigned int *all_pos_counter){
 if(ngram->count >= ngram->_ngram_max_pos - 1){
  ngram->_ngram_max_pos *= 2;
  ngram->positions = (int *) realloc(ngram->positions,ngram->_ngram_max_pos * sizeof(int));
  ngram->distances = (int *) realloc(ngram->distances,ngram->_ngram_max_pos * sizeof(int));
  if(ngram->positions == ((void *)0) || ngram->distances == ((void *)0)){
   perror("ngram->position | distances allocation\n");
   exit(1);
  }
 }
 ngram->count++;
 ngram->positions[ngram->count - 1] = position;
 if(ngram->count < 2) return;
 if(*all_pos_counter >= all_pos_max - 1){
  all_pos_max *= 2;
  all_pos = (int *)realloc(all_pos,all_pos_max * sizeof(int));
 }
 all_pos[(*all_pos_counter)++] = position;
 ngram->distances[ngram->count - 2] = ngram->positions[ngram->count - 1] - ngram->positions[0];
}

variable_types: position int


decompiled_code:
void __fastcall free_ngram_node(void *ptr)
{
free(*((void **)ptr + 4));
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
free(*((void **)ptr + 4));
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void free_ngram_node(kasiski_node_t* ngram_node) {
 free(ngram_node->distances);
 free(ngram_node->positions);
 free(ngram_node);
}

canonical_original_code:
void free_ngram_node(struct _kasiski_node *ngram_node) {
 free(ngram_node->distances);
 free(ngram_node->positions);
 free(ngram_node);
}


decompiled_code:
char *__fastcall substring_search(char *needle, __int64 a2, unsigned int a3, __int64 a4, int a5, _DWORD *a6)
{
char *result; // rax

while ( 1 )
{
result = strstr((const char *)(a2 + 1), needle);
a2 = (__int64)result;
if ( !result )
break;
add_position(a4, (_DWORD)result - a5, a3, a6);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func5(char *needle, __int64 a2, unsigned int a3, __int64 a4, int a5, _DWORD *a6)
{
char *result; // rax

while ( 1 )
{
result = strstr((const char *)(a2 + 1), needle);
a2 = (__int64)result;
if ( !result )
break;
func3(a4, (_DWORD)result - a5, a3, a6);
}
return result;
}

original_code:
void substring_search(const char *search,const char *text, int subl_len, kasiski_node_t *ngram, const char *orig_text,unsigned int *all_pos_counter){
 int pos;
 char *ptr;
 while((ptr = strstr(text + 1,search)) != ((void *)0)){
  pos = ptr - orig_text;
  add_position(ngram,pos,subl_len,all_pos_counter);
  text = ptr;
 }
}

canonical_original_code:
void substring_search(char *search, char *text, int subl_len, struct _kasiski_node *ngram, char *orig_text, unsigned int *all_pos_counter){
 int pos;
 char *ptr;
 while((ptr = strstr(text + 1,search)) != ((void *)0)){
  pos = ptr - orig_text;
  add_position(ngram,pos,subl_len,all_pos_counter);
  text = ptr;
 }
}

variable_types:
search
char *

variable_types:
text
char *

variable_types: pos int

variable_types:
ptr
char *


decompiled_code:
void __fastcall find_ngrams(const char *a1, int a2)
{
char *v2; // rbp
__int64 v3; // r12
unsigned int v4; // ebx
_QWORD *v5; // r14
int v6; // esi
int v7; // eax
int v8; // eax
char *v9; // [rsp+8h] [rbp-60h]
unsigned int v10; // [rsp+18h] [rbp-50h]
unsigned int v11; // [rsp+1Ch] [rbp-4Ch]
int v12[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v12[0] = 0;
v2 = (char *)malloc(6uLL);
all_pos = calloc(all_pos_max, 4uLL);
v3 = 3LL;
v11 = a2 - 3;
while ( 2 )
{
ngram_count[v3] = 0;
v8 = v12[0];
v12[0] = 0;
v4 = 0;
v10 = v8 - 1;
while ( (_DWORD)v3 != 3 )
{
if ( v4 > v10 )
goto LABEL_17;
substring(v2, a1, *((unsigned int *)all_pos + v4), (unsigned int)v3);
LABEL_8:
if ( !t_search(v2, &hash_char, &compare_char, &hash_table_all_ngrams, 10007LL) )
{
t_insert(v2, v2, &hash_char, &hash_table_all_ngrams, v3 + 1, v3 + 1, 10007LL);
v9 = strstr(a1, v2);
if ( v9 )
{
v5 = create_default_ngram_node();
add_position((__int64)v5, (_DWORD)v9 - (_DWORD)a1, (unsigned int)v3, v12);
substring_search(v2, (__int64)v9, v3, (__int64)v5, (int)a1, v12);
v6 = *((_DWORD *)v5 + 5);
if ( v6 > 1 )
{
*((_DWORD *)v5 + 6) = v3;
v7 = gcds_calc(v5[4], (unsigned int)(v6 - 1));
*((_DWORD *)v5 + 10) = v7;
if ( (unsigned int)(v7 - 1) > 2 || (mallock_ngrams_count & 1) != 0 && (ngram_count[v3] & 1) != 0 )
{
t_insert(v2, v5, &hash_char, &hash_table_ngrams, v3 + 1, 48LL, &unk_1ADC1);
++ngram_count[v3];
++mallock_ngrams_count;
}
}
free_ngram_node(v5);
}
}
++v4;
}
if ( v4 <= v11 )
{
substring(v2, a1, v4, 3LL);
goto LABEL_8;
}
LABEL_17:
if ( ngram_count[v3] )
{
if ( ++v3 != 6 )
continue;
}
else
{
last_ngram_index = v3 - 1;
}
break;
}
free(v2);
free(all_pos);
}

canonical_decompiled_code:
void __fastcall func6(const char *a1, int a2)
{
char *v2; // rbp
__int64 v3; // r12
unsigned int v4; // ebx
_QWORD *v5; // r14
int v6; // esi
int v7; // eax
int v8; // eax
char *v9; // [rsp+8h] [rbp-60h]
unsigned int v10; // [rsp+18h] [rbp-50h]
unsigned int v11; // [rsp+1Ch] [rbp-4Ch]
int v12[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v12[0] = 0;
v2 = (char *)malloc(6uLL);
all_pos = calloc(all_pos_max, 4uLL);
v3 = 3LL;
v11 = a2 - 3;
while ( 2 )
{
ngram_count[v3] = 0;
v8 = v12[0];
v12[0] = 0;
v4 = 0;
v10 = v8 - 1;
while ( (_DWORD)v3 != 3 )
{
if ( v4 > v10 )
goto LABEL_17;
substring(v2, a1, *((unsigned int *)all_pos + v4), (unsigned int)v3);
LABEL_8:
if ( !t_search(v2, &hash_char, &compare_char, &hash_table_all_ngrams, 10007LL) )
{
t_insert(v2, v2, &hash_char, &hash_table_all_ngrams, v3 + 1, v3 + 1, 10007LL);
v9 = strstr(a1, v2);
if ( v9 )
{
v5 = func2();
func3((__int64)v5, (_DWORD)v9 - (_DWORD)a1, (unsigned int)v3, v12);
func5(v2, (__int64)v9, v3, (__int64)v5, (int)a1, v12);
v6 = *((_DWORD *)v5 + 5);
if ( v6 > 1 )
{
*((_DWORD *)v5 + 6) = v3;
v7 = gcds_calc(v5[4], (unsigned int)(v6 - 1));
*((_DWORD *)v5 + 10) = v7;
if ( (unsigned int)(v7 - 1) > 2 || (mallock_ngrams_count & 1) != 0 && (ngram_count[v3] & 1) != 0 )
{
t_insert(v2, v5, &hash_char, &hash_table_ngrams, v3 + 1, 48LL, &unk_1ADC1);
++ngram_count[v3];
++mallock_ngrams_count;
}
}
func4(v5);
}
}
++v4;
}
if ( v4 <= v11 )
{
substring(v2, a1, v4, 3LL);
goto LABEL_8;
}
LABEL_17:
if ( ngram_count[v3] )
{
if ( ++v3 != 6 )
continue;
}
else
{
last_ngram_index = v3 - 1;
}
break;
}
free(v2);
free(all_pos);
}

original_code:
void find_ngrams(const char *c_text,unsigned int c_len){
 unsigned int sub_len,i,all_pos_counter = 0, pos_counter = 0;
 char *subst = (char *)malloc((5 + 1) * sizeof(char));
 kasiski_node_t *ngram_node;
 char *start_pos;
 int pos;
 all_pos = (int *)calloc(all_pos_max,sizeof(int));
 for(sub_len = 3; sub_len <= 5; sub_len++){
  ngram_count[sub_len] = 0;
  all_pos_counter = pos_counter;
  pos_counter = 0;
  for(i = 0; i <= (sub_len == 3 ? c_len - sub_len : all_pos_counter - 1); i++){
   if(sub_len != 3){
    substring(subst,c_text,all_pos[i],sub_len);
   }else{
    substring(subst,c_text,i,sub_len);
   }
   if(t_search(subst,hash_char,compare_char,hash_table_all_ngrams,10007) != ((void *)0)){
    continue;
   }
   t_insert(subst,subst,hash_char,hash_table_all_ngrams,sizeof(char)*sub_len+1,sizeof(char)*sub_len+1,10007);
   if((start_pos = strstr(c_text,subst)) != ((void *)0)){
    pos = start_pos - c_text;
    ngram_node = create_default_ngram_node(subst);
    add_position(ngram_node,pos,sub_len,&pos_counter);
    substring_search(subst,start_pos,sub_len,ngram_node,c_text,&pos_counter);
    if(ngram_node->count >= 2){
     ngram_node->len = sub_len;
     ngram_node->gcd = gcds_calc(ngram_node->distances,ngram_node->count - 1);
     if(((ngram_node->gcd == 1 || ngram_node->gcd == 2 || ngram_node->gcd == 3) &&
       (mallock_ngrams_count % 2 == 0 || ngram_count[sub_len] % 2 == 0))){
      free_ngram_node(ngram_node);
      continue;
     }
     t_insert(subst,ngram_node,hash_char,hash_table_ngrams,sizeof(char)*sub_len+1,sizeof(kasiski_node_t),110017);
     ngram_count[sub_len]++;
     mallock_ngrams_count++;
    }
    free_ngram_node(ngram_node);
   }
  }
  if(ngram_count[sub_len] == 0){
   last_ngram_index = sub_len - 1;
   break;
  } else {
  }
 }
 free(subst);
 free(all_pos);
}

canonical_original_code:
void find_ngrams(char *c_text, unsigned int c_len){
 unsigned int sub_len; unsigned int i; unsigned int all_pos_counter = 0; unsigned int pos_counter = 0;
 char *subst = (char *)malloc((5 + 1) * sizeof(char));
 struct _kasiski_node *ngram_node;
 char *start_pos;
 int pos;
 all_pos = (int *)calloc(all_pos_max,sizeof(int));
 for(sub_len = 3; sub_len <= 5; sub_len++){
  ngram_count[sub_len] = 0;
  all_pos_counter = pos_counter;
  pos_counter = 0;
  for(i = 0; i <= (sub_len == 3 ? c_len - sub_len : all_pos_counter - 1); i++){
   if(sub_len != 3){
    substring(subst,c_text,all_pos[i],sub_len);
   }else{
    substring(subst,c_text,i,sub_len);
   }
   if(t_search(subst,hash_char,compare_char,hash_table_all_ngrams,10007) != ((void *)0)){
    continue;
   }
   t_insert(subst,subst,hash_char,hash_table_all_ngrams,sizeof(char)*sub_len+1,sizeof(char)*sub_len+1,10007);
   if((start_pos = strstr(c_text,subst)) != ((void *)0)){
    pos = start_pos - c_text;
    ngram_node = create_default_ngram_node(subst);
    add_position(ngram_node,pos,sub_len,&pos_counter);
    substring_search(subst,start_pos,sub_len,ngram_node,c_text,&pos_counter);
    if(ngram_node->count >= 2){
     ngram_node->len = sub_len;
     ngram_node->gcd = gcds_calc(ngram_node->distances,ngram_node->count - 1);
     if(((ngram_node->gcd == 1 || ngram_node->gcd == 2 || ngram_node->gcd == 3) &&
       (mallock_ngrams_count % 2 == 0 || ngram_count[sub_len] % 2 == 0))){
      free_ngram_node(ngram_node);
      continue;
     }
     t_insert(subst,ngram_node,hash_char,hash_table_ngrams,sizeof(char)*sub_len+1,sizeof(kasiski_node_t),110017);
     ngram_count[sub_len]++;
     mallock_ngrams_count++;
    }
    free_ngram_node(ngram_node);
   }
  }
  if(ngram_count[sub_len] == 0){
   last_ngram_index = sub_len - 1;
   break;
  } else {
  }
 }
 free(subst);
 free(all_pos);
}

variable_types:
i
unsigned int

variable_types:
subst
char *


original_code:
void kasisky_hashmap_to_list(hash_table_node_t *hash_table[], int hash_table_size, kasiski_node_t *res[5], int *sizes){
 unsigned int i = 0, len = 0;
 hash_table_node_t *node;
 for (i = 0; i < hash_table_size; ++i) {
  node = hash_table[i];
  if(node != ((void *)0)){
   while(node != ((void *)0)){
    len = (*((kasiski_node_t *)node->value)).len;
    res[len][sizes[len]++] = *((kasiski_node_t *)node->value);
    node = node->next;
   }
  }
 }
}

canonical_original_code:
void kasisky_hashmap_to_list(struct _hash_table_node *hash_table[], int hash_table_size, struct _kasiski_node *res[5], int *sizes){
 unsigned int i = 0; unsigned int len = 0;
 struct _hash_table_node *node;
 for (i = 0; i < hash_table_size; ++i) {
  node = hash_table[i];
  if(node != ((void *)0)){
   while(node != ((void *)0)){
    len = (*((struct _kasiski_node *)node->value)).len;
    res[len][sizes[len]++] = *((struct _kasiski_node *)node->value);
    node = node->next;
   }
  }
 }
}

variable_types: struct _hash_table_node { struct _hash_table_node *next; void *key; void *value; } *[]

variable_types: struct _kasiski_node { struct _kasiski_node *next; int *positions; unsigned int _ngram_max_pos; int count; unsigned int len; int *distances; int gcd; } *[5]

variable_types:
sizes
int *

variable_types:
len
unsigned int


original_code:
hash_table_node_t *gcdcount_hashmap_to_list(hash_table_node_t *hash_table[],int size){
 unsigned int i = 0,j = 0;
 hash_table_node_t *node,*result;
 result = (hash_table_node_t *)malloc(sizeof(hash_table_node_t) * size);
 for (i = 0; i < 5351; ++i) {
  node = hash_table[i];
  if(node != ((void *)0)){
   while(node != ((void *)0)){
    result[j++] = *node;
    node = node->next;
   }
  }
 }
 return result;
}

canonical_original_code:
struct _hash_table_node *gcdcount_hashmap_to_list(struct _hash_table_node *hash_table[], int size){
 unsigned int i = 0; unsigned int j = 0;
 struct _hash_table_node *node; struct _hash_table_node *result;
 result = (struct _hash_table_node *)malloc(sizeof(hash_table_node_t) * size);
 for (i = 0; i < 5351; ++i) {
  node = hash_table[i];
  if(node != ((void *)0)){
   while(node != ((void *)0)){
    result[j++] = *node;
    node = node->next;
   }
  }
 }
 return result;
}

variable_types: size int

variable_types:
j
unsigned int

variable_types: struct _hash_table_node { struct _hash_table_node *next; void *key; void *value; } *


decompiled_code:
_QWORD *process_ngrams()
{
void **v0; // rax
int v1; // ebp
__int64 v2; // rbx
void **v3; // r12
int *v4; // r15
void **v5; // r14
__int64 v6; // rax
int v7; // ebx
int v8; // eax
__int64 v9; // rbp
char *v10; // rbx
_QWORD *result; // rax
int v12; // [rsp+0h] [rbp-68h]
int v13; // [rsp+4h] [rbp-64h]
void **v14; // [rsp+8h] [rbp-60h]
_QWORD *v15; // [rsp+10h] [rbp-58h]
int *ptr; // [rsp+18h] [rbp-50h]
int v17; // [rsp+28h] [rbp-40h] BYREF
int v18[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v15 = malloc(0x10uLL);
v0 = (void **)malloc(0x30uLL);
v14 = v0;
v1 = last_ngram_index;
if ( last_ngram_index <= 2 )
{
ptr = (int *)calloc(7uLL, 4uLL);
kasisky_hashmap_to_list(hash_table_ngrams, (int)&unk_1ADC1, (__int64)v14, (__int64)ptr);
v13 = 0;
}
else
{
v2 = 3LL;
v3 = v0;
do
{
v3[v2] = malloc(48LL * ngram_count[v2]);
++v2;
}
while ( v1 >= (int)v2 );
ptr = (int *)calloc(7uLL, 4uLL);
kasisky_hashmap_to_list(hash_table_ngrams, (int)&unk_1ADC1, (__int64)v14, (__int64)ptr);
v4 = ptr + 3;
v5 = v14 + 3;
v13 = 0;
v12 = 3;
do
{
qsort(*v5, *v4, 0x30uLL, (__compar_fn_t)q_compare_ngram);
v8 = *((_DWORD *)*v5 + 10);
v18[0] = v8;
if ( *v4 && v8 > 0 )
{
v9 = 48LL;
v7 = 0;
do
{
if ( v8 != 1 || *(double *)&friedman_result <= 1.5 )
{
v6 = t_search(v18, &hash_int, &compare_int, &hash_table_gcd_count, 5351LL);
if ( v6 )
{
++**(_DWORD **)(v6 + 16);
}
else
{
v17 = 1;
t_insert(v18, &v17, &hash_int, &hash_table_gcd_count, 4LL, 4LL, 5351LL);
++v13;
}
}
if ( ++v7 == 30 )
break;
v8 = *(_DWORD *)((char *)*v5 + v9 + 40);
v18[0] = v8;
v9 += 48LL;
if ( *v4 == v7 )
break;
}
while ( v8 > 0 );
}
free(*v5);
++v12;
++v4;
++v5;
}
while ( last_ngram_index >= v12 );
}
free(ptr);
free(v14);
v10 = gcdcount_hashmap_to_list((const __m128i **)&hash_table_gcd_count, v13);
qsort(v10, v13, 0x18uLL, (__compar_fn_t)q_compare_gcd);
result = v15;
*(_DWORD *)v15 = v13;
v15[1] = v10;
return result;
}

canonical_decompiled_code:
_QWORD *func9()
{
void **v0; // rax
int v1; // ebp
__int64 v2; // rbx
void **v3; // r12
int *v4; // r15
void **v5; // r14
__int64 v6; // rax
int v7; // ebx
int v8; // eax
__int64 v9; // rbp
char *v10; // rbx
_QWORD *result; // rax
int v12; // [rsp+0h] [rbp-68h]
int v13; // [rsp+4h] [rbp-64h]
void **v14; // [rsp+8h] [rbp-60h]
_QWORD *v15; // [rsp+10h] [rbp-58h]
int *ptr; // [rsp+18h] [rbp-50h]
int v17; // [rsp+28h] [rbp-40h] BYREF
int v18[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v15 = malloc(0x10uLL);
v0 = (void **)malloc(0x30uLL);
v14 = v0;
v1 = last_ngram_index;
if ( last_ngram_index <= 2 )
{
ptr = (int *)calloc(7uLL, 4uLL);
func7(hash_table_ngrams, (int)&unk_1ADC1, (__int64)v14, (__int64)ptr);
v13 = 0;
}
else
{
v2 = 3LL;
v3 = v0;
do
{
v3[v2] = malloc(48LL * ngram_count[v2]);
++v2;
}
while ( v1 >= (int)v2 );
ptr = (int *)calloc(7uLL, 4uLL);
func7(hash_table_ngrams, (int)&unk_1ADC1, (__int64)v14, (__int64)ptr);
v4 = ptr + 3;
v5 = v14 + 3;
v13 = 0;
v12 = 3;
do
{
qsort(*v5, *v4, 0x30uLL, (__compar_fn_t)q_compare_ngram);
v8 = *((_DWORD *)*v5 + 10);
v18[0] = v8;
if ( *v4 && v8 > 0 )
{
v9 = 48LL;
v7 = 0;
do
{
if ( v8 != 1 || *(double *)&friedman_result <= 1.5 )
{
v6 = t_search(v18, &hash_int, &compare_int, &hash_table_gcd_count, 5351LL);
if ( v6 )
{
++**(_DWORD **)(v6 + 16);
}
else
{
v17 = 1;
t_insert(v18, &v17, &hash_int, &hash_table_gcd_count, 4LL, 4LL, 5351LL);
++v13;
}
}
if ( ++v7 == 30 )
break;
v8 = *(_DWORD *)((char *)*v5 + v9 + 40);
v18[0] = v8;
v9 += 48LL;
if ( *v4 == v7 )
break;
}
while ( v8 > 0 );
}
free(*v5);
++v12;
++v4;
++v5;
}
while ( last_ngram_index >= v12 );
}
free(ptr);
free(v14);
v10 = func8((const __m128i **)&hash_table_gcd_count, v13);
qsort(v10, v13, 0x18uLL, (__compar_fn_t)q_compare_gcd);
result = v15;
*(_DWORD *)v15 = v13;
v15[1] = v10;
return result;
}

original_code:
kasiski_thread_result_t *process_ngrams(){
 int i, j;
 int *sizes;
 kasiski_node_t **res_list;
 hash_table_node_t *gcd_node,*values;
 int node_gcd, node_len = 0;
 kasiski_thread_result_t *result = (kasiski_thread_result_t *)malloc(sizeof(kasiski_thread_result_t));
 res_list = (kasiski_node_t **)malloc((5 + 1) * sizeof(kasiski_node_t *));
 for (i = 3; i <= last_ngram_index; ++i) {
  res_list[i] = (kasiski_node_t *)malloc(ngram_count[i] * sizeof(kasiski_node_t));
 }
 sizes = (int *)calloc(5 +2, sizeof(int));
 kasisky_hashmap_to_list(hash_table_ngrams,110017,res_list,sizes);
 for (i = 3; i <= last_ngram_index; ++i) {
  qsort(res_list[i],sizes[i],sizeof(kasiski_node_t),q_compare_ngram);
  for (j = 0; j < 30; ++j) {
   node_gcd = (res_list[i][j]).gcd;
   if(j == sizes[i] || node_gcd < 1){
    break;
   }
   if((node_gcd == 1 && friedman_result > 1.5)) continue;
   if((gcd_node = t_search(&node_gcd,hash_int,compare_int,hash_table_gcd_count,5351)) != ((void *)0)){
    (*((int *)gcd_node->value))++;
   }else{
    int node_value = 1;
    t_insert(&node_gcd,&node_value,hash_int,hash_table_gcd_count,sizeof(int),sizeof(int),5351);
    node_len++;
   }
  }
  free(res_list[i]);
 }
 free(sizes);
 free(res_list);
 values = gcdcount_hashmap_to_list(hash_table_gcd_count,node_len);
 qsort(values,node_len,sizeof(hash_table_node_t),q_compare_gcd);
 result->len = node_len;
 result->values = values;
 return result;
}

canonical_original_code:
struct _thread_result *process_ngrams(){
 int i; int j;
 int *sizes;
 struct _kasiski_node **res_list;
 struct _hash_table_node *gcd_node; struct _hash_table_node *values;
 int node_gcd; int node_len = 0;
 struct _thread_result *result = (kasiski_thread_result_t *)malloc(sizeof(kasiski_thread_result_t));
 res_list = (struct _kasiski_node **)malloc((5 + 1) * sizeof(struct _kasiski_node *));
 for (i = 3; i <= last_ngram_index; ++i) {
  res_list[i] = (struct _kasiski_node *)malloc(ngram_count[i] * sizeof(kasiski_node_t));
 }
 sizes = (int *)calloc(5 +2, sizeof(int));
 kasisky_hashmap_to_list(hash_table_ngrams,110017,res_list,sizes);
 for (i = 3; i <= last_ngram_index; ++i) {
  qsort(res_list[i],sizes[i],sizeof(kasiski_node_t),q_compare_ngram);
  for (j = 0; j < 30; ++j) {
   node_gcd = (res_list[i][j]).gcd;
   if(j == sizes[i] || node_gcd < 1){
    break;
   }
   if((node_gcd == 1 && friedman_result > 1.5)) continue;
   if((gcd_node = t_search(&node_gcd,hash_int,compare_int,hash_table_gcd_count,5351)) != ((void *)0)){
    (*((int *)gcd_node->value))++;
   }else{
    int node_value = 1;
    t_insert(&node_gcd,&node_value,hash_int,hash_table_gcd_count,sizeof(int),sizeof(int),5351);
    node_len++;
   }
  }
  free(res_list[i]);
 }
 free(sizes);
 free(res_list);
 values = gcdcount_hashmap_to_list(hash_table_gcd_count,node_len);
 qsort(values,node_len,sizeof(hash_table_node_t),q_compare_gcd);
 result->len = node_len;
 result->values = values;
 return result;
}

variable_types: i int

variable_types: j int

variable_types: struct _kasiski_node { struct _kasiski_node *next; int *positions; unsigned int _ngram_max_pos; int count; unsigned int len; int *distances; int gcd; } **

variable_types: struct _thread_result { unsigned int len; struct _hash_table_node { struct _hash_table_node *next; void *key; void *value; } *values; } *

user_defined_types: struct _thread_result { unsigned int len; struct _hash_table_node *values; }


decompiled_code:
__int64 __fastcall q_compare_int(_DWORD *a1, _DWORD *a2)
{
return (unsigned int)(*a1 - *a2);
}

canonical_decompiled_code:
__int64 __fastcall func10(_DWORD *a1, _DWORD *a2)
{
return (unsigned int)(*a1 - *a2);
}

original_code:
int q_compare_int(const void * a, const void * b){
 return ( *(int*)a - *(int*)b );
}

canonical_original_code:
int q_compare_int(void *a, void *b){
 return ( *(int *)a - *(int *)b );
}

variable_types:
a
void *

variable_types:
b
void *


original_code:
void free_hash_table(hash_table_node_t *hash_table[], int hash_table_size){
 unsigned int i = 0;
 hash_table_node_t *node,*old;
 for (i = 0; i < hash_table_size; ++i) {
  node = hash_table[i];
  if(node != ((void *)0)){
   while(node != ((void *)0)){
    free(node->key);
    free(node->value);
    old = node;
    node = old->next;
    free(old);
   }
  }
 }
}

canonical_original_code:
void free_hash_table(struct _hash_table_node *hash_table[], int hash_table_size){
 unsigned int i = 0;
 struct _hash_table_node *node; struct _hash_table_node *old;
 for (i = 0; i < hash_table_size; ++i) {
  node = hash_table[i];
  if(node != ((void *)0)){
   while(node != ((void *)0)){
    free(node->key);
    free(node->value);
    old = node;
    node = old->next;
    free(old);
   }
  }
 }
}

user_defined_types: struct _hash_table_node { struct _hash_table_node *next; void *key; void *value; }


decompiled_code:
double *__fastcall friedman_test(char *s)
{
double *v1; // rbx
size_t v2; // rax
double v3; // xmm0_8

v1 = (double *)malloc(8uLL);
v2 = strlen(s);
if ( (v2 & 0x8000000000000000LL) != 0LL )
v3 = (double)(int)(v2 & 1 | (v2 >> 1)) + (double)(int)(v2 & 1 | (v2 >> 1));
else
v3 = (double)(int)v2;
*v1 = 0.0;
if ( v3 >= 1.0 )
*v1 = 0.0265 / (COERCE_DOUBLE(index_of_coincidence((__int64)s, v3, 0.0)) - 0.0385);
return v1;
}

canonical_decompiled_code:
double *__fastcall func0(char *s)
{
double *v1; // rbx
size_t v2; // rax
double v3; // xmm0_8

v1 = (double *)malloc(8uLL);
v2 = strlen(s);
if ( (v2 & 0x8000000000000000LL) != 0LL )
v3 = (double)(int)(v2 & 1 | (v2 >> 1)) + (double)(int)(v2 & 1 | (v2 >> 1));
else
v3 = (double)(int)v2;
*v1 = 0.0;
if ( v3 >= 1.0 )
*v1 = 0.0265 / (COERCE_DOUBLE(index_of_coincidence((__int64)s, v3, 0.0)) - 0.0385);
return v1;
}

original_code:
void *friedman_test(void *ptr){
 char *c_text_s = ptr;
 double *friedman = (double *)malloc(sizeof(double));
 double k0 = 0.0, kp = 0.065, kr = 0.0385;
 double len = strlen(c_text_s);
 *friedman = 0.0;
 if(len < 1) return friedman;
 k0 = index_of_coincidence(c_text_s,len,0);
 *friedman = (kp - kr)/(k0 - kr);
 return friedman;
}

canonical_original_code:
void *friedman_test(void *ptr){
 char *c_text_s = ptr;
 double *friedman = (double *)malloc(sizeof(double));
 double k0 = 0.0; double kp = 0.065; double kr = 0.0385;
 double len = strlen(c_text_s);
 *friedman = 0.0;
 if(len < 1) return friedman;
 k0 = index_of_coincidence(c_text_s,len,0);
 *friedman = (kp - kr)/(k0 - kr);
 return friedman;
}

variable_types:
ptr
void *

variable_types:
friedman
double *

variable_types: kp double

variable_types: kr double

variable_types: len double

return_type: void *


original_code:
int ic_passwd_len(char *string, double len, double friedman, kasiski_thread_result_t *m_numbers){
 char **ics = (char **)malloc(1000 * sizeof(char *));
 unsigned long k, l = 0, m = 0;
 double diff_sum = 0.0, ic_min = 100, diff_avg, kasiski = 0.0,kas_diff;
 unsigned int result_m = 1,kasiski_key;
 if( m_numbers->len < 1){
  return 0;
 }
 kasiski_key = *((int*)m_numbers->values[0].key);
 for (l = 0; l < m_numbers->len; ++l) {
  m = *((int *)m_numbers->values[l].key);
  ics = text_to_columns(m,string,len,ics);
  diff_sum = 0;
  for (k = 0; k < m; ++k) {
   diff_sum += fabs(index_of_coincidence(ics[k],strlen(ics[k]),0.067));
   free(ics[k]);
  }
  diff_avg = diff_sum/m;
  if(diff_avg < ic_min){
   ic_min = diff_avg;
   result_m = m;
  }
  if(kasiski_key == m){
   kasiski = diff_avg;
  }
 }
 kas_diff = fabs(kasiski-ic_min);
 if(kas_diff <= 0.000040){
  result_m = kasiski_key;
 }
 if(ics != ((void *)0)) free(ics);
 return result_m;
}

canonical_original_code:
int ic_passwd_len(char *string, double len, double friedman, struct _thread_result *m_numbers){
 char **ics = (char **)malloc(1000 * sizeof(char *));
 unsigned long k; unsigned long l = 0; unsigned long m = 0;
 double diff_sum = 0.0; double ic_min = 100; double diff_avg; double kasiski = 0.0; double kas_diff;
 unsigned int result_m = 1; unsigned int kasiski_key;
 if( m_numbers->len < 1){
  return 0;
 }
 kasiski_key = *((int *)m_numbers->values[0].key);
 for (l = 0; l < m_numbers->len; ++l) {
  m = *((int *)m_numbers->values[l].key);
  ics = text_to_columns(m,string,len,ics);
  diff_sum = 0;
  for (k = 0; k < m; ++k) {
   diff_sum += fabs(index_of_coincidence(ics[k],strlen(ics[k]),0.067));
   free(ics[k]);
  }
  diff_avg = diff_sum/m;
  if(diff_avg < ic_min){
   ic_min = diff_avg;
   result_m = m;
  }
  if(kasiski_key == m){
   kasiski = diff_avg;
  }
 }
 kas_diff = fabs(kasiski-ic_min);
 if(kas_diff <= 0.000040){
  result_m = kasiski_key;
 }
 if(ics != ((void *)0)) free(ics);
 return result_m;
}

variable_types:
string
char *

variable_types: friedman double

variable_types:
ics
char **

variable_types:
k
unsigned long

variable_types:
l
unsigned long

variable_types:
m
unsigned long

variable_types: kasiski double


appMouse

repo: uOptim/pmg-enseirb

decompiled_code:
__int64 __fastcall appMouse(char a1, int a2, int a3, unsigned int a4)
{
__int64 result; // rax

result = a4;
if ( a2 )
{
if ( a2 == 1 )
mouse_buttons = 0;
}
else
{
mouse_buttons |= 1 << a1;
}
mouse_old_x = a3;
mouse_old_y = a4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1, int a2, int a3, unsigned int a4)
{
__int64 result; // rax

result = a4;
if ( a2 )
{
if ( a2 == 1 )
mouse_buttons = 0;
}
else
{
mouse_buttons |= 1 << a1;
}
mouse_old_x = a3;
mouse_old_y = a4;
return result;
}

original_code:
void appMouse(int button, int state, int x, int y)
{
 if (state == 0x0000) {
  mouse_buttons |= 1<<button;
 } else if (state == 0x0001) {
  mouse_buttons = 0;
 }
 mouse_old_x = x;
 mouse_old_y = y;
}

variable_types: button int

variable_types: state int

variable_types: x int

variable_types: y int


reshape

decompiled_code:
__int64 __fastcall reshape(int a1, int a2)
{
glViewport(0LL, 0LL, (unsigned int)a1, (unsigned int)a2);
*(double *)&aspect = (float)((float)a1 / (float)a2);
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(*(double *)&fovy, *(double *)&aspect, *(double *)&near_clip, *(double *)&far_clip);
return glMatrixMode(5888LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2)
{
glViewport(0LL, 0LL, (unsigned int)a1, (unsigned int)a2);
*(double *)&aspect = (float)((float)a1 / (float)a2);
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(*(double *)&fovy, *(double *)&aspect, *(double *)&near_clip, *(double *)&far_clip);
return glMatrixMode(5888LL);
}

original_code:
void reshape (int w, int h) {
 glViewport(0, 0, (GLsizei)w, (GLsizei)h);
 aspect = w/(float)h;
 glMatrixMode(0x1701);
 glLoadIdentity();
 gluPerspective(fovy,aspect,near_clip,far_clip);
 glMatrixMode(0x1700);
}

canonical_original_code:
void reshape(int w, int h) {
 glViewport(0, 0, (int)w, (int)h);
 aspect = w/(float)h;
 glMatrixMode(0x1701);
 glLoadIdentity();
 gluPerspective(fovy,aspect,near_clip,far_clip);
 glMatrixMode(0x1700);
}

variable_types: w int

variable_types: h int