decompiled_code:
unsigned __int64 __fastcall get_rec(__int64 a1)
{
double v1; // xmm0_8
unsigned __int64 v2; // rax
unsigned __int64 result; // rax

v1 = (double)(int)log(*(double *)(a1 + 24)) / -0.6931471805599453;
*(_DWORD *)(a1 + 8) = (int)v1;
v2 = find_close_prime(13 * *(_QWORD *)(a1 + 16) * (int)v1 / 9uLL);
*(_QWORD *)a1 = v2;
result = 9 * v2 / (13LL * *(_QWORD *)(a1 + 16));
*(_DWORD *)(a1 + 8) = result;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(__int64 a1)
{
double v1; // xmm0_8
unsigned __int64 v2; // rax
unsigned __int64 result; // rax

v1 = (double)(int)log(*(double *)(a1 + 24)) / -0.6931471805599453;
*(_DWORD *)(a1 + 8) = (int)v1;
v2 = func6(13 * *(_QWORD *)(a1 + 16) * (int)v1 / 9uLL);
*(_QWORD *)a1 = v2;
result = 9 * v2 / (13LL * *(_QWORD *)(a1 + 16));
*(_DWORD *)(a1 + 8) = result;
return result;
}

original_code:
void
get_rec (struct bloomstat *stat)
{
  stat->ideal_hashes = (int) log (stat->e) / log (0.5);
  stat->elements =
    find_close_prime ((unsigned long long) 13 * stat->capacity *
        (unsigned long long) stat->ideal_hashes / (unsigned long long) 9);
  stat->ideal_hashes = 9 * stat->elements / (13 * stat->capacity);
}

canonical_original_code:
void get_rec(struct bloomstat *stat)
{
  stat->ideal_hashes = (int) log (stat->e) / log (0.5);
  stat->elements =
    find_close_prime ((unsigned long long) 13 * stat->capacity *
        (unsigned long long) stat->ideal_hashes / (unsigned long long) 9);
  stat->ideal_hashes = 9 * stat->elements / (13 * stat->capacity);
}

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


repo: tzcoolman/FACS-OLD

decompiled_code:
__int64 __fastcall get_suggestion(__int64 a1, __int64 a2, double a3)
{
*(_QWORD *)(a1 + 16) = a2;
*(double *)(a1 + 24) = a3;
get_rec(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, double a3)
{
*(_QWORD *)(a1 + 16) = a2;
*(double *)(a1 + 24) = a3;
func7(a1);
return 0LL;
}

original_code:
int
get_suggestion (struct bloomstat *stats, unsigned long long n, double e)
{
  stats->capacity = n;
  stats->e = e;
  get_rec (stats);
  return 0;
}

canonical_original_code:
int get_suggestion(struct bloomstat *stats, unsigned long long n, double e)
{
  stats->capacity = n;
  stats->e = e;
  get_rec (stats);
  return 0;
}

variable_types:
n
unsigned long long

variable_types: e double

return_type: int

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


decompiled_code:
char **__fastcall fastq_process_m(__int64 a1, __int64 a2, char **a3, __int64 a4, float a5)
{
char **result; // rax
const char *v7; // r12
char *v8; // r15
_BYTE *v9; // rbp
const char *v10; // rbp
char *v11; // rbx
char *v12; // rax
_BYTE *v13; // rbp

result = *(char ***)(a2 + 24);
if ( result )
{
v7 = *(const char **)a2;
if ( result == a3 )
{
result = (char **)strlen(*(const char **)a2);
v8 = (char *)result + (_QWORD)v7;
}
else
{
v8 = *result;
}
if ( v7 && v7 != v8 )
{
while ( 1 )
{
v10 = strchr(v7, 10) + 1;
v11 = strstr(v10, "\n@");
if ( !v11 )
v11 = (char *)&v10[strlen(v10)];
v12 = strchr(v10, 10);
result = (char **)fastq_read_check(v10, v12 - v10, 110LL, a1, a4, a5);
if ( !(_DWORD)result )
break;
if ( (int)result > 0 )
{
GOMP_critical_start();
memcpy(contam, v7, v11 - v7);
v13 = (char *)contam + v11 - v7;
contam = v13;
if ( *v11 )
{
*v13 = 10;
contam = (char *)contam + 1;
}
LABEL_10:
result = (char **)GOMP_critical_end();
}
if ( *v11 )
{
v7 = v11 + 1;
if ( v11 + 1 != v8 )
continue;
}
return result;
}
GOMP_critical_start();
memcpy(clean, v7, v11 - v7);
v9 = (char *)clean + v11 - v7;
clean = v9;
if ( *v11 )
{
*v9 = 10;
clean = (char *)clean + 1;
}
goto LABEL_10;
}
}
return result;
}

canonical_decompiled_code:
char **__fastcall func1(__int64 a1, __int64 a2, char **a3, __int64 a4, float a5)
{
char **result; // rax
const char *v7; // r12
char *v8; // r15
_BYTE *v9; // rbp
const char *v10; // rbp
char *v11; // rbx
char *v12; // rax
_BYTE *v13; // rbp

result = *(char ***)(a2 + 24);
if ( result )
{
v7 = *(const char **)a2;
if ( result == a3 )
{
result = (char **)strlen(*(const char **)a2);
v8 = (char *)result + (_QWORD)v7;
}
else
{
v8 = *result;
}
if ( v7 && v7 != v8 )
{
while ( 1 )
{
v10 = strchr(v7, 10) + 1;
v11 = strstr(v10, "\n@");
if ( !v11 )
v11 = (char *)&v10[strlen(v10)];
v12 = strchr(v10, 10);
result = (char **)fastq_read_check(v10, v12 - v10, 110LL, a1, a4, a5);
if ( !(_DWORD)result )
break;
if ( (int)result > 0 )
{
GOMP_critical_start();
memcpy(contam, v7, v11 - v7);
v13 = (char *)contam + v11 - v7;
contam = v13;
if ( *v11 )
{
*v13 = 10;
contam = (char *)contam + 1;
}
LABEL_10:
result = (char **)GOMP_critical_end();
}
if ( *v11 )
{
v7 = v11 + 1;
if ( v11 + 1 != v8 )
continue;
}
return result;
}
GOMP_critical_start();
memcpy(clean, v7, v11 - v7);
v9 = (char *)clean + v11 - v7;
clean = v9;
if ( *v11 )
{
*v9 = 10;
clean = (char *)clean + 1;
}
goto LABEL_10;
}
}
return result;
}

original_code:
void
fastq_process_m (bloom * bl, Queue * info, Queue * tail, float tole_rate, F_set *File_head)
{
  int read_num = 0, read_contam = 0;
  char *p = info->location;
  char *next, *temp_start, *temp_end, *temp_piece = ((void *)0);
  if (info->next == ((void *)0))
    return;
  else if (info->next != tail)
    next = info->next->location;
  else
    next = strchr (p, '\0');
  while (p != next)
    {
      read_num++;
      temp_start = p;
      if (p == '\0' || p == ((void *)0))
 break;
      p = strchr (p, '\n') + 1;
      temp_end = strstr (p, "\n@");
      if (!temp_end)
 temp_end = strchr (p, '\0');
      int result =
 fastq_read_check (p, strchr (p, '\n') - p, 'n', bl, tole_rate, File_head);
      if (result == 0)
 {

#pragma omp critical
   {
     memcpy (clean, temp_start, temp_end - temp_start);
     clean += (temp_end - temp_start);
     if (*temp_end != '\0')
       {
  clean[0] = '\n';
  clean++;
       }
   }
 }
      else if (result > 0)
 {

#pragma omp critical
   {
            read_contam++;
     memcpy (contam, temp_start, temp_end - temp_start);
     contam += (temp_end - temp_start);
     if (*temp_end != '\0')
       {
  contam[0] = '\n';
  contam++;
       }
   }
 }
      if (*temp_end == '\0')
 break;
      p = temp_end + 1;
    }
  if (temp_piece)
    free (temp_piece);
}

canonical_original_code:
void fastq_process_m(struct bloom *bl, struct info *info, struct info *tail, float tole_rate, struct file_list *File_head)
{
  int read_num = 0; int read_contam = 0;
  char *p = info->location;
  char *next; char *temp_start; char *temp_end; char *temp_piece = ((void *)0);
  if (info->next == ((void *)0))
    return;
  else if (info->next != tail)
    next = info->next->location;
  else
    next = strchr (p, '\0');
  while (p != next)
    {
      read_num++;
      temp_start = p;
      if (p == '\0' || p == ((void *)0))
 break;
      p = strchr (p, '\n') + 1;
      temp_end = strstr (p, "\n@");
      if (!temp_end)
 temp_end = strchr (p, '\0');
      int result = fastq_read_check (p, strchr (p, '\n') - p, 'n', bl, tole_rate, File_head);
      if (result == 0)
 {

#pragma omp critical
   {
     memcpy (clean, temp_start, temp_end - temp_start);
     clean += (temp_end - temp_start);
     if (*temp_end != '\0')
       {
  clean[0] = '\n';
  clean++;
       }
   }
 }
      else if (result > 0)
 {

#pragma omp critical
   {
            read_contam++;
     memcpy (contam, temp_start, temp_end - temp_start);
     contam += (temp_end - temp_start);
     if (*temp_end != '\0')
       {
  contam[0] = '\n';
  contam++;
       }
   }
 }
      if (*temp_end == '\0')
 break;
      p = temp_end + 1;
    }
  if (temp_piece)
    free (temp_piece);
}

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 info { char *location; short *score; short *number; struct info *next; } *

variable_types:
tail
struct info *

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

variable_types:
p
char *

variable_types:
next
char *

variable_types: result int

return_type: void

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


decompiled_code:
int __fastcall fasta_process_m(__int64 a1, __int64 a2, char **a3, __int64 a4, float a5)
{
char **v7; // rax
const char *v8; // rbp
char *v9; // r12
unsigned int v10; // er13
char *v11; // rbx
int v12; // eax
unsigned int v14; // [rsp+Ch] [rbp-3Ch]

puts("fasta processing...");
v7 = *(char ***)(a2 + 24);
if ( v7 )
{
v8 = *(const char **)a2;
if ( v7 == a3 )
v9 = (char *)&v8[strlen(*(const char **)a2)];
else
v9 = *v7;
v14 = 0;
v10 = 0;
if ( v8 != v9 )
{
while ( 1 )
{
++v10;
v11 = strchr(v8 + 1, 62);
if ( !v11 )
v11 = v9;
v12 = fasta_read_check(v8, v11, 110LL, a1, a4, a5);
if ( v12 )
{
if ( v12 > 0 )
{
GOMP_critical_start();
++v14;
memcpy(contam, v8, v11 - v8);
contam = (char *)contam + v11 - v8;
GOMP_critical_end();
}
}
else
{
GOMP_critical_start();
memcpy(clean, v8, v11 - v8);
clean = (char *)clean + v11 - v8;
GOMP_critical_end();
}
if ( v11 == v9 )
break;
v8 = v11;
}
}
LODWORD(v7) = printf("all->%d\ncontam->%d\n", v10, v14);
}
return (int)v7;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 a2, char **a3, __int64 a4, float a5)
{
char **v7; // rax
const char *v8; // rbp
char *v9; // r12
unsigned int v10; // er13
char *v11; // rbx
int v12; // eax
unsigned int v14; // [rsp+Ch] [rbp-3Ch]

puts("fasta processing...");
v7 = *(char ***)(a2 + 24);
if ( v7 )
{
v8 = *(const char **)a2;
if ( v7 == a3 )
v9 = (char *)&v8[strlen(*(const char **)a2)];
else
v9 = *v7;
v14 = 0;
v10 = 0;
if ( v8 != v9 )
{
while ( 1 )
{
++v10;
v11 = strchr(v8 + 1, 62);
if ( !v11 )
v11 = v9;
v12 = fasta_read_check(v8, v11, 110LL, a1, a4, a5);
if ( v12 )
{
if ( v12 > 0 )
{
GOMP_critical_start();
++v14;
memcpy(contam, v8, v11 - v8);
contam = (char *)contam + v11 - v8;
GOMP_critical_end();
}
}
else
{
GOMP_critical_start();
memcpy(clean, v8, v11 - v8);
clean = (char *)clean + v11 - v8;
GOMP_critical_end();
}
if ( v11 == v9 )
break;
v8 = v11;
}
}
LODWORD(v7) = printf("all->%d\ncontam->%d\n", v10, v14);
}
return (int)v7;
}

original_code:
void
fasta_process_m (bloom * bl, Queue * info, Queue * tail, float tole_rate, F_set *File_head)
{
  printf ("fasta processing...\n");
  int read_num = 0, read_contam = 0;
  char *p = info->location;
  char *next;
  char *temp = p;
  if (info->next == ((void *)0))
    return;
  else if (info->next != tail)
    next = info->next->location;
  else
    next = strchr (p, '\0');
  while (p != next)
    {
      read_num++;
      temp = strchr (p + 1, '>');
      if (!temp)
 temp = next;
      int result = fasta_read_check (p, temp, 'n', bl, tole_rate, File_head);
      if (result == 0)
 {

#pragma omp critical
   {
     memcpy (clean, p, temp - p);
     clean += (temp - p);
   }
 }
      else if (result > 0)
 {

#pragma omp critical
   {
            read_contam++;
     memcpy (contam, p, temp - p);
     contam += (temp - p);
   }
 }
      p = temp;
    }
  printf ("all->%d\ncontam->%d\n", read_num, read_contam);
}

canonical_original_code:
void fasta_process_m(struct bloom *bl, struct info *info, struct info *tail, float tole_rate, struct file_list *File_head)
{
  printf ("fasta processing...\n");
  int read_num = 0; int read_contam = 0;
  char *p = info->location;
  char *next;
  char *temp = p;
  if (info->next == ((void *)0))
    return;
  else if (info->next != tail)
    next = info->next->location;
  else
    next = strchr (p, '\0');
  while (p != next)
    {
      read_num++;
      temp = strchr (p + 1, '>');
      if (!temp)
 temp = next;
      int result = fasta_read_check (p, temp, 'n', bl, tole_rate, File_head);
      if (result == 0)
 {

#pragma omp critical
   {
     memcpy (clean, p, temp - p);
     clean += (temp - p);
   }
 }
      else if (result > 0)
 {

#pragma omp critical
   {
            read_contam++;
     memcpy (contam, p, temp - p);
     contam += (temp - p);
   }
 }
      p = temp;
    }
  printf ("all->%d\ncontam->%d\n", read_num, read_contam);
}

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 save_result(char *s, const char *a2, int a3, const char *a4, __int64 a5, char *a6, int a7, char *a8)
{
const char *v8; // r15
char *v9; // rbx
char *v10; // rbp
void *v11; // r12
void *v12; // r13
char *v13; // r15
char *v14; // rax
const char *v15; // r14
char *v16; // rax
char *v17; // rax
size_t v18; // rax
size_t v19; // rax
size_t v21; // r15
char *v22; // rax

v8 = a4;
printf("source->%s\n", s);
printf("obj_file->%s\n", a2);
printf("prefix->%s\n", v8);
v9 = (char *)malloc(0x190uLL);
v10 = (char *)malloc(0x190uLL);
v11 = malloc(0xC8uLL);
v12 = malloc(0xC8uLL);
memset(v9, 0, 0x190uLL);
memset(v10, 0, 0x190uLL);
memset(v11, 0, 0xC8uLL);
memset(v12, 0, 0xC8uLL);
v13 = strrchr(s, 47);
v14 = strrchr(a2, 47);
if ( v13 )
{
++v13;
v15 = &v14[-(v14 == 0LL) + 1];
v16 = strrchr(s, 46);
strncat((char *)v11, v13, v16 - v13);
}
else
{
v15 = &v14[-(v14 == 0LL) + 1];
v22 = strrchr(s, 46);
strncat((char *)v11, s, v22 - s);
}
v17 = strrchr(a2, 46);
if ( v15 )
strncat((char *)v12, v15, v17 - v15);
else
strncat((char *)v12, a2, v17 - a2);
if ( a4 )
{
strcat(v9, a4);
strcat(v10, a4);
}
else if ( v13 )
{
v21 = v13 - s;
strncat(v9, s, v21);
strncat(v10, s, v21);
}
strcat(v9, (const char *)v11);
strcat(v10, (const char *)v11);
*(_WORD *)&v9[strlen(v9)] = 95;
*(_WORD *)&v10[strlen(v10)] = 95;
strcat(v9, (const char *)v12);
strcat(v10, (const char *)v12);
*(_QWORD *)&v9[strlen(v9)] = 0x6D61746E6F635FLL;
strcat(v10, "_clean");
if ( a3 == 1 )
{
strcat(v9, ".fasta");
strcat(v10, ".fasta");
}
else
{
strcat(v9, ".fastq");
strcat(v10, ".fastq");
}
printf("match->%s\n", v9);
printf("mis->%s\n", v10);
write_result(v9, a8);
write_result(v10, a6);
free(v9);
free(v10);
free(v11);
free(v12);
v18 = strlen(a8);
memset(a8, 0, v18);
v19 = strlen(a6);
return memset(a6, 0, v19);
}

canonical_decompiled_code:
void *__fastcall func4(char *s, const char *a2, int a3, const char *a4, __int64 a5, char *a6, int a7, char *a8)
{
const char *v8; // r15
char *v9; // rbx
char *v10; // rbp
void *v11; // r12
void *v12; // r13
char *v13; // r15
char *v14; // rax
const char *v15; // r14
char *v16; // rax
char *v17; // rax
size_t v18; // rax
size_t v19; // rax
size_t v21; // r15
char *v22; // rax

v8 = a4;
printf("source->%s\n", s);
printf("obj_file->%s\n", a2);
printf("prefix->%s\n", v8);
v9 = (char *)malloc(0x190uLL);
v10 = (char *)malloc(0x190uLL);
v11 = malloc(0xC8uLL);
v12 = malloc(0xC8uLL);
memset(v9, 0, 0x190uLL);
memset(v10, 0, 0x190uLL);
memset(v11, 0, 0xC8uLL);
memset(v12, 0, 0xC8uLL);
v13 = strrchr(s, 47);
v14 = strrchr(a2, 47);
if ( v13 )
{
++v13;
v15 = &v14[-(v14 == 0LL) + 1];
v16 = strrchr(s, 46);
strncat((char *)v11, v13, v16 - v13);
}
else
{
v15 = &v14[-(v14 == 0LL) + 1];
v22 = strrchr(s, 46);
strncat((char *)v11, s, v22 - s);
}
v17 = strrchr(a2, 46);
if ( v15 )
strncat((char *)v12, v15, v17 - v15);
else
strncat((char *)v12, a2, v17 - a2);
if ( a4 )
{
strcat(v9, a4);
strcat(v10, a4);
}
else if ( v13 )
{
v21 = v13 - s;
strncat(v9, s, v21);
strncat(v10, s, v21);
}
strcat(v9, (const char *)v11);
strcat(v10, (const char *)v11);
*(_WORD *)&v9[strlen(v9)] = 95;
*(_WORD *)&v10[strlen(v10)] = 95;
strcat(v9, (const char *)v12);
strcat(v10, (const char *)v12);
*(_QWORD *)&v9[strlen(v9)] = 0x6D61746E6F635FLL;
strcat(v10, "_clean");
if ( a3 == 1 )
{
strcat(v9, ".fasta");
strcat(v10, ".fasta");
}
else
{
strcat(v9, ".fastq");
strcat(v10, ".fastq");
}
printf("match->%s\n", v9);
printf("mis->%s\n", v10);
write_result(v9, a8);
write_result(v10, a6);
free(v9);
free(v10);
free(v11);
free(v12);
v18 = strlen(a8);
memset(a8, 0, v18);
v19 = strlen(a6);
return memset(a6, 0, v19);
}

original_code:
void
save_result (char *source, char *obj_file, int type, char *prefix,
      char *clean, char *clean2, char *contam, char *contam2)
{
  printf ("source->%s\n",source);
  printf ("obj_file->%s\n",obj_file);
  printf ("prefix->%s\n",prefix);
  char *so = ((void *)0), *obj = ((void *)0);
  char *match = (char *) malloc (400 * sizeof (char)),
    *mismatch = (char *) malloc (400 * sizeof (char)),
    *so_name = (char *) malloc (200 * sizeof (char)),
    *obj_name = (char *) malloc (200 * sizeof (char));
  memset (match, 0, 400);
  memset (mismatch, 0, 400);
  memset (so_name, 0, 200);
  memset (obj_name, 0, 200);
  so = strrchr (source, '/');
  obj = strrchr (obj_file,'/');
  if (so)
     so += 1;
  else
     so = ((void *)0);
  if (obj)
     obj += 1;
  else
     obj = ((void *)0);
  if (so)
    strncat (so_name, so, strrchr (source, '.') - so);
  else
    strncat (so_name, source, strrchr (source, '.') - source);
  if (obj)
    strncat (obj_name, obj, strrchr (obj_file, '.') - obj);
  else
    strncat (obj_name, obj_file, strrchr (obj_file, '.') - obj_file);
  if (prefix)
    {
      strcat (match, prefix);
      strcat (mismatch, prefix);
    }
  else if (so)
    {
      strncat (match, source, so - source);
      strncat (mismatch, source, so - source);
    }
  strcat (match, so_name);
  strcat (mismatch, so_name);
  strcat (match, "_");
  strcat (mismatch, "_");
  strcat (match, obj_name);
  strcat (mismatch, obj_name);
  strcat (match, "_contam");
  strcat (mismatch, "_clean");
  if (type == 1)
    {
      strcat (match, ".fasta");
      strcat (mismatch, ".fasta");
    }
  else
    {
      strcat (match, ".fastq");
      strcat (mismatch, ".fastq");
    }
  printf ("match->%s\n", match);
  printf ("mis->%s\n", mismatch);
  write_result (match, contam2);
  write_result (mismatch, clean2);
  free (match);
  free (mismatch);
  free (so_name);
  free (obj_name);
  memset (contam2, 0, strlen (contam2));
  memset (clean2, 0, strlen (clean2));
  clean = clean2;
  contam = contam2;
}

canonical_original_code:
void save_result(char *source, char *obj_file, int type, char *prefix, char *clean, char *clean2, char *contam, char *contam2)
{
  printf ("source->%s\n",source);
  printf ("obj_file->%s\n",obj_file);
  printf ("prefix->%s\n",prefix);
  char *so = ((void *)0); char *obj = ((void *)0);
  char *match = (char *) malloc (400 * sizeof (char)); char *mismatch = (char *) malloc (400 * sizeof (char)); char *so_name = (char *) malloc (200 * sizeof (char)); char *obj_name = (char *) malloc (200 * sizeof (char));
  memset (match, 0, 400);
  memset (mismatch, 0, 400);
  memset (so_name, 0, 200);
  memset (obj_name, 0, 200);
  so = strrchr (source, '/');
  obj = strrchr (obj_file,'/');
  if (so)
     so += 1;
  else
     so = ((void *)0);
  if (obj)
     obj += 1;
  else
     obj = ((void *)0);
  if (so)
    strncat (so_name, so, strrchr (source, '.') - so);
  else
    strncat (so_name, source, strrchr (source, '.') - source);
  if (obj)
    strncat (obj_name, obj, strrchr (obj_file, '.') - obj);
  else
    strncat (obj_name, obj_file, strrchr (obj_file, '.') - obj_file);
  if (prefix)
    {
      strcat (match, prefix);
      strcat (mismatch, prefix);
    }
  else if (so)
    {
      strncat (match, source, so - source);
      strncat (mismatch, source, so - source);
    }
  strcat (match, so_name);
  strcat (mismatch, so_name);
  strcat (match, "_");
  strcat (mismatch, "_");
  strcat (match, obj_name);
  strcat (mismatch, obj_name);
  strcat (match, "_contam");
  strcat (mismatch, "_clean");
  if (type == 1)
    {
      strcat (match, ".fasta");
      strcat (mismatch, ".fasta");
    }
  else
    {
      strcat (match, ".fastq");
      strcat (mismatch, ".fastq");
    }
  printf ("match->%s\n", match);
  printf ("mis->%s\n", mismatch);
  write_result (match, contam2);
  write_result (mismatch, clean2);
  free (match);
  free (mismatch);
  free (so_name);
  free (obj_name);
  memset (contam2, 0, strlen (contam2));
  memset (clean2, 0, strlen (clean2));
  clean = clean2;
  contam = contam2;
}

variable_types:
source
char *

variable_types: type int

variable_types:
prefix
char *

variable_types:
clean
char *

variable_types:
contam
char *

variable_types:
so
char *

variable_types:
obj
char *

variable_types:
match
char *

variable_types:
mismatch
char *


decompiled_code:
__int64 __fastcall remove_reads(char *a1, __int64 a2, __int64 a3, const char *a4, double a5)
{
unsigned int *v6; // rbp
_QWORD *v7; // rbx
char *v8; // r12
int v9; // er15
size_t v10; // rax
void *v11; // r13
size_t v12; // rax
void *v13; // r14
size_t v14; // rax
size_t v16; // rax
size_t v17; // rax
float v18; // [rsp+Ch] [rbp-8Ch]
_QWORD *v19; // [rsp+10h] [rbp-88h]
void *v20; // [rsp+18h] [rbp-80h]
__int64 v22[4]; // [rsp+30h] [rbp-68h] BYREF
float v23; // [rsp+50h] [rbp-48h]
int v24; // [rsp+54h] [rbp-44h]

v18 = *(float *)&a5;
v6 = (unsigned int *)malloc(0x48uLL);
v19 = malloc(0x20uLL);
v20 = malloc(0x20uLL);
v19[3] = v20;
v7 = (_QWORD *)make_list(a2, a3);
v8 = (char *)mmaping(a1);
v9 = get_parainfo(v8, v19);
v10 = strlen(v8);
v11 = malloc(v10);
clean = v11;
v12 = strlen(v8);
v13 = malloc(v12);
contam = v13;
while ( v7 )
{
v16 = strlen(v8);
memset(v11, 0, v16);
v17 = strlen(v8);
memset(v13, 0, v17);
load_bloom(*v7, v6);
if ( v18 == 0.0 )
{
*(float *)&a5 = mco_suggestion(v6[14], a5, v18, 0.0);
v18 = *(float *)&a5;
}
v22[3] = (__int64)v7;
v22[2] = (__int64)v20;
v22[0] = (__int64)v6;
v24 = v9;
v23 = v18;
v22[1] = (__int64)v19;
GOMP_parallel(remove_reads__omp_fn_0, v22, 0LL, 0LL);
save_result(a1, (const char *)*v7, v9, a4, (__int64)clean, (char *)v11, (int)contam, (char *)v13);
v7 = (_QWORD *)v7[6];
bloom_destroy(v6);
}
v14 = strlen(v8);
munmap(v8, v14);
puts("finish processing...");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, __int64 a2, __int64 a3, const char *a4, double a5)
{
unsigned int *v6; // rbp
_QWORD *v7; // rbx
char *v8; // r12
int v9; // er15
size_t v10; // rax
void *v11; // r13
size_t v12; // rax
void *v13; // r14
size_t v14; // rax
size_t v16; // rax
size_t v17; // rax
float v18; // [rsp+Ch] [rbp-8Ch]
_QWORD *v19; // [rsp+10h] [rbp-88h]
void *v20; // [rsp+18h] [rbp-80h]
__int64 v22[4]; // [rsp+30h] [rbp-68h] BYREF
float v23; // [rsp+50h] [rbp-48h]
int v24; // [rsp+54h] [rbp-44h]

v18 = *(float *)&a5;
v6 = (unsigned int *)malloc(0x48uLL);
v19 = malloc(0x20uLL);
v20 = malloc(0x20uLL);
v19[3] = v20;
v7 = (_QWORD *)make_list(a2, a3);
v8 = (char *)mmaping(a1);
v9 = get_parainfo(v8, v19);
v10 = strlen(v8);
v11 = malloc(v10);
clean = v11;
v12 = strlen(v8);
v13 = malloc(v12);
contam = v13;
while ( v7 )
{
v16 = strlen(v8);
memset(v11, 0, v16);
v17 = strlen(v8);
memset(v13, 0, v17);
load_bloom(*v7, v6);
if ( v18 == 0.0 )
{
*(float *)&a5 = mco_suggestion(v6[14], a5, v18, 0.0);
v18 = *(float *)&a5;
}
v22[3] = (__int64)v7;
v22[2] = (__int64)v20;
v22[0] = (__int64)v6;
v24 = v9;
v23 = v18;
v22[1] = (__int64)v19;
GOMP_parallel(remove_reads__omp_fn_0, v22, 0LL, 0LL);
func4(a1, (const char *)*v7, v9, a4, (__int64)clean, (char *)v11, (int)contam, (char *)v13);
v7 = (_QWORD *)v7[6];
bloom_destroy(v6);
}
v14 = strlen(v8);
munmap(v8, v14);
puts("finish processing...");
return 0LL;
}

original_code:
int remove_reads(char *source, char *ref, char *list, char *prefix, float tole_rate)
{
  int type = 1;
  char *position;
  char *clean2;
  char *contam2;
  bloom *bl_2 = (bloom *) malloc(sizeof(bloom));
  Queue *head = (Queue *) malloc(sizeof(Queue));
  Queue *tail = (Queue *) malloc(sizeof(Queue));
  head->next = tail;
  Queue *head2 = head;
  F_set *File_head = (F_set *) malloc(sizeof(F_set));
  File_head = make_list (ref, list);
  position = mmaping (source);
  type = get_parainfo (position, head);
  clean = (char *) malloc (strlen (position) * sizeof (char));
  contam = (char *) malloc (strlen (position) * sizeof (char));
  clean2 = clean;
  contam2 = contam;
  while (File_head)
    {
      memset (clean2, 0, strlen (position));
      memset (contam2, 0, strlen (position));
      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_m (bl_2, head, tail, tole_rate, File_head);
    else
      fastq_process_m (bl_2, head, tail, tole_rate, File_head);
                }
     }
          }
       head = head->next;
 }
      }
      save_result (source, File_head->filename, type, prefix, clean, clean2,
     contam, contam2);
      File_head = File_head->next;
      head = head2;
      bloom_destroy (bl_2);
    }
  munmap (position, strlen (position));
  printf ("finish processing...\n");
  return 0;
}

canonical_original_code:
int remove_reads(char *source, char *ref, char *list, char *prefix, float tole_rate)
{
  int type = 1;
  char *position;
  char *clean2;
  char *contam2;
  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 info *head2 = head;
  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);
  clean = (char *) malloc (strlen (position) * sizeof (char));
  contam = (char *) malloc (strlen (position) * sizeof (char));
  clean2 = clean;
  contam2 = contam;
  while (File_head)
    {
      memset (clean2, 0, strlen (position));
      memset (contam2, 0, strlen (position));
      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_m (bl_2, head, tail, tole_rate, File_head);
    else
      fastq_process_m (bl_2, head, tail, tole_rate, File_head);
                }
     }
          }
       head = head->next;
 }
      }
      save_result (source, File_head->filename, type, prefix, clean, clean2,
     contam, contam2);
      File_head = File_head->next;
      head = head2;
      bloom_destroy (bl_2);
    }
  munmap (position, strlen (position));
  printf ("finish processing...\n");
  return 0;
}

variable_types:
ref
char *

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


decompiled_code:
__int64 __fastcall remove_main(int argc, char **argv)
{
char *v2; // r12
char *v3; // r15
char *v4; // r14
char *v5; // r13
float v6; // xmm2_4
int v7; // eax
float v9; // [rsp+Ch] [rbp-3Ch]

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

canonical_decompiled_code:
__int64 __fastcall func6(int argc, char **argv)
{
char *v2; // r12
char *v3; // r15
char *v4; // r14
char *v5; // r13
float v6; // xmm2_4
int v7; // eax
float v9; // [rsp+Ch] [rbp-3Ch]

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

original_code:
int remove_main(int argc, char** argv)
{
  if (argc < 2) remove_help();
  int opt;
  float tole_rate = 0;
  char* ref = ((void *)0);
  char* list = ((void *)0);
  char* target_path = ((void *)0);
  char* source = ((void *)0);
  while ((opt = getopt (argc, argv, "t:r:o:q:l:h")) != -1) {
      switch (opt) {
          case 't':
              (optarg) && ((tole_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':
              remove_help();
          case '?':
              printf ("Unknown option: -%c\n", (char) optopt);
              remove_help();
      }
  }
  return remove_reads(source, ref, list, target_path, tole_rate);
}

canonical_original_code:
int remove_main(int argc, char **argv)
{
  if (argc < 2) remove_help();
  int opt;
  float tole_rate = 0;
  char *ref = ((void *)0);
  char *list = ((void *)0);
  char *target_path = ((void *)0);
  char *source = ((void *)0);
  while ((opt = getopt (argc, argv, "t:r:o:q:l:h")) != -1) {
      switch (opt) {
          case 't':
              (optarg) && ((tole_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':
              remove_help();
          case '?':
              printf ("Unknown option: -%c\n", (char) optopt);
              remove_help();
      }
  }
  return remove_reads(source, ref, list, target_path, tole_rate);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int


decompiled_code:
__int64 query_usage()
{
fwrite("\nUsage: ./facs query [options]\n", 1uLL, 0x1FuLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite("\t-r reference bloom filter to query against\n", 1uLL, 0x2CuLL, stderr);
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
fwrite("\nUsage: ./facs query [options]\n", 1uLL, 0x1FuLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite("\t-r reference bloom filter to query against\n", 1uLL, 0x2CuLL, stderr);
return 1LL;
}

original_code:
static int
query_usage(void)
{
    fprintf(stderr, "\nUsage: ./facs query [options]\n");
    fprintf(stderr, "Options:\n");
    fprintf(stderr, "\t-r reference bloom filter to query against\n");
    return 1;
}

canonical_original_code:
static int query_usage()
{
    fprintf(stderr, "\nUsage: ./facs query [options]\n");
    fprintf(stderr, "Options:\n");
    fprintf(stderr, "\t-r reference bloom filter to query against\n");
    return 1;
}


strrstr

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

v2 = &a1[(int)strlen(a1) - 1];
if ( a1 > v2 )
return 0LL;
v3 = *a2;
while ( 1 )
{
if ( *v2 == v3 )
{
v4 = strlen(a2);
if ( !memcmp(v2, a2, v4) )
break;
}
if ( a1 > --v2 )
return 0LL;
}
return v2;
}

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

v2 = &a1[(int)strlen(a1) - 1];
if ( a1 > v2 )
return 0LL;
v3 = *a2;
while ( 1 )
{
if ( *v2 == v3 )
{
v4 = strlen(a2);
if ( !memcmp(v2, a2, v4) )
break;
}
if ( a1 > --v2 )
return 0LL;
}
return v2;
}

original_code:
char *strrstr(char *s, char *str)
{
    char *p;
    int len = strlen(s);
    for (p = s + len - 1; p >= s; p--) {
        if ((*p == *str) && (memcmp(p, str, strlen(str)) == 0))
            return p;
    }
    return ((void *)0);
}

variable_types:
s
char *

variable_types:
str
char *

variable_types:
p
char *

variable_types: len int

return_type: char *


decompiled_code:
void __fastcall clean_list(void *ptr, void *a2)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = ptr;
if ( ptr != a2 )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[3];
free(v3);
}
while ( a2 != v2 );
}
free(a2);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr, void *a2)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = ptr;
if ( ptr != a2 )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[3];
free(v3);
}
while ( a2 != v2 );
}
free(a2);
}

original_code:
void clean_list (Queue* head, Queue *tail)
{
Queue *element;
while (head!=tail)
   {
       element = head->next;
       memset(head,0,sizeof(Queue));
       free(head);
       head = element;
   }
free(tail);
}

canonical_original_code:
void clean_list(struct info *head, struct info *tail)
{
struct info *element;
while (head!=tail)
   {
       element = head->next;
       memset(head,0,sizeof(Queue));
       free(head);
       head = element;
   }
free(tail);
}

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

variable_types:
tail
struct info *


CHUNKgz

original_code:
long long CHUNKgz(gzFile zip, long long offset,int chunk,char *position,char *extra,int type)
{
         memset(position,0,chunk);
       char c, *position2 = position;
       char *x;
       int num=0;
         if (offset == 0)
          while (offset <10*100)
          {
             c = ((zip)->have ? ((zip)->have--, (zip)->pos++, *((zip)->next)++) : (gzgetc)(zip));
            if ((c == '@' && type==2)&&(c == '>' && type==1))
                  break;
             offset++;
          }
          if (extra!=((void *)0))
             {
             memcpy(position,extra,strlen(extra));
             position+=strlen(extra);
             }
          free(extra);
          while (((c=((zip)->have ? ((zip)->have--, (zip)->pos++, *((zip)->next)++) : (gzgetc)(zip)))!=(-1))&&(num<chunk))
          {
             *position=c;
             position++;
             num++;
          }
         x = strrstr(position2,"\n@");
         extra = (char*)malloc((position-x+1)*sizeof(char));
         memcpy (x,extra,position-x+1);
         offset+=(position-x+1);
        return offset;
}

canonical_original_code:
long long CHUNKgz(struct gzFile_s *zip, long long offset, int chunk, char *position, char *extra, int type)
{
         memset(position,0,chunk);
       char c; char *position2 = position;
       char *x;
       int num = 0;
         if (offset == 0)
          while (offset <10*100)
          {
             c = ((zip)->have ? ((zip)->have--, (zip)->pos++, *((zip)->next)++) : (gzgetc)(zip));
            if ((c == '@' && type==2)&&(c == '>' && type==1))
                  break;
             offset++;
          }
          if (extra!=((void *)0))
             {
             memcpy(position,extra,strlen(extra));
             position+=strlen(extra);
             }
          free(extra);
          while (((c=((zip)->have ? ((zip)->have--, (zip)->pos++, *((zip)->next)++) : (gzgetc)(zip)))!=(-1))&&(num<chunk))
          {
             *position=c;
             position++;
             num++;
          }
         x = strrstr(position2,"\n@");
         extra = (char *)malloc((position-x+1)*sizeof(char));
         memcpy (x,extra,position-x+1);
         offset+=(position-x+1);
        return offset;
}

variable_types: struct gzFile_s { unsigned int have; unsigned char *next; long pos; } *

variable_types:
offset
long long

variable_types: chunk int

variable_types:
extra
char *

variable_types: type int

variable_types: c char

variable_types:
x
char *

variable_types: num int

return_type: long long


CHUNKer

original_code:
long long CHUNKer(gzFile zip,long long offset,int chunk,char *data,int type)
{
    char c, v;
    char *pos = ((void *)0);
    int length = 0;
    if (type == 2)
        v = '@';
    else
        v = '>';
    if (offset == 0)
        while (offset <10*100)
        {
            c = ((zip)->have ? ((zip)->have--, (zip)->pos++, *((zip)->next)++) : (gzgetc)(zip));
            if (c == v)
                break;
            offset++;
        }
    gzseek64 (zip,offset,0);
    gzread (zip,data,chunk);
    if (data != ((void *)0))
        length = strlen(data);
    if (length>=chunk) {
        if (type == 2) {
            pos = strrstr (data,"\n+");
            pos = bac_2_n (pos-1);
        } else {
            pos = strrchr (data,'>')-1;
        }
    }
    if (pos) {
        offset += (pos-data);
        memset (pos, 0, strlen(pos));
    }
    if (length<chunk)
        offset=-1;
    return offset;
}

canonical_original_code:
long long CHUNKer(struct gzFile_s *zip, long long offset, int chunk, char *data, int type)
{
    char c; char v;
    char *pos = ((void *)0);
    int length = 0;
    if (type == 2)
        v = '@';
    else
        v = '>';
    if (offset == 0)
        while (offset <10*100)
        {
            c = ((zip)->have ? ((zip)->have--, (zip)->pos++, *((zip)->next)++) : (gzgetc)(zip));
            if (c == v)
                break;
            offset++;
        }
    gzseek64 (zip,offset,0);
    gzread (zip,data,chunk);
    if (data != ((void *)0))
        length = strlen(data);
    if (length>=chunk) {
        if (type == 2) {
            pos = strrstr (data,"\n+");
            pos = bac_2_n (pos-1);
        } else {
            pos = strrchr (data,'>')-1;
        }
    }
    if (pos) {
        offset += (pos-data);
        memset (pos, 0, strlen(pos));
    }
    if (length<chunk)
        offset=-1;
    return offset;
}

variable_types:
data
char *

variable_types: v char

variable_types:
pos
char *

variable_types: length int

user_defined_types: struct gzFile_s { unsigned int have; unsigned char *next; long pos; }


query

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

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

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

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


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

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

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

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

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 *


decompiled_code:
__int64 __fastcall bloom_init(__int64 a1, __int64 a2, __int64 a3, int a4, void *a5, double a6)
{
__int64 v10; // rax
size_t v11; // rbp
void *v12; // rdi
__int64 result; // rax
double v14; // xmm0_8
double v15; // xmm0_8

if ( a2 )
{
v10 = find_close_prime(a2);
*(_QWORD *)(a1 + 24) = v10;
if ( a4 <= 0 )
{
result = 0xFFFFFFFFLL;
}
else
{
*(_DWORD *)(a1 + 32) = a4;
if ( !a5 )
a5 = &hash5;
*(_QWORD *)(a1 + 8) = a5;
*(_QWORD *)(a1 + 16) = 0LL;
if ( !a3 || a6 == 0.0 )
{
if ( v10 < 0 )
v14 = (double)(int)(v10 & 1 | ((unsigned __int64)v10 >> 1))
+ (double)(int)(v10 & 1 | ((unsigned __int64)v10 >> 1));
else
v14 = (double)(int)v10;
v15 = v14 * 0.7 / (double)a4;
if ( v15 >= 9.223372036854776e18 )
{
*(_QWORD *)(a1 + 40) = (unsigned int)(int)(v15 - 9.223372036854776e18);
*(_QWORD *)(a1 + 40) ^= 0x8000000000000000LL;
}
else
{
*(_QWORD *)(a1 + 40) = (unsigned int)(int)v15;
}
*(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 = (*(_QWORD *)(a1 + 24) >> 3) + 1LL;
v12 = malloc(v11);
*(_QWORD *)a1 = v12;
if ( v12 )
{
memset(v12, 0, 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


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


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 v3; // [rsp+0h] [rbp-18h] BYREF
char v4; // [rsp+8h] [rbp-10h]

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

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

func3(a2, (__int64)&v3);
*(_BYTE *)(v3 + a1) += v4;
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 v3; // [rsp+0h] [rbp-18h] BYREF
unsigned __int8 v4; // [rsp+8h] [rbp-10h]

finder(a2, (__int64)&v3);
return (*(_BYTE *)(a1 + v3) & v4) == v4;
}

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

func3(a2, (__int64)&v3);
return (*(_BYTE *)(a1 + v3) & v4) == v4;
}

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)
{
int v4; // er13
unsigned __int64 v5; // r12
unsigned int v7; // [rsp+Ch] [rbp-3Ch]

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

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; // rbx
int v8; // er13
size_t v9; // rbx
__int64 v10; // rbp
__int64 result; // rax
int *v12; // rbx
char *v13; // rax

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

canonical_decompiled_code:
__int64 __fastcall func10(char *a1, void **a2, __int64 a3, const char *a4)
{
char *v6; // rax
char *v7; // rbx
int v8; // er13
size_t v9; // rbx
__int64 v10; // rbp
__int64 result; // rax
int *v12; // rbx
char *v13; // rax

v6 = (char *)prefix_make(a1, a3, a4);
v7 = v6;
if ( (unsigned __int64)a4 | a3 )
{
if ( (unsigned int)is_dir(a4) )
strcat(v7, ".bloom");
}
else
{
strcat(v6, ".bloom");
v7 = v6 + 1;
}
v8 = open64(v7, 66, 420LL);
if ( v8 < 0 )
{
perror(v7);
result = 0xFFFFFFFFLL;
}
else if ( ftruncate64(v8, ((unsigned __int64)a2[3] >> 3) + 4LL * (*((_DWORD *)a2 + 8) + 1) + 73) < 0 )
{
v12 = _errno_location();
v13 = strerror(*v12);
printf("[%d]-ftruncate64 error: %s/n", (unsigned int)*v12, v13);
close(v8);
result = 0LL;
}
else
{
if ( write(v8, a2, 0x48uLL) < 0 )
{
perror(" error writing bloom file ");
exit(1);
}
v9 = ((unsigned __int64)a2[3] >> 3) + 1;
if ( v9 <= 0x77359400 )
{
v10 = 0LL;
}
else
{
v10 = 0LL;
do
{
if ( write(v8, (char *)*a2 + v10, 0x77359400uLL) < 0 )
{
perror(" error writing bloom file ");
exit(1);
}
v9 -= 2000000000LL;
v10 += 2000000000LL;
}
while ( v9 > 0x77359400 );
}
if ( write(v8, (char *)*a2 + v10, v9) < 0 )
{
perror(" error writing bloom file ");
exit(1);
}
close(v8);
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 v2; // eax
int v3; // er12
size_t v4; // rbx
__int64 v5; // rbp
unsigned int v6; // ebx

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

canonical_decompiled_code:
__int64 __fastcall func11(char *s, void *buf)
{
int v2; // eax
int v3; // er12
size_t v4; // rbx
__int64 v5; // rbp
unsigned int v6; // ebx

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

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; // ebp
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 func12(const char *a1, const char *a2)
{
int v2; // ebp
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
__int64 v2; // rax
__int64 v3; // rdx
char v4; // cl
size_t result; // rax

v1 = s;
LODWORD(v2) = strlen(s) - 1;
if ( (int)v2 > 0 )
{
v2 = (int)v2;
v3 = 0LL;
do
{
v4 = s[v3];
s[v3] = s[v2];
s[v2] = v4;
++v3;
--v2;
}
while ( (int)v3 < (int)v2 );
}
while ( 1 )
{
result = strlen(v1);
if ( !result )
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;
break;
default:
break;
}
++v1;
}
}

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

v1 = s;
LODWORD(v2) = strlen(s) - 1;
if ( (int)v2 > 0 )
{
v2 = (int)v2;
v3 = 0LL;
do
{
v4 = s[v3];
s[v3] = s[v2];
s[v2] = v4;
++v3;
--v2;
}
while ( (int)v3 < (int)v2 );
}
while ( 1 )
{
result = strlen(v1);
if ( !result )
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;
break;
default:
break;
}
++v1;
}
}

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 func14(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 *

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 func15()
{
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 func16()
{
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 func17()
{
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 func18()
{
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)
{
strcpy(dest, s);
if ( dest[strlen(s) - 1] != 47 )
*(_WORD *)&dest[strlen(dest)] = 47;
return strcat(dest, src);
}

canonical_decompiled_code:
char *__fastcall func0(char *s, char *src, char *dest)
{
strcpy(dest, s);
if ( dest[strlen(s) - 1] != 47 )
*(_WORD *)&dest[strlen(dest)] = 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; // edx
_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; // edx
_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; // edx
_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; // edx
_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(const char *a1)
{
_BOOL4 v1; // ecx

v1 = 1;
if ( strcmp(a1, ".") )
v1 = strcmp(a1, "..") == 0;
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(const char *a1)
{
_BOOL4 v1; // ecx

v1 = 1;
if ( strcmp(a1, ".") )
v1 = strcmp(a1, "..") == 0;
return v1;
}

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 )
{
*(_DWORD *)(a1 + 56) = a4;
}
else
{
v8 = get_size(a5);
*(_DWORD *)(a1 + 56) = kmer_suggestion(v8);
}
result = dx_add(*(unsigned int *)(a1 + 56));
*(_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 )
{
*(_DWORD *)(a1 + 56) = a4;
}
else
{
v8 = get_size(a5);
*(_DWORD *)(a1 + 56) = kmer_suggestion(v8);
}
result = dx_add(*(unsigned int *)(a1 + 56));
*(_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