decompiled_code:
__int64 __fastcall options_populate(int argc, char **argv)
{
unsigned int v2; // eax
const char **v3; // rbx
int v4; // xmm0_4
int v5; // xmm0_4
int v6; // xmm0_4
int v7; // xmm0_4
int v8; // xmm0_4
int v9; // xmm0_4
int v10; // xmm0_4
int v11; // xmm0_4
unsigned int v12; // eax
__int64 v13; // r14
int v14; // ebx
__int64 v15; // r15
__int64 v16; // rbx
int *v17; // r13
unsigned __int64 v18; // rax
__int64 v19; // rcx
__int64 v20; // rsi
int v21; // ebp
__int64 v22; // rbx
int v23; // eax
const char **v24; // rbp
const char *v25; // rdi
__int64 v26; // rbx
int v27; // eax
float v28; // xmm0_4
__int64 result; // rax
__int64 v30; // rsi
float v31; // xmm0_4
float v32; // xmm0_4
float v33; // xmm0_4
float v34; // xmm0_4
float v35; // xmm0_4
float v36; // xmm0_4
int v37; // [rsp+Ch] [rbp-3Ch]

options_opt[1] = 0;
*(_QWORD *)&options_opt[10] = 0LL;
*(_QWORD *)&options_opt[2] = 0LL;
options_opt[0] = 0;
*(_QWORD *)&options_opt[4] = 0LL;
options_opt[6] = 0;
options_opt[23] = 0;
options_opt[24] = 1;
*(_QWORD *)&options_opt[26] = 0LL;
options_opt[30] = 0;
*(_QWORD *)&options_opt[32] = 0LL;
options_opt[34] = 10;
options_opt[35] = 1117782016;
options_opt[36] = 1148846080;
options_opt[37] = LC2;
options_opt[38] = 1082130432;
options_opt[39] = 1036831949;
options_opt[40] = LC2;
options_opt[41] = 1084227584;
options_opt[42] = 1077936128;
opterr = 0;
while ( 1 )
{
v2 = getopt(argc, argv, "c:f:l:i:n:t:o:e:r:ad");
if ( v2 == -1 )
break;
switch ( v2 )
{
case '?':
v18 = (unsigned int)(optopt - 99);
if ( (unsigned int)v18 <= 0x11 && (v19 = 137797LL, _bittest64(&v19, v18)) )
die("-%c requires an argument\n", (unsigned int)optopt);
else
die("Unrecognized option -%c\n", (unsigned int)optopt);
break;
case 'a':
options_opt[6] = 1;
break;
case 'c':
v3 = (const char **)split_runstring(optarg);
if ( (unsigned int)size_runstring(v3) != 9 )
{
v12 = size_runstring(v3);
die("Invalid number of control parameters. %d supplied.%d required.\n", v12, 9LL);
}
options_opt[34] = atoi(*v3);
*(float *)&v4 = atof(v3[1]);
options_opt[35] = v4;
*(float *)&v5 = atof(v3[2]);
options_opt[36] = v5;
*(float *)&v6 = atof(v3[3]);
options_opt[37] = v6;
*(float *)&v7 = atof(v3[4]);
options_opt[38] = v7;
*(float *)&v8 = atof(v3[5]);
options_opt[39] = v8;
*(float *)&v9 = atof(v3[6]);
options_opt[40] = v9;
*(float *)&v10 = atof(v3[7]);
options_opt[41] = v10;
*(float *)&v11 = atof(v3[8]);
options_opt[42] = v11;
free_runstring(v3);
break;
case 'd':
options_opt[23] = 1;
break;
case 'e':
*(_QWORD *)&options_opt[10] = optarg;
break;
case 'f':
v13 = split_runstring(optarg);
v14 = size_runstring(v13);
v37 = v14;
*(_QWORD *)&options_opt[32] = malloc(4LL * v14);
if ( v14 > 0 )
{
v15 = 4LL * (unsigned int)v14;
v16 = 0LL;
do
{
v17 = (int *)(*(_QWORD *)&options_opt[32] + v16);
*v17 = atoi(*(const char **)(v13 + 2 * v16));
v16 += 4LL;
}
while ( v15 != v16 );
}
free_runstring(v13);
break;
case 'i':
*(_QWORD *)&options_opt[26] = optarg;
break;
case 'l':
options_opt[30] = atoi(optarg);
break;
case 'n':
options_opt[24] = atoi(optarg);
break;
case 'o':
*(_QWORD *)&options_opt[2] = optarg;
break;
case 'r':
*(_QWORD *)&options_opt[4] = optarg;
break;
case 't':
options_opt[1] = atoi(optarg);
options_opt[0] = 1;
break;
default:
die("Getopt error. Character %d\n", v2);
break;
}
}
if ( optind < argc )
die("Unrecognized non-option arguments\n");
if ( options_opt[0] )
{
v20 = (unsigned int)options_opt[1];
if ( (int)v20 <= 0 )
die("Specify a positive timeout, not %d [s]\n", v20);
}
if ( !*(_QWORD *)&options_opt[10] )
die("Please specify a program to execute with -e\n");
if ( options_opt[24] <= 0 )
die("Please specify a positive number of processes to execute\n");
if ( *(_QWORD *)&options_opt[32] )
{
if ( options_opt[24] != v37 )
die("The number of affinities must matchthe number of processes\n");
v21 = sysconf(84);
if ( v37 > 0 )
{
v22 = 0LL;
do
{
v23 = *(_DWORD *)(*(_QWORD *)&options_opt[32] + v22);
if ( v23 >= v21 || v23 < 0 )
die("Affinities must range in [0,# processors)\n");
v22 += 4LL;
}
while ( v22 != 4LL * (unsigned int)(v37 - 1) + 4 );
}
}
if ( *(_QWORD *)&options_opt[26] )
{
v24 = (const char **)((__int64 (*)(void))split_runstring)();
v25 = *v24;
if ( !*v24 )
goto LABEL_73;
v26 = 1LL;
do
{
v28 = atof(v25);
if ( v28 < 0.0 || v28 > 5.0 )
die("Power supply currents must be between 0 and 5 [A]\n");
else
*(float *)&options_opt[v26 + 27] = v28;
v27 = v26++;
v25 = v24[v26 - 1];
}
while ( v25 );
if ( v27 != 2 )
LABEL_73:
die("Please specify currents for each of the %d power supplies\n", 2LL);
result = free_runstring(v24);
}
else
{
result = die("Please specify initial currents for the power supplies\n");
}
if ( options_opt[30] < 0 )
result = die("Please specify a positive power supply delay [s]\n");
if ( options_opt[0] )
{
result = (unsigned int)options_opt[1];
if ( options_opt[30] > (int)result )
result = die("Power supply delay is greater than timeout time\n");
}
v30 = (unsigned int)options_opt[34];
if ( (int)v30 <= 0 )
result = die("Control interval should be >= 1, not %d\n", v30);
v31 = *(float *)&options_opt[37];
if ( v31 < 0.0 )
result = die("Control minimum current should be >= 0, not %f\n", v31);
v32 = *(float *)&options_opt[38];
if ( v32 < 0.0 )
result = die("Control max current should be >= 0, not %f\n", v32);
v33 = *(float *)&options_opt[39];
if ( v33 < 0.0 )
result = die("Frequency step should be >= 0, not %f\n", v33);
v34 = *(float *)&options_opt[40];
if ( v34 < 0.0 )
result = die("Current step should be >= 0, not %f\n", v34);
v35 = *(float *)&options_opt[41];
if ( v35 < 0.0 )
result = die("T hysteresis should be >= 0, not %f\n", v35);
v36 = *(float *)&options_opt[42];
if ( v36 < 0.0 )
result = die("P hysteresis should be >= 0, not %f\n", v36);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int argc, char **argv)
{
unsigned int v2; // eax
const char **v3; // rbx
int v4; // xmm0_4
int v5; // xmm0_4
int v6; // xmm0_4
int v7; // xmm0_4
int v8; // xmm0_4
int v9; // xmm0_4
int v10; // xmm0_4
int v11; // xmm0_4
unsigned int v12; // eax
__int64 v13; // r14
int v14; // ebx
__int64 v15; // r15
__int64 v16; // rbx
int *v17; // r13
unsigned __int64 v18; // rax
__int64 v19; // rcx
__int64 v20; // rsi
int v21; // ebp
__int64 v22; // rbx
int v23; // eax
const char **v24; // rbp
const char *v25; // rdi
__int64 v26; // rbx
int v27; // eax
float v28; // xmm0_4
__int64 result; // rax
__int64 v30; // rsi
float v31; // xmm0_4
float v32; // xmm0_4
float v33; // xmm0_4
float v34; // xmm0_4
float v35; // xmm0_4
float v36; // xmm0_4
int v37; // [rsp+Ch] [rbp-3Ch]

options_opt[1] = 0;
*(_QWORD *)&options_opt[10] = 0LL;
*(_QWORD *)&options_opt[2] = 0LL;
options_opt[0] = 0;
*(_QWORD *)&options_opt[4] = 0LL;
options_opt[6] = 0;
options_opt[23] = 0;
options_opt[24] = 1;
*(_QWORD *)&options_opt[26] = 0LL;
options_opt[30] = 0;
*(_QWORD *)&options_opt[32] = 0LL;
options_opt[34] = 10;
options_opt[35] = 1117782016;
options_opt[36] = 1148846080;
options_opt[37] = LC2;
options_opt[38] = 1082130432;
options_opt[39] = 1036831949;
options_opt[40] = LC2;
options_opt[41] = 1084227584;
options_opt[42] = 1077936128;
opterr = 0;
while ( 1 )
{
v2 = getopt(argc, argv, "c:f:l:i:n:t:o:e:r:ad");
if ( v2 == -1 )
break;
switch ( v2 )
{
case '?':
v18 = (unsigned int)(optopt - 99);
if ( (unsigned int)v18 <= 0x11 && (v19 = 137797LL, _bittest64(&v19, v18)) )
die("-%c requires an argument\n", (unsigned int)optopt);
else
die("Unrecognized option -%c\n", (unsigned int)optopt);
break;
case 'a':
options_opt[6] = 1;
break;
case 'c':
v3 = (const char **)split_runstring(optarg);
if ( (unsigned int)size_runstring(v3) != 9 )
{
v12 = size_runstring(v3);
die("Invalid number of control parameters. %d supplied.%d required.\n", v12, 9LL);
}
options_opt[34] = atoi(*v3);
*(float *)&v4 = atof(v3[1]);
options_opt[35] = v4;
*(float *)&v5 = atof(v3[2]);
options_opt[36] = v5;
*(float *)&v6 = atof(v3[3]);
options_opt[37] = v6;
*(float *)&v7 = atof(v3[4]);
options_opt[38] = v7;
*(float *)&v8 = atof(v3[5]);
options_opt[39] = v8;
*(float *)&v9 = atof(v3[6]);
options_opt[40] = v9;
*(float *)&v10 = atof(v3[7]);
options_opt[41] = v10;
*(float *)&v11 = atof(v3[8]);
options_opt[42] = v11;
free_runstring(v3);
break;
case 'd':
options_opt[23] = 1;
break;
case 'e':
*(_QWORD *)&options_opt[10] = optarg;
break;
case 'f':
v13 = split_runstring(optarg);
v14 = size_runstring(v13);
v37 = v14;
*(_QWORD *)&options_opt[32] = malloc(4LL * v14);
if ( v14 > 0 )
{
v15 = 4LL * (unsigned int)v14;
v16 = 0LL;
do
{
v17 = (int *)(*(_QWORD *)&options_opt[32] + v16);
*v17 = atoi(*(const char **)(v13 + 2 * v16));
v16 += 4LL;
}
while ( v15 != v16 );
}
free_runstring(v13);
break;
case 'i':
*(_QWORD *)&options_opt[26] = optarg;
break;
case 'l':
options_opt[30] = atoi(optarg);
break;
case 'n':
options_opt[24] = atoi(optarg);
break;
case 'o':
*(_QWORD *)&options_opt[2] = optarg;
break;
case 'r':
*(_QWORD *)&options_opt[4] = optarg;
break;
case 't':
options_opt[1] = atoi(optarg);
options_opt[0] = 1;
break;
default:
die("Getopt error. Character %d\n", v2);
break;
}
}
if ( optind < argc )
die("Unrecognized non-option arguments\n");
if ( options_opt[0] )
{
v20 = (unsigned int)options_opt[1];
if ( (int)v20 <= 0 )
die("Specify a positive timeout, not %d [s]\n", v20);
}
if ( !*(_QWORD *)&options_opt[10] )
die("Please specify a program to execute with -e\n");
if ( options_opt[24] <= 0 )
die("Please specify a positive number of processes to execute\n");
if ( *(_QWORD *)&options_opt[32] )
{
if ( options_opt[24] != v37 )
die("The number of affinities must matchthe number of processes\n");
v21 = sysconf(84);
if ( v37 > 0 )
{
v22 = 0LL;
do
{
v23 = *(_DWORD *)(*(_QWORD *)&options_opt[32] + v22);
if ( v23 >= v21 || v23 < 0 )
die("Affinities must range in [0,# processors)\n");
v22 += 4LL;
}
while ( v22 != 4LL * (unsigned int)(v37 - 1) + 4 );
}
}
if ( *(_QWORD *)&options_opt[26] )
{
v24 = (const char **)((__int64 (*)(void))split_runstring)();
v25 = *v24;
if ( !*v24 )
goto LABEL_73;
v26 = 1LL;
do
{
v28 = atof(v25);
if ( v28 < 0.0 || v28 > 5.0 )
die("Power supply currents must be between 0 and 5 [A]\n");
else
*(float *)&options_opt[v26 + 27] = v28;
v27 = v26++;
v25 = v24[v26 - 1];
}
while ( v25 );
if ( v27 != 2 )
LABEL_73:
die("Please specify currents for each of the %d power supplies\n", 2LL);
result = free_runstring(v24);
}
else
{
result = die("Please specify initial currents for the power supplies\n");
}
if ( options_opt[30] < 0 )
result = die("Please specify a positive power supply delay [s]\n");
if ( options_opt[0] )
{
result = (unsigned int)options_opt[1];
if ( options_opt[30] > (int)result )
result = die("Power supply delay is greater than timeout time\n");
}
v30 = (unsigned int)options_opt[34];
if ( (int)v30 <= 0 )
result = die("Control interval should be >= 1, not %d\n", v30);
v31 = *(float *)&options_opt[37];
if ( v31 < 0.0 )
result = die("Control minimum current should be >= 0, not %f\n", v31);
v32 = *(float *)&options_opt[38];
if ( v32 < 0.0 )
result = die("Control max current should be >= 0, not %f\n", v32);
v33 = *(float *)&options_opt[39];
if ( v33 < 0.0 )
result = die("Frequency step should be >= 0, not %f\n", v33);
v34 = *(float *)&options_opt[40];
if ( v34 < 0.0 )
result = die("Current step should be >= 0, not %f\n", v34);
v35 = *(float *)&options_opt[41];
if ( v35 < 0.0 )
result = die("T hysteresis should be >= 0, not %f\n", v35);
v36 = *(float *)&options_opt[42];
if ( v36 < 0.0 )
result = die("P hysteresis should be >= 0, not %f\n", v36);
return result;
}

original_code:
void options_populate(int argc, char **argv)
{
 options_opt.timeout_sec = 0;
 options_opt.cmd = ((void *)0);
 options_opt.output_file = ((void *)0);
 options_opt.timeout = 0;
 options_opt.error_file = ((void *)0);
 options_opt.append_error = 0;
 options_opt.debug = 0;
 options_opt.num_processes = 1;
 options_opt.pws_current_string = ((void *)0);
 options_opt.pws_delay = 0;
 options_opt.affinities = ((void *)0);
 options_opt.control_params.interval = 10;
 options_opt.control_params.tmax = 80;
 options_opt.control_params.pmax = 1000;
 options_opt.control_params.imin = 0.5;
 options_opt.control_params.imax = 4;
 options_opt.control_params.fstep = 0.1;
 options_opt.control_params.istep = 0.5;
 options_opt.control_params.t_hyst = 5;
 options_opt.control_params.p_hyst = 3;
 opterr = 0;
 int c, i;
 int num_aftys;
 char **aftys;
 char **cont_params;
 while((c = getopt(argc, argv, "c:f:l:i:n:t:o:e:r:ad")) != -1)
 {
  switch(c)
  {
   case 'c':
    cont_params = split_runstring(optarg);
    if(size_runstring(cont_params) != 9)
     die("Invalid number of control parameters. %d supplied."
      "%d required.\n", size_runstring(cont_params),
      9);
    options_opt.control_params.interval = atoi(cont_params[0]);
    options_opt.control_params.tmax = atof(cont_params[1]);
    options_opt.control_params.pmax = atof(cont_params[2]);
    options_opt.control_params.imin = atof(cont_params[3]);
    options_opt.control_params.imax = atof(cont_params[4]);
    options_opt.control_params.fstep = atof(cont_params[5]);
    options_opt.control_params.istep = atof(cont_params[6]);
    options_opt.control_params.t_hyst = atof(cont_params[7]);
    options_opt.control_params.p_hyst = atof(cont_params[8]);
    free_runstring(cont_params);
    break;
   case 'f':
    aftys = split_runstring(optarg);
    num_aftys = size_runstring(aftys);
    options_opt.affinities = (int *)malloc(num_aftys*sizeof(int));
    for(i = 0; i < num_aftys; i++)
    {
     options_opt.affinities[i] = atoi(aftys[i]);
    }
    free_runstring(aftys);
    break;
   case 'l':
    options_opt.pws_delay = atoi(optarg);
    break;
   case 'n':
    options_opt.num_processes = atoi(optarg);
    break;
   case 'd':
    options_opt.debug = 1;
    break;
   case 'a':
    options_opt.append_error = 1;
    break;
   case 'r':
    options_opt.error_file = optarg;
    break;
   case 't':
    options_opt.timeout_sec = atoi(optarg);
    options_opt.timeout = 1;
    break;
   case 'o':
    options_opt.output_file = optarg;
    break;
   case 'e':
    options_opt.cmd = optarg;
    break;
   case 'i':
    options_opt.pws_current_string = optarg;
    break;
   case '?':
    if(optopt == 'e' || optopt == 'o' || optopt == 't' || optopt == 'n' || optopt == 'i' || optopt == 'l' || optopt == 'c')
    {
     die("-%c requires an argument\n", optopt);
    }
    else
    {
     die("Unrecognized option -%c\n", optopt);
    }
    break;
   default:
    die("Getopt error. Character %d\n", c);
  }
 }
 if(optind < argc)
 {
  die("Unrecognized non-option arguments\n");
 }
 if(options_opt.timeout)
 {
  if(options_opt.timeout_sec <= 0)
  {
   die("Specify a positive timeout, not %d [s]\n",
    options_opt.timeout_sec);
  }
 }
 if(options_opt.cmd == ((void *)0))
 {
  die("Please specify a program to execute with -e\n");
 }
 if(options_opt.num_processes < 1)
  die("Please specify a positive number of processes to execute\n");
 if(options_opt.affinities != ((void *)0))
 {
  if(num_aftys != options_opt.num_processes)
  {
   die("The number of affinities must match"
    "the number of processes\n");
  }
  int i;
  int num_procr = (int)sysconf(_SC_NPROCESSORS_ONLN);
  for(i = 0; i < num_aftys; i++)
  {
   if(options_opt.affinities[i] < 0 ||
    options_opt.affinities[i] >= num_procr)
   {
    die("Affinities must range in [0,# processors)\n");
   }
  }
 }
  if(options_opt.pws_current_string != ((void *)0))
  {
   char** values = split_runstring(options_opt.pws_current_string);
   int size = 0;
   while(values[size] != ((void *)0))
   {
    float val = atof(values[size]);
    if(val < 0 || val > 5)
     die("Power supply currents must be between 0 and 5 [A]\n");
    else
     options_opt.pws_current[size] = val;
    size++;
   }
   if(size != 2)
    die("Please specify currents for each of the %d power supplies\n", 2);
   free_runstring(values);
  }
  else
   die("Please specify initial currents for the power supplies\n");
  if(options_opt.pws_delay < 0)
   die("Please specify a positive power supply delay [s]\n");
  if(options_opt.timeout &&
   options_opt.pws_delay > options_opt.timeout_sec)
   die("Power supply delay is greater than timeout time\n");
  if(options_opt.control_params.interval < 1)
   die("Control interval should be >= 1, not %d\n",
    options_opt.control_params.interval);
  if(options_opt.control_params.imin < 0)
   die("Control minimum current should be >= 0, not %f\n",
    options_opt.control_params.imin);
  if(options_opt.control_params.imax < 0)
   die("Control max current should be >= 0, not %f\n",
    options_opt.control_params.imax);
  if(options_opt.control_params.fstep < 0)
   die("Frequency step should be >= 0, not %f\n",
    options_opt.control_params.fstep);
  if(options_opt.control_params.istep < 0)
   die("Current step should be >= 0, not %f\n",
    options_opt.control_params.istep);
  if(options_opt.control_params.t_hyst < 0)
   die("T hysteresis should be >= 0, not %f\n",
    options_opt.control_params.t_hyst);
  if(options_opt.control_params.p_hyst < 0)
   die("P hysteresis should be >= 0, not %f\n",
    options_opt.control_params.p_hyst);
}

canonical_original_code:
void options_populate(int argc, char **argv)
{
 options_opt.timeout_sec = 0;
 options_opt.cmd = ((void *)0);
 options_opt.output_file = ((void *)0);
 options_opt.timeout = 0;
 options_opt.error_file = ((void *)0);
 options_opt.append_error = 0;
 options_opt.debug = 0;
 options_opt.num_processes = 1;
 options_opt.pws_current_string = ((void *)0);
 options_opt.pws_delay = 0;
 options_opt.affinities = ((void *)0);
 options_opt.control_params.interval = 10;
 options_opt.control_params.tmax = 80;
 options_opt.control_params.pmax = 1000;
 options_opt.control_params.imin = 0.5;
 options_opt.control_params.imax = 4;
 options_opt.control_params.fstep = 0.1;
 options_opt.control_params.istep = 0.5;
 options_opt.control_params.t_hyst = 5;
 options_opt.control_params.p_hyst = 3;
 opterr = 0;
 int c; int i;
 int num_aftys;
 char **aftys;
 char **cont_params;
 while((c = getopt(argc, argv, "c:f:l:i:n:t:o:e:r:ad")) != -1)
 {
  switch(c)
  {
   case 'c':
    cont_params = split_runstring(optarg);
    if(size_runstring(cont_params) != 9)
     die("Invalid number of control parameters. %d supplied."
      "%d required.\n", size_runstring(cont_params),
      9);
    options_opt.control_params.interval = atoi(cont_params[0]);
    options_opt.control_params.tmax = atof(cont_params[1]);
    options_opt.control_params.pmax = atof(cont_params[2]);
    options_opt.control_params.imin = atof(cont_params[3]);
    options_opt.control_params.imax = atof(cont_params[4]);
    options_opt.control_params.fstep = atof(cont_params[5]);
    options_opt.control_params.istep = atof(cont_params[6]);
    options_opt.control_params.t_hyst = atof(cont_params[7]);
    options_opt.control_params.p_hyst = atof(cont_params[8]);
    free_runstring(cont_params);
    break;
   case 'f':
    aftys = split_runstring(optarg);
    num_aftys = size_runstring(aftys);
    options_opt.affinities = (int *)malloc(num_aftys*sizeof(int));
    for(i = 0; i < num_aftys; i++)
    {
     options_opt.affinities[i] = atoi(aftys[i]);
    }
    free_runstring(aftys);
    break;
   case 'l':
    options_opt.pws_delay = atoi(optarg);
    break;
   case 'n':
    options_opt.num_processes = atoi(optarg);
    break;
   case 'd':
    options_opt.debug = 1;
    break;
   case 'a':
    options_opt.append_error = 1;
    break;
   case 'r':
    options_opt.error_file = optarg;
    break;
   case 't':
    options_opt.timeout_sec = atoi(optarg);
    options_opt.timeout = 1;
    break;
   case 'o':
    options_opt.output_file = optarg;
    break;
   case 'e':
    options_opt.cmd = optarg;
    break;
   case 'i':
    options_opt.pws_current_string = optarg;
    break;
   case '?':
    if(optopt == 'e' || optopt == 'o' || optopt == 't' || optopt == 'n' || optopt == 'i' || optopt == 'l' || optopt == 'c')
    {
     die("-%c requires an argument\n", optopt);
    }
    else
    {
     die("Unrecognized option -%c\n", optopt);
    }
    break;
   default:
    die("Getopt error. Character %d\n", c);
  }
 }
 if(optind < argc)
 {
  die("Unrecognized non-option arguments\n");
 }
 if(options_opt.timeout)
 {
  if(options_opt.timeout_sec <= 0)
  {
   die("Specify a positive timeout, not %d [s]\n",
    options_opt.timeout_sec);
  }
 }
 if(options_opt.cmd == ((void *)0))
 {
  die("Please specify a program to execute with -e\n");
 }
 if(options_opt.num_processes < 1)
  die("Please specify a positive number of processes to execute\n");
 if(options_opt.affinities != ((void *)0))
 {
  if(num_aftys != options_opt.num_processes)
  {
   die("The number of affinities must match"
    "the number of processes\n");
  }
  int i;
  int num_procr = (int)sysconf(_SC_NPROCESSORS_ONLN);
  for(i = 0; i < num_aftys; i++)
  {
   if(options_opt.affinities[i] < 0 ||
    options_opt.affinities[i] >= num_procr)
   {
    die("Affinities must range in [0,# processors)\n");
   }
  }
 }
  if(options_opt.pws_current_string != ((void *)0))
  {
   char **values = split_runstring(options_opt.pws_current_string);
   int size = 0;
   while(values[size] != ((void *)0))
   {
    float val = atof(values[size]);
    if(val < 0 || val > 5)
     die("Power supply currents must be between 0 and 5 [A]\n");
    else
     options_opt.pws_current[size] = val;
    size++;
   }
   if(size != 2)
    die("Please specify currents for each of the %d power supplies\n", 2);
   free_runstring(values);
  }
  else
   die("Please specify initial currents for the power supplies\n");
  if(options_opt.pws_delay < 0)
   die("Please specify a positive power supply delay [s]\n");
  if(options_opt.timeout &&
   options_opt.pws_delay > options_opt.timeout_sec)
   die("Power supply delay is greater than timeout time\n");
  if(options_opt.control_params.interval < 1)
   die("Control interval should be >= 1, not %d\n",
    options_opt.control_params.interval);
  if(options_opt.control_params.imin < 0)
   die("Control minimum current should be >= 0, not %f\n",
    options_opt.control_params.imin);
  if(options_opt.control_params.imax < 0)
   die("Control max current should be >= 0, not %f\n",
    options_opt.control_params.imax);
  if(options_opt.control_params.fstep < 0)
   die("Frequency step should be >= 0, not %f\n",
    options_opt.control_params.fstep);
  if(options_opt.control_params.istep < 0)
   die("Current step should be >= 0, not %f\n",
    options_opt.control_params.istep);
  if(options_opt.control_params.t_hyst < 0)
   die("T hysteresis should be >= 0, not %f\n",
    options_opt.control_params.t_hyst);
  if(options_opt.control_params.p_hyst < 0)
   die("P hysteresis should be >= 0, not %f\n",
    options_opt.control_params.p_hyst);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: c int

variable_types:
aftys
char **

variable_types:
values
char **

variable_types: size int

variable_types: val float


die

decompiled_code:
void __noreturn die(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
vfprintf(error_file_handle, a1, arg);
fwrite("Program failure\n", 1uLL, 0x10uLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func1(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
vfprintf(error_file_handle, a1, arg);
fwrite("Program failure\n", 1uLL, 0x10uLL, stderr);
exit(1);
}

original_code:
void die(const char *format, ...)
{
 va_list argptr;
 __builtin_va_start(argptr,format);
 vfprintf(error_file_handle, format, argptr);
 __builtin_va_end(argptr);
 fprintf(stderr, "Program failure\n");
 exit(1);
}

canonical_original_code:
void die(char *format, ...)
{
 __builtin_va_list argptr;
 __builtin_va_start(argptr,format);
 vfprintf(error_file_handle, format, argptr);
 __builtin_va_end(argptr);
 fprintf(stderr, "Program failure\n");
 exit(1);
}

variable_types:
format
char *

return_type: void


decompiled_code:
int error_message(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(error_file_handle, format, arg);
}

canonical_decompiled_code:
int func2(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(error_file_handle, format, arg);
}

original_code:
void error_message(const char *format, ...)
{
 va_list argptr;
 __builtin_va_start(argptr,format);
 vfprintf(error_file_handle, format, argptr);
 __builtin_va_end(argptr);
}

canonical_original_code:
void error_message(char *format, ...)
{
 __builtin_va_list argptr;
 __builtin_va_start(argptr,format);
 vfprintf(error_file_handle, format, argptr);
 __builtin_va_end(argptr);
}


decompiled_code:
__int64 debug_message(char *format, ...)
{
__int64 result; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

result = options_opt[23];
if ( (_DWORD)result )
{
va_start(arg, format);
vfprintf(stderr, format, arg);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func3(char *format, ...)
{
__int64 result; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

result = options_opt[23];
if ( (_DWORD)result )
{
va_start(arg, format);
vfprintf(stderr, format, arg);
result = 1LL;
}
return result;
}

original_code:
int debug_message(const char *format, ...)
{
 if(options_opt.debug)
 {
  va_list argptr;
  __builtin_va_start(argptr,format);
  vfprintf(stderr, format, argptr);
  __builtin_va_end(argptr);
  return 1;
 }
 return 0;
}

canonical_original_code:
int debug_message(char *format, ...)
{
 if(options_opt.debug)
 {
  __builtin_va_list argptr;
  __builtin_va_start(argptr,format);
  vfprintf(stderr, format, argptr);
  __builtin_va_end(argptr);
  return 1;
 }
 return 0;
}

return_type: int


decompiled_code:
__int64 __fastcall size_runstring(_QWORD *a1)
{
__int64 v1; // rax
unsigned int v2; // edx

if ( !*a1 )
return 0;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1)
{
__int64 v1; // rax
unsigned int v2; // edx

if ( !*a1 )
return 0;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

original_code:
int size_runstring(char **array)
{
 int offset = 0;
 while(array[offset] != ((void *)0))
 {
  offset++;
 }
 return offset;
}

variable_types:
array
char **

variable_types: offset int


decompiled_code:
void __fastcall free_runstring(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (char *)ptr + 8;
do
{
free(v2);
v3 += 8;
v2 = (void *)*((_QWORD *)v3 - 1);
}
while ( v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func7(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (char *)ptr + 8;
do
{
free(v2);
v3 += 8;
v2 = (void *)*((_QWORD *)v3 - 1);
}
while ( v2 );
}
free(ptr);
}

original_code:
void free_runstring(char **array)
{
 int offset = 0;
 while(array[offset] != ((void *)0))
 {
  free(array[offset]);
  offset++;
 }
 free(array);
}


decompiled_code:
int __fastcall print_runstring(const char **a1)
{
const char **v1; // rax
const char *v2; // rdi
const char **v3; // rbx

v1 = a1;
v2 = *a1;
if ( v2 )
{
v3 = v1 + 1;
do
{
LODWORD(v1) = puts(v2);
v2 = *v3++;
}
while ( v2 );
}
return (int)v1;
}

canonical_decompiled_code:
int __fastcall func8(const char **a1)
{
const char **v1; // rax
const char *v2; // rdi
const char **v3; // rbx

v1 = a1;
v2 = *a1;
if ( v2 )
{
v3 = v1 + 1;
do
{
LODWORD(v1) = puts(v2);
v2 = *v3++;
}
while ( v2 );
}
return (int)v1;
}

original_code:
void print_runstring(char **array)
{
 int offset = 0;
 while(array[offset] != ((void *)0))
 {
  printf("%s\n", array[offset]);
  offset++;
 }
}


repo: ramalho/CBofN

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

if ( a1 >= 0 && rawplot_width > a1 && a2 >= 0 && rawplot_height >= a2 )
{
result = *(_QWORD *)(rawplot_data + 8LL * a1);
*(_BYTE *)(result + a2) = a3;
}
return result;
}

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

if ( a1 >= 0 && rawplot_width > a1 && a2 >= 0 && rawplot_height >= a2 )
{
result = *(_QWORD *)(rawplot_data + 8LL * a1);
*(_BYTE *)(result + a2) = a3;
}
return result;
}

original_code:
void rawplot_point(int i, int j, int val)
{
  if(i < 0 || i >= rawplot_width || j < 0 || j > rawplot_height)
    return;
  rawplot_data[i][j] = val;
}

variable_types: i int

variable_types: j int

variable_types: val int


decompiled_code:
int rawplot_finish()
{
__int64 i; // rbp
int result; // eax
__int64 j; // rbx

for ( i = 0LL; rawplot_height > (int)i; ++i )
{
for ( j = 0LL; rawplot_width > (int)j; ++j )
result = printf(
"%d %d %d\n",
(unsigned int)j,
(unsigned int)i,
*(unsigned __int8 *)(*(_QWORD *)(rawplot_data + 8 * j) + i));
}
return result;
}

canonical_decompiled_code:
int func1()
{
__int64 i; // rbp
int result; // eax
__int64 j; // rbx

for ( i = 0LL; rawplot_height > (int)i; ++i )
{
for ( j = 0LL; rawplot_width > (int)j; ++j )
result = printf(
"%d %d %d\n",
(unsigned int)j,
(unsigned int)i,
*(unsigned __int8 *)(*(_QWORD *)(rawplot_data + 8 * j) + i));
}
return result;
}

original_code:
void rawplot_finish(void)
{
  int i, j;
  for(j = 0; j < rawplot_height; j++)
    for(i = 0; i < rawplot_width; i++)
      printf("%d %d %d\n", i, j, rawplot_data[i][j]);
}

canonical_original_code:
void rawplot_finish()
{
  int i; int j;
  for(j = 0; j < rawplot_height; j++)
    for(i = 0; i < rawplot_width; i++)
      printf("%d %d %d\n", i, j, rawplot_data[i][j]);
}


decompiled_code:
int __fastcall int_to_hexstr(unsigned int a1, char *a2)
{
int result; // eax

result = sprintf(a2, "%2x", a1);
if ( *a2 == 32 )
*a2 = 48;
if ( a2[1] == 32 )
a2[1] = 48;
return result;
}

canonical_decompiled_code:
int __fastcall func1(unsigned int a1, char *a2)
{
int result; // eax

result = sprintf(a2, "%2x", a1);
if ( *a2 == 32 )
*a2 = 48;
if ( a2[1] == 32 )
a2[1] = 48;
return result;
}

original_code:
static void int_to_hexstr(int i, char *str)
{
   sprintf(str, "%2x", i);
   for(i = 0; i < 2; i++)
     if(str[i] == ' ') str[i] = '0';
}

variable_types:
str
char *


original_code:
static inline double hue_shift(double x)
{
  return(x - floor(x));
}

variable_types: x double

return_type: double


decompiled_code:
Window __fastcall X11plot_init(int a1, int a2, int a3)
{
char *v4; // rbx
Display *v5; // rax
int v6; // er14
__int64 v7; // rbx
unsigned __int64 v8; // rcx
__int64 *v9; // rax
unsigned __int64 v10; // rcx
unsigned __int64 *v11; // rax
Window result; // rax
char *v13; // rax
__m128d v14; // xmm0
unsigned int v15; // [rsp+4h] [rbp-74h] BYREF
unsigned int v16; // [rsp+8h] [rbp-70h] BYREF
unsigned int v17; // [rsp+Ch] [rbp-6Ch] BYREF
char s[24]; // [rsp+10h] [rbp-68h] BYREF
char v19[8]; // [rsp+28h] [rbp-50h] BYREF
char v20[8]; // [rsp+30h] [rbp-48h] BYREF
char v21[8]; // [rsp+38h] [rbp-40h] BYREF
XColor v22; // [rsp+40h] [rbp-38h] BYREF

v4 = getenv("DISPLAY");
v5 = XOpenDisplay(v4);
x_display = v5;
if ( !v5 )
{
v13 = XDisplayName(v4);
fprintf(stderr, "X11plot_init: could not open display %s.\n", v13);
exit(1);
}
x_screen = XDefaultScreen(v5);
x_depth = XDefaultDepth(x_display, x_screen);
x_whitepixel = XWhitePixel(x_display, x_screen);
x_blackpixel = XBlackPixel(x_display, x_screen);
x_colormap = XDefaultColormap(x_display, x_screen);
if ( x_depth != 1 )
{
v6 = 1;
v7 = 0LL;
if ( a3 != 2 )
{
while ( 1 )
{
if ( (int)v7 <= 0 )
{
x_colors[v7] = x_blackpixel;
}
else
{
v14 = 0LL;
v14.m128d_f64[0] = (double)(int)v7 / 255.0;
hsb_to_rgb(&v17, &v16, &v15, v14);
int_to_hexstr(v17, v21);
int_to_hexstr(v16, v20);
int_to_hexstr(v15, v19);
sprintf(s, "#%s%s%s", v21, v20, v19);
if ( XParseColor(x_display, x_colormap, s, &v22) )
{
XAllocColor(x_display, x_colormap, &v22);
x_colors[v7] = v22.pixel;
}
else
{
fprintf(stderr, "No such color %s\n", s);
}
if ( v6 > 255 )
goto LABEL_8;
}
++v7;
++v6;
}
}
}
v8 = x_blackpixel;
v9 = x_colors;
do
*v9++ = v8;
while ( v9 != (__int64 *)&unk_E00 );
v10 = x_whitepixel;
v11 = (unsigned __int64 *)&unk_E00;
do
*v11++ = v10;
while ( v11 != &x_whitepixel );
LABEL_8:
x11plot_levels = a3;
result = open_window(a1 * plot_mag, plot_mag * a2);
x_window = result;
return result;
}

canonical_decompiled_code:
Window __fastcall func6(int a1, int a2, int a3)
{
char *v4; // rbx
Display *v5; // rax
int v6; // er14
__int64 v7; // rbx
unsigned __int64 v8; // rcx
__int64 *v9; // rax
unsigned __int64 v10; // rcx
unsigned __int64 *v11; // rax
Window result; // rax
char *v13; // rax
__m128d v14; // xmm0
unsigned int v15; // [rsp+4h] [rbp-74h] BYREF
unsigned int v16; // [rsp+8h] [rbp-70h] BYREF
unsigned int v17; // [rsp+Ch] [rbp-6Ch] BYREF
char s[24]; // [rsp+10h] [rbp-68h] BYREF
char v19[8]; // [rsp+28h] [rbp-50h] BYREF
char v20[8]; // [rsp+30h] [rbp-48h] BYREF
char v21[8]; // [rsp+38h] [rbp-40h] BYREF
XColor v22; // [rsp+40h] [rbp-38h] BYREF

v4 = getenv("DISPLAY");
v5 = XOpenDisplay(v4);
x_display = v5;
if ( !v5 )
{
v13 = XDisplayName(v4);
fprintf(stderr, "X11plot_init: could not open display %s.\n", v13);
exit(1);
}
x_screen = XDefaultScreen(v5);
x_depth = XDefaultDepth(x_display, x_screen);
x_whitepixel = XWhitePixel(x_display, x_screen);
x_blackpixel = XBlackPixel(x_display, x_screen);
x_colormap = XDefaultColormap(x_display, x_screen);
if ( x_depth != 1 )
{
v6 = 1;
v7 = 0LL;
if ( a3 != 2 )
{
while ( 1 )
{
if ( (int)v7 <= 0 )
{
x_colors[v7] = x_blackpixel;
}
else
{
v14 = 0LL;
v14.m128d_f64[0] = (double)(int)v7 / 255.0;
func3(&v17, &v16, &v15, v14);
func1(v17, v21);
func1(v16, v20);
func1(v15, v19);
sprintf(s, "#%s%s%s", v21, v20, v19);
if ( XParseColor(x_display, x_colormap, s, &v22) )
{
XAllocColor(x_display, x_colormap, &v22);
x_colors[v7] = v22.pixel;
}
else
{
fprintf(stderr, "No such color %s\n", s);
}
if ( v6 > 255 )
goto LABEL_8;
}
++v7;
++v6;
}
}
}
v8 = x_blackpixel;
v9 = x_colors;
do
*v9++ = v8;
while ( v9 != (__int64 *)&unk_E00 );
v10 = x_whitepixel;
v11 = (unsigned __int64 *)&unk_E00;
do
*v11++ = v10;
while ( v11 != &x_whitepixel );
LABEL_8:
x11plot_levels = a3;
result = func5(a1 * plot_mag, plot_mag * a2);
x_window = result;
return result;
}

original_code:
void X11plot_init(int width, int height, int levels)
{
  XColor x_hardwarecolor;
  char hexR[8], hexG[8], hexB[8], name[16], *display;
  int status, i, R, G, B;
  double hue;
  display = getenv("DISPLAY");
  if((x_display = XOpenDisplay(display)) == ((void *)0)) {
    fprintf(stderr, "X11plot_init: could not open display %s.\n",
            XDisplayName(display));
    exit(1);
  }
  x_screen = XDefaultScreen(x_display);
  x_depth = XDefaultDepth(x_display, x_screen);
  x_whitepixel = XWhitePixel(x_display, x_screen);
  x_blackpixel = XBlackPixel(x_display, x_screen);
  x_colormap = XDefaultColormap(x_display, x_screen);
  if(x_depth == 1 || levels == 2) {
    for(i = 0; i < 256 / 2; i++) x_colors[i] = x_blackpixel;
    for(i = 256 / 2; i < 256; i++) x_colors[i] = x_whitepixel;
  }
  else {
    for(i = 0; i < 256; i++) {
      if(i > 0) {
        hue = i / (256 - 1.0);
        hsb_to_rgb(hue, &R, &G, &B);
        int_to_hexstr(R, hexR);
        int_to_hexstr(G, hexG);
        int_to_hexstr(B, hexB);
        sprintf(name,"#%s%s%s", hexR, hexG, hexB);
        status = XParseColor(x_display, x_colormap, name, &x_hardwarecolor);
        if (status != 0) {
          status = XAllocColor(x_display, x_colormap, &x_hardwarecolor);
          x_colors[i] = x_hardwarecolor.pixel;
        }
        else
          fprintf(stderr, "No such color %s\n", name);
      }
      else
        x_colors[i] = x_blackpixel;
    }
  }
  x11plot_width = width;
  x11plot_height = height;
  x11plot_levels = levels;
  x_window = open_window(width * plot_mag, height * plot_mag);
}

canonical_original_code:
void X11plot_init(int width, int height, int levels)
{
  struct XColor x_hardwarecolor;
  char hexR[8]; char hexG[8]; char hexB[8]; char name[16]; char *display;
  int status; int i; int R; int G; int B;
  double hue;
  display = getenv("DISPLAY");
  if((x_display = XOpenDisplay(display)) == ((void *)0)) {
    fprintf(stderr, "X11plot_init: could not open display %s.\n",
            XDisplayName(display));
    exit(1);
  }
  x_screen = XDefaultScreen(x_display);
  x_depth = XDefaultDepth(x_display, x_screen);
  x_whitepixel = XWhitePixel(x_display, x_screen);
  x_blackpixel = XBlackPixel(x_display, x_screen);
  x_colormap = XDefaultColormap(x_display, x_screen);
  if(x_depth == 1 || levels == 2) {
    for(i = 0; i < 256 / 2; i++) x_colors[i] = x_blackpixel;
    for(i = 256 / 2; i < 256; i++) x_colors[i] = x_whitepixel;
  }
  else {
    for(i = 0; i < 256; i++) {
      if(i > 0) {
        hue = i / (256 - 1.0);
        hsb_to_rgb(hue, &R, &G, &B);
        int_to_hexstr(R, hexR);
        int_to_hexstr(G, hexG);
        int_to_hexstr(B, hexB);
        sprintf(name,"#%s%s%s", hexR, hexG, hexB);
        status = XParseColor(x_display, x_colormap, name, &x_hardwarecolor);
        if (status != 0) {
          status = XAllocColor(x_display, x_colormap, &x_hardwarecolor);
          x_colors[i] = x_hardwarecolor.pixel;
        }
        else
          fprintf(stderr, "No such color %s\n", name);
      }
      else
        x_colors[i] = x_blackpixel;
    }
  }
  x11plot_width = width;
  x11plot_height = height;
  x11plot_levels = levels;
  x_window = open_window(width * plot_mag, height * plot_mag);
}

variable_types: width int

variable_types: height int

variable_types: levels int

variable_types: struct XColor { unsigned long pixel; unsigned short red; char flags; char pad; }

variable_types:
hexR
char [8]

variable_types:
hexG
char [8]

variable_types:
hexB
char [8]

variable_types:
name
char [16]

variable_types:
display
char *

variable_types: status int

variable_types: R int

variable_types: G int

variable_types: B int

variable_types: hue double


decompiled_code:
int __fastcall X11plot_point(int a1, int a2, int a3)
{
int result; // eax
int i; // ebp
int j; // ebx
int v6; // ecx

if ( a3 < 0 )
{
a3 = 0;
}
else if ( x11plot_levels <= a3 )
{
a3 = x11plot_levels - 1;
}
result = XSetForeground(x_display, x_gc, x_colors[(int)((double)a3 / (double)(x11plot_levels - 1) * 255.0 + 0.5)]);
for ( i = 0; plot_mag > i; ++i )
{
v6 = plot_mag;
for ( j = 0; plot_mag > j; v6 = plot_mag )
result = XDrawPoint(x_display, x_window, x_gc, i + a1 * v6, v6 * a2 + j++);
}
if ( x11_force_flush )
result = XFlush(x_display);
return result;
}

canonical_decompiled_code:
int __fastcall func7(int a1, int a2, int a3)
{
int result; // eax
int i; // ebp
int j; // ebx
int v6; // ecx

if ( a3 < 0 )
{
a3 = 0;
}
else if ( x11plot_levels <= a3 )
{
a3 = x11plot_levels - 1;
}
result = XSetForeground(x_display, x_gc, x_colors[(int)((double)a3 / (double)(x11plot_levels - 1) * 255.0 + 0.5)]);
for ( i = 0; plot_mag > i; ++i )
{
v6 = plot_mag;
for ( j = 0; plot_mag > j; v6 = plot_mag )
result = XDrawPoint(x_display, x_window, x_gc, i + a1 * v6, v6 * a2 + j++);
}
if ( x11_force_flush )
result = XFlush(x_display);
return result;
}

original_code:
void X11plot_point(int i, int j, int val)
{
  int cval, ii, jj;
  val = (val < 0) ? 0 : (val >= x11plot_levels) ? x11plot_levels - 1: val;
  cval = ((double)val / (x11plot_levels - 1)) * (256 - 1) + 0.5;
  XSetForeground(x_display, x_gc, x_colors[cval]);
  for(ii = 0; ii < plot_mag; ii++)
    for(jj = 0; jj < plot_mag; jj++)
      XDrawPoint(x_display, x_window, x_gc, i * plot_mag + ii,
                 j * plot_mag + jj);
  if(x11_force_flush) XFlush(x_display);
}

canonical_original_code:
void X11plot_point(int i, int j, int val)
{
  int cval; int ii; int jj;
  val = (val < 0) ? 0 : (val >= x11plot_levels) ? x11plot_levels - 1: val;
  cval = ((double)val / (x11plot_levels - 1)) * (256 - 1) + 0.5;
  XSetForeground(x_display, x_gc, x_colors[cval]);
  for(ii = 0; ii < plot_mag; ii++)
    for(jj = 0; jj < plot_mag; jj++)
      XDrawPoint(x_display, x_window, x_gc, i * plot_mag + ii,
                 j * plot_mag + jj);
  if(x11_force_flush) XFlush(x_display);
}

variable_types: i int

variable_types: j int

variable_types: val int

variable_types: cval int

variable_types: ii int

variable_types: jj int


decompiled_code:
int __fastcall X11plot_line(int a1, int a2, int a3, int a4, int a5)
{
int v6; // er15
int v7; // ebp
signed int v8; // eax
int v9; // ebx
int result; // eax
double v11; // [rsp+8h] [rbp-50h]

v6 = 0;
if ( a5 >= 0 )
{
if ( x11plot_levels <= a5 )
a5 = x11plot_levels;
v6 = a5;
}
XSetForeground(x_display, x_gc, x_colors[(int)((double)v6 / (double)x11plot_levels * 255.0 + 0.5)]);
if ( plot_mag == 1 )
return XDrawLine(x_display, x_window, x_gc, a1, a2, a3, a4);
if ( a1 == a3 && a2 == a4 )
return X11plot_point(a1, a2, v6);
v7 = abs32(a2 - a4);
v8 = abs32(a1 - a3);
if ( v7 < v8 )
v7 = v8;
v11 = 0.0;
v9 = 0;
do
{
result = X11plot_point(
(int)((double)a1 * v11 + (double)a3 * (1.0 - v11) + 0.5),
(int)((double)a4 * (1.0 - v11) + (double)a2 * v11 + 0.5),
v6);
++v9;
v11 = v11 + 1.0 / (double)v7;
}
while ( v7 >= v9 );
return result;
}

canonical_decompiled_code:
int __fastcall func8(int a1, int a2, int a3, int a4, int a5)
{
int v6; // er15
int v7; // ebp
signed int v8; // eax
int v9; // ebx
int result; // eax
double v11; // [rsp+8h] [rbp-50h]

v6 = 0;
if ( a5 >= 0 )
{
if ( x11plot_levels <= a5 )
a5 = x11plot_levels;
v6 = a5;
}
XSetForeground(x_display, x_gc, x_colors[(int)((double)v6 / (double)x11plot_levels * 255.0 + 0.5)]);
if ( plot_mag == 1 )
return XDrawLine(x_display, x_window, x_gc, a1, a2, a3, a4);
if ( a1 == a3 && a2 == a4 )
return func7(a1, a2, v6);
v7 = abs32(a2 - a4);
v8 = abs32(a1 - a3);
if ( v7 < v8 )
v7 = v8;
v11 = 0.0;
v9 = 0;
do
{
result = func7(
(int)((double)a1 * v11 + (double)a3 * (1.0 - v11) + 0.5),
(int)((double)a4 * (1.0 - v11) + (double)a2 * v11 + 0.5),
v6);
++v9;
v11 = v11 + 1.0 / (double)v7;
}
while ( v7 >= v9 );
return result;
}

original_code:
void X11plot_line(int i, int j, int k, int l, int val)
{
  int cval, ii, jj;
  val = (val < 0) ? 0 : (val >= x11plot_levels) ? x11plot_levels : val;
  cval = ((double)val / x11plot_levels) * (256 - 1) + 0.5;
  XSetForeground(x_display, x_gc, x_colors[cval]);
  if(plot_mag == 1)
    XDrawLine(x_display, x_window, x_gc, i, j, k, l);
  else {
    double tx, ty, t, dt;
    int len;
    if(i == k && j == l)
      X11plot_point(i, j, val);
    else {
      len = ((((i - k) >= 0 ? (i - k) : -(i - k))) > (((j - l) >= 0 ? (j - l) : -(j - l))) ? (((i - k) >= 0 ? (i - k) : -(i - k))) : (((j - l) >= 0 ? (j - l) : -(j - l))));
      dt = 1.0 / len;
      for(ii = 0, t = 0.0; ii < len + 1; ii++, t += dt) {
        tx = t * i + (1.0 - t) * k + 0.5;
        ty = t * j + (1.0 - t) * l + 0.5;
        X11plot_point(tx, ty, val);
      }
    }
  }
}

canonical_original_code:
void X11plot_line(int i, int j, int k, int l, int val)
{
  int cval; int ii; int jj;
  val = (val < 0) ? 0 : (val >= x11plot_levels) ? x11plot_levels : val;
  cval = ((double)val / x11plot_levels) * (256 - 1) + 0.5;
  XSetForeground(x_display, x_gc, x_colors[cval]);
  if(plot_mag == 1)
    XDrawLine(x_display, x_window, x_gc, i, j, k, l);
  else {
    double tx; double ty; double t; double dt;
    int len;
    if(i == k && j == l)
      X11plot_point(i, j, val);
    else {
      len = ((((i - k) >= 0 ? (i - k) : -(i - k))) > (((j - l) >= 0 ? (j - l) : -(j - l))) ? (((i - k) >= 0 ? (i - k) : -(i - k))) : (((j - l) >= 0 ? (j - l) : -(j - l))));
      dt = 1.0 / len;
      for(ii = 0, t = 0.0; ii < len + 1; ii++, t += dt) {
        tx = t * i + (1.0 - t) * k + 0.5;
        ty = t * j + (1.0 - t) * l + 0.5;
        X11plot_point(tx, ty, val);
      }
    }
  }
}

variable_types: k int

variable_types: l int

variable_types: tx double

variable_types: ty double

variable_types: t double

variable_types: dt double

variable_types: len int


decompiled_code:
__int64 __fastcall plot_line_internal(__int64 a1, __int64 a2, int a3, int a4, unsigned int a5)
{
__int64 result; // rax
int v8; // ebp
signed int v9; // eax
int v10; // ebx
double v11; // [rsp+8h] [rbp-50h]

if ( (_DWORD)a1 == a3 && (_DWORD)a2 == a4 )
return plot_point(a1, a2, a5);
v8 = abs32(a2 - a4);
v9 = abs32(a1 - a3);
if ( v8 < v9 )
v8 = v9;
v10 = 0;
v11 = 0.0;
do
{
result = plot_point(
(unsigned int)(int)((double)(int)a1 * v11 + (double)a3 * (1.0 - v11) + 0.5),
(unsigned int)(int)((double)a4 * (1.0 - v11) + (double)(int)a2 * v11 + 0.5),
a5);
++v10;
v11 = v11 + 1.0 / (double)v8;
}
while ( v8 >= v10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3, int a4, unsigned int a5)
{
__int64 result; // rax
int v8; // ebp
signed int v9; // eax
int v10; // ebx
double v11; // [rsp+8h] [rbp-50h]

if ( (_DWORD)a1 == a3 && (_DWORD)a2 == a4 )
return func8(a1, a2, a5);
v8 = abs32(a2 - a4);
v9 = abs32(a1 - a3);
if ( v8 < v9 )
v8 = v9;
v10 = 0;
v11 = 0.0;
do
{
result = func8(
(unsigned int)(int)((double)(int)a1 * v11 + (double)a3 * (1.0 - v11) + 0.5),
(unsigned int)(int)((double)a4 * (1.0 - v11) + (double)(int)a2 * v11 + 0.5),
a5);
++v10;
v11 = v11 + 1.0 / (double)v8;
}
while ( v8 >= v10 );
return result;
}

original_code:
static void plot_line_internal(int ax, int ay, int bx, int by, int val)
{
  double tx, ty, t, dt;
  int len, i;
  if(ax == bx && ay == by)
    _plot_point(ax, ay, val);
  else {
    len = ((((ax - bx) >= 0 ? (ax - bx) : -(ax - bx))) > (((ay - by) >= 0 ? (ay - by) : -(ay - by))) ? (((ax - bx) >= 0 ? (ax - bx) : -(ax - bx))) : (((ay - by) >= 0 ? (ay - by) : -(ay - by))));
    dt = 1.0 / len;
    for(i = 0, t = 0.0; i < len + 1; i++, t += dt) {
      tx = t * ax + (1.0 - t) * bx + 0.5;
      ty = t * ay + (1.0 - t) * by + 0.5;
      _plot_point(tx, ty, val);
    }
  }
}

canonical_original_code:
static void plot_line_internal(int ax, int ay, int bx, int by, int val)
{
  double tx; double ty; double t; double dt;
  int len; int i;
  if(ax == bx && ay == by)
    _plot_point(ax, ay, val);
  else {
    len = ((((ax - bx) >= 0 ? (ax - bx) : -(ax - bx))) > (((ay - by) >= 0 ? (ay - by) : -(ay - by))) ? (((ax - bx) >= 0 ? (ax - bx) : -(ax - bx))) : (((ay - by) >= 0 ? (ay - by) : -(ay - by))));
    dt = 1.0 / len;
    for(i = 0, t = 0.0; i < len + 1; i++, t += dt) {
      tx = t * ax + (1.0 - t) * bx + 0.5;
      ty = t * ay + (1.0 - t) * by + 0.5;
      _plot_point(tx, ty, val);
    }
  }
}

variable_types: ax int

variable_types: ay int

variable_types: bx int

variable_types: by int


decompiled_code:
void none_init()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
static void none_init(int width, int height, int levels)
{
}

variable_types: width int

variable_types: height int

variable_types: levels int


decompiled_code:
void none_point()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
static void none_point(int i, int j, int val)
{
}

variable_types: i int

variable_types: j int

variable_types: val int


decompiled_code:
void none_line()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
static void none_line(int ax, int ay, int bx, int by, int val)
{
}


decompiled_code:
void none_finish()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
static void none_finish(void)
{
}

canonical_original_code:
static void none_finish()
{
}


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

if ( !a4 )
goto LABEL_8;
if ( !strcmp(a4, "x11") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&x11plot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&x11plot_point;
plot_line = (__int64)&x11plot_line;
plot_finish = (__int64)&x11plot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))x11plot_init)(a1, a2, a3);
LABEL_4:
plot_levels = a3;
plot_width = a1;
plot_height = a2;
plot_xmin = 0LL;
*(double *)&plot_xmax = (double)(int)(a1 - 1);
*(double *)&plot_ymin = (double)(int)(a2 - 1);
plot_ymax = 0LL;
return result;
}
if ( !strcmp(a4, "X11") )
{
LABEL_8:
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&X11plot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&X11plot_point;
plot_line = (__int64)&X11plot_line;
plot_finish = (__int64)&X11plot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))X11plot_init)(a1, a2, a3);
goto LABEL_4;
}
if ( !strcmp(a4, "ps") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&psplot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&psplot_point;
plot_line = (__int64)&psplot_line;
plot_finish = (__int64)&psplot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))psplot_init)(a1, a2, a3);
goto LABEL_4;
}
if ( !strcmp(a4, "pgm") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&pgmplot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&pgmplot_point;
plot_line = (__int64)plot_line_internal;
plot_finish = (__int64)&pgmplot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))pgmplot_init)(a1, a2, a3);
goto LABEL_4;
}
if ( !strcmp(a4, "raw") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&rawplot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&rawplot_point;
plot_line = (__int64)plot_line_internal;
plot_finish = (__int64)&rawplot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))rawplot_init)(a1, a2, a3);
goto LABEL_4;
}
if ( !strcmp(a4, "none") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))none_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))none_point;
plot_line = (__int64)none_line;
plot_finish = (__int64)none_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))none_init)(a1, a2, a3);
goto LABEL_4;
}
return plot_init(a1, a2, a3, "X11");
}

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

if ( !a4 )
goto LABEL_8;
if ( !strcmp(a4, "x11") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&x11plot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&x11plot_point;
plot_line = (__int64)&x11plot_line;
plot_finish = (__int64)&x11plot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))x11plot_init)(a1, a2, a3);
LABEL_4:
plot_levels = a3;
plot_width = a1;
plot_height = a2;
plot_xmin = 0LL;
*(double *)&plot_xmax = (double)(int)(a1 - 1);
*(double *)&plot_ymin = (double)(int)(a2 - 1);
plot_ymax = 0LL;
return result;
}
if ( !strcmp(a4, "X11") )
{
LABEL_8:
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&X11plot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&X11plot_point;
plot_line = (__int64)&X11plot_line;
plot_finish = (__int64)&X11plot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))X11plot_init)(a1, a2, a3);
goto LABEL_4;
}
if ( !strcmp(a4, "ps") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&psplot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&psplot_point;
plot_line = (__int64)&psplot_line;
plot_finish = (__int64)&psplot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))psplot_init)(a1, a2, a3);
goto LABEL_4;
}
if ( !strcmp(a4, "pgm") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&pgmplot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&pgmplot_point;
plot_line = (__int64)plot_line_internal;
plot_finish = (__int64)&pgmplot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))pgmplot_init)(a1, a2, a3);
goto LABEL_4;
}
if ( !strcmp(a4, "raw") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&rawplot_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))&rawplot_point;
plot_line = (__int64)plot_line_internal;
plot_finish = (__int64)&rawplot_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))rawplot_init)(a1, a2, a3);
goto LABEL_4;
}
if ( !strcmp(a4, "none") )
{
plot_init = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))none_init;
plot_point = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))none_point;
plot_line = (__int64)none_line;
plot_finish = (__int64)none_finish;
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))none_init)(a1, a2, a3);
goto LABEL_4;
}
return func5(a1, a2, a3, "X11");
}

original_code:
void plot_init(int width, int height, int levels, char *term)
{
  if(!term) term = term_default;
  if(0) ;
  else if(strcmp(term, "x11") == 0) {
    _plot_init = x11plot_init;
    _plot_point = x11plot_point;
    _plot_line = x11plot_line;
    _plot_finish = x11plot_finish;
  }
  else if(strcmp(term, "X11") == 0) {
    _plot_init = X11plot_init;
    _plot_point = X11plot_point;
    _plot_line = X11plot_line;
    _plot_finish = X11plot_finish;
  }
  else if(strcmp(term, "ps") == 0) {
    _plot_init = psplot_init;
    _plot_point = psplot_point;
    _plot_line = psplot_line;
    _plot_finish = psplot_finish;
  }
  else if(strcmp(term, "pgm") == 0) {
    _plot_init = pgmplot_init;
    _plot_point = pgmplot_point;
    _plot_line = plot_line_internal;
    _plot_finish = pgmplot_finish;
  }
  else if(strcmp(term, "raw") == 0) {
    _plot_init = rawplot_init;
    _plot_point = rawplot_point;
    _plot_line = plot_line_internal;
    _plot_finish = rawplot_finish;
  }
  else if(strcmp(term, "none") == 0) {
    _plot_init = none_init;
    _plot_point = none_point;
    _plot_line = none_line;
    _plot_finish = none_finish;
  }
  else {
    plot_init(width, height, levels, term_default);
    return;
  }
  _plot_init(width, height, levels);
  plot_levels = levels;
  plot_width = width;
  plot_height = height;
  plot_xmin = 0.0;
  plot_xmax = width - 1;
  plot_ymin = height - 1;
  plot_ymax = 0.0;
}

variable_types:
term
char *


decompiled_code:
void __fastcall plot_set_range(double a1, double a2, double a3, double a4)
{
plot_xmin = *(_QWORD *)&a1;
plot_xmax = *(_QWORD *)&a2;
plot_ymin = *(_QWORD *)&a3;
plot_ymax = *(_QWORD *)&a4;
}

canonical_decompiled_code:
void __fastcall func6(double a1, double a2, double a3, double a4)
{
plot_xmin = *(_QWORD *)&a1;
plot_xmax = *(_QWORD *)&a2;
plot_ymin = *(_QWORD *)&a3;
plot_ymax = *(_QWORD *)&a4;
}

original_code:
void plot_set_range(double xmin, double xmax, double ymin, double ymax)
{
  plot_xmin = xmin;
  plot_xmax = xmax;
  plot_ymin = ymin;
  plot_ymax = ymax;
}

variable_types: xmin double

variable_types: xmax double

variable_types: ymin double

variable_types: ymax double


decompiled_code:
__int64 plot_set_all()
{
unsigned int v0; // ebx
__int64 result; // rax

if ( plot_width > 0 )
{
v0 = 0;
do
{
result = plot_line(v0, 0LL, v0, (unsigned int)(plot_height - 1));
++v0;
}
while ( plot_width > (int)v0 );
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v0; // ebx
__int64 result; // rax

if ( plot_width > 0 )
{
v0 = 0;
do
{
result = func9(v0, 0LL, v0, (unsigned int)(plot_height - 1));
++v0;
}
while ( plot_width > (int)v0 );
}
return result;
}

original_code:
void plot_set_all(int val)
{
  int i;
  for(i = 0; i < plot_width; i++)
    _plot_line(i, 0, i, plot_height - 1, (plot_inverse ? ((plot_levels - 1) - (val)) : (val)));
}


decompiled_code:
__int64 __fastcall plot_point(unsigned int a1, double a2, double a3)
{
int v4; // edi
__int64 v5; // rdi
double v6; // xmm0_8
__int64 v7; // rsi
__int64 result; // rax

if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v4 = (int)*(double *)&plot_xmin;
else
v4 = (int)((a2 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v5 = v4 - (unsigned int)(plot_width == v4);
v6 = *(double *)&plot_ymin;
if ( *(double *)&plot_ymax != *(double *)&plot_ymin )
v6 = ((*(double *)&plot_ymin - a3) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0) * (double)plot_height;
v7 = (int)v6 - (unsigned int)(plot_height == (int)v6);
result = (int)v7 >= 0;
if ( ((unsigned __int8)result & ((int)v5 >= 0 && plot_width > (int)v5)) != 0 && plot_height > (int)v7 )
{
if ( plot_inverse )
a1 = plot_levels + ~a1;
result = plot_point(v5, v7, a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, double a2, double a3)
{
int v4; // edi
__int64 v5; // rdi
double v6; // xmm0_8
__int64 v7; // rsi
__int64 result; // rax

if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v4 = (int)*(double *)&plot_xmin;
else
v4 = (int)((a2 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v5 = v4 - (unsigned int)(plot_width == v4);
v6 = *(double *)&plot_ymin;
if ( *(double *)&plot_ymax != *(double *)&plot_ymin )
v6 = ((*(double *)&plot_ymin - a3) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0) * (double)plot_height;
v7 = (int)v6 - (unsigned int)(plot_height == (int)v6);
result = (int)v7 >= 0;
if ( ((unsigned __int8)result & ((int)v5 >= 0 && plot_width > (int)v5)) != 0 && plot_height > (int)v7 )
{
if ( plot_inverse )
a1 = plot_levels + ~a1;
result = func8(v5, v7, a1);
}
return result;
}

original_code:
void plot_point(double x, double y, int val)
{
  int xi, yi;
  xi = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((x) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); xi = (((xi) == plot_width) ? ((xi) - 1) : (xi));
  yi = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (y)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); yi = (((yi) == plot_height) ? ((yi) - 1) : (yi));
  if(!(xi < 0 || xi >= plot_width || yi < 0 || yi >= plot_height))
    _plot_point(xi, yi, (plot_inverse ? ((plot_levels - 1) - (val)) : (val)));
}

canonical_original_code:
void plot_point(double x, double y, int val)
{
  int xi; int yi;
  xi = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((x) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); xi = (((xi) == plot_width) ? ((xi) - 1) : (xi));
  yi = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (y)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); yi = (((yi) == plot_height) ? ((yi) - 1) : (yi));
  if(!(xi < 0 || xi >= plot_width || yi < 0 || yi >= plot_height))
    _plot_point(xi, yi, (plot_inverse ? ((plot_levels - 1) - (val)) : (val)));
}

variable_types: x double

variable_types: y double

variable_types: xi int

variable_types: yi int


decompiled_code:
__int64 __fastcall plot_line(double a1, double a2, double a3, double a4)
{
int v4; // edi
__int64 v5; // rdi
double v6; // xmm0_8
int v7; // esi
__int64 v8; // rsi
int v9; // edx
__int64 v10; // rdx

if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v4 = (int)*(double *)&plot_xmin;
else
v4 = (int)((a1 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v5 = v4 - (unsigned int)(plot_width == v4);
v6 = *(double *)&plot_ymin;
if ( *(double *)&plot_ymax == *(double *)&plot_ymin )
v7 = (int)*(double *)&plot_ymin;
else
v7 = (int)(((*(double *)&plot_ymin - a2) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0)
* (double)plot_height);
v8 = v7 - (unsigned int)(plot_height == v7);
if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v9 = (int)*(double *)&plot_xmin;
else
v9 = (int)((a3 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v10 = v9 - (unsigned int)(plot_width == v9);
if ( *(double *)&plot_ymax != *(double *)&plot_ymin )
v6 = ((*(double *)&plot_ymin - a4) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0) * (double)plot_height;
return plot_line(v5, v8, v10, (int)v6 - (unsigned int)(plot_height == (int)v6));
}

canonical_decompiled_code:
__int64 __fastcall func9(double a1, double a2, double a3, double a4)
{
int v4; // edi
__int64 v5; // rdi
double v6; // xmm0_8
int v7; // esi
__int64 v8; // rsi
int v9; // edx
__int64 v10; // rdx

if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v4 = (int)*(double *)&plot_xmin;
else
v4 = (int)((a1 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v5 = v4 - (unsigned int)(plot_width == v4);
v6 = *(double *)&plot_ymin;
if ( *(double *)&plot_ymax == *(double *)&plot_ymin )
v7 = (int)*(double *)&plot_ymin;
else
v7 = (int)(((*(double *)&plot_ymin - a2) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0)
* (double)plot_height);
v8 = v7 - (unsigned int)(plot_height == v7);
if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v9 = (int)*(double *)&plot_xmin;
else
v9 = (int)((a3 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v10 = v9 - (unsigned int)(plot_width == v9);
if ( *(double *)&plot_ymax != *(double *)&plot_ymin )
v6 = ((*(double *)&plot_ymin - a4) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0) * (double)plot_height;
return func9(v5, v8, v10, (int)v6 - (unsigned int)(plot_height == (int)v6));
}

original_code:
void plot_line(double x1, double y1, double x2, double y2, int val)
{
  int ax, ay, bx, by;
  ax = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((x1) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); ax = (((ax) == plot_width) ? ((ax) - 1) : (ax));
  ay = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (y1)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); ay = (((ay) == plot_height) ? ((ay) - 1) : (ay));
  bx = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((x2) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); bx = (((bx) == plot_width) ? ((bx) - 1) : (bx));
  by = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (y2)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); by = (((by) == plot_height) ? ((by) - 1) : (by));
  _plot_line(ax, ay, bx, by, (plot_inverse ? ((plot_levels - 1) - (val)) : (val)));
}

canonical_original_code:
void plot_line(double x1, double y1, double x2, double y2, int val)
{
  int ax; int ay; int bx; int by;
  ax = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((x1) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); ax = (((ax) == plot_width) ? ((ax) - 1) : (ax));
  ay = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (y1)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); ay = (((ay) == plot_height) ? ((ay) - 1) : (ay));
  bx = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((x2) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); bx = (((bx) == plot_width) ? ((bx) - 1) : (bx));
  by = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (y2)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); by = (((by) == plot_height) ? ((by) - 1) : (by));
  _plot_line(ax, ay, bx, by, (plot_inverse ? ((plot_levels - 1) - (val)) : (val)));
}

variable_types: ax int

variable_types: ay int

variable_types: bx int


decompiled_code:
__int64 plot_finish()
{
return plot_finish();
}

canonical_decompiled_code:
__int64 func10()
{
return func10();
}

original_code:
void plot_finish(void)
{
  _plot_finish();
}

canonical_original_code:
void plot_finish()
{
  _plot_finish();
}


decompiled_code:
__int64 __fastcall plot_box(int a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm0_8
int v6; // er15
unsigned int v7; // er15
int i; // ebx
unsigned int v9; // ebp
unsigned int v10; // er15
unsigned int v11; // er12
unsigned int v12; // ebp
unsigned int v13; // ebx
int v15; // [rsp+0h] [rbp-48h]
unsigned int v16; // [rsp+0h] [rbp-48h]
int v17; // [rsp+4h] [rbp-44h]
unsigned int v18; // [rsp+4h] [rbp-44h]
unsigned int v19; // [rsp+8h] [rbp-40h]

if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v15 = (int)*(double *)&plot_xmin;
else
v15 = (int)((a2 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v16 = v15 - (plot_width == v15);
v5 = *(double *)&plot_ymin;
if ( *(double *)&plot_ymax == *(double *)&plot_ymin )
v6 = (int)*(double *)&plot_ymin;
else
v6 = (int)(((*(double *)&plot_ymin - a3) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0)
* (double)plot_height);
v7 = v6 - (plot_height == v6);
if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v17 = (int)*(double *)&plot_xmin;
else
v17 = (int)((a4 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v18 = v17 - (plot_width == v17);
if ( *(double *)&plot_ymax != *(double *)&plot_ymin )
v5 = ((*(double *)&plot_ymin - a5) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0) * (double)plot_height;
v19 = (int)v5 - (plot_height == (int)v5);
plot_line(v16, v7, v18, v7);
plot_line(v18, v7, v18, v19);
plot_line(v18, v19, v16, v19);
plot_line(v16, v19, v16, v7);
if ( a1 <= 0 )
{
i = 1;
}
else
{
for ( i = 1; i <= a1; ++i )
{
plot_line(v16 - i, v7 - i, v18 + i, v7 - i);
v9 = v19 + i;
plot_line(v18 + i, v7 - i, v18 + i, v19 + i);
plot_line(v18 + i, v9, v16 - i, v9);
plot_line(v16 - i, v9, v16 - i, v7 - i);
}
}
v10 = v7 - i;
v11 = i + v18;
v12 = v16 - i;
plot_line(v16 - i, v10, i + v18, v10);
v13 = v19 + i;
plot_line(v11, v10, v11, v13);
plot_line(v11, v13, v12, v13);
return plot_line(v12, v13, v12, v10);
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm0_8
int v6; // er15
unsigned int v7; // er15
int i; // ebx
unsigned int v9; // ebp
unsigned int v10; // er15
unsigned int v11; // er12
unsigned int v12; // ebp
unsigned int v13; // ebx
int v15; // [rsp+0h] [rbp-48h]
unsigned int v16; // [rsp+0h] [rbp-48h]
int v17; // [rsp+4h] [rbp-44h]
unsigned int v18; // [rsp+4h] [rbp-44h]
unsigned int v19; // [rsp+8h] [rbp-40h]

if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v15 = (int)*(double *)&plot_xmin;
else
v15 = (int)((a2 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v16 = v15 - (plot_width == v15);
v5 = *(double *)&plot_ymin;
if ( *(double *)&plot_ymax == *(double *)&plot_ymin )
v6 = (int)*(double *)&plot_ymin;
else
v6 = (int)(((*(double *)&plot_ymin - a3) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0)
* (double)plot_height);
v7 = v6 - (plot_height == v6);
if ( *(double *)&plot_xmax == *(double *)&plot_xmin )
v17 = (int)*(double *)&plot_xmin;
else
v17 = (int)((a4 - *(double *)&plot_xmin) / (*(double *)&plot_xmax - *(double *)&plot_xmin) * (double)plot_width);
v18 = v17 - (plot_width == v17);
if ( *(double *)&plot_ymax != *(double *)&plot_ymin )
v5 = ((*(double *)&plot_ymin - a5) / (*(double *)&plot_ymax - *(double *)&plot_ymin) + 1.0) * (double)plot_height;
v19 = (int)v5 - (plot_height == (int)v5);
func9(v16, v7, v18, v7);
func9(v18, v7, v18, v19);
func9(v18, v19, v16, v19);
func9(v16, v19, v16, v7);
if ( a1 <= 0 )
{
i = 1;
}
else
{
for ( i = 1; i <= a1; ++i )
{
func9(v16 - i, v7 - i, v18 + i, v7 - i);
v9 = v19 + i;
func9(v18 + i, v7 - i, v18 + i, v19 + i);
func9(v18 + i, v9, v16 - i, v9);
func9(v16 - i, v9, v16 - i, v7 - i);
}
}
v10 = v7 - i;
v11 = i + v18;
v12 = v16 - i;
func9(v16 - i, v10, i + v18, v10);
v13 = v19 + i;
func9(v11, v10, v11, v13);
func9(v11, v13, v12, v13);
return func9(v12, v13, v12, v10);
}

original_code:
void plot_box(double ulx, double uly, double lrx, double lry, int lwidth)
{
  int i, ulxi, ulyi, lrxi, lryi;
  ulxi = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((ulx) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); ulxi = (((ulxi) == plot_width) ? ((ulxi) - 1) : (ulxi));
  ulyi = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (uly)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); ulyi = (((ulyi) == plot_height) ? ((ulyi) - 1) : (ulyi));
  lrxi = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((lrx) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); lrxi = (((lrxi) == plot_width) ? ((lrxi) - 1) : (lrxi));
  lryi = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (lry)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); lryi = (((lryi) == plot_height) ? ((lryi) - 1) : (lryi));
  _plot_line(ulxi, ulyi, lrxi, ulyi, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(lrxi, ulyi, lrxi, lryi, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(lrxi, lryi, ulxi, lryi, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(ulxi, lryi, ulxi, ulyi, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  for(i = 1; i < lwidth + 1; i++) {
    _plot_line(ulxi - i, ulyi - i, lrxi + i, ulyi - i, (plot_inverse ? ((plot_levels - 1) - (0)) : (0)));
    _plot_line(lrxi + i, ulyi - i, lrxi + i, lryi + i, (plot_inverse ? ((plot_levels - 1) - (0)) : (0)));
    _plot_line(lrxi + i, lryi + i, ulxi - i, lryi + i, (plot_inverse ? ((plot_levels - 1) - (0)) : (0)));
    _plot_line(ulxi - i, lryi + i, ulxi - i, ulyi - i, (plot_inverse ? ((plot_levels - 1) - (0)) : (0)));
  }
  _plot_line(ulxi - i, ulyi - i, lrxi + i, ulyi - i, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(lrxi + i, ulyi - i, lrxi + i, lryi + i, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(lrxi + i, lryi + i, ulxi - i, lryi + i, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(ulxi - i, lryi + i, ulxi - i, ulyi - i, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
}

canonical_original_code:
void plot_box(double ulx, double uly, double lrx, double lry, int lwidth)
{
  int i; int ulxi; int ulyi; int lrxi; int lryi;
  ulxi = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((ulx) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); ulxi = (((ulxi) == plot_width) ? ((ulxi) - 1) : (ulxi));
  ulyi = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (uly)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); ulyi = (((ulyi) == plot_height) ? ((ulyi) - 1) : (ulyi));
  lrxi = ((int) (plot_xmax == plot_xmin) ? plot_xmin : ((((lrx) - plot_xmin) / (plot_xmax - plot_xmin)) * plot_width)); lrxi = (((lrxi) == plot_width) ? ((lrxi) - 1) : (lrxi));
  lryi = ((int) (plot_ymax == plot_ymin) ? plot_ymin : (((plot_ymin - (lry)) / (plot_ymax - plot_ymin) + 1.0) * plot_height)); lryi = (((lryi) == plot_height) ? ((lryi) - 1) : (lryi));
  _plot_line(ulxi, ulyi, lrxi, ulyi, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(lrxi, ulyi, lrxi, lryi, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(lrxi, lryi, ulxi, lryi, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(ulxi, lryi, ulxi, ulyi, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  for(i = 1; i < lwidth + 1; i++) {
    _plot_line(ulxi - i, ulyi - i, lrxi + i, ulyi - i, (plot_inverse ? ((plot_levels - 1) - (0)) : (0)));
    _plot_line(lrxi + i, ulyi - i, lrxi + i, lryi + i, (plot_inverse ? ((plot_levels - 1) - (0)) : (0)));
    _plot_line(lrxi + i, lryi + i, ulxi - i, lryi + i, (plot_inverse ? ((plot_levels - 1) - (0)) : (0)));
    _plot_line(ulxi - i, lryi + i, ulxi - i, ulyi - i, (plot_inverse ? ((plot_levels - 1) - (0)) : (0)));
  }
  _plot_line(ulxi - i, ulyi - i, lrxi + i, ulyi - i, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(lrxi + i, ulyi - i, lrxi + i, lryi + i, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(lrxi + i, lryi + i, ulxi - i, lryi + i, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
  _plot_line(ulxi - i, lryi + i, ulxi - i, ulyi - i, (plot_inverse ? ((plot_levels - 1) - (plot_levels - 1)) : (plot_levels - 1)));
}

variable_types: ulx double

variable_types: uly double

variable_types: lrx double

variable_types: lry double

variable_types: lwidth int

variable_types: ulxi int

variable_types: ulyi int

variable_types: lrxi int

variable_types: lryi int


flog

decompiled_code:
double __fastcall flog(double a1, double a2)
{
return a2 * 4.0 * a1 * (1.0 - a1);
}

canonical_decompiled_code:
double __fastcall func1(double a1, double a2)
{
return a2 * 4.0 * a1 * (1.0 - a1);
}

original_code:
double flog(double x, double r)
{
  return(4.0 * r * x * (1.0 - x));
}

variable_types: r double


fgauss

decompiled_code:
double __fastcall fgauss(double a1, double a2)
{
return exp(COERCE_DOUBLE(aux ^ LC4) * (a1 - 0.5) * (a1 - 0.5)) * a2;
}

canonical_decompiled_code:
double __fastcall func3(double a1, double a2)
{
return exp(COERCE_DOUBLE(aux ^ LC4) * (a1 - 0.5) * (a1 - 0.5)) * a2;
}

original_code:
double fgauss(double x, double r)
{
  return(r * exp(-aux * (x - 0.5) * (x - 0.5)));
}

variable_types: x double


original_code:
void plot_arrow(double x1, double y1, double x2, double y2)
{
  double xm, ym, off;
  off = 0.01;
  xm = (x1 + x2) / 2.0; ym = (y1 + y2) / 2.0;
  if(x1 == x2 && fabs(y1 - y2) > off && y2 > y1) {
    plot_line(xm, ym, xm - off, ym - off, 1);
    plot_line(xm, ym, xm + off, ym - off, 1);
    plot_line(xm - off, ym - off, xm + off, ym - off, 1);
  }
  else if(x1 == x2 && fabs(y1 - y2) > off && y1 > y2) {
    plot_line(xm, ym, xm - off, ym + off, 1);
    plot_line(xm, ym, xm + off, ym + off, 1);
    plot_line(xm - off, ym + off, xm + off, ym + off, 1);
  }
  else if(y1 == y2 && fabs(x1 - x2) > off && x2 > x1) {
    plot_line(xm, ym, xm - off, ym - off, 1);
    plot_line(xm, ym, xm - off, ym + off, 1);
    plot_line(xm - off, ym - off, xm - off, ym + off, 1);
  }
  else if(y1 == y2 && fabs(x1 - x2) > off && x1 > x2) {
    plot_line(xm, ym, xm + off, ym - off, 1);
    plot_line(xm, ym, xm + off, ym + off, 1);
    plot_line(xm + off, ym - off, xm + off, ym + off, 1);
  }
}

canonical_original_code:
void plot_arrow(double x1, double y1, double x2, double y2)
{
  double xm; double ym; double off;
  off = 0.01;
  xm = (x1 + x2) / 2.0; ym = (y1 + y2) / 2.0;
  if(x1 == x2 && fabs(y1 - y2) > off && y2 > y1) {
    plot_line(xm, ym, xm - off, ym - off, 1);
    plot_line(xm, ym, xm + off, ym - off, 1);
    plot_line(xm - off, ym - off, xm + off, ym - off, 1);
  }
  else if(x1 == x2 && fabs(y1 - y2) > off && y1 > y2) {
    plot_line(xm, ym, xm - off, ym + off, 1);
    plot_line(xm, ym, xm + off, ym + off, 1);
    plot_line(xm - off, ym + off, xm + off, ym + off, 1);
  }
  else if(y1 == y2 && fabs(x1 - x2) > off && x2 > x1) {
    plot_line(xm, ym, xm - off, ym - off, 1);
    plot_line(xm, ym, xm - off, ym + off, 1);
    plot_line(xm - off, ym - off, xm - off, ym + off, 1);
  }
  else if(y1 == y2 && fabs(x1 - x2) > off && x1 > x2) {
    plot_line(xm, ym, xm + off, ym - off, 1);
    plot_line(xm, ym, xm + off, ym + off, 1);
    plot_line(xm + off, ym - off, xm + off, ym + off, 1);
  }
}

variable_types: xm double

variable_types: ym double

variable_types: off double


rparse

original_code:
int rparse(char **argv, int argc, OPTION *options, int *cargc, int opt)
{
  int i, len;
  char letter;
  if(argc == *cargc) return(1);
  len = strlen(argv[*cargc + 1]);
  for(i = 0; i < len; i++)
    if(argv[*cargc + 1][i] >= 'A' && argv[*cargc + 1][i] <= 'Z')
      argv[*cargc + 1][i] = argv[*cargc + 1][i] - 'A' + 'a';
  letter = argv[*cargc + 1][0];
  if(letter < 'a' || letter > 'z' || argv[*cargc + 1][1] != '=')
    return(1);
  rules[letter - 'a'] = &argv[*cargc + 1][2];
  *cargc += 2;
  return(0);
}

canonical_original_code:
int rparse(char **argv, int argc, struct OPTION *options, int *cargc, int opt)
{
  int i; int len;
  char letter;
  if(argc == *cargc) return(1);
  len = strlen(argv[*cargc + 1]);
  for(i = 0; i < len; i++)
    if(argv[*cargc + 1][i] >= 'A' && argv[*cargc + 1][i] <= 'Z')
      argv[*cargc + 1][i] = argv[*cargc + 1][i] - 'A' + 'a';
  letter = argv[*cargc + 1][0];
  if(letter < 'a' || letter > 'z' || argv[*cargc + 1][1] != '=')
    return(1);
  rules[letter - 'a'] = &argv[*cargc + 1][2];
  *cargc += 2;
  return(0);
}

variable_types:
argv
char **

variable_types: argc int

variable_types: struct OPTION { char *name; enum OPT_TYPE { OPT_INT=0, OPT_DOUBLE=1, OPT_STRING=2, OPT_SWITCH=3, OPT_OTHER=4, OPT_NULL=5 } type; void *ptr; char *help; } *

variable_types:
cargc
int *

variable_types: opt int

variable_types: i int

variable_types: len int

variable_types: letter char

user_defined_types: struct OPTION { char *name; enum OPT_TYPE type; void *ptr; char *help; }


decompiled_code:
void __fastcall compute_figure(__int64 a1, int a2, unsigned int a3)
{
__int64 v3; // r13
__int64 v5; // rdx
int v6; // er14
int v7; // er12
int i; // ebx
_BYTE *v9; // rbp
int v10; // eax
__int64 v11; // rsi
double v12; // xmm0_8
__int64 v13; // rdx
double v14; // xmm0_8
int v15; // ecx
int v16; // er8
int v17; // esi
int v18; // esi
int v19; // eax
int v20; // esi
int v21; // eax
double v22; // xmm0_8
__int64 v23; // rbp
__int64 v24; // r12
char v25; // cl
int v26; // eax
__int64 v28; // [rsp+10h] [rbp-48h]
double v29; // [rsp+10h] [rbp-48h]
__int64 v30; // [rsp+10h] [rbp-48h]
double v31; // [rsp+18h] [rbp-40h]
__int64 v32; // [rsp+18h] [rbp-40h]

if ( a1 )
{
v3 = a1;
v6 = strlen((const char *)a1);
if ( v6 > 0 )
{
v7 = 0;
for ( i = 0; v6 > i; ++i )
{
v9 = (_BYTE *)(v3 + i);
v10 = (unsigned __int8)*v9;
v11 = (unsigned int)(v10 - 97);
if ( (unsigned __int8)(v10 - 97) <= 0x19u || (_BYTE)v10 == 124 )
{
if ( (_BYTE)v10 == 124 || a2 <= 0 )
{
if ( (unsigned __int8)(v10 - 102) > 1u && (_BYTE)v10 != 124 )
continue;
LOBYTE(v5) = (_BYTE)v10 == 124;
v12 = random_range(a1, v11, v5, -1.0, 1.0);
v29 = sin(v12 * *(double *)&unoise + *(double *)&a) * *(double *)&s + *(double *)&x;
v14 = random_range(a1, v11, v13, -1.0, 1.0);
v31 = cos(v14 * *(double *)&unoise + *(double *)&a) * *(double *)&s + *(double *)&y;
if ( *v9 != 102 && *v9 != 124 )
goto LABEL_16;
v5 = (unsigned int)(int)((double)width * *(double *)&x + 0.5);
a1 = (unsigned int)(int)(*(double *)&y * (double)height + 0.5);
v15 = (int)((double)width * v29 + 0.5);
v16 = (int)((double)height * v31 + 0.5);
if ( a3 )
{
v17 = (int)((double)width * *(double *)&x + 0.5);
if ( maxx >= (int)v5 )
v17 = maxx;
if ( v17 < v15 )
v17 = (int)((double)width * v29 + 0.5);
maxx = v17;
if ( (int)a1 < v16 )
{
v18 = height - a1;
if ( maxy >= height - (int)a1 )
v18 = maxy;
maxy = v18;
if ( minx <= (int)v5 )
v5 = (unsigned int)minx;
if ( (int)v5 > v15 )
v5 = (unsigned int)v15;
minx = v5;
goto LABEL_30;
}
v20 = height - v16;
if ( maxy >= height - v16 )
v20 = maxy;
maxy = v20;
if ( minx <= (int)v5 )
v5 = (unsigned int)minx;
if ( (int)v5 > v15 )
v5 = (unsigned int)v15;
minx = v5;
if ( (int)a1 <= v16 )
LABEL_30:
v19 = height - v16;
else
v19 = height - a1;
if ( miny <= v19 )
v19 = miny;
miny = v19;
}
else
{
v21 = height - a1;
a1 = 1LL;
plot_line(1LL, (double)(int)v5, (double)v21, (double)v15, (double)(height - v16));
}
LABEL_16:
x = *(_QWORD *)&v29;
y = *(_QWORD *)&v31;
continue;
}
v28 = s;
*(double *)&s = *(double *)&s * *(double *)&qword_9C0;
a1 = rules[(char)*v9 - 97];
compute_figure(a1, (unsigned int)(a2 - 1), a3);
s = v28;
}
else if ( (unsigned __int8)(v10 - 48) > 9u )
{
v5 = (unsigned int)(v10 - 43);
if ( (((_BYTE)v10 - 43) & 0xFD) != 0 )
{
if ( (_BYTE)v10 == 91 )
{
v23 = x;
v24 = y;
v30 = a;
v32 = s;
a1 = v3 + i + 1;
compute_figure(a1, (unsigned int)a2, a3);
x = v23;
y = v24;
a = v30;
s = v32;
v5 = i + 1;
v7 = 1;
do
{
i = v5;
v25 = *(_BYTE *)(v3 + v5);
v26 = 1;
if ( v25 != 91 )
v26 = -(v25 == 93);
++v5;
v7 += v26;
}
while ( v7 );
}
else if ( (_BYTE)v10 == 93 )
{
return;
}
}
else
{
v5 = 1LL;
if ( !v7 )
v7 = 1;
if ( (_BYTE)v10 == 43 )
v22 = (double)v7 * *(double *)&da;
else
v22 = COERCE_DOUBLE(da ^ LC3) * (double)v7;
*(double *)&a = v22 + *(double *)&a;
v7 = 0;
}
}
else
{
v5 = (unsigned int)(5 * v7);
v7 = (char)v10 + 10 * v7 - 48;
}
}
}
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, int a2, unsigned int a3)
{
__int64 v3; // r13
__int64 v5; // rdx
int v6; // er14
int v7; // er12
int i; // ebx
_BYTE *v9; // rbp
int v10; // eax
__int64 v11; // rsi
double v12; // xmm0_8
__int64 v13; // rdx
double v14; // xmm0_8
int v15; // ecx
int v16; // er8
int v17; // esi
int v18; // esi
int v19; // eax
int v20; // esi
int v21; // eax
double v22; // xmm0_8
__int64 v23; // rbp
__int64 v24; // r12
char v25; // cl
int v26; // eax
__int64 v28; // [rsp+10h] [rbp-48h]
double v29; // [rsp+10h] [rbp-48h]
__int64 v30; // [rsp+10h] [rbp-48h]
double v31; // [rsp+18h] [rbp-40h]
__int64 v32; // [rsp+18h] [rbp-40h]

if ( a1 )
{
v3 = a1;
v6 = strlen((const char *)a1);
if ( v6 > 0 )
{
v7 = 0;
for ( i = 0; v6 > i; ++i )
{
v9 = (_BYTE *)(v3 + i);
v10 = (unsigned __int8)*v9;
v11 = (unsigned int)(v10 - 97);
if ( (unsigned __int8)(v10 - 97) <= 0x19u || (_BYTE)v10 == 124 )
{
if ( (_BYTE)v10 == 124 || a2 <= 0 )
{
if ( (unsigned __int8)(v10 - 102) > 1u && (_BYTE)v10 != 124 )
continue;
LOBYTE(v5) = (_BYTE)v10 == 124;
v12 = random_range(a1, v11, v5, -1.0, 1.0);
v29 = sin(v12 * *(double *)&unoise + *(double *)&a) * *(double *)&s + *(double *)&x;
v14 = random_range(a1, v11, v13, -1.0, 1.0);
v31 = cos(v14 * *(double *)&unoise + *(double *)&a) * *(double *)&s + *(double *)&y;
if ( *v9 != 102 && *v9 != 124 )
goto LABEL_16;
v5 = (unsigned int)(int)((double)width * *(double *)&x + 0.5);
a1 = (unsigned int)(int)(*(double *)&y * (double)height + 0.5);
v15 = (int)((double)width * v29 + 0.5);
v16 = (int)((double)height * v31 + 0.5);
if ( a3 )
{
v17 = (int)((double)width * *(double *)&x + 0.5);
if ( maxx >= (int)v5 )
v17 = maxx;
if ( v17 < v15 )
v17 = (int)((double)width * v29 + 0.5);
maxx = v17;
if ( (int)a1 < v16 )
{
v18 = height - a1;
if ( maxy >= height - (int)a1 )
v18 = maxy;
maxy = v18;
if ( minx <= (int)v5 )
v5 = (unsigned int)minx;
if ( (int)v5 > v15 )
v5 = (unsigned int)v15;
minx = v5;
goto LABEL_30;
}
v20 = height - v16;
if ( maxy >= height - v16 )
v20 = maxy;
maxy = v20;
if ( minx <= (int)v5 )
v5 = (unsigned int)minx;
if ( (int)v5 > v15 )
v5 = (unsigned int)v15;
minx = v5;
if ( (int)a1 <= v16 )
LABEL_30:
v19 = height - v16;
else
v19 = height - a1;
if ( miny <= v19 )
v19 = miny;
miny = v19;
}
else
{
v21 = height - a1;
a1 = 1LL;
plot_line(1LL, (double)(int)v5, (double)v21, (double)v15, (double)(height - v16));
}
LABEL_16:
x = *(_QWORD *)&v29;
y = *(_QWORD *)&v31;
continue;
}
v28 = s;
*(double *)&s = *(double *)&s * *(double *)&qword_9C0;
a1 = rules[(char)*v9 - 97];
func1(a1, (unsigned int)(a2 - 1), a3);
s = v28;
}
else if ( (unsigned __int8)(v10 - 48) > 9u )
{
v5 = (unsigned int)(v10 - 43);
if ( (((_BYTE)v10 - 43) & 0xFD) != 0 )
{
if ( (_BYTE)v10 == 91 )
{
v23 = x;
v24 = y;
v30 = a;
v32 = s;
a1 = v3 + i + 1;
func1(a1, (unsigned int)a2, a3);
x = v23;
y = v24;
a = v30;
s = v32;
v5 = i + 1;
v7 = 1;
do
{
i = v5;
v25 = *(_BYTE *)(v3 + v5);
v26 = 1;
if ( v25 != 91 )
v26 = -(v25 == 93);
++v5;
v7 += v26;
}
while ( v7 );
}
else if ( (_BYTE)v10 == 93 )
{
return;
}
}
else
{
v5 = 1LL;
if ( !v7 )
v7 = 1;
if ( (_BYTE)v10 == 43 )
v22 = (double)v7 * *(double *)&da;
else
v22 = COERCE_DOUBLE(da ^ LC3) * (double)v7;
*(double *)&a = v22 + *(double *)&a;
v7 = 0;
}
}
else
{
v5 = (unsigned int)(5 * v7);
v7 = (char)v10 + 10 * v7 - 48;
}
}
}
}
}

original_code:
void compute_figure(char *rule, int d, int calcbounds)
{
  double sx, sy, sa, ss;
  int len, i, ax, ay, bx, by, num;
  num = 0;
  len = (rule != ((void *)0)) ? strlen(rule) : 0;
  for(i = 0; i < len; i++) {
    if((rule[i] >= 'a' && rule[i] <= 'z') || rule[i] == '|') {
      if(d > 0 && rule[i] != '|') {
        ss = s; s *= ds;
        compute_figure(rules[rule[i] - 'a'], d - 1, calcbounds);
        s = ss;
      }
      else if(rule[i] == 'f' || rule[i] == 'g' || rule[i] == '|') {
        sx = x + sin(a + unoise * random_range(-1.0, 1.0)) * s;
        sy = y + cos(a + unoise * random_range(-1.0, 1.0)) * s;
        if(rule[i] == 'f' || rule[i] == '|') {
          ax = width * x + 0.5;
          ay = height * y + 0.5;
          bx = width * sx + 0.5;
          by = height * sy + 0.5;
          if(calcbounds) {
            maxx = ((maxx) > (((ax) > (bx) ? (ax) : (bx))) ? (maxx) : (((ax) > (bx) ? (ax) : (bx))));
            maxy = ((maxy) > (((height - ay) > (height - by) ? (height - ay) : (height - by))) ? (maxy) : (((height - ay) > (height - by) ? (height - ay) : (height - by))));
            minx = ((minx) < (((ax) < (bx) ? (ax) : (bx))) ? (minx) : (((ax) < (bx) ? (ax) : (bx))));
            miny = ((miny) < (((height - ay) < (height - by) ? (height - ay) : (height - by))) ? (miny) : (((height - ay) < (height - by) ? (height - ay) : (height - by))));
          }
          else
            plot_line(ax, height - ay, bx, height - by, 1);
        }
        x = sx; y = sy;
      }
    }
    else if(rule[i] >= '0' && rule[i] <= '9')
      num = num * 10 + (rule[i] - '0');
    else if(rule[i] == '+' || rule[i] == '-') {
      num = (num == 0) ? 1 : num;
      a += (rule[i] == '+') ? num * da : num * -da;
      num = 0;
    }
    else if(rule[i] == '[') {
      sx = x; sy = y; sa = a, ss = s;
      compute_figure(rule + i + 1, d, calcbounds);
      x = sx; y = sy; a = sa; s = ss; num = 1;
      do {
        i++;
        num = num + ((rule[i] == '[') ? 1 : (rule[i] == ']') ? -1 : 0);
      } while(num != 0);
    }
    else if(rule[i] == ']') return;
  }
}

canonical_original_code:
void compute_figure(char *rule, int d, int calcbounds)
{
  double sx; double sy; double sa; double ss;
  int len; int i; int ax; int ay; int bx; int by; int num;
  num = 0;
  len = (rule != ((void *)0)) ? strlen(rule) : 0;
  for(i = 0; i < len; i++) {
    if((rule[i] >= 'a' && rule[i] <= 'z') || rule[i] == '|') {
      if(d > 0 && rule[i] != '|') {
        ss = s; s *= ds;
        compute_figure(rules[rule[i] - 'a'], d - 1, calcbounds);
        s = ss;
      }
      else if(rule[i] == 'f' || rule[i] == 'g' || rule[i] == '|') {
        sx = x + sin(a + unoise * random_range(-1.0, 1.0)) * s;
        sy = y + cos(a + unoise * random_range(-1.0, 1.0)) * s;
        if(rule[i] == 'f' || rule[i] == '|') {
          ax = width * x + 0.5;
          ay = height * y + 0.5;
          bx = width * sx + 0.5;
          by = height * sy + 0.5;
          if(calcbounds) {
            maxx = ((maxx) > (((ax) > (bx) ? (ax) : (bx))) ? (maxx) : (((ax) > (bx) ? (ax) : (bx))));
            maxy = ((maxy) > (((height - ay) > (height - by) ? (height - ay) : (height - by))) ? (maxy) : (((height - ay) > (height - by) ? (height - ay) : (height - by))));
            minx = ((minx) < (((ax) < (bx) ? (ax) : (bx))) ? (minx) : (((ax) < (bx) ? (ax) : (bx))));
            miny = ((miny) < (((height - ay) < (height - by) ? (height - ay) : (height - by))) ? (miny) : (((height - ay) < (height - by) ? (height - ay) : (height - by))));
          }
          else
            plot_line(ax, height - ay, bx, height - by, 1);
        }
        x = sx; y = sy;
      }
    }
    else if(rule[i] >= '0' && rule[i] <= '9')
      num = num * 10 + (rule[i] - '0');
    else if(rule[i] == '+' || rule[i] == '-') {
      num = (num == 0) ? 1 : num;
      a += (rule[i] == '+') ? num * da : num * -da;
      num = 0;
    }
    else if(rule[i] == '[') {
      sx = x; sy = y; sa = a, ss = s;
      compute_figure(rule + i + 1, d, calcbounds);
      x = sx; y = sy; a = sa; s = ss; num = 1;
      do {
        i++;
        num = num + ((rule[i] == '[') ? 1 : (rule[i] == ']') ? -1 : 0);
      } while(num != 0);
    }
    else if(rule[i] == ']') return;
  }
}

variable_types:
rule
char *

variable_types: d int

variable_types: calcbounds int

variable_types: sx double

variable_types: sy double

variable_types: sa double

variable_types: ss double

variable_types: ax int

variable_types: ay int

variable_types: bx int

variable_types: by int

variable_types: num int


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
_WORD *v3; // rdx
__int64 i; // rax
int v5; // eax
__int64 v6; // rdi
__int64 j; // rax
char v8; // dl
double v9; // xmm0_8
double v10; // xmm1_8
double v11; // xmm6_8

v3 = &stubs;
for ( i = 0LL; i != 26; ++i )
{
*v3 = (unsigned __int8)(i + 97);
rules[i] = (__int64)v3++;
}
get_options(argc, argv, &options, help_string);
plot_mag = mag;
plot_inverse = invert;
v5 = strlen(axiom);
if ( v5 > 0 )
{
v6 = (unsigned int)(v5 - 1);
for ( j = 0LL; ; ++j )
{
v8 = axiom[j];
if ( (unsigned __int8)(v8 - 65) <= 0x19u )
axiom[j] = v8 + 32;
if ( j == v6 )
break;
}
}
*(double *)&aa0 = 3.141592653589793 * *(double *)&aa0 / 180.0;
*(double *)&da = 3.141592653589793 * *(double *)&da / 180.0;
plot_init((unsigned int)width, (unsigned int)height, 2LL, term);
plot_set_all(0LL);
x = 0LL;
y = 0LL;
a = aa0;
s = LC0;
srandom(0);
compute_figure((__int64)axiom, depth, 1u);
v9 = fmax((double)(maxy - miny) / (double)height, (double)(maxx - minx) / (double)width);
if ( maxx - minx <= maxy - miny )
{
v11 = (double)(minx + maxy - miny - maxx) - (double)(2 * border) * v9;
v10 = (double)(-2 * border) * v9;
}
else
{
v10 = (double)(miny + maxx - minx - maxy) - (double)(2 * border) * v9;
v11 = (double)(-2 * border) * v9;
}
plot_set_range(
v9 * (double)width + (double)minx - v11 * 0.5 - 0.5,
(double)maxx - v9 * (double)width + v11 * 0.5 + 0.5,
(double)miny + (double)height * v9 - v10 * 0.5 - 0.5,
(double)maxy - (double)height * v9 + v10 * 0.5 + 0.5);
x = 0LL;
y = 0LL;
a = aa0;
s = LC0;
srandom(0);
compute_figure((__int64)axiom, depth, 0);
plot_finish();
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
_WORD *v3; // rdx
__int64 i; // rax
int v5; // eax
__int64 v6; // rdi
__int64 j; // rax
char v8; // dl
double v9; // xmm0_8
double v10; // xmm1_8
double v11; // xmm6_8

v3 = &stubs;
for ( i = 0LL; i != 26; ++i )
{
*v3 = (unsigned __int8)(i + 97);
rules[i] = (__int64)v3++;
}
get_options(argc, argv, &options, help_string);
plot_mag = mag;
plot_inverse = invert;
v5 = strlen(axiom);
if ( v5 > 0 )
{
v6 = (unsigned int)(v5 - 1);
for ( j = 0LL; ; ++j )
{
v8 = axiom[j];
if ( (unsigned __int8)(v8 - 65) <= 0x19u )
axiom[j] = v8 + 32;
if ( j == v6 )
break;
}
}
*(double *)&aa0 = 3.141592653589793 * *(double *)&aa0 / 180.0;
*(double *)&da = 3.141592653589793 * *(double *)&da / 180.0;
plot_init((unsigned int)width, (unsigned int)height, 2LL, term);
plot_set_all(0LL);
x = 0LL;
y = 0LL;
a = aa0;
s = LC0;
srandom(0);
func1((__int64)axiom, depth, 1u);
v9 = fmax((double)(maxy - miny) / (double)height, (double)(maxx - minx) / (double)width);
if ( maxx - minx <= maxy - miny )
{
v11 = (double)(minx + maxy - miny - maxx) - (double)(2 * border) * v9;
v10 = (double)(-2 * border) * v9;
}
else
{
v10 = (double)(miny + maxx - minx - maxy) - (double)(2 * border) * v9;
v11 = (double)(-2 * border) * v9;
}
plot_set_range(
v9 * (double)width + (double)minx - v11 * 0.5 - 0.5,
(double)maxx - v9 * (double)width + v11 * 0.5 + 0.5,
(double)miny + (double)height * v9 - v10 * 0.5 - 0.5,
(double)maxy - (double)height * v9 + v10 * 0.5 + 0.5);
x = 0LL;
y = 0LL;
a = aa0;
s = LC0;
srandom(0);
func1((__int64)axiom, depth, 0);
plot_finish();
exit(0);
}

original_code:
int main(int argc, char **argv)
{
  extern int plot_mag;
  extern int plot_inverse;
  double xs, ys, xo, yo;
  int i, len;
  for(i = 0; i < ('z' - 'a' + 1); i++) {
    stubs[i * 2] = i + 'a';
    stubs[i * 2 + 1] = 0;
    rules[i] = &stubs[i * 2];
  }
  get_options(argc, argv, options, help_string);
  plot_mag = mag;
  plot_inverse = invert;
  len = strlen(axiom);
  for(i = 0; i < len; i++)
    if(axiom[i] >= 'A' && axiom[i] <= 'Z')
      axiom[i] = axiom[i] - 'A' + 'a';
  aa0 = aa0 * 3.14159265358979323846 / 180.0;
  da = da * 3.14159265358979323846 / 180.0;
  plot_init(width, height, 2, term);
  plot_set_all(0);
  x = 0; y = 0; a = aa0; s = 1;
  srandom(0);
  compute_figure(axiom, depth, 1);
  xs = (maxx - minx) / (double) width;
  ys = (maxy - miny) / (double) height;
  if(ys > xs) xs = ys; else ys = xs;
  if((maxx - minx) > (maxy - miny)) {
    yo = (maxx - minx - maxy + miny) - 2 * border * ys;
    xo = -2 * border * xs;
  }
  else {
    xo = (maxy - miny - maxx + minx) - 2 * border * xs;
    yo = -2 * border * ys;
  }
  plot_set_range(xs * width + minx - xo / 2 - 0.5,
                 maxx - xs * width + xo / 2 + 0.5,
                 ys * height + miny - yo / 2 - 0.5,
                 maxy - ys * height + yo / 2 + 0.5);
  x = 0; y = 0; a = aa0; s = 1;
  srandom(0);
  compute_figure(axiom, depth, 0);
  plot_finish();
  exit(0);
}

canonical_original_code:
int main(int argc, char **argv)
{
  extern int plot_mag;
  extern int plot_inverse;
  double xs; double ys; double xo; double yo;
  int i; int len;
  for(i = 0; i < ('z' - 'a' + 1); i++) {
    stubs[i * 2] = i + 'a';
    stubs[i * 2 + 1] = 0;
    rules[i] = &stubs[i * 2];
  }
  get_options(argc, argv, options, help_string);
  plot_mag = mag;
  plot_inverse = invert;
  len = strlen(axiom);
  for(i = 0; i < len; i++)
    if(axiom[i] >= 'A' && axiom[i] <= 'Z')
      axiom[i] = axiom[i] - 'A' + 'a';
  aa0 = aa0 * 3.14159265358979323846 / 180.0;
  da = da * 3.14159265358979323846 / 180.0;
  plot_init(width, height, 2, term);
  plot_set_all(0);
  x = 0; y = 0; a = aa0; s = 1;
  srandom(0);
  compute_figure(axiom, depth, 1);
  xs = (maxx - minx) / (double) width;
  ys = (maxy - miny) / (double) height;
  if(ys > xs) xs = ys; else ys = xs;
  if((maxx - minx) > (maxy - miny)) {
    yo = (maxx - minx - maxy + miny) - 2 * border * ys;
    xo = -2 * border * xs;
  }
  else {
    xo = (maxy - miny - maxx + minx) - 2 * border * xs;
    yo = -2 * border * ys;
  }
  plot_set_range(xs * width + minx - xo / 2 - 0.5,
                 maxx - xs * width + xo / 2 + 0.5,
                 ys * height + miny - yo / 2 - 0.5,
                 maxy - ys * height + yo / 2 + 0.5);
  x = 0; y = 0; a = aa0; s = 1;
  srandom(0);
  compute_figure(axiom, depth, 0);
  plot_finish();
  exit(0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: xs double

variable_types: ys double

variable_types: xo double

variable_types: yo double


decompiled_code:
int __fastcall bad_option(const char **a1, int a2)
{
return fprintf(stderr, "%s: unknown or incorrectly used option \"%s\".\n", *a1, a1[a2]);
}

canonical_decompiled_code:
int __fastcall func1(const char **a1, int a2)
{
return fprintf(stderr, "%s: unknown or incorrectly used option \"%s\".\n", *a1, a1[a2]);
}

original_code:
void bad_option(char **argv, int badopt)
{
  fprintf(stderr, "%s: unknown or incorrectly used option \"%s\".\n",
          argv[0], argv[badopt]);
}

variable_types: badopt int


xmalloc

decompiled_code:
void *__fastcall xmalloc(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
fprintf(stderr, "malloc failed to get %d bytes.\n", a1);
exit(1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func5(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
fprintf(stderr, "malloc failed to get %d bytes.\n", a1);
exit(1);
}
return result;
}

original_code:
void *xmalloc(size_t bytes)
{
  void *ptr;
  if((ptr = malloc(bytes)) == ((void *)0)) {
    fprintf(stderr, "malloc failed to get %d bytes.\n", bytes);
    exit(1);
  }
  return(ptr);
}

canonical_original_code:
void *xmalloc(unsigned long bytes)
{
  void *ptr;
  if((ptr = malloc(bytes)) == ((void *)0)) {
    fprintf(stderr, "malloc failed to get %d bytes.\n", bytes);
    exit(1);
  }
  return(ptr);
}

variable_types:
bytes
unsigned long

variable_types:
ptr
void *

return_type: void *