query

decompiled_code:
__int64 __fastcall query(const char *a1, __int64 a2, __int64 a3, __int64 a4, double a5, double a6)
{
char *v7; // r14
_QWORD *v8; // rax
int v9; // ebx
int *v10; // r15
__int64 v11; // r13
_QWORD *v12; // rax
_QWORD *v13; // rbp
void *v14; // rax
void *v15; // r12
size_t v16; // rax
unsigned int *v18; // [rsp+8h] [rbp-B0h]
double v19; // [rsp+10h] [rbp-A8h]
_QWORD *v20; // [rsp+18h] [rbp-A0h]
void *v21; // [rsp+30h] [rbp-88h]
__int64 v23[6]; // [rsp+40h] [rbp-78h] BYREF
int v24; // [rsp+70h] [rbp-48h]

v19 = a5;
v21 = malloc(0xF4240uLL);
v7 = (char *)malloc(0x3B9ACA01uLL);
v18 = (unsigned int *)malloc(0x48uLL);
v8 = (_QWORD *)make_list(a2, a3);
v8[2] = 0LL;
v8[3] = 0LL;
v8[4] = 0LL;
*v8 = a2;
v20 = v8;
load_bloom(a2, v18);
if ( a5 == 0.0 )
v19 = mco_suggestion(v18[14]);
v9 = 2;
v10 = (int *)gzopen64(a1, "rb");
if ( !strstr(a1, ".fastq") )
v9 = 1 - ((strstr(a1, ".fq") == 0LL) - 1);
v11 = 0LL;
do
{
v11 = CHUNKer(v10, v11, 0x3B9ACA00u, v7, v9);
v12 = malloc(0x20uLL);
*v12 = 0LL;
v13 = v12;
v14 = malloc(0x20uLL);
v13[3] = v14;
v15 = v14;
get_parainfo(v7, v13);
v23[3] = (__int64)v20;
v23[5] = (__int64)v15;
v23[2] = (__int64)v18;
v24 = v9;
v23[4] = (__int64)v13;
*(double *)&v23[1] = a6;
*(double *)v23 = v19;
GOMP_parallel(query__omp_fn_0, v23, 0LL, 0LL);
if ( !v7 )
{
perror("Cannot memset, wrong position on fastq file\n");
exit(-1);
}
v16 = strlen(v7);
memset(v7, 0, v16);
clean_list(v13, v15);
}
while ( v11 != -1 );
free(v7);
evaluate(v21, *v20, v20);
gzclose(v10);
bloom_destroy(v18);
statistic_save(v21, a1, a4);
return 0LL;
}

original_code:
int query(char* query, char* bloom_filter, double tole_rate, double sampling_rate, char* list, char* target_path)
{
  gzFile zip;
  int type = 0;
  long long offset = 0;
  char *detail = (char*) malloc((100*100*100)*sizeof(char));
  char *position = (char*) malloc((1000000000 +1)*sizeof(char));
  bloom *bl_2 = (bloom *) malloc(sizeof(bloom));
  F_set *File_head = make_list (bloom_filter, list);
  File_head->reads_num = 0;
  File_head->reads_contam = 0;
  File_head->hits = 0;
  File_head->filename = bloom_filter;
  load_bloom (File_head->filename, bl_2);
  if (tole_rate==0)
      tole_rate = mco_suggestion (bl_2->k_mer);
  if ((zip = gzopen64(query, "rb"))<0) {
  perror("query open error...\n");
     exit(-1);
  }
  if (strstr(query, ".fastq") || strstr(query, ".fq"))
      type = 2;
  else
      type = 1;
  while (offset!=-1) {
 offset = CHUNKer(zip,offset,1000000000,position,type);
    Queue *head = (Queue *) malloc(sizeof(Queue));
    head->location = ((void *)0);
    Queue *tail = (Queue *) malloc(sizeof(Queue));
    head->next = tail;
    Queue *head2 = head;
    get_parainfo (position, head);

#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;
     }
 }
}
  if (position != ((void *)0)) {
      memset (position, 0, strlen(position));
      }
  else {
      perror("Cannot memset, wrong position on fastq file\n");
      exit(-1);
  }
  clean_list (head2, tail);
    }
  free(position);
  evaluate (detail, File_head->filename, File_head);
  gzclose(zip);
  bloom_destroy (bl_2);
  statistic_save (detail, query, target_path);
  return 0;
}

canonical_original_code:
int query(char *query, char *bloom_filter, double tole_rate, double sampling_rate, char *list, char *target_path)
{
  struct gzFile_s *zip;
  int type = 0;
  long long offset = 0;
  char *detail = (char*) malloc((100*100*100)*sizeof(char));
  char *position = (char*) malloc((1000000000 +1)*sizeof(char));
  struct bloom *bl_2 = (bloom *) malloc(sizeof(bloom));
  struct file_list *File_head = make_list (bloom_filter, list);
  File_head->reads_num = 0;
  File_head->reads_contam = 0;
  File_head->hits = 0;
  File_head->filename = bloom_filter;
  load_bloom (File_head->filename, bl_2);
  if (tole_rate==0)
      tole_rate = mco_suggestion (bl_2->k_mer);
  if ((zip = gzopen64(query, "rb"))<0) {
  perror("query open error...\n");
     exit(-1);
  }
  if (strstr(query, ".fastq") || strstr(query, ".fq"))
      type = 2;
  else
      type = 1;
  while (offset!=-1) {
 offset = CHUNKer(zip,offset,1000000000,position,type);
    struct info *head = (Queue *) malloc(sizeof(Queue));
    head->location = ((void *)0);
    struct info *tail = (Queue *) malloc(sizeof(Queue));
    head->next = tail;
    struct info *head2 = head;
    get_parainfo (position, head);

#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;
     }
 }
}
  if (position != ((void *)0)) {
      memset (position, 0, strlen(position));
      }
  else {
      perror("Cannot memset, wrong position on fastq file\n");
      exit(-1);
  }
  clean_list (head2, tail);
    }
  free(position);
  evaluate (detail, File_head->filename, File_head);
  gzclose(zip);
  bloom_destroy (bl_2);
  statistic_save (detail, query, target_path);
  return 0;
}

variable_types:
query
char *

variable_types:
list
char *

variable_types:
detail
char *

variable_types:
position
char *

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


repo: tzcoolman/FACS-OLD

decompiled_code:
__int64 __fastcall bq_main(const char *argc, char **argv)
{
char *v2; // r15
char *v3; // r14
char *v4; // r13
char *v5; // r12
char **v6; // rbp
unsigned int v7; // ebx
int v8; // eax
float v10; // xmm4_4
float v11; // xmm5_4
float v12; // [rsp+0h] [rbp-40h]
float v13; // [rsp+4h] [rbp-3Ch]

if ( (int)argc <= 1 )
return query_usage(argc, argv);
v2 = 0LL;
v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = argv;
v7 = (unsigned int)argc;
v12 = 0.0;
v13 = *(float *)&LC10;
while ( 2 )
{
argv = v6;
argc = (const char *)v7;
v8 = getopt(v7, v6, "s:t:r:o:q:l:h");
if ( v8 != -1 )
{
switch ( v8 )
{
case '?':
argv = (char **)(unsigned int)(char)optopt;
argc = "Unknown option: -%c\n";
printf("Unknown option: -%c\n", argv);
return query_usage(argc, argv);
case 'h':
return query_usage(argc, argv);
case 'l':
if ( optarg )
v3 = optarg;
continue;
case 'o':
if ( optarg )
v2 = optarg;
continue;
case 'q':
if ( optarg )
v5 = optarg;
continue;
case 'r':
if ( optarg )
v4 = optarg;
continue;
case 's':
if ( optarg )
{
v11 = atof(optarg);
v13 = v11;
}
continue;
case 't':
if ( optarg )
{
v10 = atof(optarg);
v12 = v10;
}
continue;
default:
continue;
}
}
break;
}
return query(v5, (__int64)v4, (__int64)v3, (__int64)v2, v12, v13);
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *argc, char **argv)
{
char *v2; // r15
char *v3; // r14
char *v4; // r13
char *v5; // r12
char **v6; // rbp
unsigned int v7; // ebx
int v8; // eax
float v10; // xmm4_4
float v11; // xmm5_4
float v12; // [rsp+0h] [rbp-40h]
float v13; // [rsp+4h] [rbp-3Ch]

if ( (int)argc <= 1 )
return func0(argc, argv);
v2 = 0LL;
v3 = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = argv;
v7 = (unsigned int)argc;
v12 = 0.0;
v13 = *(float *)&LC10;
while ( 2 )
{
argv = v6;
argc = (const char *)v7;
v8 = getopt(v7, v6, "s:t:r:o:q:l:h");
if ( v8 != -1 )
{
switch ( v8 )
{
case '?':
argv = (char **)(unsigned int)(char)optopt;
argc = "Unknown option: -%c\n";
printf("Unknown option: -%c\n", argv);
return func0(argc, argv);
case 'h':
return func0(argc, argv);
case 'l':
if ( optarg )
v3 = optarg;
continue;
case 'o':
if ( optarg )
v2 = optarg;
continue;
case 'q':
if ( optarg )
v5 = optarg;
continue;
case 'r':
if ( optarg )
v4 = optarg;
continue;
case 's':
if ( optarg )
{
v11 = atof(optarg);
v13 = v11;
}
continue;
case 't':
if ( optarg )
{
v10 = atof(optarg);
v12 = v10;
}
continue;
default:
continue;
}
}
break;
}
return func7(v5, (__int64)v4, (__int64)v3, (__int64)v2, v12, v13);
}

original_code:
int bq_main(int argc, char** argv)
{
  if (argc < 2) return query_usage();
  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':
              return query_usage();
          case '?':
              printf ("Unknown option: -%c\n", (char) optopt);
              return query_usage();
      }
  }
  return query(source, ref, tole_rate, sampling_rate, list, target_path);
}

canonical_original_code:
int bq_main(int argc, char **argv)
{
  if (argc < 2) return query_usage();
  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':
              return query_usage();
          case '?':
              printf ("Unknown option: -%c\n", (char) optopt);
              return query_usage();
      }
  }
  return query(source, ref, tole_rate, sampling_rate, list, target_path);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int

variable_types:
ref
char *

variable_types:
source
char *

return_type: int


decompiled_code:
__int64 __fastcall bloom_init(__int64 a1, __int64 a2, __int64 a3, int a4, void *a5, double a6)
{
__int64 v9; // rax
bool v10; // dl
void *v11; // rax
__int64 result; // rax
double v13; // xmm0_8
double v14; // xmm0_8

if ( a2 )
{
v9 = find_close_prime(a2);
*(_QWORD *)(a1 + 24) = v9;
if ( a4 <= 0 )
{
result = 0xFFFFFFFFLL;
}
else
{
*(_DWORD *)(a1 + 32) = a4;
if ( !a5 )
a5 = &hash5;
*(_QWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 8) = a5;
if ( !a3 )
goto LABEL_13;
v10 = 1;
if ( a6 != 0.0 )
v10 = a3 == 0;
if ( v10 )
{
LABEL_13:
if ( v9 < 0 )
v13 = (double)(int)(v9 & 1 | ((unsigned __int64)v9 >> 1))
+ (double)(int)(v9 & 1 | ((unsigned __int64)v9 >> 1));
else
v13 = (double)(int)v9;
v14 = v13 * 0.7 / (double)a4;
if ( v14 >= 9.223372036854776e18 )
{
*(_QWORD *)(a1 + 40) = (unsigned int)(int)(v14 - 9.223372036854776e18);
*(_QWORD *)(a1 + 40) ^= 0x8000000000000000LL;
}
else
{
*(_QWORD *)(a1 + 40) = (unsigned int)(int)v14;
}
*(double *)(a1 + 48) = powf(2.0, COERCE_FLOAT(COERCE_UNSIGNED_INT((float)a4) ^ LC4));
}
else
{
*(_QWORD *)(a1 + 40) = a3;
*(double *)(a1 + 48) = a6;
}
if ( a2 < 0 )
{
fwrite("overflow2\n", 1uLL, 0xAuLL, stderr);
result = 4294967294LL;
}
else
{
v11 = calloc((*(_QWORD *)(a1 + 24) >> 3) + 1LL, 1uLL);
*(_QWORD *)a1 = v11;
if ( v11 )
{
result = 0LL;
}
else
{
perror("malloc");
result = 0xFFFFFFFFLL;
}
}
}
}
else
{
fwrite("overflow1\n", 1uLL, 0xAuLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, int a4, void *a5, double a6)
{
__int64 v9; // rax
bool v10; // dl
void *v11; // rax
__int64 result; // rax
double v13; // xmm0_8
double v14; // xmm0_8

if ( a2 )
{
v9 = find_close_prime(a2);
*(_QWORD *)(a1 + 24) = v9;
if ( a4 <= 0 )
{
result = 0xFFFFFFFFLL;
}
else
{
*(_DWORD *)(a1 + 32) = a4;
if ( !a5 )
a5 = &hash5;
*(_QWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 8) = a5;
if ( !a3 )
goto LABEL_13;
v10 = 1;
if ( a6 != 0.0 )
v10 = a3 == 0;
if ( v10 )
{
LABEL_13:
if ( v9 < 0 )
v13 = (double)(int)(v9 & 1 | ((unsigned __int64)v9 >> 1))
+ (double)(int)(v9 & 1 | ((unsigned __int64)v9 >> 1));
else
v13 = (double)(int)v9;
v14 = v13 * 0.7 / (double)a4;
if ( v14 >= 9.223372036854776e18 )
{
*(_QWORD *)(a1 + 40) = (unsigned int)(int)(v14 - 9.223372036854776e18);
*(_QWORD *)(a1 + 40) ^= 0x8000000000000000LL;
}
else
{
*(_QWORD *)(a1 + 40) = (unsigned int)(int)v14;
}
*(double *)(a1 + 48) = powf(2.0, COERCE_FLOAT(COERCE_UNSIGNED_INT((float)a4) ^ LC4));
}
else
{
*(_QWORD *)(a1 + 40) = a3;
*(double *)(a1 + 48) = a6;
}
if ( a2 < 0 )
{
fwrite("overflow2\n", 1uLL, 0xAuLL, stderr);
result = 4294967294LL;
}
else
{
v11 = calloc((*(_QWORD *)(a1 + 24) >> 3) + 1LL, 1uLL);
*(_QWORD *)a1 = v11;
if ( v11 )
{
result = 0LL;
}
else
{
perror("malloc");
result = 0xFFFFFFFFLL;
}
}
}
}
else
{
fwrite("overflow1\n", 1uLL, 0xAuLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
bloom_init (bloom * bloom, unsigned long long size, unsigned long long capacity, double error_rate,
     int hashes, hash_t hash, int flags)
{
  if (size < 1)
    {
      fprintf (stderr, "overflow1\n");
      return -1;
    }
  else
    {
      bloom->stat.elements = find_close_prime (size);
    }
  if (hashes < 1)
    {
      return -1;
    }
  else
    {
      bloom->stat.ideal_hashes = hashes;
    }
  if (hash == ((void *)0))
    {
      bloom->hash = (hash_t) hash5;
    }
  else
    {
      bloom->hash = hash;
    }
  bloom->inserts = 0;
  if (capacity == 0 || error_rate == 0)
    {
      bloom->stat.capacity = 0.7 * bloom->stat.elements / hashes;
      bloom->stat.e = powf (2.0, (float) -1 * hashes);
    }
  else
    {
      bloom->stat.capacity = capacity;
      bloom->stat.e = error_rate;
    }
  if ((size > 0x7fffffffffffffffL))
    {
      fprintf (stderr, "overflow2\n");
      return -2;
    }
  if ((bloom->vector = (char *) malloc (sizeof (char) *
     ((long long) (bloom->stat.elements /
            8) + 1))) == ((void *)0))
    {
      perror ("malloc");
      return -1;
    }
  else
    memset (bloom->vector, 0,
     sizeof (char) * ((long long) (bloom->stat.elements / 8) + 1));
  return 0;
}

canonical_original_code:
int bloom_init(struct bloom *bloom, unsigned long long size, unsigned long long capacity, double error_rate, int hashes, unsigned long long (*hash)(char *str), int flags)
{
  if (size < 1)
    {
      fprintf (stderr, "overflow1\n");
      return -1;
    }
  else
    {
      bloom->stat.elements = find_close_prime (size);
    }
  if (hashes < 1)
    {
      return -1;
    }
  else
    {
      bloom->stat.ideal_hashes = hashes;
    }
  if (hash == ((void *)0))
    {
      bloom->hash = (unsigned long long (*)(char *str)) hash5;
    }
  else
    {
      bloom->hash = hash;
    }
  bloom->inserts = 0;
  if (capacity == 0 || error_rate == 0)
    {
      bloom->stat.capacity = 0.7 * bloom->stat.elements / hashes;
      bloom->stat.e = powf (2.0, (float) -1 * hashes);
    }
  else
    {
      bloom->stat.capacity = capacity;
      bloom->stat.e = error_rate;
    }
  if ((size > 0x7fffffffffffffffL))
    {
      fprintf (stderr, "overflow2\n");
      return -2;
    }
  if ((bloom->vector = (char *) malloc (sizeof (char) *
     ((long long) (bloom->stat.elements /
            8) + 1))) == ((void *)0))
    {
      perror ("malloc");
      return -1;
    }
  else
    memset (bloom->vector, 0,
     sizeof (char) * ((long long) (bloom->stat.elements / 8) + 1));
  return 0;
}

variable_types:
size
unsigned long long

variable_types:
capacity
unsigned long long

variable_types: hashes int

variable_types:
hash
unsigned long long (*)(char *str)

variable_types: flags int

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

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


decompiled_code:
void __fastcall bloom_destroy(__int64 a1)
{
memset(*(void **)a1, 0, (*(_QWORD *)(a1 + 24) >> 3) + 1LL);
free(*(void **)a1);
*(_QWORD *)a1 = 0LL;
}

original_code:
void
bloom_destroy (bloom * bloom)
{
  memset (bloom->vector, 0,
   sizeof (char) * ((long long) (bloom->stat.elements / 8) + 1));
  free (bloom->vector);
  bloom->vector = ((void *)0);
}

canonical_original_code:
void bloom_destroy(struct bloom *bloom)
{
  memset (bloom->vector, 0,
   sizeof (char) * ((long long) (bloom->stat.elements / 8) + 1));
  free (bloom->vector);
  bloom->vector = ((void *)0);
}

return_type: void


decompiled_code:
unsigned __int64 __fastcall bloom_hash(__int64 a1, __int64 a2, int a3, unsigned int a4)
{
return (unsigned __int64)hash5(a2, (unsigned int)seed[a3], a4) % *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(__int64 a1, __int64 a2, int a3, unsigned int a4)
{
return (unsigned __int64)hash5(a2, (unsigned int)seed[a3], a4) % *(_QWORD *)(a1 + 24);
}

original_code:
unsigned long long
bloom_hash (bloom * bloom, char *str, int i, int length)
{
  unsigned long long ret = 0;
  ret = (unsigned long long) hash5 (str, seed[i], length) % (unsigned long long) bloom->stat.elements;
  return ret;
}

canonical_original_code:
unsigned long long bloom_hash(struct bloom *bloom, char *str, int i, int length)
{
  unsigned long long ret = 0;
  ret = (unsigned long long) hash5 (str, seed[i], length) % (unsigned long long) bloom->stat.elements;
  return ret;
}

variable_types:
str
char *

variable_types: i int

variable_types: length int

variable_types:
ret
unsigned long long

return_type: unsigned long long


finder

original_code:
int
finder (unsigned long long index, deref * dr)
{
  dr->index = (unsigned long long) (index >> 3);
  dr->spot = 1<<(index & 0x07);
  return 0;
}

canonical_original_code:
int finder(unsigned long long index, struct deref *dr)
{
  dr->index = (unsigned long long) (index >> 3);
  dr->spot = 1<<(index & 0x07);
  return 0;
}

variable_types:
index
unsigned long long

variable_types: struct deref { unsigned long long index; char spot; } *


set

decompiled_code:
__int64 __fastcall set(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rdx
__int64 v4; // [rsp+0h] [rbp-10h] BYREF
char v5; // [rsp+8h] [rbp-8h]

finder(a2, (__int64)&v4);
*(_BYTE *)(v4 + v2) += v5;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rdx
__int64 v4; // [rsp+0h] [rbp-10h] BYREF
char v5; // [rsp+8h] [rbp-8h]

func3(a2, (__int64)&v4);
*(_BYTE *)(v4 + v2) += v5;
return 0LL;
}

original_code:
int
set (char *big, unsigned long long index)
{
  deref dr;
  finder (index, &dr);
  big[dr.index] += dr.spot;
  return 0;
}

canonical_original_code:
int set(char *big, unsigned long long index)
{
  struct deref dr;
  finder (index, &dr);
  big[dr.index] += dr.spot;
  return 0;
}

variable_types:
big
char *

variable_types: struct deref { unsigned long long index; char spot; }


test

decompiled_code:
_BOOL8 __fastcall test(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rdx
__int64 v4; // [rsp+0h] [rbp-10h] BYREF
unsigned __int8 v5; // [rsp+8h] [rbp-8h]

finder(a2, (__int64)&v4);
return (v5 & *(_BYTE *)(v2 + v4)) == v5;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rdx
__int64 v4; // [rsp+0h] [rbp-10h] BYREF
unsigned __int8 v5; // [rsp+8h] [rbp-8h]

func3(a2, (__int64)&v4);
return (v5 & *(_BYTE *)(v2 + v4)) == v5;
}

original_code:
int
test (char *big, unsigned long long index)
{
  deref dr;
  char bucket;
  finder (index, &dr);
  bucket = big[dr.index];
  if ((bucket & dr.spot) == dr.spot)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}

canonical_original_code:
int test(char *big, unsigned long long index)
{
  struct deref dr;
  char bucket;
  finder (index, &dr);
  bucket = big[dr.index];
  if ((bucket & dr.spot) == dr.spot)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}

variable_types: bucket char

user_defined_types: struct deref { unsigned long long index; char spot; }


decompiled_code:
__int64 __fastcall bloom_test(__int64 a1, __int64 a2, int a3)
{
unsigned int v4; // er13
int v5; // er14
unsigned __int64 v6; // rax
unsigned __int64 v7; // r8

if ( *(int *)(a1 + 32) > 0 )
{
v4 = 1;
v5 = 0;
while ( 1 )
{
v6 = bloom_hash(a1, a2, v5, *(_DWORD *)(a1 + 56));
if ( !test(*(_QWORD *)a1, v6) )
{
if ( a3 != 1 )
return 0LL;
v4 = 0;
set(*(_QWORD *)a1, v7);
}
if ( *(_DWORD *)(a1 + 32) <= ++v5 )
return v4;
}
}
return 1;
}

original_code:
int
bloom_test (bloom * bloom, char *str, int mode)
{
  int i, hit;
  unsigned long long ret;
  hit = 1;
  for (i = 0; i < bloom->stat.ideal_hashes; i++)
    {
      ret = bloom_hash (bloom, str, i, bloom->k_mer);
      if (!test (bloom->vector, ret))
 {
   hit = 0;
   if (mode == 1)
     {
       set (bloom->vector, ret);
     }
   else
     {
       return hit;
     }
 }
    }
  return hit;
}

canonical_original_code:
int bloom_test(struct bloom *bloom, char *str, int mode)
{
  int i; int hit;
  unsigned long long ret;
  hit = 1;
  for (i = 0; i < bloom->stat.ideal_hashes; i++)
    {
      ret = bloom_hash (bloom, str, i, bloom->k_mer);
      if (!test (bloom->vector, ret))
 {
   hit = 0;
   if (mode == 1)
     {
       set (bloom->vector, ret);
     }
   else
     {
       return hit;
     }
 }
    }
  return hit;
}

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: mode int

variable_types: hit int


decompiled_code:
__int64 __fastcall bloom_check(__int64 a1, __int64 a2)
{
return bloom_test(a1, a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
return func6(a1, a2, 0);
}

original_code:
int
bloom_check (bloom * bloom, char *str)
{
  return bloom_test (bloom, str, 0);
}

canonical_original_code:
int bloom_check(struct bloom *bloom, char *str)
{
  return bloom_test (bloom, str, 0);
}


decompiled_code:
__int64 __fastcall bloom_add(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = bloom_test(a1, a2, 1);
if ( !(_DWORD)result )
++*(_QWORD *)(a1 + 16);
return result;
}

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

result = func6(a1, a2, 1);
if ( !(_DWORD)result )
++*(_QWORD *)(a1 + 16);
return result;
}

original_code:
int
bloom_add (bloom * bloom, char *str)
{
  int ret;
  ret = bloom_test (bloom, str, 1);
  if (ret == 0)
    {
      bloom->inserts++;
    }
  return ret;
}

canonical_original_code:
int bloom_add(struct bloom *bloom, char *str)
{
  int ret;
  ret = bloom_test (bloom, str, 1);
  if (ret == 0)
    {
      bloom->inserts++;
    }
  return ret;
}

variable_types: ret int


decompiled_code:
__int64 __fastcall report_capacity(__int64 a1)
{
return *(_QWORD *)(a1 + 40);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(_QWORD *)(a1 + 40);
}

original_code:
unsigned long long
report_capacity (bloom * bloom)
{
  return bloom->stat.capacity;
}

canonical_original_code:
unsigned long long report_capacity(struct bloom *bloom)
{
  return bloom->stat.capacity;
}


decompiled_code:
__int64 __fastcall save_bloom(char *a1, void **a2, __int64 a3, const char *a4)
{
char *v6; // rax
char *v7; // r12
int v8; // eax
int v9; // er13
__int64 v10; // rbx
signed __int64 v11; // r12
__int64 result; // rax
int *v13; // rbx
char *v14; // rax

v6 = prefix_make(a1, a3, a4);
v7 = v6;
if ( __PAIR128__(a3, (unsigned __int64)a4) == 0 )
{
v7 = v6 + 1;
strcat(v6, ".bloom");
}
else if ( (unsigned int)is_dir(a4) )
{
strcat(v7, ".bloom");
}
v8 = open64(v7, 66, 420LL);
v9 = v8;
if ( v8 < 0 )
{
perror(v7);
result = 0xFFFFFFFFLL;
}
else if ( ftruncate64(v8, ((unsigned __int64)a2[3] >> 3) + 4LL * (*((_DWORD *)a2 + 8) + 1) + 73) < 0 )
{
v13 = _errno_location();
v14 = strerror(*v13);
printf("[%d]-ftruncate64 error: %s/n", (unsigned int)*v13, v14);
close(v9);
result = 0LL;
}
else
{
if ( write(v9, a2, 0x48uLL) < 0 )
goto LABEL_15;
v10 = 0LL;
v11 = ((unsigned __int64)a2[3] >> 3) + 1;
if ( v11 > 2000000000 )
{
while ( write(v9, (char *)*a2 + v10, 0x77359400uLL) >= 0 )
{
v11 -= 2000000000LL;
v10 += 2000000000LL;
if ( (unsigned __int64)v11 <= 0x77359400 )
goto LABEL_9;
}
LABEL_15:
perror(" error writing bloom file ");
exit(1);
}
LABEL_9:
if ( write(v9, (char *)*a2 + v10, v11) < 0 )
goto LABEL_15;
close(v9);
memset(*a2, 0, ((unsigned __int64)a2[3] >> 3) + 1);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(char *a1, void **a2, __int64 a3, const char *a4)
{
char *v6; // rax
char *v7; // r12
int v8; // eax
int v9; // er13
__int64 v10; // rbx
signed __int64 v11; // r12
__int64 result; // rax
int *v13; // rbx
char *v14; // rax

v6 = func10(a1, a3, a4);
v7 = v6;
if ( __PAIR128__(a3, (unsigned __int64)a4) == 0 )
{
v7 = v6 + 1;
strcat(v6, ".bloom");
}
else if ( (unsigned int)is_dir(a4) )
{
strcat(v7, ".bloom");
}
v8 = open64(v7, 66, 420LL);
v9 = v8;
if ( v8 < 0 )
{
perror(v7);
result = 0xFFFFFFFFLL;
}
else if ( ftruncate64(v8, ((unsigned __int64)a2[3] >> 3) + 4LL * (*((_DWORD *)a2 + 8) + 1) + 73) < 0 )
{
v13 = _errno_location();
v14 = strerror(*v13);
printf("[%d]-ftruncate64 error: %s/n", (unsigned int)*v13, v14);
close(v9);
result = 0LL;
}
else
{
if ( write(v9, a2, 0x48uLL) < 0 )
goto LABEL_15;
v10 = 0LL;
v11 = ((unsigned __int64)a2[3] >> 3) + 1;
if ( v11 > 2000000000 )
{
while ( write(v9, (char *)*a2 + v10, 0x77359400uLL) >= 0 )
{
v11 -= 2000000000LL;
v10 += 2000000000LL;
if ( (unsigned __int64)v11 <= 0x77359400 )
goto LABEL_9;
}
LABEL_15:
perror(" error writing bloom file ");
exit(1);
}
LABEL_9:
if ( write(v9, (char *)*a2 + v10, v11) < 0 )
goto LABEL_15;
close(v9);
memset(*a2, 0, ((unsigned __int64)a2[3] >> 3) + 1);
result = 0LL;
}
return result;
}

original_code:
int
save_bloom (char *filename, bloom * bl, char *prefix, char *target)
{
  char *bloom_file = ((void *)0);
  int fd;
  bloom_file = prefix_make(filename, prefix, target);
  if (prefix==((void *)0) && target==((void *)0))
      {
      strcat (bloom_file,".bloom");
      bloom_file++;
      }
  else if (is_dir(target))
      strcat (bloom_file,".bloom");
  fd = open (bloom_file, 02 | 0100 | 0, 0644);
  if (fd < 0)
    {
      perror (bloom_file);
      return -1;
    }
  unsigned long long total_size =
    sizeof (bloom) + sizeof (char) * ((long long) (bl->stat.elements / 8) +
          1) +
    sizeof (int) * (bl->stat.ideal_hashes + 1);
  if (ftruncate64 (fd, total_size) < 0)
    {
      printf ("[%d]-ftruncate64 error: %s/n", (*__errno_location ()), strerror ((*__errno_location ())));
      close (fd);
      return 0;
    }
  if(write (fd, bl, sizeof (bloom)) < 0) {
      perror (" error writing bloom file ");
      exit (1);
  }
  total_size = (long long) (bl->stat.elements / 8) + 1;
  unsigned long long off = 0;
  while (total_size > 2000000000)
    {
      if(write(fd, bl->vector + off, sizeof (char) * 2000000000) < 0) {
       perror (" error writing bloom file ");
       exit (1);
      }
      total_size -= 2000000000;
      off += 2000000000;
    }
  if (write (fd, bl->vector + off, sizeof (char) * total_size) < 0){
       perror (" error writing bloom file ");
       exit (1);
  };
  close (fd);
  memset (bl->vector, 0,
   sizeof (char) * ((long long) (bl->stat.elements / 8) + 1));
  return 0;
}

canonical_original_code:
int save_bloom(char *filename, struct bloom *bl, char *prefix, char *target)
{
  char *bloom_file = ((void *)0);
  int fd;
  bloom_file = prefix_make(filename, prefix, target);
  if (prefix==((void *)0) && target==((void *)0))
      {
      strcat (bloom_file,".bloom");
      bloom_file++;
      }
  else if (is_dir(target))
      strcat (bloom_file,".bloom");
  fd = open (bloom_file, 02 | 0100 | 0, 0644);
  if (fd < 0)
    {
      perror (bloom_file);
      return -1;
    }
  unsigned long long total_size = sizeof (bloom) + sizeof (char) * ((long long) (bl->stat.elements / 8) +
          1) +
    sizeof (int) * (bl->stat.ideal_hashes + 1);
  if (ftruncate64 (fd, total_size) < 0)
    {
      printf ("[%d]-ftruncate64 error: %s/n", (*__errno_location ()), strerror ((*__errno_location ())));
      close (fd);
      return 0;
    }
  if(write (fd, bl, sizeof (bloom)) < 0) {
      perror (" error writing bloom file ");
      exit (1);
  }
  total_size = (long long) (bl->stat.elements / 8) + 1;
  unsigned long long off = 0;
  while (total_size > 2000000000)
    {
      if(write(fd, bl->vector + off, sizeof (char) * 2000000000) < 0) {
       perror (" error writing bloom file ");
       exit (1);
      }
      total_size -= 2000000000;
      off += 2000000000;
    }
  if (write (fd, bl->vector + off, sizeof (char) * total_size) < 0){
       perror (" error writing bloom file ");
       exit (1);
  };
  close (fd);
  memset (bl->vector, 0,
   sizeof (char) * ((long long) (bl->stat.elements / 8) + 1));
  return 0;
}

variable_types:
filename
char *

variable_types:
prefix
char *

variable_types:
target
char *

variable_types: fd int

variable_types:
off
unsigned long long


decompiled_code:
__int64 __fastcall load_bloom(char *s, void *buf)
{
int v3; // eax
int v4; // ebp
signed __int64 v5; // r12
char *v6; // rax
char *v7; // rsi
__int64 v8; // r13
unsigned int v9; // er12

v3 = open64(s, 0, 420LL);
if ( v3 < 0 )
{
v9 = -1;
perror(s);
}
else
{
v4 = v3;
if ( read(v3, buf, 0x48uLL) < 0 )
perror("Problem reading bloom filter");
v5 = (*((_QWORD *)buf + 3) >> 3) + 1LL;
v6 = (char *)malloc(v5);
*(_QWORD *)buf = v6;
v7 = v6;
if ( v5 > 2000000000 )
{
v8 = 0LL;
do
{
if ( (int)read(v4, &v7[v8], 0x77359400uLL) < 0 )
perror("Problem reading bloom filter");
v5 -= 2000000000LL;
v7 = *(char **)buf;
v8 += 2000000000LL;
}
while ( (unsigned __int64)v5 > 0x77359400 );
v7 += v8;
}
v9 = read(v4, v7, v5);
close(v4);
}
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func12(char *s, void *buf)
{
int v3; // eax
int v4; // ebp
signed __int64 v5; // r12
char *v6; // rax
char *v7; // rsi
__int64 v8; // r13
unsigned int v9; // er12

v3 = open64(s, 0, 420LL);
if ( v3 < 0 )
{
v9 = -1;
perror(s);
}
else
{
v4 = v3;
if ( read(v3, buf, 0x48uLL) < 0 )
perror("Problem reading bloom filter");
v5 = (*((_QWORD *)buf + 3) >> 3) + 1LL;
v6 = (char *)malloc(v5);
*(_QWORD *)buf = v6;
v7 = v6;
if ( v5 > 2000000000 )
{
v8 = 0LL;
do
{
if ( (int)read(v4, &v7[v8], 0x77359400uLL) < 0 )
perror("Problem reading bloom filter");
v5 -= 2000000000LL;
v7 = *(char **)buf;
v8 += 2000000000LL;
}
while ( (unsigned __int64)v5 > 0x77359400 );
v7 += v8;
}
v9 = read(v4, v7, v5);
close(v4);
}
return v9;
}

original_code:
int
load_bloom (char *filename, bloom * bl)
{
  int fd = 0;
  int ret;
  fd = open64 (filename, 00, 0644);
  if (fd < 0) {
      perror (filename);
      return -1;
  }
  if (read (fd, bl, sizeof (bloom)) < 0){
     perror("Problem reading bloom filter");
  };
  bl->vector = (char *) malloc (sizeof (char) * ((long long) (bl->stat.elements / 8) + 1));
  unsigned long long off = 0, total_size = ((long long) (bl->stat.elements / 8) + 1);
  while (total_size > 2000000000) {
      ret = read(fd, bl->vector + off, sizeof (char) * 2000000000);
      if (ret < 0)
          perror("Problem reading bloom filter");
      total_size -= 2000000000;
      off += 2000000000;
  }
  ret = read (fd, bl->vector + off, sizeof (char) * total_size);
  close (fd);
  return ret;
}

canonical_original_code:
int load_bloom(char *filename, struct bloom *bl)
{
  int fd = 0;
  int ret;
  fd = open64 (filename, 00, 0644);
  if (fd < 0) {
      perror (filename);
      return -1;
  }
  if (read (fd, bl, sizeof (bloom)) < 0){
     perror("Problem reading bloom filter");
  };
  bl->vector = (char *) malloc (sizeof (char) * ((long long) (bl->stat.elements / 8) + 1));
  unsigned long long off = 0; unsigned long long total_size = ((long long) (bl->stat.elements / 8) + 1);
  while (total_size > 2000000000) {
      ret = read(fd, bl->vector + off, sizeof (char) * 2000000000);
      if (ret < 0)
          perror("Problem reading bloom filter");
      total_size -= 2000000000;
      off += 2000000000;
  }
  ret = read (fd, bl->vector + off, sizeof (char) * total_size);
  close (fd);
  return ret;
}


decompiled_code:
int __fastcall write_result(const char *a1, const char *a2)
{
int v2; // er12
size_t v3; // rax

v2 = open64(a1, 66, 448LL);
v3 = strlen(a2);
if ( write(v2, a2, v3) < 0 )
{
perror(" error writing result file ");
exit(1);
}
return close(v2);
}

canonical_decompiled_code:
int __fastcall func13(const char *a1, const char *a2)
{
int v2; // er12
size_t v3; // rax

v2 = open64(a1, 66, 448LL);
v3 = strlen(a2);
if ( write(v2, a2, v3) < 0 )
{
perror(" error writing result file ");
exit(1);
}
return close(v2);
}

original_code:
void
write_result (char *filename, char *detail)
{
  int fd;
  fd = open (filename, 0100 | 02, (0400|0200|0100));
  if (write (fd, detail, strlen (detail)) < 0) {
      perror (" error writing result file ");
      exit (1);
  }
  close (fd);
}

canonical_original_code:
void write_result(char *filename, char *detail)
{
  int fd;
  fd = open (filename, 0100 | 02, (0400|0200|0100));
  if (write (fd, detail, strlen (detail)) < 0) {
      perror (" error writing result file ");
      exit (1);
  }
  close (fd);
}

variable_types:
detail
char *


decompiled_code:
size_t __fastcall rev_trans(char *s)
{
char *v1; // rbx
size_t v2; // rdx
size_t result; // rax
__int64 v4; // rdx
char v5; // cl

v1 = s;
v2 = strlen(s);
result = (unsigned int)(v2 - 1);
if ( (int)result <= 0 )
goto LABEL_5;
result = (int)result;
v4 = 0LL;
do
{
v5 = s[v4];
s[v4++] = s[result];
s[result--] = v5;
}
while ( (int)result > (int)v4 );
while ( 1 )
{
result = strlen(v1);
v2 = result;
LABEL_5:
if ( !v2 )
return result;
switch ( *v1 )
{
case 'A':
*v1++ = 84;
break;
case 'C':
*v1++ = 71;
break;
case 'G':
*v1++ = 67;
break;
case 'T':
*v1++ = 65;
break;
case 'a':
*v1++ = 116;
break;
case 'c':
*v1++ = 103;
break;
case 'g':
*v1++ = 99;
break;
case 't':
*v1 = 97;
goto LABEL_8;
default:
LABEL_8:
++v1;
break;
}
}
}

canonical_decompiled_code:
size_t __fastcall func14(char *s)
{
char *v1; // rbx
size_t v2; // rdx
size_t result; // rax
__int64 v4; // rdx
char v5; // cl

v1 = s;
v2 = strlen(s);
result = (unsigned int)(v2 - 1);
if ( (int)result <= 0 )
goto LABEL_5;
result = (int)result;
v4 = 0LL;
do
{
v5 = s[v4];
s[v4++] = s[result];
s[result--] = v5;
}
while ( (int)result > (int)v4 );
while ( 1 )
{
result = strlen(v1);
v2 = result;
LABEL_5:
if ( !v2 )
return result;
switch ( *v1 )
{
case 'A':
*v1++ = 84;
break;
case 'C':
*v1++ = 71;
break;
case 'G':
*v1++ = 67;
break;
case 'T':
*v1++ = 65;
break;
case 'a':
*v1++ = 116;
break;
case 'c':
*v1++ = 103;
break;
case 'g':
*v1++ = 99;
break;
case 't':
*v1 = 97;
goto LABEL_8;
default:
LABEL_8:
++v1;
break;
}
}
}

original_code:
void
rev_trans (char *s)
{
  int i;
  int j;
  for (i = 0, j = strlen (s) - 1; i < j; ++i, --j)
    {
      char c = s[i];
      s[i] = s[j];
      s[j] = c;
    }
  i = 0;
  while (i < strlen (s))
    {
      switch (s[i])
 {
 case 'A':
   s[0] = 'T';
   break;
 case 'C':
   s[0] = 'G';
   break;
 case 'G':
   s[0] = 'C';
   break;
 case 'T':
   s[0] = 'A';
   break;
 case 'a':
   s[0] = 't';
   break;
 case 'c':
   s[0] = 'g';
   break;
 case 'g':
   s[0] = 'c';
   break;
 case 't':
   s[0] = 'a';
   break;
 }
      s++;
    }
}

canonical_original_code:
void rev_trans(char *s)
{
  int i;
  int j;
  for (i = 0, j = strlen (s) - 1; i < j; ++i, --j)
    {
      char c = s[i];
      s[i] = s[j];
      s[j] = c;
    }
  i = 0;
  while (i < strlen (s))
    {
      switch (s[i])
 {
 case 'A':
   s[0] = 'T';
   break;
 case 'C':
   s[0] = 'G';
   break;
 case 'G':
   s[0] = 'C';
   break;
 case 'T':
   s[0] = 'A';
   break;
 case 'a':
   s[0] = 't';
   break;
 case 'c':
   s[0] = 'g';
   break;
 case 'g':
   s[0] = 'c';
   break;
 case 't':
   s[0] = 'a';
   break;
 }
      s++;
    }
}

variable_types:
s
char *

variable_types: i int

variable_types: j int

variable_types: c char


mmaping

decompiled_code:
void *__fastcall mmaping(const char *a1)
{
int v1; // eax
int v2; // ebx
void *result; // rax
struct stat64 v4; // [rsp+0h] [rbp-98h] BYREF

v1 = open64(a1, 0);
if ( v1 < 0 )
{
perror(" open source ");
exit(1);
}
v2 = v1;
if ( fstat64(v1, &v4) < 0 )
{
perror(" fstat source ");
exit(1);
}
result = mmap64(0LL, v4.st_size, 1, 16385, v2, 0LL);
if ( result == (void *)-1LL )
{
perror(" mmap source ");
exit(1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func15(const char *a1)
{
int v1; // eax
int v2; // ebx
void *result; // rax
struct stat64 v4; // [rsp+0h] [rbp-98h] BYREF

v1 = open64(a1, 0);
if ( v1 < 0 )
{
perror(" open source ");
exit(1);
}
v2 = v1;
if ( fstat64(v1, &v4) < 0 )
{
perror(" fstat source ");
exit(1);
}
result = mmap64(0LL, v4.st_size, 1, 16385, v2, 0LL);
if ( result == (void *)-1LL )
{
perror(" mmap source ");
exit(1);
}
return result;
}

original_code:
char *
mmaping (char *source)
{
  struct stat statbuf;
  int src;
  char *sm;
  if ((src = open(source, 00 | 0)) < 0)
    {
      perror (" open source ");
      exit (1);
    }
  if (fstat (src, &statbuf) < 0)
    {
      perror (" fstat source ");
      exit (1);
    }
  sm =
    mmap (0, (long long) statbuf.st_size, 0x1, 0x01 | 0x04000,
   src, 0);
  if (((void *) -1) == sm)
    {
      perror (" mmap source ");
      exit (1);
    }
  return sm;
}

canonical_original_code:
char *mmaping(char *source)
{
  struct stat statbuf;
  int src;
  char *sm;
  if ((src = open(source, 00 | 0)) < 0)
    {
      perror (" open source ");
      exit (1);
    }
  if (fstat (src, &statbuf) < 0)
    {
      perror (" fstat source ");
      exit (1);
    }
  sm =
    mmap (0, (long long) statbuf.st_size, 0x1, 0x01 | 0x04000,
   src, 0);
  if (((void *) -1) == sm)
    {
      perror (" mmap source ");
      exit (1);
    }
  return sm;
}

variable_types:
source
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: src int

variable_types:
sm
char *

return_type: char *

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
void __noreturn build_help()
{
puts("USAGE");
puts("##########################################################################");
puts("---Bloom build----");
puts("# ./facs build [option] [option] [option] [option] <option>");
puts("#");
puts("# Options:");
puts("# -r reference file name or directory name");
puts("# -l a list containing multiple reference filenames");
puts("!!! either -r or -l can only be allowed each time !!!");
puts("# -k k_mer size (default size 21)");
puts("# -e error rate (default rate 0.0005)");
puts("# -h show help documents");
puts("# -o output file name (default file is saved as the same as binary file)");
puts("##########################################################################");
exit(1);
}

canonical_decompiled_code:
void __noreturn func16()
{
puts("USAGE");
puts("##########################################################################");
puts("---Bloom build----");
puts("# ./facs build [option] [option] [option] [option] <option>");
puts("#");
puts("# Options:");
puts("# -r reference file name or directory name");
puts("# -l a list containing multiple reference filenames");
puts("!!! either -r or -l can only be allowed each time !!!");
puts("# -k k_mer size (default size 21)");
puts("# -e error rate (default rate 0.0005)");
puts("# -h show help documents");
puts("# -o output file name (default file is saved as the same as binary file)");
puts("##########################################################################");
exit(1);
}

original_code:
void
build_help ()
{
  printf ("USAGE\n");
  printf
    ("##########################################################################\n");
  printf ("---Bloom build----\n");
  printf ("#  ./facs build [option] [option] [option] [option] <option>\n");
  printf ("#\n");
  printf ("#  Options:\n");
  printf ("#  -r reference file name or directory name\n");
  printf ("#  -l a list containing multiple reference filenames\n");
  printf ("!!! either -r or -l can only be allowed each time !!!\n");
  printf ("#  -k k_mer size (default size 21)\n");
  printf ("#  -e error rate (default rate 0.0005)\n");
  printf ("#  -h show help documents\n");
  printf
    ("#  -o output file name (default file is saved as the same as binary file)\n");
  printf
    ("##########################################################################\n");
  exit (1);
}

canonical_original_code:
void build_help()
{
  printf ("USAGE\n");
  printf
    ("##########################################################################\n");
  printf ("---Bloom build----\n");
  printf ("#  ./facs build [option] [option] [option] [option] <option>\n");
  printf ("#\n");
  printf ("#  Options:\n");
  printf ("#  -r reference file name or directory name\n");
  printf ("#  -l a list containing multiple reference filenames\n");
  printf ("!!! either -r or -l can only be allowed each time !!!\n");
  printf ("#  -k k_mer size (default size 21)\n");
  printf ("#  -e error rate (default rate 0.0005)\n");
  printf ("#  -h show help documents\n");
  printf
    ("#  -o output file name (default file is saved as the same as binary file)\n");
  printf
    ("##########################################################################\n");
  exit (1);
}


decompiled_code:
void __noreturn check_help()
{
puts("USAGE");
puts("##########################################################################");
puts("---contamination check---");
puts("# ./facs check [option] [option] [option] [option] [option] <option>");
printf("# Either query dataset is compressed or larger than 2GB, use:");
puts("# ./facs query [option] [option] [option] [option] [option] <option>");
puts("#");
puts("# Options:");
puts("# -t tolerant rate (The program will automatically select a value if you don't provide any.)");
puts("# -s sampling rate (default rate 1)");
puts("# -q query file name");
puts("# -l a list containing all bloom files");
puts("# -r single reference bloom filter file or directory");
puts("!!! either -r or -l can only be allowed each time !!!");
puts("# -h help documents");
puts("# -o output file name (default file is saved as the same path as the binary file)");
puts("##########################################################################");
exit(1);
}

canonical_decompiled_code:
void __noreturn func17()
{
puts("USAGE");
puts("##########################################################################");
puts("---contamination check---");
puts("# ./facs check [option] [option] [option] [option] [option] <option>");
printf("# Either query dataset is compressed or larger than 2GB, use:");
puts("# ./facs query [option] [option] [option] [option] [option] <option>");
puts("#");
puts("# Options:");
puts("# -t tolerant rate (The program will automatically select a value if you don't provide any.)");
puts("# -s sampling rate (default rate 1)");
puts("# -q query file name");
puts("# -l a list containing all bloom files");
puts("# -r single reference bloom filter file or directory");
puts("!!! either -r or -l can only be allowed each time !!!");
puts("# -h help documents");
puts("# -o output file name (default file is saved as the same path as the binary file)");
puts("##########################################################################");
exit(1);
}

original_code:
void
check_help ()
{
  printf ("USAGE\n");
  printf
    ("##########################################################################\n");
  printf ("---contamination check---\n");
  printf ("#  ./facs check [option] [option] [option] [option] [option] <option>\n");
  printf ("#  Either query dataset is compressed or larger than 2GB, use:");
  printf ("#  ./facs query [option] [option] [option] [option] [option] <option>\n");
  printf ("#\n");
  printf ("#  Options:\n");
  printf ("#  -t tolerant rate (The program will automatically select a value if you don't provide any.)\n");
  printf ("#  -s sampling rate (default rate 1)\n");
  printf ("#  -q query file name\n");
  printf ("#  -l a list containing all bloom files\n");
  printf ("#  -r single reference bloom filter file or directory\n");
  printf ("!!! either -r or -l can only be allowed each time !!!\n");
  printf ("#  -h help documents\n");
  printf
    ("#  -o output file name (default file is saved as the same path as the binary file)\n");
  printf
    ("##########################################################################\n");
  exit (1);
}

canonical_original_code:
void check_help()
{
  printf ("USAGE\n");
  printf
    ("##########################################################################\n");
  printf ("---contamination check---\n");
  printf ("#  ./facs check [option] [option] [option] [option] [option] <option>\n");
  printf ("#  Either query dataset is compressed or larger than 2GB, use:");
  printf ("#  ./facs query [option] [option] [option] [option] [option] <option>\n");
  printf ("#\n");
  printf ("#  Options:\n");
  printf ("#  -t tolerant rate (The program will automatically select a value if you don't provide any.)\n");
  printf ("#  -s sampling rate (default rate 1)\n");
  printf ("#  -q query file name\n");
  printf ("#  -l a list containing all bloom files\n");
  printf ("#  -r single reference bloom filter file or directory\n");
  printf ("!!! either -r or -l can only be allowed each time !!!\n");
  printf ("#  -h help documents\n");
  printf
    ("#  -o output file name (default file is saved as the same path as the binary file)\n");
  printf
    ("##########################################################################\n");
  exit (1);
}


decompiled_code:
void __noreturn remove_help()
{
puts("USAGE");
puts("##########################################################################");
puts("---contamination remove---");
puts("# ./facs remove [option] [option] [option] [option] <option>");
puts("#");
puts("# Options:");
puts("# -t tolerant rate (The program will automatically select a value if you don't provide any.)");
puts("# -q query file name");
puts("# -l a list containing all bloom files");
puts("# -r reference bloom filter file or dir");
puts("!!! either -r or -l can only be allowed each time !!!");
puts("# -h help documents");
puts("# -o output file name (default file is saved as the same path as the binary file)");
puts("##########################################################################");
exit(1);
}

canonical_decompiled_code:
void __noreturn func18()
{
puts("USAGE");
puts("##########################################################################");
puts("---contamination remove---");
puts("# ./facs remove [option] [option] [option] [option] <option>");
puts("#");
puts("# Options:");
puts("# -t tolerant rate (The program will automatically select a value if you don't provide any.)");
puts("# -q query file name");
puts("# -l a list containing all bloom files");
puts("# -r reference bloom filter file or dir");
puts("!!! either -r or -l can only be allowed each time !!!");
puts("# -h help documents");
puts("# -o output file name (default file is saved as the same path as the binary file)");
puts("##########################################################################");
exit(1);
}

original_code:
void
remove_help ()
{
  printf ("USAGE\n");
  printf
    ("##########################################################################\n");
  printf ("---contamination remove---\n");
  printf ("#  ./facs remove [option] [option] [option] [option] <option>\n");
  printf ("#\n");
  printf ("#  Options:\n");
  printf ("#  -t tolerant rate (The program will automatically select a value if you don't provide any.)\n");
  printf ("#  -q query file name\n");
  printf ("#  -l a list containing all bloom files\n");
  printf ("#  -r reference bloom filter file or dir\n");
  printf ("!!! either -r or -l can only be allowed each time !!!\n");
  printf ("#  -h help documents\n");
  printf
    ("#  -o output file name (default file is saved as the same path as the binary file)\n");
  printf
    ("##########################################################################\n");
  exit (1);
}

canonical_original_code:
void remove_help()
{
  printf ("USAGE\n");
  printf
    ("##########################################################################\n");
  printf ("---contamination remove---\n");
  printf ("#  ./facs remove [option] [option] [option] [option] <option>\n");
  printf ("#\n");
  printf ("#  Options:\n");
  printf ("#  -t tolerant rate (The program will automatically select a value if you don't provide any.)\n");
  printf ("#  -q query file name\n");
  printf ("#  -l a list containing all bloom files\n");
  printf ("#  -r reference bloom filter file or dir\n");
  printf ("!!! either -r or -l can only be allowed each time !!!\n");
  printf ("#  -h help documents\n");
  printf
    ("#  -o output file name (default file is saved as the same path as the binary file)\n");
  printf
    ("##########################################################################\n");
  exit (1);
}


decompiled_code:
void __noreturn remove_l_help()
{
puts("USAGE");
puts("##########################################################################");
puts("---contamination remove list mode---");
puts("Similar with mode remove but with slight difference");
puts("Reads will be classified to the most like reference if\nmultiple reference files exist");
puts("# ./facs classify [option] [option] [option] [option] <option>");
puts("#");
puts("# Options:");
puts("# -t tolerant rate");
puts("# -q query file name");
puts("# -l a list containing all bloom files");
puts("# -r reference bloom filter file or dir");
puts("!!! either -r or -l can only be allowed each time !!!");
puts("# -h help documents");
puts("# -o output file name (default file is saved as the same path as the binary file)");
puts("##########################################################################");
exit(1);
}

canonical_decompiled_code:
void __noreturn func19()
{
puts("USAGE");
puts("##########################################################################");
puts("---contamination remove list mode---");
puts("Similar with mode remove but with slight difference");
puts("Reads will be classified to the most like reference if\nmultiple reference files exist");
puts("# ./facs classify [option] [option] [option] [option] <option>");
puts("#");
puts("# Options:");
puts("# -t tolerant rate");
puts("# -q query file name");
puts("# -l a list containing all bloom files");
puts("# -r reference bloom filter file or dir");
puts("!!! either -r or -l can only be allowed each time !!!");
puts("# -h help documents");
puts("# -o output file name (default file is saved as the same path as the binary file)");
puts("##########################################################################");
exit(1);
}

original_code:
void
remove_l_help ()
{
  printf ("USAGE\n");
  printf ("##########################################################################\n");
  printf ("---contamination remove list mode---\n");
  printf ("Similar with mode remove but with slight difference\n");
  printf ("Reads will be classified to the most like reference if\nmultiple reference files exist\n");
  printf ("#  ./facs classify [option] [option] [option] [option] <option>\n");
  printf ("#\n");
  printf ("#  Options:\n");
  printf ("#  -t tolerant rate\n");
  printf ("#  -q query file name\n");
  printf ("#  -l a list containing all bloom files\n");
  printf ("#  -r reference bloom filter file or dir\n");
  printf ("!!! either -r or -l can only be allowed each time !!!\n");
  printf ("#  -h help documents\n");
  printf ("#  -o output file name (default file is saved as the same path as the binary file)\n");
  printf ("##########################################################################\n");
  exit (1);
}

canonical_original_code:
void remove_l_help()
{
  printf ("USAGE\n");
  printf ("##########################################################################\n");
  printf ("---contamination remove list mode---\n");
  printf ("Similar with mode remove but with slight difference\n");
  printf ("Reads will be classified to the most like reference if\nmultiple reference files exist\n");
  printf ("#  ./facs classify [option] [option] [option] [option] <option>\n");
  printf ("#\n");
  printf ("#  Options:\n");
  printf ("#  -t tolerant rate\n");
  printf ("#  -q query file name\n");
  printf ("#  -l a list containing all bloom files\n");
  printf ("#  -r reference bloom filter file or dir\n");
  printf ("!!! either -r or -l can only be allowed each time !!!\n");
  printf ("#  -h help documents\n");
  printf ("#  -o output file name (default file is saved as the same path as the binary file)\n");
  printf ("##########################################################################\n");
  exit (1);
}


decompiled_code:
char *__fastcall get_file_path(char *s, char *src, char *dest)
{
char *v4; // rbx

v4 = stpcpy(dest, s);
if ( dest[strlen(s) - 1] != 47 )
*(_WORD *)v4 = 47;
return strcat(dest, src);
}

canonical_decompiled_code:
char *__fastcall func0(char *s, char *src, char *dest)
{
char *v4; // rbx

v4 = stpcpy(dest, s);
if ( dest[strlen(s) - 1] != 47 )
*(_WORD *)v4 = 47;
return strcat(dest, src);
}

original_code:
void
get_file_path (const char *path, const char *file_name, char *file_path)
{
  strcpy (file_path, path);
  if (file_path[strlen (path) - 1] != '/')
    strcat (file_path, "/");
  strcat (file_path, file_name);
}

canonical_original_code:
void get_file_path(char *path, char *file_name, char *file_path)
{
  strcpy (file_path, path);
  if (file_path[strlen (path) - 1] != '/')
    strcat (file_path, "/");
  strcat (file_path, file_name);
}

variable_types:
path
char *


decompiled_code:
_BOOL8 __fastcall is_dir(const char *a1)
{
int v1; // er8
_BOOL8 result; // rax
struct stat64 v3; // [rsp+0h] [rbp-98h] BYREF

v1 = lstat64(a1, &v3);
result = 0LL;
if ( !v1 )
result = (v3.st_mode & 0xF000) == 0x4000;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(const char *a1)
{
int v1; // er8
_BOOL8 result; // rax
struct stat64 v3; // [rsp+0h] [rbp-98h] BYREF

v1 = lstat64(a1, &v3);
result = 0LL;
if ( !v1 )
result = (v3.st_mode & 0xF000) == 0x4000;
return result;
}

original_code:
int
is_dir (const char *path)
{
  struct stat statbuf;
  if (lstat (path, &statbuf) == 0)
    {
      return ((((statbuf.st_mode)) & 0170000) == (0040000)) != 0;
    }
  return 0;
}

canonical_original_code:
int is_dir(char *path)
{
  struct stat statbuf;
  if (lstat (path, &statbuf) == 0)
    {
      return ((((statbuf.st_mode)) & 0170000) == (0040000)) != 0;
    }
  return 0;
}

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


decompiled_code:
_BOOL8 __fastcall is_file(const char *a1)
{
int v1; // er8
_BOOL8 result; // rax
struct stat64 v3; // [rsp+0h] [rbp-98h] BYREF

v1 = lstat64(a1, &v3);
result = 0LL;
if ( !v1 )
result = (v3.st_mode & 0xF000) == 0x8000;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(const char *a1)
{
int v1; // er8
_BOOL8 result; // rax
struct stat64 v3; // [rsp+0h] [rbp-98h] BYREF

v1 = lstat64(a1, &v3);
result = 0LL;
if ( !v1 )
result = (v3.st_mode & 0xF000) == 0x8000;
return result;
}

original_code:
int
is_file (const char *path)
{
  struct stat statbuf;
  if (lstat (path, &statbuf) == 0)
    return ((((statbuf.st_mode)) & 0170000) == (0100000)) != 0;
  return 0;
}

canonical_original_code:
int is_file(char *path)
{
  struct stat statbuf;
  if (lstat (path, &statbuf) == 0)
    return ((((statbuf.st_mode)) & 0170000) == (0100000)) != 0;
  return 0;
}


decompiled_code:
_BOOL8 __fastcall is_special_dir(unsigned __int8 *a1)
{
_BOOL8 result; // rax
int v2; // eax

if ( *a1 != 46 || (result = 1LL, a1[1]) )
{
v2 = *a1 - 46;
if ( *a1 == 46 && (v2 = a1[1] - 46, a1[1] == 46) )
result = a1[2] == 0;
else
result = v2 == 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(unsigned __int8 *a1)
{
_BOOL8 result; // rax
int v2; // eax

if ( *a1 != 46 || (result = 1LL, a1[1]) )
{
v2 = *a1 - 46;
if ( *a1 == 46 && (v2 = a1[1] - 46, a1[1] == 46) )
result = a1[2] == 0;
else
result = v2 == 0;
}
return result;
}

original_code:
int
is_special_dir (const char *path)
{
  return strcmp (path, ".") == 0 || strcmp (path, "..") == 0;
}

canonical_original_code:
int is_special_dir(char *path)
{
  return strcmp (path, ".") == 0 || strcmp (path, "..") == 0;
}


decompiled_code:
__int64 build_usage()
{
fwrite("\nUsage: ./facs build [options]\n", 1uLL, 0x1FuLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite("\t-r path/to/something.fasta\n", 1uLL, 0x1CuLL, stderr);
fwrite("\t-o have to use it, but does not write file! :_/ XXX\n", 1uLL, 0x35uLL, stderr);
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
fwrite("\nUsage: ./facs build [options]\n", 1uLL, 0x1FuLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite("\t-r path/to/something.fasta\n", 1uLL, 0x1CuLL, stderr);
fwrite("\t-o have to use it, but does not write file! :_/ XXX\n", 1uLL, 0x35uLL, stderr);
return 1LL;
}

original_code:
static int
build_usage(void)
{
    fprintf(stderr, "\nUsage: ./facs build [options]\n");
    fprintf(stderr, "Options:\n");
    fprintf(stderr, "\t-r path/to/something.fasta\n");
    fprintf(stderr, "\t-o have to use it, but does not write file! :_/ XXX\n");
    return 1;
}

canonical_original_code:
static int build_usage()
{
    fprintf(stderr, "\nUsage: ./facs build [options]\n");
    fprintf(stderr, "Options:\n");
    fprintf(stderr, "\t-r path/to/something.fasta\n");
    fprintf(stderr, "\t-o have to use it, but does not write file! :_/ XXX\n");
    return 1;
}


decompiled_code:
__int64 __fastcall init_bloom(__int64 a1, float a2, __int64 a3, unsigned int a4, __int64 a5)
{
__int64 result; // rax
__int64 v8; // rax

get_suggestion(a1 + 24, a2);
bloom_init(a1, *(_QWORD *)(a1 + 24), *(_QWORD *)(a1 + 40), *(unsigned int *)(a1 + 32), 0LL, 3LL, *(double *)(a1 + 48));
printf("k_mer->%d\n", a4);
if ( !a4 )
{
v8 = get_size(a5);
a4 = kmer_suggestion(v8);
}
*(_DWORD *)(a1 + 56) = a4;
result = dx_add(a4);
*(_DWORD *)(a1 + 60) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, float a2, __int64 a3, unsigned int a4, __int64 a5)
{
__int64 result; // rax
__int64 v8; // rax

get_suggestion(a1 + 24, a2);
bloom_init(a1, *(_QWORD *)(a1 + 24), *(_QWORD *)(a1 + 40), *(unsigned int *)(a1 + 32), 0LL, 3LL, *(double *)(a1 + 48));
printf("k_mer->%d\n", a4);
if ( !a4 )
{
v8 = get_size(a5);
a4 = kmer_suggestion(v8);
}
*(_DWORD *)(a1 + 56) = a4;
result = dx_add(a4);
*(_DWORD *)(a1 + 60) = result;
return result;
}

original_code:
void
init_bloom (bloom * bl, unsigned long long capacity, float error_rate, int k_mer, char* filename)
{
  int flags = 3;
  get_suggestion (&bl->stat, capacity, error_rate);
  bloom_init (bl, bl->stat.elements, bl->stat.capacity, bl->stat.e,
       bl->stat.ideal_hashes, ((void *)0), flags);
  printf ("k_mer->%d\n",k_mer);
  if (k_mer!=0)
      bl->k_mer = k_mer;
  else
      bl->k_mer = kmer_suggestion(get_size(filename));
  bl->dx = dx_add (bl->k_mer);
}

canonical_original_code:
void init_bloom(struct bloom *bl, unsigned long long capacity, float error_rate, int k_mer, char *filename)
{
  int flags = 3;
  get_suggestion (&bl->stat, capacity, error_rate);
  bloom_init (bl, bl->stat.elements, bl->stat.capacity, bl->stat.e,
       bl->stat.ideal_hashes, ((void *)0), flags);
  printf ("k_mer->%d\n",k_mer);
  if (k_mer!=0)
      bl->k_mer = k_mer;
  else
      bl->k_mer = kmer_suggestion(get_size(filename));
  bl->dx = dx_add (bl->k_mer);
}

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:
capacity
unsigned long long

variable_types: flags int


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 *


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:
position
char *

variable_types:
key
char *

variable_types:
v
char *


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

result = (unsigned __int8)*a2;
if ( (_BYTE)result )
{
v4 = a2;
do
{
while ( (_BYTE)result == 62 )
{
v4 = fasta_title(v4);
result = (unsigned __int8)*v4;
if ( !(_BYTE)result )
return result;
}
v4 = fasta_data(a1, v4);
result = (unsigned __int8)*v4;
}
while ( (_BYTE)result );
}
return result;
}

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

result = (unsigned __int8)*a2;
if ( (_BYTE)result )
{
v4 = a2;
do
{
while ( (_BYTE)result == 62 )
{
v4 = func2(v4);
result = (unsigned __int8)*v4;
if ( !(_BYTE)result )
return result;
}
v4 = func4(a1, v4);
result = (unsigned __int8)*v4;
}
while ( (_BYTE)result );
}
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);
    }
}


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, unsigned int a3, double a4)
{
char *v6; // r13
double *v7; // rbp
__int64 v8; // rdi
__int64 v10; // rax

v6 = (char *)mmaping();
v7 = (double *)malloc(0x48uLL);
if ( !a3 )
{
v10 = get_size(a1);
a3 = kmer_suggestion(v10);
}
*((_DWORD *)v7 + 14) = a3;
printf("k_mer->%d\n", a3);
v8 = *((unsigned int *)v7 + 14);
v7[6] = a4;
*((_DWORD *)v7 + 15) = dx_add(v8);
*((_QWORD *)v7 + 5) = strlen(v6);
get_rec(v7 + 3);
bloom_init(v7, *((_QWORD *)v7 + 3), *((_QWORD *)v7 + 5), *((unsigned int *)v7 + 8), 0LL, 3LL, v7[6]);
ref_add((__int64)v7, v6);
save_bloom(a1, v7, 0LL, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, unsigned int a3, double a4)
{
char *v6; // r13
double *v7; // rbp
__int64 v8; // rdi
__int64 v10; // rax

v6 = (char *)mmaping();
v7 = (double *)malloc(0x48uLL);
if ( !a3 )
{
v10 = get_size(a1);
a3 = kmer_suggestion(v10);
}
*((_DWORD *)v7 + 14) = a3;
printf("k_mer->%d\n", a3);
v8 = *((unsigned int *)v7 + 14);
v7[6] = a4;
*((_DWORD *)v7 + 15) = dx_add(v8);
*((_QWORD *)v7 + 5) = strlen(v6);
get_rec(v7 + 3);
bloom_init(v7, *((_QWORD *)v7 + 3), *((_QWORD *)v7 + 5), *((unsigned int *)v7 + 8), 0LL, 3LL, v7[6]);
func6((__int64)v7, v6);
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 *


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

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

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

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

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: opt int

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


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, __int64 a2, char **a3, __int64 a4, __m128i a5, float a6)
{
const char *v6; // rbp
char **v7; // rax
unsigned int v9; // er15
char *v10; // rbx
__int64 v11; // rax
char *v12; // r14

v6 = *(const char **)a2;
if ( *(_QWORD *)a2 )
{
v7 = *(char ***)(a2 + 24);
v9 = _mm_cvtsi128_si32(a5);
if ( v7 == a3 )
v10 = (char *)&v6[strlen(v6)];
else
v10 = *v7;
while ( v10 != v6 )
{
while ( 1 )
{
v11 = jump(v6, 1LL, *(double *)_mm_cvtsi32_si128(v9).m128i_i64);
if ( v6 == (const char *)v11 )
break;
v6 = (const char *)v11;
if ( v10 == (char *)v11 )
return;
}
_InterlockedAdd64((volatile signed __int64 *)(a4 + 16), 1uLL);
v12 = strchr(v6 + 1, 62);
if ( !v12 )
v12 = v10;
if ( (int)fasta_read_check(v6, v12, 110LL, a1, a4, COERCE_DOUBLE((unsigned __int64)LODWORD(a6))) > 0 )
_InterlockedAdd64((volatile signed __int64 *)(a4 + 24), 1uLL);
v6 = v12;
}
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, __int64 a2, char **a3, __int64 a4, __m128i a5, float a6)
{
const char *v6; // rbp
char **v7; // rax
unsigned int v9; // er15
char *v10; // rbx
__int64 v11; // rax
char *v12; // r14

v6 = *(const char **)a2;
if ( *(_QWORD *)a2 )
{
v7 = *(char ***)(a2 + 24);
v9 = _mm_cvtsi128_si32(a5);
if ( v7 == a3 )
v10 = (char *)&v6[strlen(v6)];
else
v10 = *v7;
while ( v10 != v6 )
{
while ( 1 )
{
v11 = jump(v6, 1LL, *(double *)_mm_cvtsi32_si128(v9).m128i_i64);
if ( v6 == (const char *)v11 )
break;
v6 = (const char *)v11;
if ( v10 == (char *)v11 )
return;
}
_InterlockedAdd64((volatile signed __int64 *)(a4 + 16), 1uLL);
v12 = strchr(v6 + 1, 62);
if ( !v12 )
v12 = v10;
if ( (int)fasta_read_check(v6, v12, 110LL, a1, a4, COERCE_DOUBLE((unsigned __int64)LODWORD(a6))) > 0 )
_InterlockedAdd64((volatile signed __int64 *)(a4 + 24), 1uLL);
v6 = v12;
}
}
}

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; // rbp

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; // rbp

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


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

v16 = __PAIR64__(LODWORD(a5), LODWORD(a4));
v6 = (char *)calloc(0xF4240uLL, 1uLL);
v7 = malloc(0x20uLL);
v8 = malloc(0x20uLL);
v9 = malloc(0x48uLL);
v7[3] = v8;
*v7 = 0LL;
v10 = (__int64)v9;
v11 = (_QWORD *)make_list(a2, a3);
s = (char *)mmaping(a1);
v12 = get_parainfo(s, v7);
if ( v11 )
{
v13 = v12;
do
{
load_bloom(*v11, v10);
if ( *(float *)&v16 == 0.0 )
{
*(float *)&a4 = mco_suggestion(*(unsigned int *)(v10 + 56), a4, a5, *(float *)&v16, 0.0);
LODWORD(v16) = LODWORD(a4);
}
v18[3] = (__int64)v11;
v18[4] = v16;
v18[2] = v10;
v18[1] = (__int64)v8;
v19 = v13;
v18[0] = (__int64)v7;
GOMP_parallel(check_all__omp_fn_0, v18, 0LL, 0LL);
evaluate(v6, (const char *)*v11, v11);
v11 = (_QWORD *)v11[6];
bloom_destroy(v10);
}
while ( v11 );
}
statistic_save((__int64)v6, a1);
v14 = strlen(s);
munmap(s, v14);
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:
source
char *

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
int v5; // eax
float v6; // xmm4_4
int v7; // xmm5_4
float v9; // [rsp+8h] [rbp-40h]
int v10; // [rsp+Ch] [rbp-3Ch]

if ( argc <= 1 )
check_help();
v2 = 0LL;
v3 = 0LL;
v4 = 0LL;
v9 = 0.0;
v10 = LC9;
while ( 1 )
{
v5 = getopt(argc, argv, "s:t:r:o:q:l:h");
if ( v5 == -1 )
return check_all(
(__int64)v2,
(__int64)v4,
(__int64)v3,
COERCE_DOUBLE((unsigned __int64)LODWORD(v9)),
COERCE_DOUBLE((unsigned __int64)v10));
switch ( v5 )
{
case '?':
goto LABEL_7;
case 'h':
check_help();
LABEL_7:
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 *)&v7 = atof(optarg);
v10 = v7;
}
break;
case 't':
if ( optarg )
{
v6 = atof(optarg);
v9 = v6;
}
break;
default:
continue;
}
}
}

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

if ( argc <= 1 )
check_help();
v2 = 0LL;
v3 = 0LL;
v4 = 0LL;
v9 = 0.0;
v10 = LC9;
while ( 1 )
{
v5 = getopt(argc, argv, "s:t:r:o:q:l:h");
if ( v5 == -1 )
return func6(
(__int64)v2,
(__int64)v4,
(__int64)v3,
COERCE_DOUBLE((unsigned __int64)LODWORD(v9)),
COERCE_DOUBLE((unsigned __int64)v10));
switch ( v5 )
{
case '?':
goto LABEL_7;
case 'h':
check_help();
LABEL_7:
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 *)&v7 = atof(optarg);
v10 = v7;
}
break;
case 't':
if ( optarg )
{
v6 = atof(optarg);
v9 = v6;
}
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 **


printtext

repo: tzwaan/datastructuren

decompiled_code:
int __fastcall printtext(char *a1, int a2)
{
__int64 v2; // rbp
char *v3; // rbx
int v4; // edi

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

canonical_decompiled_code:
int __fastcall func0(char *a1, int a2)
{
__int64 v2; // rbp
char *v3; // rbx
int v4; // edi

if ( a2 > 0 )
{
v2 = (__int64)&a1[a2 - 1 + 1];
v3 = a1;
do
{
v4 = *v3++;
putchar(v4);
}
while ( v3 != (char *)v2 );
}
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
int v3; // eax
__int64 v4; // xmm0_8
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 i; // rdx
int v3; // eax
__int64 v4; // xmm0_8
__int64 result; // rax

for ( i = 0LL; i != 26; ++i )
{
v3 = *(char *)(a1 + i);
v4 = *(_QWORD *)(a2 + 8 * i);
result = v3 - 97;
freqtable[result] = v4;
}
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
double v2; // xmm0_8
__int64 v3; // rsi
int result; // eax

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

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
__int64 i; // rbx
double v2; // xmm0_8
__int64 v3; // rsi
int result; // eax

for ( i = 0LL; i != 26; ++i )
{
v2 = *(double *)(a1 + 8 * i);
v3 = (unsigned int)(i + 97);
result = printf("%c = %2.3f\n", v3, v2);
}
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
__int64 v2; // rdx
__int64 v3; // rsi
int result; // eax

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

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

for ( i = 0LL; i != 26; ++i )
{
v2 = *(unsigned int *)(a1 + 4 * i);
v3 = (unsigned int)(i + 97);
result = printf("%c = %d\n", v3, v2);
}
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