decompiled_code:
void __fastcall liste_modifier_valeur(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void liste_modifier_valeur(liste * obj, void * valeur)
{
  obj->valeur = valeur;
}

canonical_original_code:
void liste_modifier_valeur(struct liste *obj, void *valeur)
{
  obj->valeur = valeur;
}

variable_types:
valeur
void *

user_defined_types: struct liste { struct liste *suivant; void *valeur; }


repo: altor/tamagochi

decompiled_code:
__int64 __fastcall liste_obtenir_valeur(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

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

original_code:
void * liste_obtenir_valeur(liste * obj)
{
  return obj->valeur;
}

canonical_original_code:
void *liste_obtenir_valeur(struct liste *obj)
{
  return obj->valeur;
}

variable_types: struct liste { struct liste *suivant; void *valeur; } *

return_type: void *


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

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

original_code:
liste * liste_obtenir_suivant(liste * obj)
{
  return obj->suivant;
}

canonical_original_code:
struct liste *liste_obtenir_suivant(struct liste *obj)
{
  return obj->suivant;
}

variable_types:
obj
struct liste *

return_type: struct liste { struct liste *suivant; void *valeur; } *


original_code:
void manger_gout(char * chaine, int gout)
{
  if(gout > 8)
    strcpy(chaine, ">8");
  else if(gout > 6)
    strcpy(chaine, ">6");
  else if(gout > 4)
    strcpy(chaine, ">4");
  else if(gout > 2)
    strcpy(chaine, ">2");
  else if(gout > 0)
    strcpy(chaine, ">0");
  else if(gout > -2)
    strcpy(chaine, ">-2");
  else if(gout > -4)
    strcpy(chaine, ">-4");
  else if(gout > -6)
    strcpy(chaine, ">-6");
  else if(gout > -8)
    strcpy(chaine, ">-8");
  else if(gout > -10)
    strcpy(chaine, ">-10");
}

canonical_original_code:
void manger_gout(char *chaine, int gout)
{
  if(gout > 8)
    strcpy(chaine, ">8");
  else if(gout > 6)
    strcpy(chaine, ">6");
  else if(gout > 4)
    strcpy(chaine, ">4");
  else if(gout > 2)
    strcpy(chaine, ">2");
  else if(gout > 0)
    strcpy(chaine, ">0");
  else if(gout > -2)
    strcpy(chaine, ">-2");
  else if(gout > -4)
    strcpy(chaine, ">-4");
  else if(gout > -6)
    strcpy(chaine, ">-6");
  else if(gout > -8)
    strcpy(chaine, ">-8");
  else if(gout > -10)
    strcpy(chaine, ">-10");
}

variable_types:
chaine
char *

variable_types: gout int

return_type: void


decompiled_code:
__int64 __fastcall serv_chaine(__int64 a1, __int64 a2, int a3)
{
_BYTE *v3; // rbp

v3 = (_BYTE *)(a2 + a3);
*v3 = 10;
v3[1] = 0;
if ( a3 + 1 != (unsigned int)writen(a1, a2, (unsigned int)(a3 + 1)) )
err_dump("serveur_chaine : erreur lors de l'appel de writen");
*v3 = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
_BYTE *v3; // rbp

v3 = (_BYTE *)(a2 + a3);
*v3 = 10;
v3[1] = 0;
if ( a3 + 1 != (unsigned int)writen(a1, a2, (unsigned int)(a3 + 1)) )
err_dump("serveur_chaine : erreur lors de l'appel de writen");
*v3 = 0;
return 0LL;
}

original_code:
int serv_chaine(int sockfd, char * chaine,int taille)
{
  chaine[taille] = '\n';
  chaine[taille + 1] = 0;
  if(writen(sockfd, chaine, (taille + 1)) != (taille + 1))
    err_dump("serveur_chaine : erreur lors de l'appel de writen");
  chaine[taille] = 0;
  return 0;
}

canonical_original_code:
int serv_chaine(int sockfd, char *chaine, int taille)
{
  chaine[taille] = '\n';
  chaine[taille + 1] = 0;
  if(writen(sockfd, chaine, (taille + 1)) != (taille + 1))
    err_dump("serveur_chaine : erreur lors de l'appel de writen");
  chaine[taille] = 0;
  return 0;
}

variable_types: sockfd int

variable_types: taille int

return_type: int


original_code:
int recup_arguments(char arguments[12][512], char * chaine_env, int longueur)
{
  int i;
  int nb_arguments = 0;
  int j = 0;
  for(i = 0; i < longueur; i++){
    if(chaine_env[i] == 32){
      arguments[nb_arguments][j] = 0;
      nb_arguments ++;
      j = 0;
    }
    else{
      arguments[nb_arguments][j] = chaine_env[i];
      j ++;
    }
  }
  arguments[nb_arguments][j] = 0;
  for(i = (nb_arguments + 1); i < 12; i++)
    arguments[i][0] = 0;
  return nb_arguments + 1;
}

canonical_original_code:
int recup_arguments(char arguments[12][512], char *chaine_env, int longueur)
{
  int i;
  int nb_arguments = 0;
  int j = 0;
  for(i = 0; i < longueur; i++){
    if(chaine_env[i] == 32){
      arguments[nb_arguments][j] = 0;
      nb_arguments ++;
      j = 0;
    }
    else{
      arguments[nb_arguments][j] = chaine_env[i];
      j ++;
    }
  }
  arguments[nb_arguments][j] = 0;
  for(i = (nb_arguments + 1); i < 12; i++)
    arguments[i][0] = 0;
  return nb_arguments + 1;
}

variable_types:
arguments
char [12][512]

variable_types: longueur int

variable_types: i int

variable_types: j int


readline

decompiled_code:
__int64 __fastcall readline(int fd, _BYTE *a2, int a3)
{
unsigned int v5; // ebp
int v6; // eax
char buf[41]; // [rsp+Fh] [rbp-29h] BYREF

if ( a3 <= 1 )
{
v5 = 1;
}
else
{
v5 = 1;
while ( 1 )
{
v6 = read(fd, buf, 1uLL);
if ( v6 != 1 )
break;
if ( buf[0] != 10 )
{
*a2++ = buf[0];
if ( a3 != ++v5 )
continue;
}
goto LABEL_6;
}
if ( v6 )
return (unsigned int)-1;
if ( v5 == 1 )
return 0;
}
LABEL_6:
*a2 = 0;
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func8(int fd, _BYTE *a2, int a3)
{
unsigned int v5; // ebp
int v6; // eax
char buf[41]; // [rsp+Fh] [rbp-29h] BYREF

if ( a3 <= 1 )
{
v5 = 1;
}
else
{
v5 = 1;
while ( 1 )
{
v6 = read(fd, buf, 1uLL);
if ( v6 != 1 )
break;
if ( buf[0] != 10 )
{
*a2++ = buf[0];
if ( a3 != ++v5 )
continue;
}
goto LABEL_6;
}
if ( v6 )
return (unsigned int)-1;
if ( v5 == 1 )
return 0;
}
LABEL_6:
*a2 = 0;
return v5;
}

original_code:
int readline(int fd, char * ptr, int maxlen)
{
  int n, rc;
  char c;
  for (n = 1; n < maxlen; n++) {
    if ( (rc = read(fd, &c, 1)) == 1) {
      if (c == '\n')
 break;
      *ptr++ = c;
    }
    else if (rc == 0) {
      if (n == 1)
 return(0);
      else
 break;
    }
    else
      return(-1);
  }
  *ptr = 0;
  return(n);
}

canonical_original_code:
int readline(int fd, char *ptr, int maxlen)
{
  int n; int rc;
  char c;
  for (n = 1; n < maxlen; n++) {
    if ( (rc = read(fd, &c, 1)) == 1) {
      if (c == '\n')
 break;
      *ptr++ = c;
    }
    else if (rc == 0) {
      if (n == 1)
 return(0);
      else
 break;
    }
    else
      return(-1);
  }
  *ptr = 0;
  return(n);
}

variable_types: fd int

variable_types:
ptr
char *

variable_types: maxlen int

variable_types: n int

variable_types: rc int

variable_types: c char


writen

decompiled_code:
__int64 __fastcall writen(int fd, void *buf, int a3)
{
int v3; // er13
int v5; // ebx
int v6; // eax
unsigned int v7; // edx

v3 = a3;
if ( a3 <= 0 )
{
v5 = a3;
LABEL_5:
v7 = v3 - v5;
}
else
{
v5 = a3;
while ( 1 )
{
v6 = write(fd, buf, v5);
v7 = v6;
if ( v6 <= 0 )
break;
v5 -= v6;
buf = (char *)buf + v6;
if ( v5 <= 0 )
goto LABEL_5;
}
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func9(int fd, void *buf, int a3)
{
int v3; // er13
int v5; // ebx
int v6; // eax
unsigned int v7; // edx

v3 = a3;
if ( a3 <= 0 )
{
v5 = a3;
LABEL_5:
v7 = v3 - v5;
}
else
{
v5 = a3;
while ( 1 )
{
v6 = write(fd, buf, v5);
v7 = v6;
if ( v6 <= 0 )
break;
v5 -= v6;
buf = (char *)buf + v6;
if ( v5 <= 0 )
goto LABEL_5;
}
}
return v7;
}

original_code:
int writen(int fd, char * ptr, int nbytes)
{
  int nleft, nwritten;
  nleft = nbytes;
  while (nleft > 0) {
    nwritten = write(fd, ptr, nleft);
    if (nwritten <= 0)
      return(nwritten);
    nleft -= nwritten;
    ptr += nwritten;
  }
  return(nbytes - nleft);
}

canonical_original_code:
int writen(int fd, char *ptr, int nbytes)
{
  int nleft; int nwritten;
  nleft = nbytes;
  while (nleft > 0) {
    nwritten = write(fd, ptr, nleft);
    if (nwritten <= 0)
      return(nwritten);
    nleft -= nwritten;
    ptr += nwritten;
  }
  return(nbytes - nleft);
}

variable_types: nbytes int

variable_types: nleft int

variable_types: nwritten int


decompiled_code:
void __fastcall __noreturn err_dump(const char *a1)
{
fprintf(stderr, "%s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func10(const char *a1)
{
fprintf(stderr, "%s\n", a1);
exit(1);
}

original_code:
void err_dump(char * p)
{
  fprintf(stderr,"%s\n",p);
  exit(1);
}

canonical_original_code:
void err_dump(char *p)
{
  fprintf(stderr,"%s\n",p);
  exit(1);
}

variable_types:
p
char *


strrstr

decompiled_code:
const char *__fastcall strrstr(char *s, char *s2)
{
size_t v2; // rbx
size_t v3; // rax
size_t v4; // rbp
char *v5; // rax
const char *v6; // rbx

v2 = strlen(s);
v3 = strlen(s2);
if ( v2 < v3 )
return 0LL;
v4 = v3;
v5 = strrchr(s, s2[v3 - 1]);
v6 = v5;
if ( v5 )
{
v6 = &v5[-v4 + 1];
if ( s > v6 )
{
v6 = 0LL;
}
else
{
while ( strncmp(v6, s2, v4) )
{
if ( s > --v6 )
return 0LL;
}
}
}
return v6;
}

canonical_decompiled_code:
const char *__fastcall func1(char *s, char *s2)
{
size_t v2; // rbx
size_t v3; // rax
size_t v4; // rbp
char *v5; // rax
const char *v6; // rbx

v2 = strlen(s);
v3 = strlen(s2);
if ( v2 < v3 )
return 0LL;
v4 = v3;
v5 = strrchr(s, s2[v3 - 1]);
v6 = v5;
if ( v5 )
{
v6 = &v5[-v4 + 1];
if ( s > v6 )
{
v6 = 0LL;
}
else
{
while ( strncmp(v6, s2, v4) )
{
if ( s > --v6 )
return 0LL;
}
}
}
return v6;
}

original_code:
char *strrstr(const char* str1, const char *str2)
{
 size_t str1len = strlen(str1);
 size_t str2len = strlen(str2);
 if (str2len > str1len)
  return ((void *)0);
 char *pos = strrchr(str1, str2[str2len-1]);
 if (pos)
  pos -= (str2len - 1);
 while ( pos && pos >= str1 )
 {
  if ( !strncmp(pos, str2, str2len) )
   return pos;
  --pos;
 }
 return ((void *)0);
}

canonical_original_code:
char *strrstr(char *str1, char *str2)
{
 unsigned long str1len = strlen(str1);
 unsigned long str2len = strlen(str2);
 if (str2len > str1len)
  return ((void *)0);
 char *pos = strrchr(str1, str2[str2len-1]);
 if (pos)
  pos -= (str2len - 1);
 while ( pos && pos >= str1 )
 {
  if ( !strncmp(pos, str2, str2len) )
   return pos;
  --pos;
 }
 return ((void *)0);
}

variable_types:
pos
char *

return_type: char *


delProteinMap

decompiled_code:
__int64 __fastcall delProteinMap(void *ptr, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = (void **)ptr;
do
{
if ( *v2 )
{
free(*v2);
*v2 = 0LL;
}
++v2;
}
while ( v2 != (void **)((char *)ptr + 8 * (unsigned int)(a2 - 1) + 8) );
}
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(void *ptr, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = (void **)ptr;
do
{
if ( *v2 )
{
free(*v2);
*v2 = 0LL;
}
++v2;
}
while ( v2 != (void **)((char *)ptr + 8 * (unsigned int)(a2 - 1) + 8) );
}
free(ptr);
return 0LL;
}

original_code:
char **delProteinMap(char** proteinMap, int peptideCount){
 for(int i=0; i<peptideCount; ++i){
  if(proteinMap[i]){
   free(proteinMap[i]);
   proteinMap[i] = ((void *)0);
  }
 }
 free(proteinMap);
 proteinMap = ((void *)0);
 return proteinMap;
}

canonical_original_code:
char **delProteinMap(char **proteinMap, int peptideCount){
 for(int i = 0; i<peptideCount; ++i){
  if(proteinMap[i]){
   free(proteinMap[i]);
   proteinMap[i] = ((void *)0);
  }
 }
 free(proteinMap);
 proteinMap = ((void *)0);
 return proteinMap;
}

variable_types:
proteinMap
char **

variable_types: peptideCount int

return_type: char **


linfunc

original_code:
int linfunc(int m, int n, double *p, double *dy, double **dvec, void *vars){
 int i;
 struct vars_struct *v = (struct vars_struct *) vars;
 double *x, *y, *ey, f;
 x = v->x;
 y = v->y;
 ey = v->ey;
 for (i=0; i<m; i++) {
  f = p[0] - p[1]*x[i];
  dy[i] = (y[i] - f)/ey[i];
 }
  return 0;
}

canonical_original_code:
int linfunc(int m, int n, double *p, double *dy, double **dvec, void *vars){
 int i;
 struct vars_struct *v = (struct vars_struct *) vars;
 double *x; double *y; double *ey; double f;
 x = v->x;
 y = v->y;
 ey = v->ey;
 for (i=0; i<m; i++) {
  f = p[0] - p[1]*x[i];
  dy[i] = (y[i] - f)/ey[i];
 }
  return 0;
}

variable_types: m int

variable_types:
p
double *

variable_types:
dy
double *

variable_types:
dvec
double **

variable_types:
vars
void *

variable_types: struct vars_struct { double *x; double *y; double *ey; } *

variable_types:
x
double *

variable_types:
y
double *

variable_types:
ey
double *

variable_types: f double


fit

original_code:
int fit(double *x, double *y, int n, double *p){
  int i;
 double *ey = (double *)malloc(n * sizeof(double));
 for (i=0; i<n; i++){
  ey[i] = 1;
 }
 int status;
 struct vars_struct v;
 v.x = x;
 v.y = y;
 v.ey = ey;
 status = mpfit(linfunc, n, 2, p, 0, 0, (void *) &v, 0);
  return status;
}

variable_types: n int

variable_types: i int

variable_types: status int

variable_types: struct vars_struct { double *x; double *y; double *ey; }


leastSquares

original_code:
double **leastSquares(double **rt, double *median, int peptideCount,
 int fileCount){
 double **params = new2Darray(fileCount, 2);
 int i,j;
 for(i=0; i<fileCount; ++i){
  double *x = (double*)malloc(peptideCount*sizeof(double) );
  double *y = (double*)malloc(peptideCount*sizeof(double) );
  for(j=0; j<2; ++j){
   params[i][j] = 1;
  }
  int n = 0;
  for(j=0; j<peptideCount; ++j){
   if(rt[j][i] != 0 && median[j] != 0
     && fabs(rt[j][i] - median[j]) < alignWindow){
    y[n] = rt[j][i];
    x[n] = median[j];
    n++;
   }
  }
  fit(x, y, n, params[i]);
  free(x);
  free(y);
 }
 return params;
}

canonical_original_code:
double **leastSquares(double **rt, double *median, int peptideCount, int fileCount){
 double **params = new2Darray(fileCount, 2);
 int i; int j;
 for(i=0; i<fileCount; ++i){
  double *x = (double*)malloc(peptideCount*sizeof(double) );
  double *y = (double*)malloc(peptideCount*sizeof(double) );
  for(j=0; j<2; ++j){
   params[i][j] = 1;
  }
  int n = 0;
  for(j=0; j<peptideCount; ++j){
   if(rt[j][i] != 0 && median[j] != 0
     && fabs(rt[j][i] - median[j]) < alignWindow){
    y[n] = rt[j][i];
    x[n] = median[j];
    n++;
   }
  }
  fit(x, y, n, params[i]);
  free(x);
  free(y);
 }
 return params;
}

variable_types:
rt
double **

variable_types:
median
double *

variable_types: fileCount int

variable_types:
params
double **

variable_types: j int

return_type: double **


align

original_code:
void align(double **ms2rt, double **ms1rt, double *ms2median,
 double *ms1median, double **ms2params, double **ms1params,
 int peptideCount, int fileCount){
 int i, j;
 for(i = 0; i < peptideCount; ++i){
  for(j = 0; j < fileCount; ++j){
   if(ms2rt[i][j] == 0){
    if(fabs(ms2median[i] - ms1median[i]) < alignWindow &&
     ms1median[i] > 0){
     ms2rt[i][j] = ms1params[j][0] -
      ms1params[j][1]*ms1median[i];
    }else{
     ms2rt[i][j] = ms2params[j][0] -
      ms2params[j][1]*ms2median[i];
    }
   }else if(fabs(ms2rt[i][j] - ms1rt[i][j]) < alignWindow &&
    ms1rt[i][j] > 0){
    ms2rt[i][j] = ms1rt[i][j];
   }
  }
 }
 return;
}

canonical_original_code:
void align(double **ms2rt, double **ms1rt, double *ms2median, double *ms1median, double **ms2params, double **ms1params, int peptideCount, int fileCount){
 int i; int j;
 for(i = 0; i < peptideCount; ++i){
  for(j = 0; j < fileCount; ++j){
   if(ms2rt[i][j] == 0){
    if(fabs(ms2median[i] - ms1median[i]) < alignWindow &&
     ms1median[i] > 0){
     ms2rt[i][j] = ms1params[j][0] -
      ms1params[j][1]*ms1median[i];
    }else{
     ms2rt[i][j] = ms2params[j][0] -
      ms2params[j][1]*ms2median[i];
    }
   }else if(fabs(ms2rt[i][j] - ms1rt[i][j]) < alignWindow &&
    ms1rt[i][j] > 0){
    ms2rt[i][j] = ms1rt[i][j];
   }
  }
 }
 return;
}

variable_types: peptideCount int


comparedouble

decompiled_code:
__int64 __fastcall comparedouble(const void *a1, const void *a2)
{
return (unsigned int)(int)(*(double *)a2 - *(double *)a1);
}

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

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

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

variable_types:
a
void *

variable_types:
b
void *


median

original_code:
double median(double *list, int size){
 double copyList[size];
 memcpy(copyList, list, size*sizeof(double));
 qsort(copyList, size, sizeof(double), comparedouble);
 while(size > 0 && copyList[size-1] == 0){
  size--;
 }
 if (size < 3) return 0;
 double third_quartile = (size/2)%2 ?
   (copyList[size/4]) :
   ( (copyList[size/4-1] + copyList[size/4]) / 2);
 double first_quartile = (size/2)%2 ?
    (copyList[3*size/4]) :
    ( (copyList[3*size/4-1] + copyList[3*size/4]) / 2);
 double iqr = third_quartile - first_quartile;
 if(iqr > 250) {
  return 0;
 }
 if(size%2){
  return (copyList[size/2]);
 }else{
  return ( (copyList[size/2-1] + copyList[size/2]) / 2 );
 }
}

canonical_original_code:
double median(double *list, int size){
 double copyList[-1];
 memcpy(copyList, list, size*sizeof(double));
 qsort(copyList, size, sizeof(double), comparedouble);
 while(size > 0 && copyList[size-1] == 0){
  size--;
 }
 if (size < 3) return 0;
 double third_quartile = (size/2)%2 ?
   (copyList[size/4]) :
   ( (copyList[size/4-1] + copyList[size/4]) / 2);
 double first_quartile = (size/2)%2 ?
    (copyList[3*size/4]) :
    ( (copyList[3*size/4-1] + copyList[3*size/4]) / 2);
 double iqr = third_quartile - first_quartile;
 if(iqr > 250) {
  return 0;
 }
 if(size%2){
  return (copyList[size/2]);
 }else{
  return ( (copyList[size/2-1] + copyList[size/2]) / 2 );
 }
}

variable_types:
list
double *

variable_types: size int

variable_types:
copyList
double [-1]

variable_types: iqr double

return_type: double


decompiled_code:
__int64 __fastcall del2Darray(void *ptr, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = (void **)ptr;
do
free(*v2++);
while ( v2 != (void **)((char *)ptr + 8 * (unsigned int)(a2 - 1) + 8) );
}
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *ptr, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = (void **)ptr;
do
free(*v2++);
while ( v2 != (void **)((char *)ptr + 8 * (unsigned int)(a2 - 1) + 8) );
}
free(ptr);
return 0LL;
}

original_code:
double **del2Darray(double **array, int x){
 int i;
 for(i = 0; i < x; ++i){
  free(array[i]);
 }
 free(array);
 array = ((void *)0);
 return array;
}

variable_types:
array
double **

variable_types: x int


printUsage

decompiled_code:
int printUsage()
{
return puts("Usage: pepquant2 -x|y|z data_source -f path_to_fasta [options]\n\tUse '-h' for help");
}

canonical_decompiled_code:
int func0()
{
return puts("Usage: pepquant2 -x|y|z data_source -f path_to_fasta [options]\n\tUse '-h' for help");
}

original_code:
void printUsage(){
 printf("Usage: pepquant2 -x|y|z data_source -f path_to_fasta [options]\n"
   "\tUse '-h' for help\n");
 return;
}


printHelp

decompiled_code:
int printHelp()
{
return puts(
"Usage: pepquant2 -x|y|z data_source -f path_to_fasta [options]\n"
"Required:\n"
"\t-f path_to_fasta_file\t\tFasta file used by search engine\n"
"\n"
"\tand one of:\n"
"\n"
"\t-x path_to_statQuest_dir int\tRun pepquant2 using statQuest\n"
"\t\t\t\t\twith passed confidence filter results\n"
"\t-y path_to_pepXML_dir\t\tRun pepquant2 using pepXML results\n"
"\t-z path_to_msms.txt\t\tRun pepquant2 using MaxQuant results\n"
"\n"
"\n"
"Options:\n"
"\t-a integer\tThe permissible difference between MS2 and MS1 \n"
"\t\t\tretention times before defaulting to MS2 over MS1\n"
"\t\t\tDefault = 90\n"
"\t-c float\tThe correlation cutoff for found isotopic pattern\n"
"\t\t\tmatching to theoretical isotopic patter\n"
"\t\t\tDefault = 0.99\n"
"\t-e integer\tThe maximum time window within which at least one\n"
"\t\t\tneighbor peak must be found to declare a MS1 retention\n"
"\t\t\ttime the apical retention time.\n"
"\t\t\tDefault = 30\n"
"\t-i float\tThe minimal intensity of an observed isotopic\n"
"\t\t\tpattern for a given charge state for it to be considered\n"
"\t\t\ta valid hit.\n"
"\t\t\tDefault = 1E6\n"
"\t-k integer\tThe label status of lysine. A value of 6 assumes\n"
"\t\t\tlysine is made using C13 and 8 assumes lysine is made\n"
"\t\t\tusing both C13 and N15.\n"
"\t\t\tDefault = 0\n"
"\t-m integer\tThe maximum charge to be looked at by PepQuant2\n"
"\t\t\twhen looking through MS1 spectra from isotopic patterns.\n"
"\t\t\tDefault = 4\n"
"\t-o\t\tWhether to ignore modification localization. If set, \n"
"\t\t\tall mods will be pushed onto the leftmost unmodified and\n"
"\t\t\tequivalent AA. S and T are considered to be equivalent.\n"
"\t-p float\tThe PPM tolerance divided by 1E6. Used for\n"
"\t\t\tgeneration of theoretical isotopic patterns and matching\n"
"\t\t\tthese patterns to observed patterns.\n"
"\t\t\tDefault = 0.000010\n"
"\t-q integer\tThe time window around the calibrated retention\n"
"\t\t\ttime used for quantification.\n"
"\t\t\tDefault = 150\n"
"\t-r integer\tThe label status of arginine. Value of 6 assumes\n"
"\t\t\targinine is made using C13 and 10 assumes arginine is\n"
"\t\t\tmade using both C13 and N15.\n"
"\t\t\tDefault = 0\n"
"\t-s integer\tThe number of isotopic states used in the\n"
"\t\t\ttheoretical isotopic pattern.\n"
"\t\t\tDefault = 4\n"
"\t-t integer\tThe number of threads to use during isotopic\n"
"\t\t\tpattern generation and MS1 spectra interrogation.\n"
"\t\t\tDefault = 1\n"
"\t-v\t\tPrint the current version of PepQuant2");
}

canonical_decompiled_code:
int func1()
{
return puts(
"Usage: pepquant2 -x|y|z data_source -f path_to_fasta [options]\n"
"Required:\n"
"\t-f path_to_fasta_file\t\tFasta file used by search engine\n"
"\n"
"\tand one of:\n"
"\n"
"\t-x path_to_statQuest_dir int\tRun pepquant2 using statQuest\n"
"\t\t\t\t\twith passed confidence filter results\n"
"\t-y path_to_pepXML_dir\t\tRun pepquant2 using pepXML results\n"
"\t-z path_to_msms.txt\t\tRun pepquant2 using MaxQuant results\n"
"\n"
"\n"
"Options:\n"
"\t-a integer\tThe permissible difference between MS2 and MS1 \n"
"\t\t\tretention times before defaulting to MS2 over MS1\n"
"\t\t\tDefault = 90\n"
"\t-c float\tThe correlation cutoff for found isotopic pattern\n"
"\t\t\tmatching to theoretical isotopic patter\n"
"\t\t\tDefault = 0.99\n"
"\t-e integer\tThe maximum time window within which at least one\n"
"\t\t\tneighbor peak must be found to declare a MS1 retention\n"
"\t\t\ttime the apical retention time.\n"
"\t\t\tDefault = 30\n"
"\t-i float\tThe minimal intensity of an observed isotopic\n"
"\t\t\tpattern for a given charge state for it to be considered\n"
"\t\t\ta valid hit.\n"
"\t\t\tDefault = 1E6\n"
"\t-k integer\tThe label status of lysine. A value of 6 assumes\n"
"\t\t\tlysine is made using C13 and 8 assumes lysine is made\n"
"\t\t\tusing both C13 and N15.\n"
"\t\t\tDefault = 0\n"
"\t-m integer\tThe maximum charge to be looked at by PepQuant2\n"
"\t\t\twhen looking through MS1 spectra from isotopic patterns.\n"
"\t\t\tDefault = 4\n"
"\t-o\t\tWhether to ignore modification localization. If set, \n"
"\t\t\tall mods will be pushed onto the leftmost unmodified and\n"
"\t\t\tequivalent AA. S and T are considered to be equivalent.\n"
"\t-p float\tThe PPM tolerance divided by 1E6. Used for\n"
"\t\t\tgeneration of theoretical isotopic patterns and matching\n"
"\t\t\tthese patterns to observed patterns.\n"
"\t\t\tDefault = 0.000010\n"
"\t-q integer\tThe time window around the calibrated retention\n"
"\t\t\ttime used for quantification.\n"
"\t\t\tDefault = 150\n"
"\t-r integer\tThe label status of arginine. Value of 6 assumes\n"
"\t\t\targinine is made using C13 and 10 assumes arginine is\n"
"\t\t\tmade using both C13 and N15.\n"
"\t\t\tDefault = 0\n"
"\t-s integer\tThe number of isotopic states used in the\n"
"\t\t\ttheoretical isotopic pattern.\n"
"\t\t\tDefault = 4\n"
"\t-t integer\tThe number of threads to use during isotopic\n"
"\t\t\tpattern generation and MS1 spectra interrogation.\n"
"\t\t\tDefault = 1\n"
"\t-v\t\tPrint the current version of PepQuant2");
}

original_code:
void printHelp(){
 printf("Usage: pepquant2 -x|y|z data_source -f path_to_fasta [options]\n"
   "Required:\n"
   "\t-f path_to_fasta_file\t\tFasta file used by search engine\n"
   "\n\tand one of:\n\n"
   "\t-x path_to_statQuest_dir int\tRun pepquant2 using statQuest\n"
   "\t\t\t\t\twith passed confidence filter results\n"
   "\t-y path_to_pepXML_dir\t\tRun pepquant2 using pepXML results\n"
   "\t-z path_to_msms.txt\t\tRun pepquant2 using MaxQuant results\n"
   "\n\n"
   "Options:\n"
   "\t-a integer\tThe permissible difference between MS2 and MS1 \n"
   "\t\t\tretention times before defaulting to MS2 over MS1\n"
   "\t\t\tDefault = 90\n"
   "\t-c float\tThe correlation cutoff for found isotopic pattern\n"
   "\t\t\tmatching to theoretical isotopic patter\n"
   "\t\t\tDefault = 0.99\n"
   "\t-e integer\tThe maximum time window within which at least one\n"
   "\t\t\tneighbor peak must be found to declare a MS1 retention\n"
   "\t\t\ttime the apical retention time.\n"
   "\t\t\tDefault = 30\n"
   "\t-i float\tThe minimal intensity of an observed isotopic\n"
   "\t\t\tpattern for a given charge state for it to be considered\n"
   "\t\t\ta valid hit.\n"
   "\t\t\tDefault = 1E6\n"
   "\t-k integer\tThe label status of lysine. A value of 6 assumes\n"
   "\t\t\tlysine is made using C13 and 8 assumes lysine is made\n"
   "\t\t\tusing both C13 and N15.\n"
   "\t\t\tDefault = 0\n"
   "\t-m integer\tThe maximum charge to be looked at by PepQuant2\n"
   "\t\t\twhen looking through MS1 spectra from isotopic patterns.\n"
   "\t\t\tDefault = 4\n"
   "\t-o\t\tWhether to ignore modification localization. If set, \n"
   "\t\t\tall mods will be pushed onto the leftmost unmodified and\n"
   "\t\t\tequivalent AA. S and T are considered to be equivalent.\n"
   "\t-p float\tThe PPM tolerance divided by 1E6. Used for\n"
   "\t\t\tgeneration of theoretical isotopic patterns and matching\n"
   "\t\t\tthese patterns to observed patterns.\n"
   "\t\t\tDefault = 0.000010\n"
   "\t-q integer\tThe time window around the calibrated retention\n"
   "\t\t\ttime used for quantification.\n"
   "\t\t\tDefault = 150\n"
   "\t-r integer\tThe label status of arginine. Value of 6 assumes\n"
   "\t\t\targinine is made using C13 and 10 assumes arginine is\n"
   "\t\t\tmade using both C13 and N15.\n"
   "\t\t\tDefault = 0\n"
   "\t-s integer\tThe number of isotopic states used in the\n"
   "\t\t\ttheoretical isotopic pattern.\n"
   "\t\t\tDefault = 4\n"
   "\t-t integer\tThe number of threads to use during isotopic\n"
   "\t\t\tpattern generation and MS1 spectra interrogation.\n"
   "\t\t\tDefault = 1\n"
   "\t-v\t\tPrint the current version of PepQuant2\n"
   );
 return;
}


parseArgs

decompiled_code:
void __fastcall parseArgs(int a1, __int64 a2)
{
int v2; // ebx
__int64 v3; // rcx

if ( a1 > 1 )
{
v2 = 1;
do
{
v3 = 8LL * v2;
switch ( *(_BYTE *)(*(_QWORD *)(a2 + v3) + 1LL) )
{
case 'A':
case 'a':
alignWindow = atoi(*(const char **)(a2 + 8LL * v2 + 8));
v2 += 2;
break;
case 'C':
case 'c':
corrCutOff = atof(*(const char **)(a2 + 8LL * v2 + 8));
v2 += 2;
break;
case 'E':
case 'e':
peakWindow = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'F':
case 'f':
fastaName = *(_QWORD *)(a2 + v3 + 8);
v2 += 2;
break;
case 'H':
case 'h':
printHelp();
exit(0);
case 'I':
case 'i':
intCutOff = atof(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'K':
case 'k':
lys = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'L':
case 'l':
dataList = parseFileList(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'M':
case 'm':
maxCharge = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'O':
case 'o':
ignoreModSite = 1;
++v2;
break;
case 'P':
case 'p':
ppmCutOff = atof(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'Q':
case 'q':
quantWindow = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'R':
case 'r':
arg = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'S':
case 's':
isotopicStates = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'T':
case 't':
threadCount = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'V':
case 'v':
printf("PepQuant2\n\tcommit: %s\n\tversion: %s\n", commit, gitversion);
exit(0);
case 'W':
case 'w':
fuse = *(_QWORD *)(a2 + v3 + 8);
v2 += 2;
break;
case 'X':
case 'x':
statQuestdir = *(_QWORD *)(a2 + v3 + 8);
statQuestcutoff = atoi(*(const char **)(a2 + v3 + 16));
v2 += 3;
break;
case 'Y':
case 'y':
pepXMLdir = *(_QWORD *)(a2 + v3 + 8);
v2 += 2;
break;
case 'Z':
case 'z':
maxQuant = *(_QWORD *)(a2 + v3 + 8);
v2 += 2;
break;
default:
printUsage();
exit(1);
}
}
while ( v2 < a1 );
}
if ( !fastaName && !maxQuant && !pepXMLdir && (!statQuestdir || !statQuestcutoff) )
{
printUsage();
exit(1);
}
}

canonical_decompiled_code:
void __fastcall func3(int a1, __int64 a2)
{
int v2; // ebx
__int64 v3; // rcx

if ( a1 > 1 )
{
v2 = 1;
do
{
v3 = 8LL * v2;
switch ( *(_BYTE *)(*(_QWORD *)(a2 + v3) + 1LL) )
{
case 'A':
case 'a':
alignWindow = atoi(*(const char **)(a2 + 8LL * v2 + 8));
v2 += 2;
break;
case 'C':
case 'c':
corrCutOff = atof(*(const char **)(a2 + 8LL * v2 + 8));
v2 += 2;
break;
case 'E':
case 'e':
peakWindow = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'F':
case 'f':
fastaName = *(_QWORD *)(a2 + v3 + 8);
v2 += 2;
break;
case 'H':
case 'h':
func1();
exit(0);
case 'I':
case 'i':
intCutOff = atof(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'K':
case 'k':
lys = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'L':
case 'l':
dataList = parseFileList(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'M':
case 'm':
maxCharge = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'O':
case 'o':
ignoreModSite = 1;
++v2;
break;
case 'P':
case 'p':
ppmCutOff = atof(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'Q':
case 'q':
quantWindow = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'R':
case 'r':
arg = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'S':
case 's':
isotopicStates = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'T':
case 't':
threadCount = atoi(*(const char **)(a2 + v3 + 8));
v2 += 2;
break;
case 'V':
case 'v':
printf("PepQuant2\n\tcommit: %s\n\tversion: %s\n", commit, gitversion);
exit(0);
case 'W':
case 'w':
fuse = *(_QWORD *)(a2 + v3 + 8);
v2 += 2;
break;
case 'X':
case 'x':
statQuestdir = *(_QWORD *)(a2 + v3 + 8);
statQuestcutoff = atoi(*(const char **)(a2 + v3 + 16));
v2 += 3;
break;
case 'Y':
case 'y':
pepXMLdir = *(_QWORD *)(a2 + v3 + 8);
v2 += 2;
break;
case 'Z':
case 'z':
maxQuant = *(_QWORD *)(a2 + v3 + 8);
v2 += 2;
break;
default:
func0();
exit(1);
}
}
while ( v2 < a1 );
}
if ( !fastaName && !maxQuant && !pepXMLdir && (!statQuestdir || !statQuestcutoff) )
{
func0();
exit(1);
}
}

original_code:
void parseArgs(int argc, char *argv[]){
 int i = 1;
 while(i < argc){
  switch( (int)argv[i][1]){
   case 'a':
   case 'A':
    alignWindow = atoi(argv[i+1]);
    i+=2;
    break;
   case 'c':
   case 'C':
    corrCutOff = atof(argv[i+1]);
    i+=2;
    break;
   case 'e':
   case 'E':
    peakWindow = atoi(argv[i+1]);
    i+=2;
    break;
   case 'f':
   case 'F':
    fastaName = argv[i+1];
    i+=2;
    break;
   case 'h':
   case 'H':
    printHelp();
    exit(0);
   case 'i':
   case 'I':
    intCutOff = atof(argv[i+1]);
    i+=2;
    break;
   case 'k':
   case 'K':
    lys = atoi(argv[i+1]);
    i+=2;
    break;
   case 'l':
   case 'L':
    dataList = parseFileList(argv[i+1]);
    i+=2;
    break;
   case 'm':
   case 'M':
    maxCharge = atoi(argv[i+1]);
    i+=2;
    break;
   case 'o':
   case 'O':
    ignoreModSite = 1;
    ++i;
    break;
   case 'p':
   case 'P':
    ppmCutOff = atof(argv[i+1]);
    i+=2;
    break;
   case 'q':
   case 'Q':
    quantWindow = atoi(argv[i+1]);
    i+=2;
    break;
   case 'r':
   case 'R':
    arg = atoi(argv[i+1]);
    i+=2;
    break;
   case 's':
   case 'S':
    isotopicStates = atoi(argv[i+1]);
    i+=2;
    break;
   case 't':
   case 'T':
    threadCount = atoi(argv[i+1]);
    i+=2;
    break;
   case 'v':
   case 'V':
    printf("PepQuant2\n\tcommit: %s\n\tversion: %s\n",
      commit, gitversion);
    exit(0);
   case 'w':
   case 'W':
    fuse = argv[i+1];
    i+=2;
    break;
   case 'x':
   case 'X':
    statQuestdir = argv[i+1];
    statQuestcutoff = atoi(argv[i+2]);
    i+=3;
    break;
   case 'y':
   case 'Y':
    pepXMLdir = argv[i+1];
    i+=2;
    break;
   case 'z':
   case 'Z':
    maxQuant = argv[i+1];
    i+=2;
    break;
   default:
    printUsage();
    exit(1);
  }
 }
 if( !fastaName &&
   !(maxQuant || pepXMLdir || (statQuestdir && statQuestcutoff) )
 ){
  printUsage();
  exit(1);
 }
 return;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: i int


repo: alvneiayu/task

decompiled_code:
int __fastcall type_of(int *a1)
{
int result; // eax

result = *a1;
switch ( *a1 )
{
case 0:
result = puts("type_object");
break;
case 1:
result = puts("type_array");
break;
case 2:
result = puts("type_string");
break;
case 3:
result = puts("type_int");
break;
case 4:
result = puts("type_real");
break;
case 7:
result = puts("type_null");
break;
default:
return result;
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(int *a1)
{
int result; // eax

result = *a1;
switch ( *a1 )
{
case 0:
result = puts("type_object");
break;
case 1:
result = puts("type_array");
break;
case 2:
result = puts("type_string");
break;
case 3:
result = puts("type_int");
break;
case 4:
result = puts("type_real");
break;
case 7:
result = puts("type_null");
break;
default:
return result;
}
return result;
}

original_code:
void type_of(json_t *root){
 json_type type = ((root)->type);
 switch (type) {
  case JSON_NULL: printf("type_null\n");
   break;
  case JSON_REAL: printf("type_real\n");
   break;
  case JSON_INTEGER: printf("type_int\n");
   break;
  case JSON_OBJECT: printf("type_object\n");
   break;
  case JSON_ARRAY: printf("type_array\n");
   break;
  case JSON_STRING: printf("type_string\n");
   break;
 }
}

canonical_original_code:
void type_of(struct json_t *root){
 enum json_type type = ((root)->type);
 switch (type) {
  case JSON_NULL: printf("type_null\n");
   break;
  case JSON_REAL: printf("type_real\n");
   break;
  case JSON_INTEGER: printf("type_int\n");
   break;
  case JSON_OBJECT: printf("type_object\n");
   break;
  case JSON_ARRAY: printf("type_array\n");
   break;
  case JSON_STRING: printf("type_string\n");
   break;
 }
}

variable_types: struct json_t { enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 } type; unsigned long refcount; } *

user_defined_types: struct json_t { enum json_type type; unsigned long refcount; }


decompiled_code:
__int64 load_file()
{
__int64 v0; // rbx
unsigned int v2; // [rsp+0h] [rbp-108h]
char v3[172]; // [rsp+5Ch] [rbp-ACh] BYREF

v0 = json_load_file();
if ( !v0 )
printf("Error in the line: %d: %s \n", v2, v3);
return v0;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 v0; // rbx
unsigned int v2; // [rsp+0h] [rbp-108h]
char v3[172]; // [rsp+5Ch] [rbp-ACh] BYREF

v0 = json_load_file();
if ( !v0 )
printf("Error in the line: %d: %s \n", v2, v3);
return v0;
}

original_code:
json_t* load_file(char *url){
 json_t *json;
 json_error_t error;
 json = json_load_file(url, 0, &error);
 if(!json) {
  printf("Error in the line: %d: %s \n",error.line, error.text);
 }
 return json;
}

canonical_original_code:
struct json_t *load_file(char *url){
 struct json_t *json;
 struct json_error_t error;
 json = json_load_file(url, 0, &error);
 if(!json) {
  printf("Error in the line: %d: %s \n",error.line, error.text);
 }
 return json;
}

variable_types:
url
char *

variable_types: struct json_error_t { int line; int column; int position; char source[80]; char text[160]; }

return_type: struct json_t { enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 } type; unsigned long refcount; } *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int *v3; // r14
const char *i; // rbx
int j; // er12
const char *k; // rbx
const char *v8; // rax
int *v9; // r13

v3 = (int *)load_file("file.json", argv, envp);
printf("Type of the root: ");
type_of(v3);
json_object_iter();
for ( i = (const char *)json_object_iter_key(); i; i = (const char *)json_object_iter_key() )
{
json_object_key_to_iter();
v9 = (int *)json_object_iter_value();
if ( !v9 )
break;
puts("Root's key");
printf("\t-%s\n", i);
printf("Type of Value: ");
type_of(v9);
puts("Values:");
for ( j = 0; (int)json_array_size() > j; ++j )
{
json_array_get();
json_object_iter();
for ( k = (const char *)json_object_iter_key(); k; k = (const char *)json_object_iter_key() )
{
json_object_key_to_iter();
if ( !json_object_iter_value() )
break;
v8 = (const char *)json_string_value();
printf("\t%s : %s\n", k, v8);
json_object_key_to_iter();
json_object_iter_next();
}
}
json_object_key_to_iter();
json_object_iter_next();
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int *v3; // r14
const char *i; // rbx
int j; // er12
const char *k; // rbx
const char *v8; // rax
int *v9; // r13

v3 = (int *)func8("file.json", argv, envp);
printf("Type of the root: ");
func7(v3);
json_object_iter();
for ( i = (const char *)json_object_iter_key(); i; i = (const char *)json_object_iter_key() )
{
json_object_key_to_iter();
v9 = (int *)json_object_iter_value();
if ( !v9 )
break;
puts("Root's key");
printf("\t-%s\n", i);
printf("Type of Value: ");
func7(v9);
puts("Values:");
for ( j = 0; (int)json_array_size() > j; ++j )
{
json_array_get();
json_object_iter();
for ( k = (const char *)json_object_iter_key(); k; k = (const char *)json_object_iter_key() )
{
json_object_key_to_iter();
if ( !json_object_iter_value() )
break;
v8 = (const char *)json_string_value();
printf("\t%s : %s\n", k, v8);
json_object_key_to_iter();
json_object_iter_next();
}
}
json_object_key_to_iter();
json_object_iter_next();
}
return 0;
}

original_code:
int main(void) {
 json_t *root;
 const char *key;
 json_t *value;
 json_t *value2;
 root = load_file("file.json");
 printf("Type of the root: ");
 type_of(root);
 for(key = json_object_iter_key(json_object_iter(root)); key && (value = json_object_iter_value(json_object_key_to_iter(key))); key = json_object_iter_key(json_object_iter_next(root, json_object_key_to_iter(key)))) {
  printf("Root's key\n");
  printf("	-%s\n",key);
  printf("Type of Value: ");
  type_of(value);
  json_t* temp;
  printf("Values:\n");
  for(int i = 0; i<(int)json_array_size(value); i++){
   temp = json_array_get(value,(size_t)i);
   for(key = json_object_iter_key(json_object_iter(temp)); key && (value2 = json_object_iter_value(json_object_key_to_iter(key))); key = json_object_iter_key(json_object_iter_next(temp, json_object_key_to_iter(key)))) {
    printf("	%s : %s\n",key,json_string_value(value2));
   }
  }
 }
}

canonical_original_code:
int main() {
 struct json_t *root;
 char *key;
 struct json_t *value;
 struct json_t *value2;
 root = load_file("file.json");
 printf("Type of the root: ");
 type_of(root);
 for(key = json_object_iter_key(json_object_iter(root)); key && (value = json_object_iter_value(json_object_key_to_iter(key))); key = json_object_iter_key(json_object_iter_next(root, json_object_key_to_iter(key)))) {
  printf("Root's key\n");
  printf("	-%s\n",key);
  printf("Type of Value: ");
  type_of(value);
  struct json_t *temp;
  printf("Values:\n");
  for(int i = 0; i<(int)json_array_size(value); i++){
   temp = json_array_get(value,(unsigned long)i);
   for(key = json_object_iter_key(json_object_iter(temp)); key && (value2 = json_object_iter_value(json_object_key_to_iter(key))); key = json_object_iter_key(json_object_iter_next(temp, json_object_key_to_iter(key)))) {
    printf("	%s : %s\n",key,json_string_value(value2));
   }
  }
 }
}

variable_types:
key
char *

user_defined_types: enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 }


cmpName

decompiled_code:
int __fastcall cmpName(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

canonical_decompiled_code:
int __fastcall func7(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code:
int cmpName(const void *a, const void *b){
  struct EnvVar *p, *q;
  p = (struct EnvVar *)a;
  q = (struct EnvVar *)b;
  return strcmp(p->name,q->name);
}

canonical_original_code:
int cmpName(void *a, void *b){
  struct EnvVar *p; struct EnvVar *q;
  p = (struct EnvVar *)a;
  q = (struct EnvVar *)b;
  return strcmp(p->name,q->name);
}

variable_types:
p
struct EnvVar { char *name; } *

variable_types:
q
struct EnvVar { char *name; } *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // r13
const char *v5; // rbp
void **v6; // r12
size_t v7; // rbx
int v8; // er14
char *v9; // rbp
size_t v10; // rax
char *v11; // rdi
char *v12; // rbp
size_t v13; // rax
char *v14; // rdi
__int64 v15; // rbx
__int64 v16; // rbx
void *ptr[135]; // [rsp+0h] [rbp-438h] BYREF

v3 = (char *)malloc(0x400uLL);
if ( !v3 )
{
perror("scratch");
exit(1);
}
v4 = v3;
v5 = *(const char **)_bss_start;
v6 = ptr;
v7 = 1LL;
if ( *(_QWORD *)_bss_start )
{
while ( 1 )
{
v8 = v7 - 1;
if ( strlen(v5) + 1 > 0x400 )
{
puts("env var too long");
return 1;
}
strcpy(v4, v5);
v9 = strtok(v4, "=");
v10 = strlen(v9);
v11 = (char *)malloc(v10 + 1);
*v6 = v11;
if ( !v11 )
{
perror("myEnvVar[i].name");
exit(1);
}
strcpy(v11, v9);
v12 = strtok(0LL, " ");
v13 = strlen(v12);
v14 = (char *)malloc(v13 + 1);
v6[1] = v14;
if ( !v14 )
{
perror("myEnvVar[i].value");
exit(1);
}
strcpy(v14, v12);
v5 = *(const char **)(_bss_start + 8 * v7);
v6 += 2;
if ( !v5 )
break;
++v7;
}
printf("%d env variables\n\n", (unsigned int)v7);
if ( (int)v7 <= 0 )
goto LABEL_4;
do
{
printf("%s\t%s\n", (const char *)ptr[2 * (_QWORD)v5], (const char *)ptr[2 * (_QWORD)v5 + 1]);
++v5;
}
while ( (int)v5 - 1 < v8 );
puts("\n\nSorted by name");
qsort(ptr, v7, 0x10uLL, cmpName);
v15 = 0LL;
do
{
printf("%s\t%s\n", (const char *)ptr[2 * v15], (const char *)ptr[2 * v15 + 1]);
++v15;
}
while ( (int)v15 - 1 < v8 );
v16 = 0LL;
do
{
free(ptr[2 * v16]);
free(ptr[2 * v16++ + 1]);
}
while ( (int)v16 - 1 < v8 );
}
else
{
printf("%d env variables\n\n", 0LL);
v7 = 0LL;
LABEL_4:
puts("\n\nSorted by name");
qsort(ptr, v7, 0x10uLL, cmpName);
}
free(v4);
return 0;
}

original_code:
int main(int argc, char *argv[]){
  int i, numEnvVar;
  char *ptr, *scratch;
  struct EnvVar myEnvVar[64];
  scratch = (char*)malloc(sizeof(char)*1024);
  if (scratch == ((void *)0)){
    perror("scratch");
    exit(1);
  }
  i = 0;
  while (environ[i] != ((void *)0)){
    if (strlen(environ[i])+1 > 1024){
      printf("env var too long\n");
      return 1;
    }
    strcpy(scratch,environ[i]);
    ptr = strtok(scratch,"=");
    myEnvVar[i].name = (char*)malloc(sizeof(char)*(strlen(ptr)+1));
    if (myEnvVar[i].name == ((void *)0)){
      perror("myEnvVar[i].name");
      exit(1);
    }
    strcpy(myEnvVar[i].name,ptr);
    ptr = strtok(((void *)0)," ");
    myEnvVar[i].value = (char*)malloc(sizeof(char)*(strlen(ptr)+1));
    if (myEnvVar[i].value == ((void *)0)){
      perror("myEnvVar[i].value");
      exit(1);
    }
    strcpy(myEnvVar[i].value,ptr);
    i++;
  }
  numEnvVar = i;
  printf("%d env variables\n\n",numEnvVar);
  for(i=0;i<numEnvVar;i++){
    printf("%s\t%s\n",myEnvVar[i].name,myEnvVar[i].value);
  }
  printf("\n\nSorted by name\n");
  qsort((void *)myEnvVar,numEnvVar,sizeof(struct EnvVar),cmpName);
  for(i=0;i<numEnvVar;i++){
    printf("%s\t%s\n",myEnvVar[i].name,myEnvVar[i].value);
  }
  for(i=0;i<numEnvVar;i++){
    free(myEnvVar[i].name);
    free(myEnvVar[i].value);
  }
  free(scratch);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
  int i; int numEnvVar;
  char *ptr; char *scratch;
  struct EnvVar myEnvVar[64];
  scratch = (char *)malloc(sizeof(char)*1024);
  if (scratch == ((void *)0)){
    perror("scratch");
    exit(1);
  }
  i = 0;
  while (environ[i] != ((void *)0)){
    if (strlen(environ[i])+1 > 1024){
      printf("env var too long\n");
      return 1;
    }
    strcpy(scratch,environ[i]);
    ptr = strtok(scratch,"=");
    myEnvVar[i].name = (char *)malloc(sizeof(char)*(strlen(ptr)+1));
    if (myEnvVar[i].name == ((void *)0)){
      perror("myEnvVar[i].name");
      exit(1);
    }
    strcpy(myEnvVar[i].name,ptr);
    ptr = strtok(((void *)0)," ");
    myEnvVar[i].value = (char *)malloc(sizeof(char)*(strlen(ptr)+1));
    if (myEnvVar[i].value == ((void *)0)){
      perror("myEnvVar[i].value");
      exit(1);
    }
    strcpy(myEnvVar[i].value,ptr);
    i++;
  }
  numEnvVar = i;
  printf("%d env variables\n\n",numEnvVar);
  for(i=0;i<numEnvVar;i++){
    printf("%s\t%s\n",myEnvVar[i].name,myEnvVar[i].value);
  }
  printf("\n\nSorted by name\n");
  qsort((void *)myEnvVar,numEnvVar,sizeof(struct EnvVar),cmpName);
  for(i=0;i<numEnvVar;i++){
    printf("%s\t%s\n",myEnvVar[i].name,myEnvVar[i].value);
  }
  for(i=0;i<numEnvVar;i++){
    free(myEnvVar[i].name);
    free(myEnvVar[i].value);
  }
  free(scratch);
  return 0;
}

variable_types: numEnvVar int

variable_types:
ptr
char *

variable_types:
scratch
char *

variable_types:
myEnvVar
struct EnvVar { char *name; } [64]


decompiled_code:
size_t __fastcall show_string(char *s)
{
printf("%s", s);
return strlen(s);
}

canonical_decompiled_code:
size_t __fastcall func0(char *s)
{
printf("%s", s);
return strlen(s);
}

original_code:
int show_string(const char *str) {
  printf("%s", str);
  return strlen(str);
  }

canonical_original_code:
int show_string(char *str) {
  printf("%s", str);
  return strlen(str);
  }

variable_types:
str
char *


bubbleSortHelper

decompiled_code:
__int64 __fastcall bubbleSortHelper(int a1, __int64 a2, unsigned int a3)
{
char *v3; // r8
char v4; // si
char v5; // cl
__int64 result; // rax

v3 = (char *)(a2 + a1);
v4 = *v3;
v5 = v3[1];
result = a3;
if ( v5 > *v3 )
{
v4 = v3[1];
v5 = *v3;
result = 1LL;
}
*v3 = v4;
v3[1] = v5;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, __int64 a2, unsigned int a3)
{
char *v3; // r8
char v4; // si
char v5; // cl
__int64 result; // rax

v3 = (char *)(a2 + a1);
v4 = *v3;
v5 = v3[1];
result = a3;
if ( v5 > *v3 )
{
v4 = v3[1];
v5 = *v3;
result = 1LL;
}
*v3 = v4;
v3[1] = v5;
return result;
}

original_code:
int bubbleSortHelper(int i, char * list, int swapped) {
 char *var1 = &list[i];
 char *var2 = &list[i+1];
 __asm__(
  "cmpb %3, %4\n\t"
  "jle noswap\n\t"
  "xchgb %0, %1\n\t"
  "movl $1, %2\n\t"
  "noswap:\n\t"
  :"=r" (*var1), "=r" (*var2), "=r" (swapped)
  :"0" (*var1), "1" (*var2), "2" (swapped)
 );
 return swapped;
}

canonical_original_code:
int bubbleSortHelper(int i, char *list, int swapped) {
 char *var1 = &list[i];
 char *var2 = &list[i+1];
 __asm__(
  "cmpb %3, %4\n\t"
  "jle noswap\n\t"
  "xchgb %0, %1\n\t"
  "movl $1, %2\n\t"
  "noswap:\n\t"
  :"=r" (*var1), "=r" (*var2), "=r" (swapped)
  :"0" (*var1), "1" (*var2), "2" (swapped)
 );
 return swapped;
}

variable_types:
list
char *

variable_types: swapped int


bubbleSort

decompiled_code:
__int64 __fastcall bubbleSort(__int64 a1, int a2)
{
int v2; // er13
unsigned int v3; // edx
unsigned int v4; // eax
int v5; // er13
unsigned int v6; // eax

while ( a2 > 1 )
{
v2 = 0;
v3 = 0;
do
{
v4 = bubbleSortHelper(v2, a1, v3);
v3 = v4;
++v2;
}
while ( a2 - 1 != v2 );
if ( !v4 )
break;
v5 = a2 - 2;
if ( a2 - 2 >= 0 )
{
do
{
v6 = bubbleSortHelper(v5, a1, v3);
v3 = v6;
--v5;
}
while ( v5 != -1 );
if ( !v6 )
break;
}
}
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
int v2; // er13
unsigned int v3; // edx
unsigned int v4; // eax
int v5; // er13
unsigned int v6; // eax

while ( a2 > 1 )
{
v2 = 0;
v3 = 0;
do
{
v4 = func8(v2, a1, v3);
v3 = v4;
++v2;
}
while ( a2 - 1 != v2 );
if ( !v4 )
break;
v5 = a2 - 2;
if ( a2 - 2 >= 0 )
{
do
{
v6 = func8(v5, a1, v3);
v3 = v6;
--v5;
}
while ( v5 != -1 );
if ( !v6 )
break;
}
}
return a1;
}

original_code:
char* bubbleSort(char * list, int size) {
 int swapped = 0;
 do {
  swapped = 0;
  int i;
  for(i = 0; i <= size-2; ++i) {
   swapped = bubbleSortHelper(i, list, swapped);
  }
  if(!swapped) break;
  for(i = size-2; i >= 0; --i) {
   swapped = bubbleSortHelper(i, list, swapped);
  }
 } while(swapped);
 return list;
}

canonical_original_code:
char *bubbleSort(char *list, int size) {
 int swapped = 0;
 do {
  swapped = 0;
  int i;
  for(i = 0; i <= size-2; ++i) {
   swapped = bubbleSortHelper(i, list, swapped);
  }
  if(!swapped) break;
  for(i = size-2; i >= 0; --i) {
   swapped = bubbleSortHelper(i, list, swapped);
  }
 } while(swapped);
 return list;
}

variable_types: size int


getListSize

decompiled_code:
__int64 getListSize()
{
return (unsigned int)listSize;
}

canonical_decompiled_code:
__int64 func10()
{
return (unsigned int)listSize;
}

original_code:
int getListSize() {
 return listSize;
}

canonical_original_code:
int getListSize() {
 return listSize;
}


radian

decompiled_code:
double __fastcall radian(double a1)
{
return a1 * 3.141592653589793 / 180.0;
}

original_code:
double radian( double number )
{
 return number*3.14159265358979323846/180;
}

canonical_original_code:
double radian(double number)
{
 return number*3.14159265358979323846/180;
}

variable_types: number double


degree

decompiled_code:
double __fastcall degree(double a1)
{
return a1 * 180.0 / 3.141592653589793;
}

original_code:
double degree( double number )
{
 return number*180/3.14159265358979323846;
}

canonical_original_code:
double degree(double number)
{
 return number*180/3.14159265358979323846;
}


decompiled_code:
int __fastcall diseqc_send_msg(int fd, __int64 a2, int a3)
{
__int64 v4; // [rsp+8h] [rbp-10h] BYREF

v4 = a2;
if ( a3 )
printf(
"DiSEqC: %02x %02x %02x %02x %02x %02x length: %d\n",
(unsigned __int8)v4,
BYTE1(v4),
BYTE2(v4),
BYTE3(v4),
BYTE4(v4),
BYTE5(v4),
BYTE6(v4));
if ( ioctl(fd, 0x40076F3FuLL, &v4) == -1 )
puts("FE_DISEQC_SEND_MASTER_CMD ERROR! ");
return usleep(0x4E20u);
}

canonical_decompiled_code:
int __fastcall func2(int fd, __int64 a2, int a3)
{
__int64 v4; // [rsp+8h] [rbp-10h] BYREF

v4 = a2;
if ( a3 )
printf(
"DiSEqC: %02x %02x %02x %02x %02x %02x length: %d\n",
(unsigned __int8)v4,
BYTE1(v4),
BYTE2(v4),
BYTE3(v4),
BYTE4(v4),
BYTE5(v4),
BYTE6(v4));
if ( ioctl(fd, 0x40076F3FuLL, &v4) == -1 )
puts("FE_DISEQC_SEND_MASTER_CMD ERROR! ");
return usleep(0x4E20u);
}

original_code:
void diseqc_send_msg(int fefd, struct dvb_diseqc_master_cmd cmd, unsigned int verbose)
{
 if (verbose) {
  printf("DiSEqC: %02x %02x %02x %02x %02x %02x length: %d\n",
   cmd.msg[0], cmd.msg[1],
   cmd.msg[2], cmd.msg[3],
   cmd.msg[4], cmd.msg[5], cmd.msg_len);
 }
 if (ioctl(fefd, (((1U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((63)) << 0) | ((((sizeof(struct dvb_diseqc_master_cmd)))) << ((0 +8)+8))), &cmd) == -1)
  printf("FE_DISEQC_SEND_MASTER_CMD ERROR! \n");
 usleep(20000);
}

variable_types: fefd int

variable_types: struct dvb_diseqc_master_cmd { unsigned char msg[6]; unsigned char msg_len; }

variable_types:
verbose
unsigned int


decompiled_code:
unsigned int __fastcall motor_usals(int fd, int a2, unsigned int a3, double a4, double a5, double a6)
{
double v6; // r13
double v7; // rbx
double v8; // r14
double v9; // xmm0_8
double v10; // xmm0_8
double v11; // xmm0_8
double v12; // rbx
int v13; // er12
int v14; // eax
unsigned int v15; // ebp
double v16; // r14
double v17; // r13
double v18; // xmm0_8
double v20; // [rsp+8h] [rbp-70h]
double v21; // [rsp+10h] [rbp-68h]
double cosx; // [rsp+20h] [rbp-58h] BYREF
double sinx[2]; // [rsp+28h] [rbp-50h] BYREF
unsigned __int16 v25; // [rsp+39h] [rbp-3Fh]
unsigned __int8 v26; // [rsp+3Bh] [rbp-3Dh]
unsigned __int8 v27; // [rsp+3Ch] [rbp-3Ch]
unsigned __int8 v28; // [rsp+3Dh] [rbp-3Bh]
unsigned __int8 v29; // [rsp+3Eh] [rbp-3Ah]
unsigned __int8 v30; // [rsp+3Fh] [rbp-39h]

if ( ioctl(fd, 0x6F42uLL, 1LL) == -1 )
puts("FE_SET_TONE ERROR! ");
usleep(0x4E20u);
if ( ioctl(fd, 0x6F43uLL, 1LL) == -1 )
puts("FE_SET_VOLTAGE ERROR! ");
usleep(0x4E20u);
v6 = radian(a4);
sincos(v6, sinx, &cosx);
v7 = cosx;
v20 = radian(a5);
v8 = radian(a6);
v9 = atan(6378.14 * sinx[0] / ((1.0 - v7) * 6378.14 + 35786.43));
v21 = degree(v9);
sincos(v20 - v8, sinx, &cosx);
v10 = atan(42164.57 * sinx[0] / (42164.57 * cosx - v7 * 6378.14));
v11 = degree(v10);
v12 = v11;
v13 = (int)(COERCE_DOUBLE(*(_QWORD *)&v11 & LC10) * 16.0 + 0.5);
v14 = 224;
if ( v11 > 0.0 )
v14 = 208;
v15 = v14 | (v13 >> 8);
v16 = degree(v8);
v17 = degree(v6);
v18 = degree(v20);
printf(
"Long: %.2f, Lat: %.2f, Orbital Pos: %.2f, RotorCmd: %02x %02x, motor_angle: %.2f declination: %.2f\n",
v18,
v17,
v16,
v15,
(unsigned __int8)v13,
v12,
v21);
v25 = 12768;
v26 = 110;
v27 = v15;
v28 = v13;
v29 = 0;
v30 = 5;
sleep(1u);
diseqc_send_msg(
fd,
((unsigned __int64)v29 << 40) | ((unsigned __int64)v27 << 24) | v25 | ((unsigned __int64)v26 << 16) | ((unsigned __int64)v28 << 32) | ((unsigned __int64)v30 << 48),
a2);
printf("Waiting %d seconds for motor to move\n", a3);
return sleep(a3);
}

canonical_decompiled_code:
unsigned int __fastcall func3(int fd, int a2, unsigned int a3, double a4, double a5, double a6)
{
double v6; // r13
double v7; // rbx
double v8; // r14
double v9; // xmm0_8
double v10; // xmm0_8
double v11; // xmm0_8
double v12; // rbx
int v13; // er12
int v14; // eax
unsigned int v15; // ebp
double v16; // r14
double v17; // r13
double v18; // xmm0_8
double v20; // [rsp+8h] [rbp-70h]
double v21; // [rsp+10h] [rbp-68h]
double cosx; // [rsp+20h] [rbp-58h] BYREF
double sinx[2]; // [rsp+28h] [rbp-50h] BYREF
unsigned __int16 v25; // [rsp+39h] [rbp-3Fh]
unsigned __int8 v26; // [rsp+3Bh] [rbp-3Dh]
unsigned __int8 v27; // [rsp+3Ch] [rbp-3Ch]
unsigned __int8 v28; // [rsp+3Dh] [rbp-3Bh]
unsigned __int8 v29; // [rsp+3Eh] [rbp-3Ah]
unsigned __int8 v30; // [rsp+3Fh] [rbp-39h]

if ( ioctl(fd, 0x6F42uLL, 1LL) == -1 )
puts("FE_SET_TONE ERROR! ");
usleep(0x4E20u);
if ( ioctl(fd, 0x6F43uLL, 1LL) == -1 )
puts("FE_SET_VOLTAGE ERROR! ");
usleep(0x4E20u);
v6 = func0(a4);
sincos(v6, sinx, &cosx);
v7 = cosx;
v20 = func0(a5);
v8 = func0(a6);
v9 = atan(6378.14 * sinx[0] / ((1.0 - v7) * 6378.14 + 35786.43));
v21 = func1(v9);
sincos(v20 - v8, sinx, &cosx);
v10 = atan(42164.57 * sinx[0] / (42164.57 * cosx - v7 * 6378.14));
v11 = func1(v10);
v12 = v11;
v13 = (int)(COERCE_DOUBLE(*(_QWORD *)&v11 & LC10) * 16.0 + 0.5);
v14 = 224;
if ( v11 > 0.0 )
v14 = 208;
v15 = v14 | (v13 >> 8);
v16 = func1(v8);
v17 = func1(v6);
v18 = func1(v20);
printf(
"Long: %.2f, Lat: %.2f, Orbital Pos: %.2f, RotorCmd: %02x %02x, motor_angle: %.2f declination: %.2f\n",
v18,
v17,
v16,
v15,
(unsigned __int8)v13,
v12,
v21);
v25 = 12768;
v26 = 110;
v27 = v15;
v28 = v13;
v29 = 0;
v30 = 5;
sleep(1u);
func2(
fd,
((unsigned __int64)v29 << 40) | ((unsigned __int64)v27 << 24) | v25 | ((unsigned __int64)v26 << 16) | ((unsigned __int64)v28 << 32) | ((unsigned __int64)v30 << 48),
a2);
printf("Waiting %d seconds for motor to move\n", a3);
return sleep(a3);
}

original_code:
void motor_usals(int fefd, double site_lat, double site_long, double sat_long,
 unsigned int verbose, int motor_wait_time)
{
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((66)) << 0) | ((0) << ((0 +8)+8))), SEC_TONE_OFF) == -1)
  printf("FE_SET_TONE ERROR! \n");
 usleep(20000);
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((67)) << 0) | ((0) << ((0 +8)+8))), SEC_VOLTAGE_18) == -1)
  printf("FE_SET_VOLTAGE ERROR! \n");
 usleep(20000);
 double r_eq = 6378.14;
 double r_sat = 42164.57;
 site_lat = radian(site_lat);
 site_long = radian(site_long);
 sat_long = radian(sat_long);
 double declination = degree( atan( r_eq * sin(site_lat) / ( (r_sat - r_eq) + (r_eq * (1 - cos(site_lat))) ) ) );
 double dishVector[3] = { r_eq * cos(site_lat), 0, r_eq * sin(site_lat) };
 double satVector[3] = { r_sat * cos(site_long - sat_long), r_sat * sin(site_long - sat_long), 0 };
 double satPointing[3] = { satVector[0] - dishVector[0], satVector[1] - dishVector[1], satVector[2] - dishVector[2] } ;
 double motor_angle = degree( atan( satPointing[1]/satPointing[0] ) );
 int sixteenths = fabs(motor_angle) * 16.0 + 0.5;
 int angle_1, angle_2;
 angle_1 = motor_angle > 0.0 ? 0xd0 : 0xe0;
 angle_1 |= sixteenths >> 8;
 angle_2 = sixteenths & 0xff;
 printf("Long: %.2f, Lat: %.2f, Orbital Pos: %.2f, RotorCmd: %02x %02x, motor_angle: %.2f declination: %.2f\n", degree(site_long), degree(site_lat), degree(sat_long), angle_1, angle_2, motor_angle, declination);
 struct dvb_diseqc_master_cmd usals_cmd = { { 0xe0, 0x31, 0x6e, angle_1, angle_2, 0x00 }, 5 };
 sleep(1);
 diseqc_send_msg(fefd, usals_cmd, verbose);
 printf("Waiting %d seconds for motor to move\n", motor_wait_time);
 sleep(motor_wait_time);
}

canonical_original_code:
void motor_usals(int fefd, double site_lat, double site_long, double sat_long, unsigned int verbose, int motor_wait_time)
{
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((66)) << 0) | ((0) << ((0 +8)+8))), SEC_TONE_OFF) == -1)
  printf("FE_SET_TONE ERROR! \n");
 usleep(20000);
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((67)) << 0) | ((0) << ((0 +8)+8))), SEC_VOLTAGE_18) == -1)
  printf("FE_SET_VOLTAGE ERROR! \n");
 usleep(20000);
 double r_eq = 6378.14;
 double r_sat = 42164.57;
 site_lat = radian(site_lat);
 site_long = radian(site_long);
 sat_long = radian(sat_long);
 double declination = degree( atan( r_eq * sin(site_lat) / ( (r_sat - r_eq) + (r_eq * (1 - cos(site_lat))) ) ) );
 double dishVector[3] = { r_eq * cos(site_lat), 0, r_eq * sin(site_lat) };
 double satVector[3] = { r_sat * cos(site_long - sat_long), r_sat * sin(site_long - sat_long), 0 };
 double satPointing[3] = { satVector[0] - dishVector[0], satVector[1] - dishVector[1], satVector[2] - dishVector[2] };
 double motor_angle = degree( atan( satPointing[1]/satPointing[0] ) );
 int sixteenths = fabs(motor_angle) * 16.0 + 0.5;
 int angle_1; int angle_2;
 angle_1 = motor_angle > 0.0 ? 0xd0 : 0xe0;
 angle_1 |= sixteenths >> 8;
 angle_2 = sixteenths & 0xff;
 printf("Long: %.2f, Lat: %.2f, Orbital Pos: %.2f, RotorCmd: %02x %02x, motor_angle: %.2f declination: %.2f\n", degree(site_long), degree(site_lat), degree(sat_long), angle_1, angle_2, motor_angle, declination);
 struct dvb_diseqc_master_cmd usals_cmd = { { 0xe0, 0x31, 0x6e, angle_1, angle_2, 0x00 }, 5 };
 sleep(1);
 diseqc_send_msg(fefd, usals_cmd, verbose);
 printf("Waiting %d seconds for motor to move\n", motor_wait_time);
 sleep(motor_wait_time);
}

variable_types: declination double

variable_types:
dishVector
double [3]

variable_types:
satVector
double [3]

variable_types:
satPointing
double [3]

variable_types: sixteenths int

user_defined_types: struct dvb_diseqc_master_cmd { unsigned char msg[6]; unsigned char msg_len; }


decompiled_code:
int __fastcall motor_dir(int a1, int a2, int a3)
{
__int64 v3; // rax

v3 = 7LL * a2;
diseqc_send_msg(
a1,
((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 5] << 40) | ((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 3] << 24) | *(unsigned __int16 *)&dir_cmd[v3] | ((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 2] << 16) | ((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 4] << 32) | ((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 6] << 48),
a3);
return usleep(0x4E20u);
}

canonical_decompiled_code:
int __fastcall func4(int a1, int a2, int a3)
{
__int64 v3; // rax

v3 = 7LL * a2;
func2(
a1,
((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 5] << 40) | ((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 3] << 24) | *(unsigned __int16 *)&dir_cmd[v3] | ((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 2] << 16) | ((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 4] << 32) | ((unsigned __int64)(unsigned __int8)dir_cmd[v3 + 6] << 48),
a3);
return usleep(0x4E20u);
}

original_code:
void motor_dir(int fefd, int dir, unsigned int verbose)
{
 diseqc_send_msg(fefd, dir_cmd[dir], verbose);
 usleep(20000);
}

variable_types: dir int


decompiled_code:
int __fastcall setup_switch(int fd, unsigned int a2, unsigned int a3, int a4, int a5, int a6)
{
__int64 v11; // r12
__int64 v12; // rbp

if ( ioctl(fd, 0x6F42uLL, 1LL) == -1 )
puts("FE_SET_TONE ERROR! ");
usleep(0x4E20u);
if ( ioctl(fd, 0x6F43uLL, a2) == -1 )
puts("FE_SET_VOLTAGE ERROR! ");
usleep(0x4E20u);
if ( a5 )
{
v11 = a5 - 1;
diseqc_send_msg(
fd,
((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 5] << 40) | ((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 3] << 24) | *(unsigned __int16 *)&uncommitted_switch_cmds[7 * v11] | ((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 2] << 16) | ((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 4] << 32) | ((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 6] << 48),
a6);
}
if ( a4 )
{
v12 = a4 - 1;
diseqc_send_msg(
fd,
((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 5] << 40) | ((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 3] << 24) | *(unsigned __int16 *)&committed_switch_cmds[7 * v12] | ((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 2] << 16) | ((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 4] << 32) | ((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 6] << 48),
a6);
}
if ( ioctl(fd, 0x6F42uLL, a3) == -1 )
puts("FE_SET_TONE ERROR! ");
return usleep(0x4E20u);
}

canonical_decompiled_code:
int __fastcall func5(int fd, unsigned int a2, unsigned int a3, int a4, int a5, int a6)
{
__int64 v11; // r12
__int64 v12; // rbp

if ( ioctl(fd, 0x6F42uLL, 1LL) == -1 )
puts("FE_SET_TONE ERROR! ");
usleep(0x4E20u);
if ( ioctl(fd, 0x6F43uLL, a2) == -1 )
puts("FE_SET_VOLTAGE ERROR! ");
usleep(0x4E20u);
if ( a5 )
{
v11 = a5 - 1;
func2(
fd,
((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 5] << 40) | ((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 3] << 24) | *(unsigned __int16 *)&uncommitted_switch_cmds[7 * v11] | ((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 2] << 16) | ((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 4] << 32) | ((unsigned __int64)(unsigned __int8)uncommitted_switch_cmds[7 * v11 + 6] << 48),
a6);
}
if ( a4 )
{
v12 = a4 - 1;
func2(
fd,
((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 5] << 40) | ((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 3] << 24) | *(unsigned __int16 *)&committed_switch_cmds[7 * v12] | ((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 2] << 16) | ((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 4] << 32) | ((unsigned __int64)(unsigned __int8)committed_switch_cmds[7 * v12 + 6] << 48),
a6);
}
if ( ioctl(fd, 0x6F42uLL, a3) == -1 )
puts("FE_SET_TONE ERROR! ");
return usleep(0x4E20u);
}

original_code:
void setup_switch (int fefd, fe_sec_voltage_t voltage, fe_sec_tone_mode_t tone,
 int committed, int uncommitted, unsigned int verbose)
{
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((66)) << 0) | ((0) << ((0 +8)+8))), SEC_TONE_OFF) == -1)
  printf("FE_SET_TONE ERROR! \n");
 usleep(20000);
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((67)) << 0) | ((0) << ((0 +8)+8))), voltage) == -1)
  printf("FE_SET_VOLTAGE ERROR! \n");
 usleep(20000);
 if (uncommitted)
  diseqc_send_msg(fefd, uncommitted_switch_cmds[uncommitted-1], verbose);
 if (committed)
  diseqc_send_msg(fefd, committed_switch_cmds[committed-1], verbose);
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((66)) << 0) | ((0) << ((0 +8)+8))), tone) == -1)
  printf("FE_SET_TONE ERROR! \n");
 usleep(20000);
}

canonical_original_code:
void setup_switch(int fefd, enum fe_sec_voltage voltage, enum fe_sec_tone_mode tone, int committed, int uncommitted, unsigned int verbose)
{
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((66)) << 0) | ((0) << ((0 +8)+8))), SEC_TONE_OFF) == -1)
  printf("FE_SET_TONE ERROR! \n");
 usleep(20000);
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((67)) << 0) | ((0) << ((0 +8)+8))), voltage) == -1)
  printf("FE_SET_VOLTAGE ERROR! \n");
 usleep(20000);
 if (uncommitted)
  diseqc_send_msg(fefd, uncommitted_switch_cmds[uncommitted-1], verbose);
 if (committed)
  diseqc_send_msg(fefd, committed_switch_cmds[committed-1], verbose);
 if (ioctl(fefd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((66)) << 0) | ((0) << ((0 +8)+8))), tone) == -1)
  printf("FE_SET_TONE ERROR! \n");
 usleep(20000);
}

variable_types: enum fe_sec_voltage { SEC_VOLTAGE_13=0, SEC_VOLTAGE_18=1, SEC_VOLTAGE_OFF=2 }

variable_types: enum fe_sec_tone_mode { SEC_TONE_ON=0, SEC_TONE_OFF=1 }

variable_types: committed int

variable_types: uncommitted int


main

original_code:
int main(int argc, char **argv)
{
 NSGA2Type nsga2Params;
 void *inp = ((void *)0);
 void *out = ((void *)0);
 nsga2Params = ReadParameters(argc, argv);
 InitNSGA2(&nsga2Params, inp, out);
 NSGA2(&nsga2Params, inp, out);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct NSGA2Type nsga2Params;
 void *inp = ((void *)0);
 void *out = ((void *)0);
 nsga2Params = ReadParameters(argc, argv);
 InitNSGA2(&nsga2Params, inp, out);
 NSGA2(&nsga2Params, inp, out);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct NSGA2Type { double seed; int nreal; int nbin; int nobj; int ncon; int popsize; double pcross_real; double pcross_bin; double pmut_real; double pmut_bin; double eta_c; double eta_m; int ngen; int nbinmut; int nrealmut; int nbincross; int nrealcross; int *nbits; double *min_realvar; double *max_realvar; double *min_binvar; double *max_binvar; int bitlength; int choice; int obj1; int obj2; int obj3; int angle1; int angle2; }

variable_types:
inp
void *

variable_types:
out
void *


decompiled_code:
double *advance_random()
{
double *v0; // rax
double v1; // xmm0_8
double *result; // rax
double v3; // xmm0_8

v0 = (double *)&oldrand;
do
{
v1 = *v0 - v0[31];
if ( v1 < 0.0 )
v1 = v1 + 1.0;
*v0++ = v1;
}
while ( v0 != (double *)(unsigned int)((_DWORD)&oldrand + 192) );
result = (double *)(unsigned int)((_DWORD)&oldrand + 192);
do
{
v3 = *result - *(result - 24);
if ( v3 < 0.0 )
v3 = v3 + 1.0;
*result++ = v3;
}
while ( result != (double *)(unsigned int)((_DWORD)&oldrand + 440) );
return result;
}

canonical_decompiled_code:
double *func0()
{
double *v0; // rax
double v1; // xmm0_8
double *result; // rax
double v3; // xmm0_8

v0 = (double *)&oldrand;
do
{
v1 = *v0 - v0[31];
if ( v1 < 0.0 )
v1 = v1 + 1.0;
*v0++ = v1;
}
while ( v0 != (double *)(unsigned int)((_DWORD)&oldrand + 192) );
result = (double *)(unsigned int)((_DWORD)&oldrand + 192);
do
{
v3 = *result - *(result - 24);
if ( v3 < 0.0 )
v3 = v3 + 1.0;
*result++ = v3;
}
while ( result != (double *)(unsigned int)((_DWORD)&oldrand + 440) );
return result;
}

original_code:
void advance_random ()
{
    int j1;
    double new_random;
    for(j1=0; j1<24; j1++)
    {
        new_random = oldrand[j1]-oldrand[j1+31];
        if(new_random<0.0)
        {
            new_random = new_random+1.0;
        }
        oldrand[j1] = new_random;
    }
    for(j1=24; j1<55; j1++)
    {
        new_random = oldrand[j1]-oldrand[j1-24];
        if(new_random<0.0)
        {
            new_random = new_random+1.0;
        }
        oldrand[j1] = new_random;
    }
}

canonical_original_code:
void advance_random()
{
    int j1;
    double new_random;
    for(j1=0; j1<24; j1++)
    {
        new_random = oldrand[j1]-oldrand[j1+31];
        if(new_random<0.0)
        {
            new_random = new_random+1.0;
        }
        oldrand[j1] = new_random;
    }
    for(j1=24; j1<55; j1++)
    {
        new_random = oldrand[j1]-oldrand[j1-24];
        if(new_random<0.0)
        {
            new_random = new_random+1.0;
        }
        oldrand[j1] = new_random;
    }
}


original_code:
void warmup_random (double seed)
{
    int j1, ii;
    double new_random, prev_random;
    oldrand[54] = seed;
    new_random = 0.000000001;
    prev_random = seed;
    for(j1=1; j1<=54; j1++)
    {
        ii = (21*j1)%54;
        oldrand[ii] = new_random;
        new_random = prev_random-new_random;
        if(new_random<0.0)
        {
            new_random += 1.0;
        }
        prev_random = oldrand[ii];
    }
    advance_random ();
    advance_random ();
    advance_random ();
    jrand = 0;
    return;
}

canonical_original_code:
void warmup_random(double seed)
{
    int j1; int ii;
    double new_random; double prev_random;
    oldrand[54] = seed;
    new_random = 0.000000001;
    prev_random = seed;
    for(j1=1; j1<=54; j1++)
    {
        ii = (21*j1)%54;
        oldrand[ii] = new_random;
        new_random = prev_random-new_random;
        if(new_random<0.0)
        {
            new_random += 1.0;
        }
        prev_random = oldrand[ii];
    }
    advance_random ();
    advance_random ();
    advance_random ();
    jrand = 0;
    return;
}

variable_types: seed double

variable_types: ii int


randomize

decompiled_code:
double *__fastcall randomize(__m128 a1)
{
__int64 *v1; // rax

v1 = oldrand;
do
*v1++ = 0LL;
while ( v1 != (__int64 *)(unsigned int)((_DWORD)oldrand + 440) );
jrand = 0;
return warmup_random(a1);
}

canonical_decompiled_code:
double *__fastcall func2(__m128 a1)
{
__int64 *v1; // rax

v1 = oldrand;
do
*v1++ = 0LL;
while ( v1 != (__int64 *)(unsigned int)((_DWORD)oldrand + 440) );
jrand = 0;
return func1(a1);
}

original_code:
void randomize(double seed)
{
    int j1;
    for(j1=0; j1<=54; j1++)
    {
        oldrand[j1] = 0.0;
    }
    jrand=0;
    warmup_random (seed);
    return;
}


randomperc

decompiled_code:
double randomperc()
{
if ( jrand + 1 > 54 )
{
jrand = 1;
advance_random();
}
else
{
++jrand;
}
return oldrand[jrand];
}

canonical_decompiled_code:
double func3()
{
if ( jrand + 1 > 54 )
{
jrand = 1;
func0();
}
else
{
++jrand;
}
return oldrand[jrand];
}

original_code:
double randomperc()
{
    jrand++;
    if(jrand>=55)
    {
        jrand = 1;
        advance_random();
    }
    return((double)oldrand[jrand]);
}


rnd

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

v2 = a1;
if ( a1 < a2 )
{
v2 = (int)((double)(a2 - a1 + 1) * randomperc() + (double)a1);
if ( v2 > a2 )
v2 = a2;
}
return (unsigned int)v2;
}

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

v2 = a1;
if ( a1 < a2 )
{
v2 = (int)((double)(a2 - a1 + 1) * func3() + (double)a1);
if ( v2 > a2 )
v2 = a2;
}
return (unsigned int)v2;
}

original_code:
int rnd (int low, int high)
{
    int res;
    if (low >= high)
    {
        res = low;
    }
    else
    {
        res = low + (randomperc()*(high-low+1));
        if (res > high)
        {
            res = high;
        }
    }
    return (res);
}

canonical_original_code:
int rnd(int low, int high)
{
    int res;
    if (low >= high)
    {
        res = low;
    }
    else
    {
        res = low + (randomperc()*(high-low+1));
        if (res > high)
        {
            res = high;
        }
    }
    return (res);
}

variable_types: low int

variable_types: high int

variable_types: res int


del

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

if ( !a1 )
{
puts("\n Error!! asked to delete a NULL pointer, hence exiting ");
exit(1);
}
v1 = a1[1];
v2 = a1[2];
*(_QWORD *)(v1 + 16) = v2;
if ( v2 )
*(_QWORD *)(v2 + 8) = v1;
free(a1);
return v1;
}

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

if ( !a1 )
{
puts("\n Error!! asked to delete a NULL pointer, hence exiting ");
exit(1);
}
v1 = a1[1];
v2 = a1[2];
*(_QWORD *)(v1 + 16) = v2;
if ( v2 )
*(_QWORD *)(v2 + 8) = v1;
free(a1);
return v1;
}

original_code:
list* del (list *node)
{
    list *temp;
    if (node==((void *)0))
    {
        printf("\n Error!! asked to delete a NULL pointer, hence exiting \n");
        exit(1);
    }
    temp = node->parent;
    temp->child = node->child;
    if (temp->child!=((void *)0))
    {
        temp->child->parent = temp;
    }
    free (node);
    return (temp);
}

canonical_original_code:
struct lists *del(struct lists *node)
{
    struct lists *temp;
    if (node==((void *)0))
    {
        printf("\n Error!! asked to delete a NULL pointer, hence exiting \n");
        exit(1);
    }
    temp = node->parent;
    temp->child = node->child;
    if (temp->child!=((void *)0))
    {
        temp->child->parent = temp;
    }
    free (node);
    return (temp);
}

variable_types:
node
struct lists *

variable_types: struct lists { int index; struct lists *parent; struct lists *child; } *


maximum

decompiled_code:
double __fastcall maximum(double a1, double a2)
{
return fmax(a1, a2);
}

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

original_code:
double maximum (double a, double b)
{
    if (a>b)
    {
        return(a);
    }
    return (b);
}

canonical_original_code:
double maximum(double a, double b)
{
    if (a>b)
    {
        return(a);
    }
    return (b);
}

variable_types: a double

variable_types: b double


minimum

decompiled_code:
double __fastcall minimum(double a1, double a2)
{
return fmin(a1, a2);
}

canonical_decompiled_code:
double __fastcall func1(double a1, double a2)
{
return fmin(a1, a2);
}

original_code:
double minimum (double a, double b)
{
    if (a<b)
    {
        return (a);
    }
    return (b);
}

canonical_original_code:
double minimum(double a, double b)
{
    if (a<b)
    {
        return (a);
    }
    return (b);
}


original_code:
void decode_ind (NSGA2Type *nsga2Params, individual *ind)
{
    int j, k;
    int sum;
    if (nsga2Params->nbin!=0)
    {
        for (j=0; j<nsga2Params->nbin; j++)
        {
            sum=0;
            for (k=0; k<nsga2Params->nbits[j]; k++)
            {
                if (ind->gene[j][k]==1)
                {
                    sum += pow(2,nsga2Params->nbits[j]-1-k);
                }
            }
            ind->xbin[j] = nsga2Params->min_binvar[j] + (double)sum*(nsga2Params->max_binvar[j] - nsga2Params->min_binvar[j])/(double)(pow(2,nsga2Params->nbits[j])-1);
        }
    }
    return;
}

canonical_original_code:
void decode_ind(struct NSGA2Type *nsga2Params, struct individual *ind)
{
    int j; int k;
    int sum;
    if (nsga2Params->nbin!=0)
    {
        for (j=0; j<nsga2Params->nbin; j++)
        {
            sum=0;
            for (k=0; k<nsga2Params->nbits[j]; k++)
            {
                if (ind->gene[j][k]==1)
                {
                    sum += pow(2,nsga2Params->nbits[j]-1-k);
                }
            }
            ind->xbin[j] = nsga2Params->min_binvar[j] + (double)sum*(nsga2Params->max_binvar[j] - nsga2Params->min_binvar[j])/(double)(pow(2,nsga2Params->nbits[j])-1);
        }
    }
    return;
}

variable_types: struct NSGA2Type { double seed; int nreal; int nbin; int nobj; int ncon; int popsize; double pcross_real; double pcross_bin; double pmut_real; double pmut_bin; double eta_c; double eta_m; int ngen; int nbinmut; int nrealmut; int nbincross; int nrealcross; int *nbits; double *min_realvar; double *max_realvar; double *min_binvar; double *max_binvar; int bitlength; int choice; int obj1; int obj2; int obj3; int angle1; int angle2; } *

variable_types: struct individual { int rank; double constr_violation; double *xreal; int **gene; double *xbin; double *obj; double *constr; double crowd_dist; } *

variable_types: j int

variable_types: k int

variable_types: sum int


original_code:
void decode_pop (NSGA2Type *nsga2Params, population *pop)
{
    int i;
    if (nsga2Params->nbin!=0)
    {
        for (i=0; i<nsga2Params->popsize; i++)
        {
            decode_ind (nsga2Params, &(pop->ind[i]));
        }
    }
    return;
}

canonical_original_code:
void decode_pop(struct NSGA2Type *nsga2Params, struct population *pop)
{
    int i;
    if (nsga2Params->nbin!=0)
    {
        for (i=0; i<nsga2Params->popsize; i++)
        {
            decode_ind (nsga2Params, &(pop->ind[i]));
        }
    }
    return;
}

variable_types: struct population { struct individual { int rank; double constr_violation; double *xreal; int **gene; double *xbin; double *obj; double *constr; double crowd_dist; } *ind; } *

variable_types: i int

user_defined_types: struct NSGA2Type { double seed; int nreal; int nbin; int nobj; int ncon; int popsize; double pcross_real; double pcross_bin; double pmut_real; double pmut_bin; double eta_c; double eta_m; int ngen; int nbinmut; int nrealmut; int nbincross; int nrealcross; int *nbits; double *min_realvar; double *max_realvar; double *min_binvar; double *max_binvar; int bitlength; int choice; int obj1; int obj2; int obj3; int angle1; int angle2; }

user_defined_types: struct population { struct individual *ind; }


original_code:
void q_sort_front_obj(population *pop, int objcount, int obj_array[], int left, int right)
{
    int index;
    int temp;
    int i, j;
    double pivot;
    if (left<right)
    {
        index = rnd (left, right);
        temp = obj_array[right];
        obj_array[right] = obj_array[index];
        obj_array[index] = temp;
        pivot = pop->ind[obj_array[right]].obj[objcount];
        i = left-1;
        for (j=left; j<right; j++)
        {
            if (pop->ind[obj_array[j]].obj[objcount] <= pivot)
            {
                i+=1;
                temp = obj_array[j];
                obj_array[j] = obj_array[i];
                obj_array[i] = temp;
            }
        }
        index=i+1;
        temp = obj_array[index];
        obj_array[index] = obj_array[right];
        obj_array[right] = temp;
        q_sort_front_obj (pop, objcount, obj_array, left, index-1);
        q_sort_front_obj (pop, objcount, obj_array, index+1, right);
    }
    return;
}

canonical_original_code:
void q_sort_front_obj(struct population *pop, int objcount, int obj_array[], int left, int right)
{
    int index;
    int temp;
    int i; int j;
    double pivot;
    if (left<right)
    {
        index = rnd (left, right);
        temp = obj_array[right];
        obj_array[right] = obj_array[index];
        obj_array[index] = temp;
        pivot = pop->ind[obj_array[right]].obj[objcount];
        i = left-1;
        for (j=left; j<right; j++)
        {
            if (pop->ind[obj_array[j]].obj[objcount] <= pivot)
            {
                i+=1;
                temp = obj_array[j];
                obj_array[j] = obj_array[i];
                obj_array[i] = temp;
            }
        }
        index=i+1;
        temp = obj_array[index];
        obj_array[index] = obj_array[right];
        obj_array[right] = temp;
        q_sort_front_obj (pop, objcount, obj_array, left, index-1);
        q_sort_front_obj (pop, objcount, obj_array, index+1, right);
    }
    return;
}

variable_types: objcount int

variable_types: left int

variable_types: right int

variable_types: index int

variable_types: temp int

variable_types: pivot double

user_defined_types: struct individual { int rank; double constr_violation; double *xreal; int **gene; double *xbin; double *obj; double *constr; double crowd_dist; }


decompiled_code:
void __fastcall quicksort_front_obj(_QWORD *a1, unsigned int a2, __int64 a3, int a4)
{
q_sort_front_obj(a1, a2, a3, 0, a4 - 1);
}

canonical_decompiled_code:
void __fastcall func1(_QWORD *a1, unsigned int a2, __int64 a3, int a4)
{
func0(a1, a2, a3, 0, a4 - 1);
}

original_code:
void quicksort_front_obj(population *pop, int objcount, int obj_array[], int obj_array_size)
{
    q_sort_front_obj (pop, objcount, obj_array, 0, obj_array_size-1);
    return;
}

canonical_original_code:
void quicksort_front_obj(struct population *pop, int objcount, int obj_array[], int obj_array_size)
{
    q_sort_front_obj (pop, objcount, obj_array, 0, obj_array_size-1);
    return;
}


original_code:
void q_sort_dist(population *pop, int *dist, int left, int right)
{
    int index;
    int temp;
    int i, j;
    double pivot;
    if (left<right)
    {
        index = rnd (left, right);
        temp = dist[right];
        dist[right] = dist[index];
        dist[index] = temp;
        pivot = pop->ind[dist[right]].crowd_dist;
        i = left-1;
        for (j=left; j<right; j++)
        {
            if (pop->ind[dist[j]].crowd_dist <= pivot)
            {
                i+=1;
                temp = dist[j];
                dist[j] = dist[i];
                dist[i] = temp;
            }
        }
        index=i+1;
        temp = dist[index];
        dist[index] = dist[right];
        dist[right] = temp;
        q_sort_dist (pop, dist, left, index-1);
        q_sort_dist (pop, dist, index+1, right);
    }
    return;
}

canonical_original_code:
void q_sort_dist(struct population *pop, int *dist, int left, int right)
{
    int index;
    int temp;
    int i; int j;
    double pivot;
    if (left<right)
    {
        index = rnd (left, right);
        temp = dist[right];
        dist[right] = dist[index];
        dist[index] = temp;
        pivot = pop->ind[dist[right]].crowd_dist;
        i = left-1;
        for (j=left; j<right; j++)
        {
            if (pop->ind[dist[j]].crowd_dist <= pivot)
            {
                i+=1;
                temp = dist[j];
                dist[j] = dist[i];
                dist[i] = temp;
            }
        }
        index=i+1;
        temp = dist[index];
        dist[index] = dist[right];
        dist[right] = temp;
        q_sort_dist (pop, dist, left, index-1);
        q_sort_dist (pop, dist, index+1, right);
    }
    return;
}

variable_types:
dist
int *


decompiled_code:
void __fastcall quicksort_dist(_QWORD *a1, __int64 a2, int a3)
{
q_sort_dist(a1, a2, 0, a3 - 1);
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1, __int64 a2, int a3)
{
func2(a1, a2, 0, a3 - 1);
}

original_code:
void quicksort_dist(population *pop, int *dist, int front_size)
{
    q_sort_dist (pop, dist, 0, front_size-1);
    return;
}

canonical_original_code:
void quicksort_dist(struct population *pop, int *dist, int front_size)
{
    q_sort_dist (pop, dist, 0, front_size-1);
    return;
}


original_code:
void evaluate_ind (NSGA2Type *nsga2Params, individual *ind, void *inp, void *out)
{
    int j;
    test_problem (ind->xreal, ind->xbin, ind->gene, ind->obj, ind->constr);
    if (nsga2Params->ncon==0)
    {
        ind->constr_violation = 0.0;
    }
    else
    {
        ind->constr_violation = 0.0;
        for (j=0; j<nsga2Params->ncon; j++)
        {
            if (ind->constr[j]<0.0)
            {
                ind->constr_violation += ind->constr[j];
            }
        }
    }
    return;
}

canonical_original_code:
void evaluate_ind(struct NSGA2Type *nsga2Params, struct individual *ind, void *inp, void *out)
{
    int j;
    test_problem (ind->xreal, ind->xbin, ind->gene, ind->obj, ind->constr);
    if (nsga2Params->ncon==0)
    {
        ind->constr_violation = 0.0;
    }
    else
    {
        ind->constr_violation = 0.0;
        for (j=0; j<nsga2Params->ncon; j++)
        {
            if (ind->constr[j]<0.0)
            {
                ind->constr_violation += ind->constr[j];
            }
        }
    }
    return;
}

variable_types:
inp
void *

variable_types:
out
void *


decompiled_code:
__int64 __fastcall evaluate_pop(__int64 a1, _QWORD *a2)
{
__int64 v2; // rbx
__int64 result; // rax

if ( *(int *)(a1 + 24) > 0 )
{
v2 = 0LL;
do
result = evaluate_ind(a1, (double *)(*a2 + (v2++ << 6)));
while ( *(_DWORD *)(a1 + 24) > (int)v2 );
}
return result;
}

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

if ( *(int *)(a1 + 24) > 0 )
{
v2 = 0LL;
do
result = func0(a1, (double *)(*a2 + (v2++ << 6)));
while ( *(_DWORD *)(a1 + 24) > (int)v2 );
}
return result;
}

original_code:
void evaluate_pop (NSGA2Type *nsga2Params, population *pop, void *inp, void *out)
{
    int i;
    for (i=0; i<nsga2Params->popsize; i++)
    {
        evaluate_ind (nsga2Params, &(pop->ind[i]), inp, out);
    }
    return;
}

canonical_original_code:
void evaluate_pop(struct NSGA2Type *nsga2Params, struct population *pop, void *inp, void *out)
{
    int i;
    for (i=0; i<nsga2Params->popsize; i++)
    {
        evaluate_ind (nsga2Params, &(pop->ind[i]), inp, out);
    }
    return;
}


original_code:
void copy_ind (NSGA2Type *nsga2Params, individual *ind1, individual *ind2)
{
    int i, j;
    ind2->rank = ind1->rank;
    ind2->constr_violation = ind1->constr_violation;
    ind2->crowd_dist = ind1->crowd_dist;
    if (nsga2Params->nreal!=0)
    {
        for (i=0; i<nsga2Params->nreal; i++)
        {
            ind2->xreal[i] = ind1->xreal[i];
        }
    }
    if (nsga2Params->nbin!=0)
    {
        for (i=0; i<nsga2Params->nbin; i++)
        {
            ind2->xbin[i] = ind1->xbin[i];
            for (j=0; j<nsga2Params->nbits[i]; j++)
            {
                ind2->gene[i][j] = ind1->gene[i][j];
            }
        }
    }
    for (i=0; i<nsga2Params->nobj; i++)
    {
        ind2->obj[i] = ind1->obj[i];
    }
    if (nsga2Params->ncon!=0)
    {
        for (i=0; i<nsga2Params->ncon; i++)
        {
            ind2->constr[i] = ind1->constr[i];
        }
    }
    return;
}

canonical_original_code:
void copy_ind(struct NSGA2Type *nsga2Params, struct individual *ind1, struct individual *ind2)
{
    int i; int j;
    ind2->rank = ind1->rank;
    ind2->constr_violation = ind1->constr_violation;
    ind2->crowd_dist = ind1->crowd_dist;
    if (nsga2Params->nreal!=0)
    {
        for (i=0; i<nsga2Params->nreal; i++)
        {
            ind2->xreal[i] = ind1->xreal[i];
        }
    }
    if (nsga2Params->nbin!=0)
    {
        for (i=0; i<nsga2Params->nbin; i++)
        {
            ind2->xbin[i] = ind1->xbin[i];
            for (j=0; j<nsga2Params->nbits[i]; j++)
            {
                ind2->gene[i][j] = ind1->gene[i][j];
            }
        }
    }
    for (i=0; i<nsga2Params->nobj; i++)
    {
        ind2->obj[i] = ind1->obj[i];
    }
    if (nsga2Params->ncon!=0)
    {
        for (i=0; i<nsga2Params->ncon; i++)
        {
            ind2->constr[i] = ind1->constr[i];
        }
    }
    return;
}


merge

original_code:
void merge(NSGA2Type *nsga2Params, population *pop1, population *pop2, population *pop3)
{
    int i, k;
    for (i=0; i<nsga2Params->popsize; i++)
    {
        copy_ind (nsga2Params, &(pop1->ind[i]), &(pop3->ind[i]));
    }
    for (i=0, k=nsga2Params->popsize; i<nsga2Params->popsize; i++, k++)
    {
        copy_ind (nsga2Params, &(pop2->ind[i]), &(pop3->ind[k]));
    }
    return;
}

canonical_original_code:
void merge(struct NSGA2Type *nsga2Params, struct population *pop1, struct population *pop2, struct population *pop3)
{
    int i; int k;
    for (i=0; i<nsga2Params->popsize; i++)
    {
        copy_ind (nsga2Params, &(pop1->ind[i]), &(pop3->ind[i]));
    }
    for (i=0, k=nsga2Params->popsize; i<nsga2Params->popsize; i++, k++)
    {
        copy_ind (nsga2Params, &(pop2->ind[i]), &(pop3->ind[k]));
    }
    return;
}


realcross

original_code:
void realcross (NSGA2Type *nsga2Params, individual *parent1, individual *parent2, individual *child1, individual *child2)
{
    int i;
    double rand;
    double y1, y2, yl, yu;
    double c1, c2;
    double alpha, beta, betaq;
    if (randomperc() <= nsga2Params->pcross_real)
    {
        nsga2Params->nrealcross++;
        for (i=0; i<nsga2Params->nreal; i++)
        {
            if (randomperc()<=0.5 )
            {
                if (fabs(parent1->xreal[i]-parent2->xreal[i]) > 1.0e-14)
                {
                    if (parent1->xreal[i] < parent2->xreal[i])
                    {
                        y1 = parent1->xreal[i];
                        y2 = parent2->xreal[i];
                    }
                    else
                    {
                        y1 = parent2->xreal[i];
                        y2 = parent1->xreal[i];
                    }
                    yl = nsga2Params->min_realvar[i];
                    yu = nsga2Params->max_realvar[i];
                    rand = randomperc();
                    beta = 1.0 + (2.0*(y1-yl)/(y2-y1));
                    alpha = 2.0 - pow(beta,-(nsga2Params->eta_c+1.0));
                    if (rand <= (1.0/alpha))
                    {
                        betaq = pow ((rand*alpha),(1.0/(nsga2Params->eta_c+1.0)));
                    }
                    else
                    {
                        betaq = pow ((1.0/(2.0 - rand*alpha)),(1.0/(nsga2Params->eta_c+1.0)));
                    }
                    c1 = 0.5*((y1+y2)-betaq*(y2-y1));
                    beta = 1.0 + (2.0*(yu-y2)/(y2-y1));
                    alpha = 2.0 - pow(beta,-(nsga2Params->eta_c+1.0));
                    if (rand <= (1.0/alpha))
                    {
                        betaq = pow ((rand*alpha),(1.0/(nsga2Params->eta_c+1.0)));
                    }
                    else
                    {
                        betaq = pow ((1.0/(2.0 - rand*alpha)),(1.0/(nsga2Params->eta_c+1.0)));
                    }
                    c2 = 0.5*((y1+y2)+betaq*(y2-y1));
                    if (c1<yl)
                        c1=yl;
                    if (c2<yl)
                        c2=yl;
                    if (c1>yu)
                        c1=yu;
                    if (c2>yu)
                        c2=yu;
                    if (randomperc()<=0.5)
                    {
                        child1->xreal[i] = c2;
                        child2->xreal[i] = c1;
                    }
                    else
                    {
                        child1->xreal[i] = c1;
                        child2->xreal[i] = c2;
                    }
                }
                else
                {
                    child1->xreal[i] = parent1->xreal[i];
                    child2->xreal[i] = parent2->xreal[i];
                }
            }
            else
            {
                child1->xreal[i] = parent1->xreal[i];
                child2->xreal[i] = parent2->xreal[i];
            }
        }
    }
    else
    {
        for (i=0; i<nsga2Params->nreal; i++)
        {
            child1->xreal[i] = parent1->xreal[i];
            child2->xreal[i] = parent2->xreal[i];
        }
    }
    return;
}

canonical_original_code:
void realcross(struct NSGA2Type *nsga2Params, struct individual *parent1, struct individual *parent2, struct individual *child1, struct individual *child2)
{
    int i;
    double rand;
    double y1; double y2; double yl; double yu;
    double c1; double c2;
    double alpha; double beta; double betaq;
    if (randomperc() <= nsga2Params->pcross_real)
    {
        nsga2Params->nrealcross++;
        for (i=0; i<nsga2Params->nreal; i++)
        {
            if (randomperc()<=0.5 )
            {
                if (fabs(parent1->xreal[i]-parent2->xreal[i]) > 1.0e-14)
                {
                    if (parent1->xreal[i] < parent2->xreal[i])
                    {
                        y1 = parent1->xreal[i];
                        y2 = parent2->xreal[i];
                    }
                    else
                    {
                        y1 = parent2->xreal[i];
                        y2 = parent1->xreal[i];
                    }
                    yl = nsga2Params->min_realvar[i];
                    yu = nsga2Params->max_realvar[i];
                    rand = randomperc();
                    beta = 1.0 + (2.0*(y1-yl)/(y2-y1));
                    alpha = 2.0 - pow(beta,-(nsga2Params->eta_c+1.0));
                    if (rand <= (1.0/alpha))
                    {
                        betaq = pow ((rand*alpha),(1.0/(nsga2Params->eta_c+1.0)));
                    }
                    else
                    {
                        betaq = pow ((1.0/(2.0 - rand*alpha)),(1.0/(nsga2Params->eta_c+1.0)));
                    }
                    c1 = 0.5*((y1+y2)-betaq*(y2-y1));
                    beta = 1.0 + (2.0*(yu-y2)/(y2-y1));
                    alpha = 2.0 - pow(beta,-(nsga2Params->eta_c+1.0));
                    if (rand <= (1.0/alpha))
                    {
                        betaq = pow ((rand*alpha),(1.0/(nsga2Params->eta_c+1.0)));
                    }
                    else
                    {
                        betaq = pow ((1.0/(2.0 - rand*alpha)),(1.0/(nsga2Params->eta_c+1.0)));
                    }
                    c2 = 0.5*((y1+y2)+betaq*(y2-y1));
                    if (c1<yl)
                        c1=yl;
                    if (c2<yl)
                        c2=yl;
                    if (c1>yu)
                        c1=yu;
                    if (c2>yu)
                        c2=yu;
                    if (randomperc()<=0.5)
                    {
                        child1->xreal[i] = c2;
                        child2->xreal[i] = c1;
                    }
                    else
                    {
                        child1->xreal[i] = c1;
                        child2->xreal[i] = c2;
                    }
                }
                else
                {
                    child1->xreal[i] = parent1->xreal[i];
                    child2->xreal[i] = parent2->xreal[i];
                }
            }
            else
            {
                child1->xreal[i] = parent1->xreal[i];
                child2->xreal[i] = parent2->xreal[i];
            }
        }
    }
    else
    {
        for (i=0; i<nsga2Params->nreal; i++)
        {
            child1->xreal[i] = parent1->xreal[i];
            child2->xreal[i] = parent2->xreal[i];
        }
    }
    return;
}

variable_types: rand double

variable_types: yl double

variable_types: yu double

variable_types: alpha double

variable_types: beta double

variable_types: betaq double


bincross

original_code:
void bincross (NSGA2Type *nsga2Params, individual *parent1, individual *parent2, individual *child1, individual *child2)
{
    int i, j;
    double rand;
    int temp, site1, site2;
    for (i=0; i<nsga2Params->nbin; i++)
    {
        rand = randomperc();
        if (rand <= nsga2Params->pcross_bin)
        {
            nsga2Params->nbincross++;
            site1 = rnd(0,nsga2Params->nbits[i]-1);
            site2 = rnd(0,nsga2Params->nbits[i]-1);
            if (site1 > site2)
            {
                temp = site1;
                site1 = site2;
                site2 = temp;
            }
            for (j=0; j<site1; j++)
            {
                child1->gene[i][j] = parent1->gene[i][j];
                child2->gene[i][j] = parent2->gene[i][j];
            }
            for (j=site1; j<site2; j++)
            {
                child1->gene[i][j] = parent2->gene[i][j];
                child2->gene[i][j] = parent1->gene[i][j];
            }
            for (j=site2; j<nsga2Params->nbits[i]; j++)
            {
                child1->gene[i][j] = parent1->gene[i][j];
                child2->gene[i][j] = parent2->gene[i][j];
            }
        }
        else
        {
            for (j=0; j<nsga2Params->nbits[i]; j++)
            {
                child1->gene[i][j] = parent1->gene[i][j];
                child2->gene[i][j] = parent2->gene[i][j];
            }
        }
    }
    return;
}

canonical_original_code:
void bincross(struct NSGA2Type *nsga2Params, struct individual *parent1, struct individual *parent2, struct individual *child1, struct individual *child2)
{
    int i; int j;
    double rand;
    int temp; int site1; int site2;
    for (i=0; i<nsga2Params->nbin; i++)
    {
        rand = randomperc();
        if (rand <= nsga2Params->pcross_bin)
        {
            nsga2Params->nbincross++;
            site1 = rnd(0,nsga2Params->nbits[i]-1);
            site2 = rnd(0,nsga2Params->nbits[i]-1);
            if (site1 > site2)
            {
                temp = site1;
                site1 = site2;
                site2 = temp;
            }
            for (j=0; j<site1; j++)
            {
                child1->gene[i][j] = parent1->gene[i][j];
                child2->gene[i][j] = parent2->gene[i][j];
            }
            for (j=site1; j<site2; j++)
            {
                child1->gene[i][j] = parent2->gene[i][j];
                child2->gene[i][j] = parent1->gene[i][j];
            }
            for (j=site2; j<nsga2Params->nbits[i]; j++)
            {
                child1->gene[i][j] = parent1->gene[i][j];
                child2->gene[i][j] = parent2->gene[i][j];
            }
        }
        else
        {
            for (j=0; j<nsga2Params->nbits[i]; j++)
            {
                child1->gene[i][j] = parent1->gene[i][j];
                child2->gene[i][j] = parent2->gene[i][j];
            }
        }
    }
    return;
}

variable_types: struct NSGA2Type { double seed; int nreal; int nbin; int nobj; int ncon; int popsize; double pcross_real; double pcross_bin; double pmut_real; double pmut_bin; double eta_c; double eta_m; int ngen; int nbinmut; int nrealmut; int nbincross; int nrealcross; int *nbits; double *min_realvar; double *max_realvar; double *min_binvar; double *max_binvar; int bitlength; int choice; int obj1; int obj2; int obj3; int angle1; int angle2; } *

variable_types: struct individual { int rank; double constr_violation; double *xreal; int **gene; double *xbin; double *obj; double *constr; double crowd_dist; } *

variable_types: j int


crossover

decompiled_code:
void __fastcall crossover(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
if ( *(_DWORD *)(a1 + 8) )
realcross(a1, a2, a3, a4, a5);
if ( *(_DWORD *)(a1 + 12) )
bincross(a1, a2, a3, a4, a5);
}

original_code:
void crossover (NSGA2Type *nsga2Params, individual *parent1, individual *parent2, individual *child1, individual *child2)
{
    if (nsga2Params->nreal!=0)
    {
        realcross (nsga2Params, parent1, parent2, child1, child2);
    }
    if (nsga2Params->nbin!=0)
    {
        bincross (nsga2Params, parent1, parent2, child1, child2);
    }
    return;
}

canonical_original_code:
void crossover(struct NSGA2Type *nsga2Params, struct individual *parent1, struct individual *parent2, struct individual *child1, struct individual *child2)
{
    if (nsga2Params->nreal!=0)
    {
        realcross (nsga2Params, parent1, parent2, child1, child2);
    }
    if (nsga2Params->nbin!=0)
    {
        bincross (nsga2Params, parent1, parent2, child1, child2);
    }
    return;
}