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

decompiled_code:
double __fastcall median(void *src, int a2)
{
__int64 v2; // rbx
void *v3; // rsp
double result; // xmm0_8
char v5; // dl
int v6; // eax
int v7; // edi
double v8; // xmm1_8
int v9; // ecx
double v10; // xmm2_8
_QWORD v11[2]; // [rsp+0h] [rbp-10h] BYREF

v2 = a2;
v3 = alloca(8LL * a2);
memcpy(v11, src, 8LL * a2);
qsort(v11, a2, 8uLL, (__compar_fn_t)comparedouble);
result = 0.0;
while ( 1 )
{
v5 = v2;
v6 = v2;
if ( (int)v2 <= 0 )
break;
if ( *(double *)&v11[--v2] != 0.0 )
{
if ( v6 <= 2 )
return result;
v7 = v6 >> 1;
v8 = *(double *)&v11[v6 >> 2];
v9 = (3 * v6) >> 2;
v10 = *(double *)&v11[v9];
if ( (v6 & 2) != 0 )
{
if ( v8 - v10 > 250.0 )
return result;
}
else if ( (v8 + *(double *)&v11[(v6 >> 2) - 1]) * 0.5 - (v10 + *(double *)&v11[v9 - 1]) * 0.5 > 250.0 )
{
return result;
}
result = *(double *)&v11[v7];
if ( (v5 & 1) == 0 )
result = (result + *(double *)&v11[v7 - 1]) * 0.5;
return result;
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func1(void *src, int a2)
{
__int64 v2; // rbx
void *v3; // rsp
double result; // xmm0_8
char v5; // dl
int v6; // eax
int v7; // edi
double v8; // xmm1_8
int v9; // ecx
double v10; // xmm2_8
_QWORD v11[2]; // [rsp+0h] [rbp-10h] BYREF

v2 = a2;
v3 = alloca(8LL * a2);
memcpy(v11, src, 8LL * a2);
qsort(v11, a2, 8uLL, (__compar_fn_t)comparedouble);
result = 0.0;
while ( 1 )
{
v5 = v2;
v6 = v2;
if ( (int)v2 <= 0 )
break;
if ( *(double *)&v11[--v2] != 0.0 )
{
if ( v6 <= 2 )
return result;
v7 = v6 >> 1;
v8 = *(double *)&v11[v6 >> 2];
v9 = (3 * v6) >> 2;
v10 = *(double *)&v11[v9];
if ( (v6 & 2) != 0 )
{
if ( v8 - v10 > 250.0 )
return result;
}
else if ( (v8 + *(double *)&v11[(v6 >> 2) - 1]) * 0.5 - (v10 + *(double *)&v11[v9 - 1]) * 0.5 > 250.0 )
{
return result;
}
result = *(double *)&v11[v7];
if ( (v5 & 1) == 0 )
result = (result + *(double *)&v11[v7 - 1]) * 0.5;
return result;
}
}
return result;
}

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; // r12
void **v3; // rbx
void **v4; // rbp
void *v5; // rdi

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

canonical_decompiled_code:
__int64 __fastcall func3(void *ptr, int a2)
{
void *v2; // r12
void **v3; // rbx
void **v4; // rbp
void *v5; // rdi

v2 = ptr;
if ( a2 > 0 )
{
v3 = (void **)ptr;
v4 = (void **)((char *)ptr + 8 * (unsigned int)(a2 - 1) + 8);
do
{
v5 = *v3++;
free(v5);
}
while ( v3 != v4 );
}
free(v2);
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

variable_types: i int

return_type: double **


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

return_type: void


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; // rdx
int v4; // eax
int v5; // eax

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

canonical_decompiled_code:
void __fastcall func3(int a1, __int64 a2)
{
int v2; // ebx
__int64 v3; // rdx
int v4; // eax
int v5; // eax

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


main

canonical_name: main

repo: alvneiayu/task

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r14
const char *i; // rbp
__int64 v5; // r13
__int64 v6; // r12
const char *v7; // rax
const char *v8; // rbp

v3 = 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();
v5 = json_object_iter_value();
if ( !v5 )
break;
v6 = 0LL;
puts("Root's key");
printf("\t-%s\n", i);
printf("Type of Value: ");
type_of(v5);
puts("Values:");
if ( (int)json_array_size() > 0 )
{
do
{
json_array_get();
json_object_iter();
while ( 1 )
{
v8 = (const char *)json_object_iter_key();
if ( !v8 )
break;
json_object_key_to_iter();
if ( !json_object_iter_value() )
break;
v7 = (const char *)json_string_value();
printf("\t%s : %s\n", v8, v7);
json_object_key_to_iter();
json_object_iter_next();
}
++v6;
}
while ( (int)json_array_size() > (int)v6 );
}
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)
{
__int64 v3; // r14
const char *i; // rbp
__int64 v5; // r13
__int64 v6; // r12
const char *v7; // rax
const char *v8; // rbp

v3 = 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();
v5 = json_object_iter_value();
if ( !v5 )
break;
v6 = 0LL;
puts("Root's key");
printf("\t-%s\n", i);
printf("Type of Value: ");
func7(v5);
puts("Values:");
if ( (int)json_array_size() > 0 )
{
do
{
json_array_get();
json_object_iter();
while ( 1 )
{
v8 = (const char *)json_object_iter_key();
if ( !v8 )
break;
json_object_key_to_iter();
if ( !json_object_iter_value() )
break;
v7 = (const char *)json_string_value();
printf("\t%s : %s\n", v8, v7);
json_object_key_to_iter();
json_object_iter_next();
}
++v6;
}
while ( (int)json_array_size() > (int)v6 );
}
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: 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; } *

variable_types:
key
char *

return_type: int

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


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


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

result = json_load_file();
if ( !result )
{
printf("Error in the line: %d: %s \n", v1, v2);
result = 0LL;
}
return result;
}

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

result = json_load_file();
if ( !result )
{
printf("Error in the line: %d: %s \n", v1, v2);
result = 0LL;
}
return result;
}

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


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)
{
_DWORD *v3; // rax
_DWORD *v4; // r12
_BYTE *v5; // r14
char **v6; // rbx
__int64 v7; // rbp
const char *v8; // r15
char *v9; // r15
size_t v10; // rax
char *v11; // rax
char *v12; // r15
size_t v13; // rax
char *v14; // rax
size_t v15; // rax
_OWORD *v17; // r15
_OWORD *v18; // rbx
_BYTE *v19; // r13
const char *v20; // rdx
const char *v21; // rsi
size_t v22; // rsi
_BYTE *v23; // rbp
const char *v24; // rdx
const char *v25; // rsi
void *v26; // rdi
_BYTE v27[16]; // [rsp+0h] [rbp-438h] BYREF
_OWORD v28[66]; // [rsp+10h] [rbp-428h] BYREF

v3 = malloc(0x400uLL);
if ( !v3 )
{
perror("scratch");
exit(1);
}
v4 = v3;
v5 = v27;
v6 = (char **)v27;
v7 = 1LL;
v8 = *(const char **)_bss_start;
if ( *(_QWORD *)_bss_start )
{
while ( 1 )
{
v15 = strlen(v8) + 1;
if ( v15 > 0x400 )
{
puts("env var too long");
return 1;
}
if ( (unsigned int)v15 < 8 )
{
if ( (v15 & 4) != 0 )
{
*v4 = *(_DWORD *)v8;
*(_DWORD *)((char *)v4 + (unsigned int)v15 - 4) = *(_DWORD *)&v8[(unsigned int)v15 - 4];
}
else if ( (_DWORD)v15 )
{
*(_BYTE *)v4 = *v8;
if ( (v15 & 2) != 0 )
*(_WORD *)((char *)v4 + (unsigned int)v15 - 2) = *(_WORD *)&v8[(unsigned int)v15 - 2];
}
}
else
{
*(_QWORD *)((char *)v4 + (unsigned int)v15 - 8) = *(_QWORD *)&v8[(unsigned int)v15 - 8];
qmemcpy(v4, v8, 8LL * ((unsigned int)(v15 - 1) >> 3));
}
v9 = strtok((char *)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);
}
v6 += 2;
strcpy(v14, v12);
v8 = *(const char **)(_bss_start + 8 * v7);
if ( !v8 )
break;
++v7;
}
printf("%d env variables\n\n", (unsigned int)v7);
v17 = v28;
v18 = &v28[(unsigned int)(v7 - 1)];
v19 = v27;
do
{
v20 = (const char *)*((_QWORD *)v19 + 1);
v21 = *(const char **)v19;
v19 += 16;
printf("%s\t%s\n", v21, v20);
}
while ( v19 != (_BYTE *)v18 );
puts("\n\nSorted by name");
v22 = v7;
v23 = v27;
qsort(v27, v22, 0x10uLL, cmpName);
do
{
v24 = (const char *)*((_QWORD *)v23 + 1);
v25 = *(const char **)v23;
v23 += 16;
printf("%s\t%s\n", v25, v24);
}
while ( v23 != (_BYTE *)v18 );
while ( 1 )
{
free(*(void **)v5);
v26 = (void *)*((_QWORD *)v5 + 1);
v5 = v17;
free(v26);
if ( v17 == v18 )
break;
++v17;
}
}
else
{
printf("%d env variables\n\n", 0LL);
puts("\n\nSorted by name");
qsort(v27, 0LL, 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)
{
__int64 result; // rax
char *v4; // r8
char v5; // cl
char v6; // si

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

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

result = a3;
v4 = (char *)(a2 + a1);
v5 = v4[1];
v6 = *v4;
if ( v5 > *v4 )
{
v6 = v4[1];
v5 = *v4;
result = 1LL;
}
*v4 = v6;
v4[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 v3; // er11
int v4; // er9
unsigned int v5; // edx
unsigned int v6; // eax
int v7; // er9
unsigned int v8; // eax
int v9; // er9
bool v10; // cf

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

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
int v3; // er11
int v4; // er9
unsigned int v5; // edx
unsigned int v6; // eax
int v7; // er9
unsigned int v8; // eax
int v9; // er9
bool v10; // cf

v3 = a2 - 1;
while ( v3 > 0 )
{
v4 = 0;
v5 = 0;
do
{
v6 = func8(v4, a1, v5);
v5 = v6;
}
while ( v4 != v3 );
if ( !v6 )
break;
v7 = a2 - 2;
if ( a2 - 2 >= 0 )
{
do
{
v8 = func8(v7, a1, v5);
v5 = v8;
v10 = v9 == 0;
v7 = v9 - 1;
}
while ( !v10 );
if ( !v8 )
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

variable_types: i int

return_type: char *


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 v7; // xmm7_8
double v8; // xmm0_8
double v9; // xmm0_8
double v10; // xmm3_8
double v11; // xmm2_8
double v12; // xmm1_8
int v13; // eax
unsigned int v14; // ebx
double v15; // xmm0_8
double v17; // [rsp+0h] [rbp-80h]
double v18; // [rsp+8h] [rbp-78h]
double v19; // [rsp+18h] [rbp-68h]
double v20; // [rsp+20h] [rbp-60h]
double cosx; // [rsp+28h] [rbp-58h] BYREF
double sinx[2]; // [rsp+30h] [rbp-50h] BYREF
unsigned __int16 v23; // [rsp+41h] [rbp-3Fh]
unsigned __int8 v24; // [rsp+43h] [rbp-3Dh]
unsigned __int8 v25; // [rsp+44h] [rbp-3Ch]
unsigned __int8 v26; // [rsp+45h] [rbp-3Bh]
__int16 v27; // [rsp+46h] [rbp-3Ah]

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);
v20 = radian(a4);
sincos(v20, sinx, &cosx);
v7 = cosx;
v17 = radian(a5);
v18 = radian(a6);
v8 = atan(6378.14 * sinx[0] / ((1.0 - v7) * 6378.14 + 35786.43));
v19 = degree(v8);
sincos(v17 - v18, sinx, &cosx);
v9 = atan(sinx[0] * 42164.57 / (42164.57 * cosx - 6378.14 * v7));
v10 = degree(v9);
v11 = degree(v18);
v12 = degree(v20);
v14 = v13 | ((int)(16.0 * COERCE_DOUBLE(*(_QWORD *)&v10 & LC10) + 0.5) >> 8);
v15 = degree(v17);
printf(
"Long: %.2f, Lat: %.2f, Orbital Pos: %.2f, RotorCmd: %02x %02x, motor_angle: %.2f declination: %.2f\n",
v14,
v15,
v12,
v11,
v10,
v19);
v25 = v14;
v26 = (int)(16.0 * COERCE_DOUBLE(*(_QWORD *)&v10 & LC10) + 0.5);
v27 = 1280;
v23 = 12768;
v24 = 110;
sleep(1u);
diseqc_send_msg(
fd,
((unsigned __int64)(unsigned __int8)v27 << 40) | ((unsigned __int64)v25 << 24) | v23 | ((unsigned __int64)v24 << 16) | ((unsigned __int64)v26 << 32) | ((unsigned __int64)HIBYTE(v27) << 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 v7; // xmm7_8
double v8; // xmm0_8
double v9; // xmm0_8
double v10; // xmm3_8
double v11; // xmm2_8
double v12; // xmm1_8
int v13; // eax
unsigned int v14; // ebx
double v15; // xmm0_8
double v17; // [rsp+0h] [rbp-80h]
double v18; // [rsp+8h] [rbp-78h]
double v19; // [rsp+18h] [rbp-68h]
double v20; // [rsp+20h] [rbp-60h]
double cosx; // [rsp+28h] [rbp-58h] BYREF
double sinx[2]; // [rsp+30h] [rbp-50h] BYREF
unsigned __int16 v23; // [rsp+41h] [rbp-3Fh]
unsigned __int8 v24; // [rsp+43h] [rbp-3Dh]
unsigned __int8 v25; // [rsp+44h] [rbp-3Ch]
unsigned __int8 v26; // [rsp+45h] [rbp-3Bh]
__int16 v27; // [rsp+46h] [rbp-3Ah]

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);
v20 = func0(a4);
sincos(v20, sinx, &cosx);
v7 = cosx;
v17 = func0(a5);
v18 = func0(a6);
v8 = atan(6378.14 * sinx[0] / ((1.0 - v7) * 6378.14 + 35786.43));
v19 = func1(v8);
sincos(v17 - v18, sinx, &cosx);
v9 = atan(sinx[0] * 42164.57 / (42164.57 * cosx - 6378.14 * v7));
v10 = func1(v9);
v11 = func1(v18);
v12 = func1(v20);
v14 = v13 | ((int)(16.0 * COERCE_DOUBLE(*(_QWORD *)&v10 & LC10) + 0.5) >> 8);
v15 = func1(v17);
printf(
"Long: %.2f, Lat: %.2f, Orbital Pos: %.2f, RotorCmd: %02x %02x, motor_angle: %.2f declination: %.2f\n",
v14,
v15,
v12,
v11,
v10,
v19);
v25 = v14;
v26 = (int)(16.0 * COERCE_DOUBLE(*(_QWORD *)&v10 & LC10) + 0.5);
v27 = 1280;
v23 = 12768;
v24 = 110;
sleep(1u);
func2(
fd,
((unsigned __int64)(unsigned __int8)v27 << 40) | ((unsigned __int64)v25 << 24) | v23 | ((unsigned __int64)v24 << 16) | ((unsigned __int64)v26 << 32) | ((unsigned __int64)HIBYTE(v27) << 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; // rbx

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 )
goto LABEL_7;
}
else if ( !a4 )
{
goto LABEL_7;
}
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);
LABEL_7:
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; // rbx

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 )
goto LABEL_7;
}
else if ( !a4 )
{
goto LABEL_7;
}
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);
LABEL_7:
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()
{
__int64 *v0; // rax
double v1; // xmm0_8
double *result; // rax
double v3; // xmm0_8

v0 = &oldrand;
do
{
v1 = *(double *)v0 - *((double *)v0 + 31);
if ( v1 < 0.0 )
v1 = v1 + 1.0;
*(double *)v0++ = v1;
}
while ( v0 != &oldrand + 24 );
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 *)(&oldrand + 55) );
return result;
}

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

v0 = &oldrand;
do
{
v1 = *(double *)v0 - *((double *)v0 + 31);
if ( v1 < 0.0 )
v1 = v1 + 1.0;
*(double *)v0++ = v1;
}
while ( v0 != &oldrand + 24 );
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 *)(&oldrand + 55) );
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;
    }
}


decompiled_code:
double *__fastcall warmup_random(__m128 a1)
{
__m128 v1; // xmm2
unsigned int v2; // edx
__m128 i; // xmm0
__m128 v4; // xmm1
double *result; // rax

v1 = a1;
v2 = 21;
oldrand[54] = a1.m128_u64[0];
for ( i = (__m128)(unsigned __int64)LC2; ; i = v4 )
{
*(double *)v1.m128_u64 = *(double *)v1.m128_u64 - *(double *)i.m128_u64;
v4 = v1;
oldrand[v2 % 0x36] = i.m128_u64[0];
if ( *(double *)v1.m128_u64 < 0.0 )
*(double *)v4.m128_u64 = *(double *)v1.m128_u64 + 1.0;
v2 += 21;
v1 = i;
if ( v2 == 1155 )
break;
}
advance_random();
advance_random();
result = advance_random();
jrand = 0;
return result;
}

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)
{
jrand = 0;
memset(oldrand, 0, sizeof(oldrand));
return warmup_random(a1);
}

canonical_decompiled_code:
double *__fastcall func2(__m128 a1)
{
jrand = 0;
memset(oldrand, 0, sizeof(oldrand));
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()
{
int v0; // eax
double result; // xmm0_8

v0 = jrand + 1;
if ( jrand + 1 > 54 )
{
jrand = 1;
advance_random();
result = oldrand[jrand];
}
else
{
++jrand;
result = oldrand[v0];
}
return result;
}

canonical_decompiled_code:
double func3()
{
int v0; // eax
double result; // xmm0_8

v0 = jrand + 1;
if ( jrand + 1 > 54 )
{
jrand = 1;
func0();
result = oldrand[jrand];
}
else
{
++jrand;
result = oldrand[v0];
}
return result;
}

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 v3; // er8

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

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

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

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; // r12
__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; // r12
__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


decompiled_code:
__int64 __fastcall decode_pop(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // rsi

if ( *(_DWORD *)(a1 + 12) )
{
result = *(unsigned int *)(a1 + 24);
if ( (int)result > 0 )
{
v4 = 0LL;
do
{
v5 = v4++;
result = decode_ind(a1, *a2 + (v5 << 6));
}
while ( *(_DWORD *)(a1 + 24) > (int)v4 );
}
}
return result;
}

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

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

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(__int64 *a1, unsigned int a2, __int64 a3, int a4)
{
q_sort_front_obj(a1, a2, a3, 0, a4 - 1);
}

canonical_decompiled_code:
void __fastcall func1(__int64 *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(__int64 *a1, __int64 a2, int a3)
{
q_sort_dist(a1, a2, 0, a3 - 1);
}

canonical_decompiled_code:
void __fastcall func3(__int64 *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;
}


decompiled_code:
double *__fastcall evaluate_ind(__int64 a1, double *a2)
{
double *result; // rax
double *v3; // rdx
__int64 v4; // rcx
__int64 v5; // rcx

test_problem(*((_QWORD *)a2 + 2), *((_QWORD *)a2 + 4), *((_QWORD *)a2 + 3), *((_QWORD *)a2 + 5), *((_QWORD *)a2 + 6));
result = (double *)*(unsigned int *)(a1 + 20);
a2[1] = 0.0;
if ( (_DWORD)result && (int)result > 0 )
{
v3 = (double *)*((_QWORD *)a2 + 6);
v4 = (unsigned int)((_DWORD)result - 1);
result = v3 + 1;
v5 = (__int64)&v3[v4 + 1];
while ( 1 )
{
if ( *v3 < 0.0 )
a2[1] = *v3 + a2[1];
v3 = result;
if ( result == (double *)v5 )
break;
++result;
}
}
return result;
}

canonical_decompiled_code:
double *__fastcall func0(__int64 a1, double *a2)
{
double *result; // rax
double *v3; // rdx
__int64 v4; // rcx
__int64 v5; // rcx

test_problem(*((_QWORD *)a2 + 2), *((_QWORD *)a2 + 4), *((_QWORD *)a2 + 3), *((_QWORD *)a2 + 5), *((_QWORD *)a2 + 6));
result = (double *)*(unsigned int *)(a1 + 20);
a2[1] = 0.0;
if ( (_DWORD)result && (int)result > 0 )
{
v3 = (double *)*((_QWORD *)a2 + 6);
v4 = (unsigned int)((_DWORD)result - 1);
result = v3 + 1;
v5 = (__int64)&v3[v4 + 1];
while ( 1 )
{
if ( *v3 < 0.0 )
a2[1] = *v3 + a2[1];
v3 = result;
if ( result == (double *)v5 )
break;
++result;
}
}
return result;
}

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:
double *__fastcall evaluate_pop(__int64 a1, _QWORD *a2)
{
double *result; // rax
__int64 v4; // rbx
double *v5; // rsi

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

canonical_decompiled_code:
double *__fastcall func1(__int64 a1, _QWORD *a2)
{
double *result; // rax
__int64 v4; // rbx
double *v5; // rsi

result = (double *)*(unsigned int *)(a1 + 24);
if ( (int)result > 0 )
{
v4 = 0LL;
do
{
v5 = (double *)(*a2 + (v4++ << 6));
result = func0(a1, v5);
}
while ( *(_DWORD *)(a1 + 24) > (int)v4 );
}
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)
{
__int64 v7; // [rsp+8h] [rbp-30h]

if ( !*(_DWORD *)(a1 + 8) )
{
if ( !*(_DWORD *)(a1 + 12) )
return;
LABEL_5:
bincross(a1, a2, a3, a4, a5);
return;
}
v7 = a5;
realcross(a1, a2, a3, a4, a5);
a5 = v7;
if ( *(_DWORD *)(a1 + 12) )
goto LABEL_5;
}

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


original_code:
void assign_crowding_distance (NSGA2Type *nsga2Params, population *pop, int *dist, int **obj_array, int front_size)
{
    int i, j;
    for (i=0; i<nsga2Params->nobj; i++)
    {
        for (j=0; j<front_size; j++)
        {
            obj_array[i][j] = dist[j];
        }
        quicksort_front_obj (pop, i, obj_array[i], front_size);
    }
    for (j=0; j<front_size; j++)
    {
        pop->ind[dist[j]].crowd_dist = 0.0;
    }
    for (i=0; i<nsga2Params->nobj; i++)
    {
        pop->ind[obj_array[i][0]].crowd_dist = 1.0e14;
    }
    for (i=0; i<nsga2Params->nobj; i++)
    {
        for (j=1; j<front_size-1; j++)
        {
            if (pop->ind[obj_array[i][j]].crowd_dist != 1.0e14)
            {
                if (pop->ind[obj_array[i][front_size-1]].obj[i] == pop->ind[obj_array[i][0]].obj[i])
                {
                    pop->ind[obj_array[i][j]].crowd_dist += 0.0;
                }
                else
                {
                    pop->ind[obj_array[i][j]].crowd_dist += (pop->ind[obj_array[i][j+1]].obj[i] - pop->ind[obj_array[i][j-1]].obj[i])/(pop->ind[obj_array[i][front_size-1]].obj[i] - pop->ind[obj_array[i][0]].obj[i]);
                }
            }
        }
    }
    for (j=0; j<front_size; j++)
    {
        if (pop->ind[dist[j]].crowd_dist != 1.0e14)
        {
            pop->ind[dist[j]].crowd_dist = (pop->ind[dist[j]].crowd_dist)/nsga2Params->nobj;
        }
    }
    return;
}

canonical_original_code:
void assign_crowding_distance(struct NSGA2Type *nsga2Params, struct population *pop, int *dist, int **obj_array, int front_size)
{
    int i; int j;
    for (i=0; i<nsga2Params->nobj; i++)
    {
        for (j=0; j<front_size; j++)
        {
            obj_array[i][j] = dist[j];
        }
        quicksort_front_obj (pop, i, obj_array[i], front_size);
    }
    for (j=0; j<front_size; j++)
    {
        pop->ind[dist[j]].crowd_dist = 0.0;
    }
    for (i=0; i<nsga2Params->nobj; i++)
    {
        pop->ind[obj_array[i][0]].crowd_dist = 1.0e14;
    }
    for (i=0; i<nsga2Params->nobj; i++)
    {
        for (j=1; j<front_size-1; j++)
        {
            if (pop->ind[obj_array[i][j]].crowd_dist != 1.0e14)
            {
                if (pop->ind[obj_array[i][front_size-1]].obj[i] == pop->ind[obj_array[i][0]].obj[i])
                {
                    pop->ind[obj_array[i][j]].crowd_dist += 0.0;
                }
                else
                {
                    pop->ind[obj_array[i][j]].crowd_dist += (pop->ind[obj_array[i][j+1]].obj[i] - pop->ind[obj_array[i][j-1]].obj[i])/(pop->ind[obj_array[i][front_size-1]].obj[i] - pop->ind[obj_array[i][0]].obj[i]);
                }
            }
        }
    }
    for (j=0; j<front_size; j++)
    {
        if (pop->ind[dist[j]].crowd_dist != 1.0e14)
        {
            pop->ind[dist[j]].crowd_dist = (pop->ind[dist[j]].crowd_dist)/nsga2Params->nobj;
        }
    }
    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


original_code:
void assign_crowding_distance_list (NSGA2Type *nsga2Params, population *pop, list *lst, int front_size)
{
    int **obj_array;
    int *dist;
    int i, j;
    list *temp;
    temp = lst;
    if (front_size==1)
    {
        pop->ind[lst->index].crowd_dist = 1.0e14;
        return;
    }
    if (front_size==2)
    {
        pop->ind[lst->index].crowd_dist = 1.0e14;
        pop->ind[lst->child->index].crowd_dist = 1.0e14;
        return;
    }
    obj_array = (int **)malloc(nsga2Params->nobj*sizeof(int*));
    dist = (int *)malloc(front_size*sizeof(int));
    for (i=0; i<nsga2Params->nobj; i++)
    {
        obj_array[i] = (int *)malloc(front_size*sizeof(int));
    }
    for (j=0; j<front_size; j++)
    {
        dist[j] = temp->index;
        temp = temp->child;
    }
    assign_crowding_distance (nsga2Params, pop, dist, obj_array, front_size);
    free (dist);
    for (i=0; i<nsga2Params->nobj; i++)
    {
        free (obj_array[i]);
    }
    free (obj_array);
    return;
}

canonical_original_code:
void assign_crowding_distance_list(struct NSGA2Type *nsga2Params, struct population *pop, struct lists *lst, int front_size)
{
    int **obj_array;
    int *dist;
    int i; int j;
    struct lists *temp;
    temp = lst;
    if (front_size==1)
    {
        pop->ind[lst->index].crowd_dist = 1.0e14;
        return;
    }
    if (front_size==2)
    {
        pop->ind[lst->index].crowd_dist = 1.0e14;
        pop->ind[lst->child->index].crowd_dist = 1.0e14;
        return;
    }
    obj_array = (int **)malloc(nsga2Params->nobj*sizeof(int *));
    dist = (int *)malloc(front_size*sizeof(int));
    for (i=0; i<nsga2Params->nobj; i++)
    {
        obj_array[i] = (int *)malloc(front_size*sizeof(int));
    }
    for (j=0; j<front_size; j++)
    {
        dist[j] = temp->index;
        temp = temp->child;
    }
    assign_crowding_distance (nsga2Params, pop, dist, obj_array, front_size);
    free (dist);
    for (i=0; i<nsga2Params->nobj; i++)
    {
        free (obj_array[i]);
    }
    free (obj_array);
    return;
}

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


original_code:
void assign_crowding_distance_indices (NSGA2Type *nsga2Params, population *pop, int c1, int c2)
{
    int **obj_array;
    int *dist;
    int i, j;
    int front_size;
    front_size = c2-c1+1;
    if (front_size==1)
    {
        pop->ind[c1].crowd_dist = 1.0e14;
        return;
    }
    if (front_size==2)
    {
        pop->ind[c1].crowd_dist = 1.0e14;
        pop->ind[c2].crowd_dist = 1.0e14;
        return;
    }
    obj_array = (int **)malloc(nsga2Params->nobj*sizeof(int*));
    dist = (int *)malloc(front_size*sizeof(int));
    for (i=0; i<nsga2Params->nobj; i++)
    {
        obj_array[i] = (int *)malloc(front_size*sizeof(int));
    }
    for (j=0; j<front_size; j++)
    {
        dist[j] = c1++;
    }
    assign_crowding_distance(nsga2Params, pop, dist, obj_array, front_size);
    free (dist);
    for (i=0; i<nsga2Params->nobj; i++)
    {
        free (obj_array[i]);
    }
    free (obj_array);
    return;
}

canonical_original_code:
void assign_crowding_distance_indices(struct NSGA2Type *nsga2Params, struct population *pop, int c1, int c2)
{
    int **obj_array;
    int *dist;
    int i; int j;
    int front_size;
    front_size = c2-c1+1;
    if (front_size==1)
    {
        pop->ind[c1].crowd_dist = 1.0e14;
        return;
    }
    if (front_size==2)
    {
        pop->ind[c1].crowd_dist = 1.0e14;
        pop->ind[c2].crowd_dist = 1.0e14;
        return;
    }
    obj_array = (int **)malloc(nsga2Params->nobj*sizeof(int *));
    dist = (int *)malloc(front_size*sizeof(int));
    for (i=0; i<nsga2Params->nobj; i++)
    {
        obj_array[i] = (int *)malloc(front_size*sizeof(int));
    }
    for (j=0; j<front_size; j++)
    {
        dist[j] = c1++;
    }
    assign_crowding_distance(nsga2Params, pop, dist, obj_array, front_size);
    free (dist);
    for (i=0; i<nsga2Params->nobj; i++)
    {
        free (obj_array[i]);
    }
    free (obj_array);
    return;
}


original_code:
void bin_mutate_ind (NSGA2Type *nsga2Params, individual *ind)
{
    int j, k;
    double prob;
    for (j=0; j<nsga2Params->nbin; j++)
    {
        for (k=0; k<nsga2Params->nbits[j]; k++)
        {
            prob = randomperc();
            if (prob <=nsga2Params->pmut_bin)
            {
                if (ind->gene[j][k] == 0)
                {
                    ind->gene[j][k] = 1;
                }
                else
                {
                    ind->gene[j][k] = 0;
                }
                nsga2Params->nbinmut+=1;
            }
        }
    }
    return;
}

canonical_original_code:
void bin_mutate_ind(struct NSGA2Type *nsga2Params, struct individual *ind)
{
    int j; int k;
    double prob;
    for (j=0; j<nsga2Params->nbin; j++)
    {
        for (k=0; k<nsga2Params->nbits[j]; k++)
        {
            prob = randomperc();
            if (prob <=nsga2Params->pmut_bin)
            {
                if (ind->gene[j][k] == 0)
                {
                    ind->gene[j][k] = 1;
                }
                else
                {
                    ind->gene[j][k] = 0;
                }
                nsga2Params->nbinmut+=1;
            }
        }
    }
    return;
}

variable_types: k int

variable_types: prob double