main

repo: sahilsd/LazyEDF

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
unsigned int v4; // er13
__int64 v5; // r12
size_t v6; // rbp
int v7; // er12
size_t v8; // rbp
__int64 v9; // rbp
__int64 v10; // rbp
__int64 v11; // r12
__int64 v12; // rbp
__int64 v13; // r14
int v14; // er15
__int64 v15; // r12
void **v16; // rbp
__int64 v17; // rbp
int v18; // er13
_QWORD *v19; // rax
_QWORD *v20; // rax
_QWORD *v21; // rax
const char *v22; // rsi
__int64 v23; // r15
__int64 v24; // r12
int v25; // eax
__int64 v26; // rdx
__int64 v27; // r14
__int64 v28; // rbp
unsigned int v29; // edi
int v30; // eax
_QWORD *v31; // rcx
unsigned int *v32; // rsi
int v33; // er8
float v34; // xmm0_4
__int64 v35; // rcx
__int64 v36; // r8
__int64 v37; // rdx
__int64 v38; // rbx
__int64 v39; // rbx
__int64 v40; // rsi
__int64 v41; // rcx
__int64 v42; // rbp
__int64 v43; // rbx
__int64 v44; // rbx
__int64 v46; // [rsp+8h] [rbp-40h]

energy = 0;
preemptions = 0;
latency = 0LL;
cache_impacts = 0;
zzzTime = LC2;
create_Queue(argc, argv, envp);
prev_alpha = LC2;
alpha = LC2;
operating_frequency = LC2;
sleepFlag = 0;
finishTask = 0;
fpin = (__int64)fopen(argv[1], "r+");
fpout = fopen("schedule.txt", "a+");
fp_job = (__int64)fopen(argv[2], "r+");
fp_freq = (__int64)fopen("frequencies.txt", "r+");
fp_param = fopen("parameters.txt", "a+");
fp_lat = fopen("latencies.txt", "a+");
fp_time_per_freq = fopen("time_per_freq.txt", "a+");
fp_output = fopen("output_param.txt", "a+");
fp_execution_times = (__int64)fopen("execution_times.txt", "a+");
fp_excel_sched = fopen("table_schedule.txt", "a+");
fp_plau = fopen("plausibles.txt", "a+");
fwrite("Start\tFinish\tTask\tCPU Decision\tFrequency\n\n", 1uLL, 0x2AuLL, fp_excel_sched);
_isoc99_fscanf(fpin, "%d", &no_of_tasks);
v4 = no_of_tasks;
v5 = no_of_tasks;
v6 = 4LL * no_of_tasks;
t = (__int64)malloc(20LL * no_of_tasks);
job = (__int64)malloc(8 * v5);
min_exec_tasks = (__int64)malloc(v6);
max_exec_tasks = (__int64)malloc(v6);
total_exec_tasks = (__int64)malloc(v6);
avg_exec_tasks = (__int64)malloc(v6);
min_lat = (__int64)malloc(v6);
max_lat = (__int64)malloc(v6);
avg_lat = (__int64)malloc(v6);
total_lat = (__int64)malloc(v6);
fprintf(fpout, "The no. of tasks are %d\n\n\n", v4);
_isoc99_fscanf(fp_freq, "%d", &no_of_freq);
v7 = no_of_freq;
v8 = 4LL * no_of_freq;
time_per_freq = (__int64)malloc(v8);
freq = (__int64)malloc(v8);
if ( v7 > 0 )
{
v9 = 0LL;
do
{
_isoc99_fscanf(fp_freq, "%f", freq + 4 * v9);
*(_DWORD *)(time_per_freq + 4 * v9) = 0;
v7 = no_of_freq;
++v9;
}
while ( no_of_freq > (int)v9 );
}
fprintf(fpout, "The available frequencies are %d\n", (unsigned int)v7);
if ( no_of_freq > 0 )
{
v10 = 0LL;
do
fprintf(fpout, "%f\n", *(float *)(freq + 4 * v10++));
while ( no_of_freq > (int)v10 );
}
fwrite("\n\n", 1uLL, 2uLL, fpout);
fwrite("T[i][j]\tRls\tPlau\tDeadline\truntime\n\n", 1uLL, 0x23uLL, fp_plau);
time = 0;
min_arrival = 9999999;
curr_exec = 1259902591;
if ( no_of_tasks > 0 )
{
v11 = 0LL;
v12 = 0LL;
do
{
_isoc99_fscanf(fpin, "%d %d %d %f %d", t + v11, t + v11 + 4, t + v11 + 16, t + v11 + 12, t + v11 + 8);
*(_DWORD *)(min_exec_tasks + 4 * v12) = LC24;
*(_DWORD *)(max_exec_tasks + 4 * v12) = LC25;
*(_DWORD *)(min_lat + 4 * v12) = LC24;
*(_DWORD *)(max_lat + 4 * v12++) = LC25;
v11 += 20LL;
}
while ( no_of_tasks > (int)v12 );
}
find_hyperperiod();
if ( no_of_tasks > 0 )
{
v13 = 0LL;
v46 = 0LL;
do
{
v14 = hyperperiod / *(_DWORD *)(t + v13 + 16);
v15 = 8 * v46;
v16 = (void **)(job + 8 * v46);
*v16 = malloc(56LL * v14);
if ( v14 > 0 )
{
v17 = 0LL;
v18 = 0;
do
{
*(_DWORD *)(*(_QWORD *)(job + 8 * v46) + v17) = *(_DWORD *)(t + v13);
*(_DWORD *)(*(_QWORD *)(job + 8 * v46) + v17 + 4) = *(_DWORD *)(t + v13 + 16) * v18;
v19 = (_QWORD *)(job + v15);
*(_DWORD *)(*(_QWORD *)(job + 8 * v46) + v17 + 16) = *(_DWORD *)(t + v13 + 16);
_isoc99_fscanf(fp_job, "%f", *v19 + v17 + 12);
++v18;
v20 = (_QWORD *)(job + v15);
*(_DWORD *)(*(_QWORD *)(job + 8 * v46) + v17 + 8) = *(_DWORD *)(t + v13 + 8) * v18;
_isoc99_fscanf(fp_job, "%f", *v20 + v17 + 32);
v21 = (_QWORD *)(job + v15);
*(_DWORD *)(*(_QWORD *)(job + 8 * v46) + v17 + 20) = *(_DWORD *)(*(_QWORD *)(job + 8 * v46) + v17 + 32);
*(_DWORD *)(*v21 + v17 + 24) = *(_DWORD *)(*v21 + v17 + 32);
*(float *)(*v21 + v17 + 36) = (float)*(int *)(*v21 + v17 + 8) - *(float *)(*v21 + v17 + 12);
*(float *)(*v21 + v17 + 40) = (float)*(int *)(*v21 + v17 + 4);
*(_DWORD *)(*v21 + v17 + 44) = 0;
*(_DWORD *)(*v21 + v17 + 48) = 0;
v17 += 56LL;
}
while ( v18 != v14 );
}
++v46;
v13 += 20LL;
}
while ( no_of_tasks > (int)v46 );
}
fwrite("The latencies of the tasks are : \n\n\n", 1uLL, 0x24uLL, fp_lat);
create_Hyper_Queue();
v22 = "a+";
hyper = fopen("Hyper_debug.txt", "a+");
if ( no_of_tasks > 0 )
{
v23 = 0LL;
do
{
v24 = 20 * v23;
v26 = (unsigned int)(hyperperiod >> 31);
LODWORD(v26) = hyperperiod % *(_DWORD *)(t + 20 * v23 + 16);
v25 = hyperperiod / *(_DWORD *)(t + 20 * v23 + 16);
if ( v25 > 0 )
{
v27 = 56LL * (unsigned int)v25;
v28 = 0LL;
do
{
v3 = create_node(v3, v22, v26);
v29 = *(_DWORD *)(t + 20 * v23);
*(_DWORD *)v3 = v29;
v30 = *(_DWORD *)(*(_QWORD *)(job + 8 * v23) + v28 + 4);
*(_DWORD *)(v3 + 4) = v30;
v31 = (_QWORD *)(job + 8 * v23);
*(_DWORD *)(v3 + 12) = *(_DWORD *)(*v31 + v28 + 12);
*(_DWORD *)(v3 + 8) = *(_DWORD *)(*v31 + v28 + 8);
v32 = (unsigned int *)(t + v24);
v33 = *(_DWORD *)(t + v24 + 16);
*(_DWORD *)(v3 + 16) = v33;
*(_DWORD *)(v3 + 20) = *(_DWORD *)(*v31 + v28 + 20);
*(_DWORD *)(v3 + 24) = *(_DWORD *)(*v31 + v28 + 32);
v34 = (float)*(int *)(*v31 + v28 + 8) - *(float *)(*v31 + v28 + 12);
*(float *)(v3 + 36) = v34;
*(float *)(v3 + 40) = (float)*(int *)(*v31 + v28 + 4);
*(_DWORD *)(v3 + 44) = 0;
*(_DWORD *)(v3 + 48) = 0;
*(_DWORD *)(v3 + 52) = v30 / v33;
v35 = *v31 + v28;
v36 = (unsigned int)(*(_DWORD *)(v35 + 4) / (int)v32[4]);
v37 = *v32;
v22 = "Enqueued T[%d][%d-%d] (r-%d, dd-%d, plau-%f)\n";
fprintf(
hyper,
"Enqueued T[%d][%d-%d] (r-%d, dd-%d, plau-%f)\n",
v37,
v29,
v36,
*(unsigned int *)(v35 + 4),
*(unsigned int *)(v35 + 8),
v34);
Enqueue_Hyper(v3);
v28 += 56LL;
}
while ( v27 != v28 );
}
++v23;
}
while ( no_of_tasks > (int)v23 );
}
Calc_Plausible_Time_Hyper();
puts("xyz");
Calc_Urgent_Time_Hyper();
Calc_Slack();
Schedule();
fwrite("\n\nThe parameters of the algorithm are :\n\n\n", 1uLL, 0x2AuLL, fp_param);
fprintf(fp_param, "Total Energy consumption per unit capacitance is : %f\n", *(float *)&energy);
fprintf(fp_param, "Total Sleep Energy is : %f\n", *(float *)&sleepenergy);
fprintf(fp_param, "Total sleep time is : %f\n", *(float *)&sleepTimeTotal);
fprintf(fp_param, "Total Static Energy is : %f\n", (float)((float)hyperperiod - *(float *)&sleepTimeTotal) * 3.0);
fprintf(
fp_param,
"Total Energy is : %f\n",
(float)((float)hyperperiod - *(float *)&sleepTimeTotal) * 3.0 + (float)(*(float *)&energy + *(float *)&sleepenergy));
fwrite("The Time per frequency is :\n\n", 1uLL, 0x1DuLL, fp_time_per_freq);
if ( no_of_freq > 0 )
{
v38 = 0LL;
do
{
fprintf(fp_time_per_freq, "Freq[%f] : %f \n\n", *(float *)(freq + 4 * v38), *(float *)(time_per_freq + 4 * v38));
++v38;
}
while ( no_of_freq > (int)v38 );
}
fprintf(fp_time_per_freq, "Sleeptime : %f\n", *(float *)&sleepTimeTotal);
fwrite("The Time per Voltage is :\n\n", 1uLL, 0x1BuLL, fp_time_per_freq);
if ( no_of_freq > 0 )
{
v39 = 0LL;
do
{
fprintf(
fp_time_per_freq,
"Voltage[%f] : %f \n\n",
*(float *)(freq + 4 * v39) * 2.4,
*(float *)(time_per_freq + 4 * v39));
++v39;
}
while ( no_of_freq > (int)v39 );
}
if ( no_of_tasks > 0 )
{
v40 = 0LL;
v41 = 0LL;
do
{
*(float *)(avg_lat + 4 * v41) = *(float *)(total_lat + 4 * v41) / (float)(hyperperiod / *(_DWORD *)(t + v40 + 16));
*(float *)(avg_exec_tasks + 4 * v41) = *(float *)(total_exec_tasks + 4 * v41)
/ (float)(hyperperiod / *(_DWORD *)(t + v40 + 16));
++v41;
v40 += 20LL;
}
while ( no_of_tasks > (int)v41 );
}
fwrite("The following are total exec times of all tasks\n\n", 1uLL, 0x31uLL, fp_output);
fwrite(
"# of Tasks\tHyperperiod\tTotal Energy\tDecision pts\tFrequency Switches\tPreemptions\tCacheImpacts\t<Period\tWCET\tM"
"INACET\tMAXACET\tTOTALACET\tAVGACET\tMINLATENCY\tMAXLATENCY\tAVGLATENCY>...<time per frequency>\n",
1uLL,
0xC5uLL,
fp_output);
fprintf(
fp_output,
"%d\t%d\t%f\t%d\t%d\t%d\t%d\t",
(unsigned int)no_of_tasks,
(unsigned int)hyperperiod,
(float)((float)hyperperiod - *(float *)&sleepTimeTotal) * 3.0 + (float)(*(float *)&energy + *(float *)&sleepenergy),
(unsigned int)no_of_decn_pts,
(unsigned int)no_of_freq_switches,
(unsigned int)preemptions,
(unsigned int)cache_impacts);
if ( no_of_tasks > 0 )
{
v42 = 0LL;
v43 = 0LL;
do
{
fprintf(
fp_output,
"%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t",
*(unsigned int *)(t + v42 + 16),
*(float *)(t + v42 + 12),
*(float *)(min_exec_tasks + 4 * v43),
*(float *)(max_exec_tasks + 4 * v43),
*(float *)(total_exec_tasks + 4 * v43),
*(float *)(avg_exec_tasks + 4 * v43),
*(float *)(min_lat + 4 * v43),
*(float *)(max_lat + 4 * v43),
*(float *)(avg_lat + 4 * v43));
++v43;
v42 += 20LL;
}
while ( no_of_tasks > (int)v43 );
}
if ( no_of_freq > 0 )
{
v44 = 0LL;
do
{
fprintf(fp_output, "Freq[%f] : %f \t", *(float *)(freq + 4 * v44), *(float *)(time_per_freq + 4 * v44));
++v44;
}
while ( no_of_freq > (int)v44 );
}
fwrite("\nNEW LINE\n", 1uLL, 0xAuLL, fp_output);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 int i = 0, j = 0;
 node *z;
 int instances;
 energy = 0;
 preemptions = 0;
 latency = 0;
 cache_impacts = 0;
 zzzTime = 1.0000;
 create_Queue();
 prev_alpha = 1;
 alpha = 1;
 operating_frequency = 1;
 sleepFlag = 0;
 finishTask=0;
 fpin = fopen(argv[1],"r+");
 fpout = fopen("schedule.txt","a+");
 fp_job = fopen(argv[2],"r+");
 fp_freq = fopen("frequencies.txt","r+");
 fp_param = fopen("parameters.txt","a+");
 fp_lat = fopen("latencies.txt","a+");
 fp_time_per_freq = fopen("time_per_freq.txt","a+");
 fp_output = fopen("output_param.txt","a+");
 fp_execution_times = fopen("execution_times.txt","a+");
 fp_excel_sched = fopen("table_schedule.txt","a+");
 fp_plau = fopen("plausibles.txt","a+");
 fprintf(fp_excel_sched,"Start\tFinish\tTask\tCPU Decision\tFrequency\n\n");
 fscanf(fpin,"%d",&no_of_tasks);
 t = (task *)malloc(no_of_tasks*sizeof(task));
 job = (job_instance **)malloc(no_of_tasks*sizeof(job_instance *));
 min_exec_tasks = (float *)malloc(no_of_tasks * sizeof(float));
 max_exec_tasks = (float *)malloc(no_of_tasks * sizeof(float));
 total_exec_tasks = (float *)malloc(no_of_tasks * sizeof(float));
 avg_exec_tasks = (float *)malloc(no_of_tasks * sizeof(float));
 min_lat = (float *)malloc(no_of_tasks * sizeof(float));
 max_lat = (float *)malloc(no_of_tasks * sizeof(float));
 avg_lat = (float *)malloc(no_of_tasks * sizeof(float));
 total_lat = (float *)malloc(no_of_tasks * sizeof(float));
 fprintf(fpout,"The no. of tasks are %d\n\n\n",no_of_tasks);
 fscanf(fp_freq,"%d",&no_of_freq);
 time_per_freq = (float *)malloc(no_of_freq * sizeof(float));
 freq = (float *)malloc(no_of_freq * sizeof(float));
 for(i=0; i<no_of_freq; i++)
 {
  fscanf(fp_freq,"%f",&freq[i]);
  time_per_freq[i] = 0;
 }
 fprintf(fpout, "The available frequencies are %d\n",no_of_freq);
 for(i=0; i<no_of_freq; i++)
 fprintf(fpout,"%f\n",freq[i]);
 fprintf(fpout,"\n\n");
 fprintf(fp_plau,"T[i][j]\tRls\tPlau\tDeadline\truntime\n\n");
 time = 0;
 min_arrival = 9999999;
 curr_exec = 9999999;
 for(i=0; i<no_of_tasks; i++)
 {
  fscanf(fpin,"%d %d %d %f %d", &t[i].id, &t[i].release_time, &t[i].period, &t[i].max_computation_time, &t[i].deadline);
  min_exec_tasks[i] = 99999;
  max_exec_tasks[i] = -99999;
  min_lat[i] = 99999;
  max_lat[i] = -99999;
 }
 find_hyperperiod();
 for(i=0; i<no_of_tasks; i++)
 {
  instances = hyperperiod/t[i].period;
  job[i] = (job_instance *)malloc(instances*sizeof(job_instance));
  for(j=0; j<instances; j++)
  {
   job[i][j].id = t[i].id;
   job[i][j].release_time = t[i].period * j;
   job[i][j].period = t[i].period;
   fscanf(fp_job,"%f",&job[i][j].max_computation_time);
   job[i][j].deadline = t[i].deadline * (j+1);
   fscanf(fp_job,"%f",&job[i][j].invocation);
   job[i][j].remaining_time = (float)job[i][j].invocation;
   job[i][j].abs_rem = (float)job[i][j].invocation;
   job[i][j].plausible_time = (float)(job[i][j].deadline - job[i][j].max_computation_time);
   job[i][j].start_time = (float)job[i][j].release_time;
   job[i][j].slack = 0;
   job[i][j].execution_time = 0;
  }
 }
 fprintf(fp_lat,"The latencies of the tasks are : \n\n\n");
 create_Hyper_Queue();
 i = 0;
 hyper = fopen("Hyper_debug.txt","a+");
 while(i<no_of_tasks)
 {
  instances = hyperperiod/t[i].period;
  for(j=0; j<instances; j++)
  {
   z = create_node(z);
   (z->job).id = t[i].id;
   (z->job).release_time = job[i][j].release_time;
   (z->job).max_computation_time = job[i][j].max_computation_time;
   (z->job).deadline = job[i][j].deadline;
   (z->job).period = t[i].period;
   (z->job).remaining_time = (float)job[i][j].remaining_time;
   (z->job).abs_rem = (float)job[i][j].invocation;
   (z->job).plausible_time = (float)(job[i][j].deadline - job[i][j].max_computation_time);
   (z->job).start_time = (float)job[i][j].release_time;
   (z->job).slack = 0;
   (z->job).execution_time = 0;
   z->job.instance = z->job.release_time / z->job.period;
   fprintf(hyper,"Enqueued T[%d][%d-%d] (r-%d, dd-%d, plau-%f)\n",t[i].id,z->job.id,job[i][j].release_time/t[i].period,job[i][j].release_time,job[i][j].deadline,(z->job).plausible_time);
   Enqueue_Hyper(z);
  }
  i++;
 }
 Calc_Plausible_Time_Hyper();
 printf("xyz\n");
 Calc_Urgent_Time_Hyper();
 Calc_Slack();
 Schedule();
 fprintf(fp_param,"\n\nThe parameters of the algorithm are :\n\n\n");
 fprintf(fp_param,"Total Energy consumption per unit capacitance is : %f\n",energy);
 fprintf(fp_param,"Total Sleep Energy is : %f\n",sleepenergy);
 fprintf(fp_param, "Total sleep time is : %f\n", sleepTimeTotal);
 fprintf(fp_param, "Total Static Energy is : %f\n",(3.0 * (hyperperiod - sleepTimeTotal)));
 fprintf(fp_param,"Total Energy is : %f\n",energy+sleepenergy+(3.0 * (hyperperiod - sleepTimeTotal)));
 fprintf(fp_time_per_freq,"The Time per frequency is :\n\n");
 for(i=0; i<no_of_freq; i++)
 {
  fprintf(fp_time_per_freq,"Freq[%f] : %f \n\n",freq[i],time_per_freq[i]);
 }
 fprintf(fp_time_per_freq,"Sleeptime : %f\n",sleepTimeTotal);
 fprintf(fp_time_per_freq,"The Time per Voltage is :\n\n");
 for(i=0; i<no_of_freq; i++)
 {
  fprintf(fp_time_per_freq,"Voltage[%f] : %f \n\n",freq[i]*2.4,time_per_freq[i]);
 }
 for(i=0; i<no_of_tasks; i++)
 {
  avg_lat[i] = (total_lat[i] / (hyperperiod/t[i].period));
  avg_exec_tasks[i] = (total_exec_tasks[i] / (hyperperiod/t[i].period));
 }
 fprintf(fp_output,"The following are total exec times of all tasks\n\n");
 fprintf(fp_output,"# of Tasks\tHyperperiod\tTotal Energy\tDecision pts\tFrequency Switches\tPreemptions\tCacheImpacts\t<Period\tWCET\tMINACET\tMAXACET\tTOTALACET\tAVGACET\tMINLATENCY\tMAXLATENCY\tAVGLATENCY>...<time per frequency>\n");
 fprintf(fp_output,"%d\t%d\t%f\t%d\t%d\t%d\t%d\t",no_of_tasks,hyperperiod,energy+sleepenergy+(3.0 * (hyperperiod - sleepTimeTotal)),no_of_decn_pts, no_of_freq_switches,preemptions,cache_impacts);
 for(i=0; i<no_of_tasks; i++)
 {
  fprintf(fp_output,"%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t",t[i].period,t[i].max_computation_time,min_exec_tasks[i],max_exec_tasks[i],total_exec_tasks[i],avg_exec_tasks[i],min_lat[i],max_lat[i],avg_lat[i]);
 }
 for(i=0; i<no_of_freq; i++)
 {
  fprintf(fp_output,"Freq[%f] : %f \t",freq[i],time_per_freq[i]);
 }
 fprintf(fp_output,"\nNEW LINE\n");
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int i = 0; int j = 0;
 struct node *z;
 int instances;
 energy = 0;
 preemptions = 0;
 latency = 0;
 cache_impacts = 0;
 zzzTime = 1.0000;
 create_Queue();
 prev_alpha = 1;
 alpha = 1;
 operating_frequency = 1;
 sleepFlag = 0;
 finishTask=0;
 fpin = fopen(argv[1],"r+");
 fpout = fopen("schedule.txt","a+");
 fp_job = fopen(argv[2],"r+");
 fp_freq = fopen("frequencies.txt","r+");
 fp_param = fopen("parameters.txt","a+");
 fp_lat = fopen("latencies.txt","a+");
 fp_time_per_freq = fopen("time_per_freq.txt","a+");
 fp_output = fopen("output_param.txt","a+");
 fp_execution_times = fopen("execution_times.txt","a+");
 fp_excel_sched = fopen("table_schedule.txt","a+");
 fp_plau = fopen("plausibles.txt","a+");
 fprintf(fp_excel_sched,"Start\tFinish\tTask\tCPU Decision\tFrequency\n\n");
 fscanf(fpin,"%d",&no_of_tasks);
 t = (struct task *)malloc(no_of_tasks*sizeof(task));
 job = (struct job_instance **)malloc(no_of_tasks*sizeof(struct job_instance *));
 min_exec_tasks = (float *)malloc(no_of_tasks * sizeof(float));
 max_exec_tasks = (float *)malloc(no_of_tasks * sizeof(float));
 total_exec_tasks = (float *)malloc(no_of_tasks * sizeof(float));
 avg_exec_tasks = (float *)malloc(no_of_tasks * sizeof(float));
 min_lat = (float *)malloc(no_of_tasks * sizeof(float));
 max_lat = (float *)malloc(no_of_tasks * sizeof(float));
 avg_lat = (float *)malloc(no_of_tasks * sizeof(float));
 total_lat = (float *)malloc(no_of_tasks * sizeof(float));
 fprintf(fpout,"The no. of tasks are %d\n\n\n",no_of_tasks);
 fscanf(fp_freq,"%d",&no_of_freq);
 time_per_freq = (float *)malloc(no_of_freq * sizeof(float));
 freq = (float *)malloc(no_of_freq * sizeof(float));
 for(i=0; i<no_of_freq; i++)
 {
  fscanf(fp_freq,"%f",&freq[i]);
  time_per_freq[i] = 0;
 }
 fprintf(fpout, "The available frequencies are %d\n",no_of_freq);
 for(i=0; i<no_of_freq; i++)
 fprintf(fpout,"%f\n",freq[i]);
 fprintf(fpout,"\n\n");
 fprintf(fp_plau,"T[i][j]\tRls\tPlau\tDeadline\truntime\n\n");
 time = 0;
 min_arrival = 9999999;
 curr_exec = 9999999;
 for(i=0; i<no_of_tasks; i++)
 {
  fscanf(fpin,"%d %d %d %f %d", &t[i].id, &t[i].release_time, &t[i].period, &t[i].max_computation_time, &t[i].deadline);
  min_exec_tasks[i] = 99999;
  max_exec_tasks[i] = -99999;
  min_lat[i] = 99999;
  max_lat[i] = -99999;
 }
 find_hyperperiod();
 for(i=0; i<no_of_tasks; i++)
 {
  instances = hyperperiod/t[i].period;
  job[i] = (struct job_instance *)malloc(instances*sizeof(job_instance));
  for(j=0; j<instances; j++)
  {
   job[i][j].id = t[i].id;
   job[i][j].release_time = t[i].period * j;
   job[i][j].period = t[i].period;
   fscanf(fp_job,"%f",&job[i][j].max_computation_time);
   job[i][j].deadline = t[i].deadline * (j+1);
   fscanf(fp_job,"%f",&job[i][j].invocation);
   job[i][j].remaining_time = (float)job[i][j].invocation;
   job[i][j].abs_rem = (float)job[i][j].invocation;
   job[i][j].plausible_time = (float)(job[i][j].deadline - job[i][j].max_computation_time);
   job[i][j].start_time = (float)job[i][j].release_time;
   job[i][j].slack = 0;
   job[i][j].execution_time = 0;
  }
 }
 fprintf(fp_lat,"The latencies of the tasks are : \n\n\n");
 create_Hyper_Queue();
 i = 0;
 hyper = fopen("Hyper_debug.txt","a+");
 while(i<no_of_tasks)
 {
  instances = hyperperiod/t[i].period;
  for(j=0; j<instances; j++)
  {
   z = create_node(z);
   (z->job).id = t[i].id;
   (z->job).release_time = job[i][j].release_time;
   (z->job).max_computation_time = job[i][j].max_computation_time;
   (z->job).deadline = job[i][j].deadline;
   (z->job).period = t[i].period;
   (z->job).remaining_time = (float)job[i][j].remaining_time;
   (z->job).abs_rem = (float)job[i][j].invocation;
   (z->job).plausible_time = (float)(job[i][j].deadline - job[i][j].max_computation_time);
   (z->job).start_time = (float)job[i][j].release_time;
   (z->job).slack = 0;
   (z->job).execution_time = 0;
   z->job.instance = z->job.release_time / z->job.period;
   fprintf(hyper,"Enqueued T[%d][%d-%d] (r-%d, dd-%d, plau-%f)\n",t[i].id,z->job.id,job[i][j].release_time/t[i].period,job[i][j].release_time,job[i][j].deadline,(z->job).plausible_time);
   Enqueue_Hyper(z);
  }
  i++;
 }
 Calc_Plausible_Time_Hyper();
 printf("xyz\n");
 Calc_Urgent_Time_Hyper();
 Calc_Slack();
 Schedule();
 fprintf(fp_param,"\n\nThe parameters of the algorithm are :\n\n\n");
 fprintf(fp_param,"Total Energy consumption per unit capacitance is : %f\n",energy);
 fprintf(fp_param,"Total Sleep Energy is : %f\n",sleepenergy);
 fprintf(fp_param, "Total sleep time is : %f\n", sleepTimeTotal);
 fprintf(fp_param, "Total Static Energy is : %f\n",(3.0 * (hyperperiod - sleepTimeTotal)));
 fprintf(fp_param,"Total Energy is : %f\n",energy+sleepenergy+(3.0 * (hyperperiod - sleepTimeTotal)));
 fprintf(fp_time_per_freq,"The Time per frequency is :\n\n");
 for(i=0; i<no_of_freq; i++)
 {
  fprintf(fp_time_per_freq,"Freq[%f] : %f \n\n",freq[i],time_per_freq[i]);
 }
 fprintf(fp_time_per_freq,"Sleeptime : %f\n",sleepTimeTotal);
 fprintf(fp_time_per_freq,"The Time per Voltage is :\n\n");
 for(i=0; i<no_of_freq; i++)
 {
  fprintf(fp_time_per_freq,"Voltage[%f] : %f \n\n",freq[i]*2.4,time_per_freq[i]);
 }
 for(i=0; i<no_of_tasks; i++)
 {
  avg_lat[i] = (total_lat[i] / (hyperperiod/t[i].period));
  avg_exec_tasks[i] = (total_exec_tasks[i] / (hyperperiod/t[i].period));
 }
 fprintf(fp_output,"The following are total exec times of all tasks\n\n");
 fprintf(fp_output,"# of Tasks\tHyperperiod\tTotal Energy\tDecision pts\tFrequency Switches\tPreemptions\tCacheImpacts\t<Period\tWCET\tMINACET\tMAXACET\tTOTALACET\tAVGACET\tMINLATENCY\tMAXLATENCY\tAVGLATENCY>...<time per frequency>\n");
 fprintf(fp_output,"%d\t%d\t%f\t%d\t%d\t%d\t%d\t",no_of_tasks,hyperperiod,energy+sleepenergy+(3.0 * (hyperperiod - sleepTimeTotal)),no_of_decn_pts, no_of_freq_switches,preemptions,cache_impacts);
 for(i=0; i<no_of_tasks; i++)
 {
  fprintf(fp_output,"%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t",t[i].period,t[i].max_computation_time,min_exec_tasks[i],max_exec_tasks[i],total_exec_tasks[i],avg_exec_tasks[i],min_lat[i],max_lat[i],avg_lat[i]);
 }
 for(i=0; i<no_of_freq; i++)
 {
  fprintf(fp_output,"Freq[%f] : %f \t",freq[i],time_per_freq[i]);
 }
 fprintf(fp_output,"\nNEW LINE\n");
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct node { struct job_instance { int id; int release_time; int deadline; float max_computation_time; int period; float remaining_time; float abs_rem; float ui; float invocation; float plausible_time; float start_time; float slack; float execution_time; int instance; } job; struct node *next; struct node *prev; } *

variable_types: instances int

user_defined_types: struct node { struct job_instance job; struct node *next; struct node *prev; }

user_defined_types: struct task { int id; int release_time; int deadline; float max_computation_time; int period; }


decompiled_code:
_QWORD *create_Hyper_Queue()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
Q_Hyper = (__int64)result;
*result = 0LL;
result[1] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
Q_Hyper = (__int64)result;
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
void create_Hyper_Queue()
{
 Q_Hyper = (Queue *)malloc(sizeof(Queue));
 Q_Hyper->front = ((void *)0);
 Q_Hyper->rear = ((void *)0);
}

canonical_original_code:
void create_Hyper_Queue()
{
 Q_Hyper = (struct Queue *)malloc(sizeof(Queue));
 Q_Hyper->front = ((void *)0);
 Q_Hyper->rear = ((void *)0);
}

return_type: void

user_defined_types: struct Queue { struct node *front; struct node *rear; }

user_defined_types: struct job_instance { int id; int release_time; int deadline; float max_computation_time; int period; float remaining_time; float abs_rem; float ui; float invocation; float plausible_time; float start_time; float slack; float execution_time; int instance; }


decompiled_code:
float __fastcall next_highest_plausible(__int64 a1)
{
float v1; // xmm1_4
float result; // xmm0_4

v1 = *(float *)(a1 + 36);
do
{
a1 = *(_QWORD *)(a1 + 56);
result = *(float *)(a1 + 36);
}
while ( v1 > result );
return result;
}

canonical_decompiled_code:
float __fastcall func1(__int64 a1)
{
float v1; // xmm1_4
float result; // xmm0_4

v1 = *(float *)(a1 + 36);
do
{
a1 = *(_QWORD *)(a1 + 56);
result = *(float *)(a1 + 36);
}
while ( v1 > result );
return result;
}

original_code:
float next_highest_plausible(node *x)
{
 float plau = x->job.plausible_time;
 while(x->next->job.plausible_time < plau) x=x->next;
 return x->next->job.plausible_time;
}

canonical_original_code:
float next_highest_plausible(struct node *x)
{
 float plau = x->job.plausible_time;
 while(x->next->job.plausible_time < plau) x=x->next;
 return x->next->job.plausible_time;
}

variable_types: plau float

return_type: float


decompiled_code:
int Calc_Plausible_Time_Hyper_prev()
{
__int64 v0; // rbx
__int64 v1; // rax
_QWORD *i; // rdx

v0 = *(_QWORD *)(Q_Hyper + 8);
LODWORD(v1) = fflush(stdout);
for ( i = (_QWORD *)Q_Hyper; *i != v0; v0 = *(_QWORD *)(v0 + 64) )
{
v1 = *(_QWORD *)(v0 + 64);
*(float *)(v1 + 36) = fminf(*(float *)(v0 + 36) - *(float *)(v1 + 12), *(float *)(v1 + 36));
}
return v1;
}

original_code:
void Calc_Plausible_Time_Hyper_prev()
{
 node *temp;
 node *temp1;
 temp = Q_Hyper->rear;
 float min_plausible_time;
 fflush(stdout);
 while(temp != Q_Hyper->front)
 {
  temp1 = temp->prev;
  min_plausible_time = (temp->job).plausible_time;
  (temp1->job).plausible_time = (min_plausible_time - (temp1->job).max_computation_time)<(temp1->job).plausible_time?(min_plausible_time - (temp1->job).max_computation_time):(temp1->job).plausible_time;
  temp = temp->prev;
 }
}

canonical_original_code:
void Calc_Plausible_Time_Hyper_prev()
{
 struct node *temp;
 struct node *temp1;
 temp = Q_Hyper->rear;
 float min_plausible_time;
 fflush(stdout);
 while(temp != Q_Hyper->front)
 {
  temp1 = temp->prev;
  min_plausible_time = (temp->job).plausible_time;
  (temp1->job).plausible_time = (min_plausible_time - (temp1->job).max_computation_time)<(temp1->job).plausible_time?(min_plausible_time - (temp1->job).max_computation_time):(temp1->job).plausible_time;
  temp = temp->prev;
 }
}


original_code:
void Enqueue_Hyper(node *z)
{
 node *y;
 node *x;
 x = Q_Hyper->front;
 y = ((void *)0);
 if(Q_Hyper->front == ((void *)0) && Q_Hyper->rear == ((void *)0))
 {
  Q_Hyper->front = z;
  Q_Hyper->rear = z;
 }
 else
 {
  while(x!=((void *)0) && (x->job).deadline < (z->job).deadline)
  {
   y = x;
   x = x->next;
  }
  if(y == ((void *)0))
  {
   z->next = Q_Hyper->front;
   Q_Hyper->front->prev = z;
   Q_Hyper->front = z;
  }
  else if(x == ((void *)0))
  {
   Q_Hyper->rear->next = z;
   z->prev = Q_Hyper->rear;
   Q_Hyper->rear = z;
  }
  else
  {
   z->next = y->next;
   z->next->prev = z;
   y->next = z;
   z->prev = y;
  }
 }
}

canonical_original_code:
void Enqueue_Hyper(struct node *z)
{
 struct node *y;
 struct node *x;
 x = Q_Hyper->front;
 y = ((void *)0);
 if(Q_Hyper->front == ((void *)0) && Q_Hyper->rear == ((void *)0))
 {
  Q_Hyper->front = z;
  Q_Hyper->rear = z;
 }
 else
 {
  while(x!=((void *)0) && (x->job).deadline < (z->job).deadline)
  {
   y = x;
   x = x->next;
  }
  if(y == ((void *)0))
  {
   z->next = Q_Hyper->front;
   Q_Hyper->front->prev = z;
   Q_Hyper->front = z;
  }
  else if(x == ((void *)0))
  {
   Q_Hyper->rear->next = z;
   z->prev = Q_Hyper->rear;
   Q_Hyper->rear = z;
  }
  else
  {
   z->next = y->next;
   z->next->prev = z;
   y->next = z;
   z->prev = y;
  }
 }
}


original_code:
void Calc_Plausible_Time_Hyper()
{
 node *temp;
 node *temp1;
 node *z;
 prev_min = ((void *)0);
 temp = Q_Hyper->rear;
 float min_plausible_time;
 float rem_wcet=0;
 fflush(stdout);
 while(temp != Q_Hyper->front)
 {
  temp1 = temp->prev;
  if(temp1->job.release_time+temp1->job.max_computation_time > temp->job.plausible_time)
  {
   fprintf(hyper,"Breaking bad S%dE%d\n",temp->job.id,temp->job.instance);
   z = create_node(z);
   if(temp1->job.release_time + temp1->job.max_computation_time < temp->job.plausible_time + temp->job.max_computation_time)
   {
    (z->job).id = (temp->job).id;
    (z->job).release_time = (temp->job).release_time;
    (z->job).max_computation_time = temp1->job.release_time+temp1->job.max_computation_time - temp->job.plausible_time;
    (z->job).deadline = (temp1->job).release_time;
    (z->job).period = (temp->job).period;
    (z->job).plausible_time = (float)((temp1->job).release_time - (z->job).max_computation_time);
    (z->job).start_time = (float)temp->job.release_time;
    (z->job).slack = 0;
    (z->job).execution_time = 0;
    z->job.instance = temp->job.instance;
    Enqueue_Hyper(z);
    temp->job.plausible_time = temp1->job.release_time + temp1->job.max_computation_time;
    temp->job.max_computation_time -= z->job.max_computation_time;
    temp1->job.plausible_time=temp1->job.release_time;
   }
   else
   {
    (z->job).id = (temp->job).id;
    (z->job).release_time = (temp->job).release_time;
    (z->job).max_computation_time = temp->job.max_computation_time;
    (z->job).deadline = (temp1->job).release_time;
    (z->job).period = (temp->job).period;
    z->job.plausible_time = z->job.deadline - z->job.max_computation_time;
    (z->job).start_time = (float)temp->job.release_time;
    (z->job).slack = 0;
    (z->job).execution_time = 0;
    z->job.instance = temp->job.instance;
    Enqueue_Hyper(z);
    z = temp;
    temp->prev->next = temp->next;
    temp->next->prev = temp->prev;
    temp = temp->prev;
    z->next = ((void *)0);
    z->prev = ((void *)0);
    free(z);
    continue;
    temp1->job.plausible_time=temp1->job.release_time;
   }
  }
  else
   temp1->job.plausible_time = temp1->job.plausible_time<temp->job.plausible_time - temp1->job.max_computation_time?temp1->job.plausible_time:temp->job.plausible_time - temp1->job.max_computation_time;
  temp = temp->prev;
 }
}

canonical_original_code:
void Calc_Plausible_Time_Hyper()
{
 struct node *temp;
 struct node *temp1;
 struct node *z;
 prev_min = ((void *)0);
 temp = Q_Hyper->rear;
 float min_plausible_time;
 float rem_wcet = 0;
 fflush(stdout);
 while(temp != Q_Hyper->front)
 {
  temp1 = temp->prev;
  if(temp1->job.release_time+temp1->job.max_computation_time > temp->job.plausible_time)
  {
   fprintf(hyper,"Breaking bad S%dE%d\n",temp->job.id,temp->job.instance);
   z = create_node(z);
   if(temp1->job.release_time + temp1->job.max_computation_time < temp->job.plausible_time + temp->job.max_computation_time)
   {
    (z->job).id = (temp->job).id;
    (z->job).release_time = (temp->job).release_time;
    (z->job).max_computation_time = temp1->job.release_time+temp1->job.max_computation_time - temp->job.plausible_time;
    (z->job).deadline = (temp1->job).release_time;
    (z->job).period = (temp->job).period;
    (z->job).plausible_time = (float)((temp1->job).release_time - (z->job).max_computation_time);
    (z->job).start_time = (float)temp->job.release_time;
    (z->job).slack = 0;
    (z->job).execution_time = 0;
    z->job.instance = temp->job.instance;
    Enqueue_Hyper(z);
    temp->job.plausible_time = temp1->job.release_time + temp1->job.max_computation_time;
    temp->job.max_computation_time -= z->job.max_computation_time;
    temp1->job.plausible_time=temp1->job.release_time;
   }
   else
   {
    (z->job).id = (temp->job).id;
    (z->job).release_time = (temp->job).release_time;
    (z->job).max_computation_time = temp->job.max_computation_time;
    (z->job).deadline = (temp1->job).release_time;
    (z->job).period = (temp->job).period;
    z->job.plausible_time = z->job.deadline - z->job.max_computation_time;
    (z->job).start_time = (float)temp->job.release_time;
    (z->job).slack = 0;
    (z->job).execution_time = 0;
    z->job.instance = temp->job.instance;
    Enqueue_Hyper(z);
    z = temp;
    temp->prev->next = temp->next;
    temp->next->prev = temp->prev;
    temp = temp->prev;
    z->next = ((void *)0);
    z->prev = ((void *)0);
    free(z);
    continue;
    temp1->job.plausible_time=temp1->job.release_time;
   }
  }
  else
   temp1->job.plausible_time = temp1->job.plausible_time<temp->job.plausible_time - temp1->job.max_computation_time?temp1->job.plausible_time:temp->job.plausible_time - temp1->job.max_computation_time;
  temp = temp->prev;
 }
}


decompiled_code:
int __fastcall Calc_Plausible_Time_Hyper_OBSOLETE()
{
unsigned int *v0; // rbx
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rax
float v4; // xmm2_4
float v5; // xmm0_4
__int64 v6; // rax
float i; // xmm2_4
__int64 v8; // rdx
float v9; // xmm0_4
__int64 v11; // rdx
float v12; // xmm1_4
float *v13; // rbx
float v14; // er13
__int64 v15; // rax
float v16; // xmm0_4
__m128i v17; // xmm1
float v18; // er14
float v19; // er13
__int64 v20; // rax
float v21; // xmm2_4
unsigned int v22; // esi
__int64 v23; // r8
__int64 v24; // rax
__int64 v25; // r9
signed int v26; // ecx
float v27; // xmm0_4
float v28; // xmm2_4
unsigned int v29; // esi
__int64 v30; // r8
__int64 v31; // rax
__int64 v32; // r9
signed int v33; // ecx
float v34; // xmm0_4
float v35; // [rsp+Ch] [rbp-2Ch]
float v36; // [rsp+Ch] [rbp-2Ch]

prev_min = 0LL;
v2 = *(_QWORD *)(Q_Hyper + 8);
fflush(stdout);
if ( v2 == *(_QWORD *)(*(_QWORD *)Q_Hyper + 56LL) )
{
v2 = *(_QWORD *)(*(_QWORD *)Q_Hyper + 56LL);
}
else
{
do
{
printf("plau T[%d][%d](%d)", *v0, (unsigned int)((int)v0[1] / (int)v0[4]), v0[2]);
v13 = *(float **)(v2 + 64);
v14 = *(float *)(v2 + 36);
fprintf(
hyper,
"Updated @#$ plau T[%d][%d] from %f to %f (dd-%d)\n",
*(unsigned int *)v13,
(unsigned int)(*((_DWORD *)v13 + 1) / *((_DWORD *)v13 + 4)),
v13[9],
fminf(v14 - v13[3], v13[9]),
*((unsigned int *)v13 + 2));
v13[9] = fminf(v14 - v13[3], v13[9]);
min = (__int64)v13;
v11 = *(_QWORD *)(v2 + 64);
v15 = (__int64)v13;
while ( (float)((float)*(int *)(v15 + 4) + *(float *)(v15 + 12)) <= *(float *)(v11 + 36) )
{
v15 = *(_QWORD *)(v15 + 64);
if ( !v15 )
goto LABEL_11;
}
prev_min = (__int64)v13;
min = v15;
v11 = v15;
LABEL_11:
fprintf(
hyper,
"***Found prev min(%d) rls T[%d][%d] = %f(%d)\n",
min != v11,
*(unsigned int *)min,
*(unsigned int *)(min + 52),
*(float *)(min + 36),
*(unsigned int *)(min + 8));
v0 = *(unsigned int **)(v2 + 64);
v12 = *((float *)v0 + 9);
if ( (float)((float)*(int *)(min + 4) + *(float *)(min + 12)) > v12 && (unsigned int *)min != v0 )
{
fprintf(
hyper,
"Changing plau T[%d][%d] from %f to %d\n\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v12,
*(unsigned int *)(min + 8));
v16 = (float)*(int *)(min + 8);
*((float *)v0 + 9) = v16;
if ( v16 == *(float *)(*((_QWORD *)v0 + 7) + 36LL) )
fwrite("______________________\n", 1uLL, 0x17uLL, hyper);
v17 = (__m128i)v0[3];
v18 = *((float *)v0 + 9);
v35 = *((float *)v0 + 3) - (float)((float)(int)v0[2] - v18);
*(float *)v17.m128i_i32 = *(float *)v17.m128i_i32 - v35;
v19 = COERCE_FLOAT(_mm_cvtsi128_si32(v17));
v0[3] = v17.m128i_i32[0];
if ( v35 < 0.0 || v18 == *(float *)(*((_QWORD *)v0 + 7) + 36LL) )
{
fprintf(hyper, "can't be broken... so moving (%d)\n", v18 == *(float *)(*((_QWORD *)v0 + 7) + 36LL));
v36 = v35 + *((float *)v0 + 3);
v20 = *((_QWORD *)v0 + 7);
*(_QWORD *)(*((_QWORD *)v0 + 8) + 56LL) = v20;
*(_QWORD *)(v20 + 64) = *((_QWORD *)v0 + 8);
v21 = next_highest_plausible((__int64)v0);
fprintf(
hyper,
"rem_wcet@@ T[%d][%d] %f = %f - (%f-%f)\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v36,
*((float *)v0 + 3),
v21,
*((float *)v0 + 9));
v1 = create_node(v1);
v22 = *v0;
*(_DWORD *)v1 = *v0;
v23 = v0[1];
*(_DWORD *)(v1 + 4) = v23;
*(float *)(v1 + 12) = v36;
v24 = min;
v25 = (unsigned int)(int)*(float *)(min + 36);
*(_DWORD *)(v1 + 8) = v25;
v26 = v0[4];
*(_DWORD *)(v1 + 16) = v26;
v27 = *(float *)(v24 + 36) - v36;
*(float *)(v1 + 36) = v27;
*(float *)(v1 + 40) = (float)(int)v0[1];
*(_DWORD *)(v1 + 44) = 0;
*(_DWORD *)(v1 + 48) = 0;
*(_DWORD *)(v1 + 52) = v0[13];
fprintf(
hyper,
"moving T[%d][%d]** (r-%d, dd-%d, plau-%f)\n",
v22,
(unsigned int)((int)v23 / v26),
v23,
v25,
v27);
Enqueue_Hyper(v1);
}
else
{
v28 = next_highest_plausible((__int64)v0);
fprintf(
hyper,
"rem_wcet T[%d][%d] %f = %f - (%f-%f)\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v35,
v19,
v28,
v18);
v1 = create_node(v1);
v29 = *v0;
*(_DWORD *)v1 = *v0;
v30 = v0[1];
*(_DWORD *)(v1 + 4) = v30;
*(float *)(v1 + 12) = v35;
v31 = min;
v32 = (unsigned int)(int)*(float *)(min + 36);
*(_DWORD *)(v1 + 8) = v32;
v33 = v0[4];
*(_DWORD *)(v1 + 16) = v33;
v34 = *(float *)(v31 + 36) - v35;
*(float *)(v1 + 36) = v34;
*(float *)(v1 + 40) = (float)(int)v0[1];
*(_DWORD *)(v1 + 44) = 0;
*(_DWORD *)(v1 + 48) = 0;
*(_DWORD *)(v1 + 52) = v0[13];
fprintf(
hyper,
"Enqueued T[%d][%d]** (r-%d, dd-%d, plau-%f, abs rem-%f)\n",
v29,
(unsigned int)((int)v30 / v33),
v30,
v32,
v34,
*(float *)(v1 + 24));
Enqueue_Hyper(v1);
}
}
v2 = *(_QWORD *)(v2 + 64);
printf("(%d) ", *(unsigned int *)(v2 + 8));
puts("done");
}
while ( *(_QWORD *)(*(_QWORD *)Q_Hyper + 56LL) != v2 );
}
v3 = *(_QWORD *)(v2 + 56);
v4 = *(float *)(v2 + 12);
v5 = *(float *)(v3 + 36) - v4;
if ( *(float *)(v2 + 36) > v5 )
*(float *)(v2 + 36) = v5;
fprintf(hyper, "2nd last job %f<> %f\n", *(float *)(v2 + 36), (float)(*(float *)(v3 + 36) - v4));
v6 = *(_QWORD *)(v2 + 64);
for ( i = *(float *)(v6 + 12); (float)((float)*(int *)(v6 + 4) + i) > *(float *)(v2 + 36); i = *(float *)(v6 + 12) )
{
puts("STILL GG\n");
v6 = *(_QWORD *)(v2 + 64);
}
v8 = *(_QWORD *)(v6 + 56);
v9 = *(float *)(v8 + 36) - i;
if ( *(float *)(v6 + 36) > v9 )
*(float *)(v6 + 36) = v9;
return fprintf(hyper, "last job %f <> %f\n", *(float *)(v6 + 36), (float)(*(float *)(v8 + 36) - i));
}

canonical_decompiled_code:
int __fastcall func5()
{
unsigned int *v0; // rbx
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rax
float v4; // xmm2_4
float v5; // xmm0_4
__int64 v6; // rax
float i; // xmm2_4
__int64 v8; // rdx
float v9; // xmm0_4
__int64 v11; // rdx
float v12; // xmm1_4
float *v13; // rbx
float v14; // er13
__int64 v15; // rax
float v16; // xmm0_4
__m128i v17; // xmm1
float v18; // er14
float v19; // er13
__int64 v20; // rax
float v21; // xmm2_4
unsigned int v22; // esi
__int64 v23; // r8
__int64 v24; // rax
__int64 v25; // r9
signed int v26; // ecx
float v27; // xmm0_4
float v28; // xmm2_4
unsigned int v29; // esi
__int64 v30; // r8
__int64 v31; // rax
__int64 v32; // r9
signed int v33; // ecx
float v34; // xmm0_4
float v35; // [rsp+Ch] [rbp-2Ch]
float v36; // [rsp+Ch] [rbp-2Ch]

prev_min = 0LL;
v2 = *(_QWORD *)(Q_Hyper + 8);
fflush(stdout);
if ( v2 == *(_QWORD *)(*(_QWORD *)Q_Hyper + 56LL) )
{
v2 = *(_QWORD *)(*(_QWORD *)Q_Hyper + 56LL);
}
else
{
do
{
printf("plau T[%d][%d](%d)", *v0, (unsigned int)((int)v0[1] / (int)v0[4]), v0[2]);
v13 = *(float **)(v2 + 64);
v14 = *(float *)(v2 + 36);
fprintf(
hyper,
"Updated @#$ plau T[%d][%d] from %f to %f (dd-%d)\n",
*(unsigned int *)v13,
(unsigned int)(*((_DWORD *)v13 + 1) / *((_DWORD *)v13 + 4)),
v13[9],
fminf(v14 - v13[3], v13[9]),
*((unsigned int *)v13 + 2));
v13[9] = fminf(v14 - v13[3], v13[9]);
min = (__int64)v13;
v11 = *(_QWORD *)(v2 + 64);
v15 = (__int64)v13;
while ( (float)((float)*(int *)(v15 + 4) + *(float *)(v15 + 12)) <= *(float *)(v11 + 36) )
{
v15 = *(_QWORD *)(v15 + 64);
if ( !v15 )
goto LABEL_11;
}
prev_min = (__int64)v13;
min = v15;
v11 = v15;
LABEL_11:
fprintf(
hyper,
"***Found prev min(%d) rls T[%d][%d] = %f(%d)\n",
min != v11,
*(unsigned int *)min,
*(unsigned int *)(min + 52),
*(float *)(min + 36),
*(unsigned int *)(min + 8));
v0 = *(unsigned int **)(v2 + 64);
v12 = *((float *)v0 + 9);
if ( (float)((float)*(int *)(min + 4) + *(float *)(min + 12)) > v12 && (unsigned int *)min != v0 )
{
fprintf(
hyper,
"Changing plau T[%d][%d] from %f to %d\n\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v12,
*(unsigned int *)(min + 8));
v16 = (float)*(int *)(min + 8);
*((float *)v0 + 9) = v16;
if ( v16 == *(float *)(*((_QWORD *)v0 + 7) + 36LL) )
fwrite("______________________\n", 1uLL, 0x17uLL, hyper);
v17 = (__m128i)v0[3];
v18 = *((float *)v0 + 9);
v35 = *((float *)v0 + 3) - (float)((float)(int)v0[2] - v18);
*(float *)v17.m128i_i32 = *(float *)v17.m128i_i32 - v35;
v19 = COERCE_FLOAT(_mm_cvtsi128_si32(v17));
v0[3] = v17.m128i_i32[0];
if ( v35 < 0.0 || v18 == *(float *)(*((_QWORD *)v0 + 7) + 36LL) )
{
fprintf(hyper, "can't be broken... so moving (%d)\n", v18 == *(float *)(*((_QWORD *)v0 + 7) + 36LL));
v36 = v35 + *((float *)v0 + 3);
v20 = *((_QWORD *)v0 + 7);
*(_QWORD *)(*((_QWORD *)v0 + 8) + 56LL) = v20;
*(_QWORD *)(v20 + 64) = *((_QWORD *)v0 + 8);
v21 = func1((__int64)v0);
fprintf(
hyper,
"rem_wcet@@ T[%d][%d] %f = %f - (%f-%f)\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v36,
*((float *)v0 + 3),
v21,
*((float *)v0 + 9));
v1 = create_node(v1);
v22 = *v0;
*(_DWORD *)v1 = *v0;
v23 = v0[1];
*(_DWORD *)(v1 + 4) = v23;
*(float *)(v1 + 12) = v36;
v24 = min;
v25 = (unsigned int)(int)*(float *)(min + 36);
*(_DWORD *)(v1 + 8) = v25;
v26 = v0[4];
*(_DWORD *)(v1 + 16) = v26;
v27 = *(float *)(v24 + 36) - v36;
*(float *)(v1 + 36) = v27;
*(float *)(v1 + 40) = (float)(int)v0[1];
*(_DWORD *)(v1 + 44) = 0;
*(_DWORD *)(v1 + 48) = 0;
*(_DWORD *)(v1 + 52) = v0[13];
fprintf(
hyper,
"moving T[%d][%d]** (r-%d, dd-%d, plau-%f)\n",
v22,
(unsigned int)((int)v23 / v26),
v23,
v25,
v27);
func3(v1);
}
else
{
v28 = func1((__int64)v0);
fprintf(
hyper,
"rem_wcet T[%d][%d] %f = %f - (%f-%f)\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v35,
v19,
v28,
v18);
v1 = create_node(v1);
v29 = *v0;
*(_DWORD *)v1 = *v0;
v30 = v0[1];
*(_DWORD *)(v1 + 4) = v30;
*(float *)(v1 + 12) = v35;
v31 = min;
v32 = (unsigned int)(int)*(float *)(min + 36);
*(_DWORD *)(v1 + 8) = v32;
v33 = v0[4];
*(_DWORD *)(v1 + 16) = v33;
v34 = *(float *)(v31 + 36) - v35;
*(float *)(v1 + 36) = v34;
*(float *)(v1 + 40) = (float)(int)v0[1];
*(_DWORD *)(v1 + 44) = 0;
*(_DWORD *)(v1 + 48) = 0;
*(_DWORD *)(v1 + 52) = v0[13];
fprintf(
hyper,
"Enqueued T[%d][%d]** (r-%d, dd-%d, plau-%f, abs rem-%f)\n",
v29,
(unsigned int)((int)v30 / v33),
v30,
v32,
v34,
*(float *)(v1 + 24));
func3(v1);
}
}
v2 = *(_QWORD *)(v2 + 64);
printf("(%d) ", *(unsigned int *)(v2 + 8));
puts("done");
}
while ( *(_QWORD *)(*(_QWORD *)Q_Hyper + 56LL) != v2 );
}
v3 = *(_QWORD *)(v2 + 56);
v4 = *(float *)(v2 + 12);
v5 = *(float *)(v3 + 36) - v4;
if ( *(float *)(v2 + 36) > v5 )
*(float *)(v2 + 36) = v5;
fprintf(hyper, "2nd last job %f<> %f\n", *(float *)(v2 + 36), (float)(*(float *)(v3 + 36) - v4));
v6 = *(_QWORD *)(v2 + 64);
for ( i = *(float *)(v6 + 12); (float)((float)*(int *)(v6 + 4) + i) > *(float *)(v2 + 36); i = *(float *)(v6 + 12) )
{
puts("STILL GG\n");
v6 = *(_QWORD *)(v2 + 64);
}
v8 = *(_QWORD *)(v6 + 56);
v9 = *(float *)(v8 + 36) - i;
if ( *(float *)(v6 + 36) > v9 )
*(float *)(v6 + 36) = v9;
return fprintf(hyper, "last job %f <> %f\n", *(float *)(v6 + 36), (float)(*(float *)(v8 + 36) - i));
}

original_code:
void Calc_Plausible_Time_Hyper_OBSOLETE()
{
 node *temp;
 node *temp1;
 node *z;
 prev_min = ((void *)0);
 temp = Q_Hyper->rear;
 float min_plausible_time;
 float rem_wcet=0;
 fflush(stdout);
 while(temp != Q_Hyper->front->next)
 {
  printf("plau T[%d][%d](%d)",(temp1->job).id,(temp1->job).release_time/(temp1->job).period,temp1->job.deadline);
  temp1 = temp->prev;
  min_plausible_time = (temp->job).plausible_time;
  fprintf(hyper,"Updated @#$ plau T[%d][%d] from %f to %f (dd-%d)\n",(temp1->job).id,(temp1->job).release_time/(temp1->job).period, (temp1->job).plausible_time,(min_plausible_time - (temp1->job).max_computation_time)<(temp1->job).plausible_time?(min_plausible_time - (temp1->job).max_computation_time):(temp1->job).plausible_time,(temp1->job).deadline);
  (temp1->job).plausible_time = (min_plausible_time - (temp1->job).max_computation_time)<(temp1->job).plausible_time?(min_plausible_time - (temp1->job).max_computation_time):(temp1->job).plausible_time;
  min = temp1;
  while(1)
  {
   if(temp1 == ((void *)0)) { temp1 = temp->prev; break; }
   if(temp->prev->job.plausible_time < temp1->job.release_time+temp1->job.max_computation_time)
   {
    prev_min = min;
    min = temp1;
    break;
   }
   temp1 = temp1->prev;
  }
  fprintf(hyper,"***Found prev min(%d) rls T[%d][%d] = %f(%d)\n",min!=temp1,min->job.id, min->job.instance, min->job.plausible_time, min->job.deadline);
  temp1 = temp->prev;
  if((temp1->job).plausible_time < min->job.release_time + min->job.max_computation_time && temp1 != min)
  {
   fprintf(hyper,"Changing plau T[%d][%d] from %f to %d\n\n",(temp1->job).id,(temp1->job).release_time/(temp1->job).period, (temp1->job).plausible_time, (min->job).deadline);
   (temp1->job).plausible_time = (min->job).deadline;
   if((temp1->job).plausible_time == (temp1->next->job).plausible_time) fprintf(hyper,"______________________\n");
   rem_wcet = ((temp1->job).max_computation_time) - (temp1->job.deadline - (temp1->job).plausible_time);
   temp1->job.max_computation_time -= rem_wcet;
   if(rem_wcet < 0 || (temp1->job).plausible_time == (temp1->next->job).plausible_time)
   {
    fprintf(hyper,"can't be broken... so moving (%d)\n",(temp1->job).plausible_time == (temp1->next->job).plausible_time);
    rem_wcet += temp1->job.max_computation_time;
    temp1->prev->next = temp1->next;
    temp1->next->prev = temp1->prev;
    fprintf(hyper,"rem_wcet@@ T[%d][%d] %f = %f - (%f-%f)\n",(temp1->job).id,(temp1->job).release_time/(temp1->job).period,rem_wcet,((temp1->job).max_computation_time) , next_highest_plausible(temp1), (temp1->job).plausible_time);
    z = create_node(z);
    (z->job).id = (temp1->job).id;
    (z->job).release_time = (temp1->job).release_time;
    (z->job).max_computation_time = rem_wcet;
    (z->job).deadline = (min->job).plausible_time;
    (z->job).period = (temp1->job).period;
    (z->job).plausible_time = (float)((min->job).plausible_time - rem_wcet);
    (z->job).start_time = (float)temp1->job.release_time;
    (z->job).slack = 0;
    (z->job).execution_time = 0;
    z->job.instance = temp1->job.instance;
    fprintf(hyper,"moving T[%d][%d]** (r-%d, dd-%d, plau-%f)\n",z->job.id,z->job.release_time/z->job.period,z->job.release_time,z->job.deadline,z->job.plausible_time);
    Enqueue_Hyper(z);
   }
   else
   {
    fprintf(hyper,"rem_wcet T[%d][%d] %f = %f - (%f-%f)\n",(temp1->job).id,(temp1->job).release_time/(temp1->job).period,rem_wcet,((temp1->job).max_computation_time) , next_highest_plausible(temp1), (temp1->job).plausible_time);
    z = create_node(z);
    (z->job).id = (temp1->job).id;
    (z->job).release_time = (temp1->job).release_time;
    (z->job).max_computation_time = rem_wcet;
    (z->job).deadline = (min->job).plausible_time;
    (z->job).period = (temp1->job).period;
    (z->job).plausible_time = (float)((min->job).plausible_time - rem_wcet);
    (z->job).start_time = (float)temp1->job.release_time;
    (z->job).slack = 0;
    (z->job).execution_time = 0;
    z->job.instance = temp1->job.instance;
    fprintf(hyper,"Enqueued T[%d][%d]** (r-%d, dd-%d, plau-%f, abs rem-%f)\n",z->job.id,z->job.release_time/z->job.period,z->job.release_time,z->job.deadline,z->job.plausible_time,z->job.abs_rem);
    Enqueue_Hyper(z);
   }
  }
  temp = temp->prev;
  printf("(%d) ",temp->job.deadline);
printf("done\n");
 }
 temp->job.plausible_time > (temp->next->job.plausible_time-temp->job.max_computation_time) ? temp->job.plausible_time = temp->next->job.plausible_time-temp->job.max_computation_time : 1;
 fprintf(hyper,"2nd last job %f<> %f\n",temp->job.plausible_time , (temp->next->job.plausible_time-temp->job.max_computation_time));
 while(temp->job.plausible_time < temp->prev->job.release_time+temp->prev->job.max_computation_time)
 {
  printf("STILL GG\n\n");
 }
 temp = temp->prev;
 temp->job.plausible_time > (temp->next->job.plausible_time-temp->job.max_computation_time) ? temp->job.plausible_time = temp->next->job.plausible_time-temp->job.max_computation_time : 1;
 fprintf(hyper,"last job %f <> %f\n",temp->job.plausible_time , (temp->next->job.plausible_time-temp->job.max_computation_time));
}

canonical_original_code:
void Calc_Plausible_Time_Hyper_OBSOLETE()
{
 struct node *temp;
 struct node *temp1;
 struct node *z;
 prev_min = ((void *)0);
 temp = Q_Hyper->rear;
 float min_plausible_time;
 float rem_wcet = 0;
 fflush(stdout);
 while(temp != Q_Hyper->front->next)
 {
  printf("plau T[%d][%d](%d)",(temp1->job).id,(temp1->job).release_time/(temp1->job).period,temp1->job.deadline);
  temp1 = temp->prev;
  min_plausible_time = (temp->job).plausible_time;
  fprintf(hyper,"Updated @#$ plau T[%d][%d] from %f to %f (dd-%d)\n",(temp1->job).id,(temp1->job).release_time/(temp1->job).period, (temp1->job).plausible_time,(min_plausible_time - (temp1->job).max_computation_time)<(temp1->job).plausible_time?(min_plausible_time - (temp1->job).max_computation_time):(temp1->job).plausible_time,(temp1->job).deadline);
  (temp1->job).plausible_time = (min_plausible_time - (temp1->job).max_computation_time)<(temp1->job).plausible_time?(min_plausible_time - (temp1->job).max_computation_time):(temp1->job).plausible_time;
  min = temp1;
  while(1)
  {
   if(temp1 == ((void *)0)) { temp1 = temp->prev; break; }
   if(temp->prev->job.plausible_time < temp1->job.release_time+temp1->job.max_computation_time)
   {
    prev_min = min;
    min = temp1;
    break;
   }
   temp1 = temp1->prev;
  }
  fprintf(hyper,"***Found prev min(%d) rls T[%d][%d] = %f(%d)\n",min!=temp1,min->job.id, min->job.instance, min->job.plausible_time, min->job.deadline);
  temp1 = temp->prev;
  if((temp1->job).plausible_time < min->job.release_time + min->job.max_computation_time && temp1 != min)
  {
   fprintf(hyper,"Changing plau T[%d][%d] from %f to %d\n\n",(temp1->job).id,(temp1->job).release_time/(temp1->job).period, (temp1->job).plausible_time, (min->job).deadline);
   (temp1->job).plausible_time = (min->job).deadline;
   if((temp1->job).plausible_time == (temp1->next->job).plausible_time) fprintf(hyper,"______________________\n");
   rem_wcet = ((temp1->job).max_computation_time) - (temp1->job.deadline - (temp1->job).plausible_time);
   temp1->job.max_computation_time -= rem_wcet;
   if(rem_wcet < 0 || (temp1->job).plausible_time == (temp1->next->job).plausible_time)
   {
    fprintf(hyper,"can't be broken... so moving (%d)\n",(temp1->job).plausible_time == (temp1->next->job).plausible_time);
    rem_wcet += temp1->job.max_computation_time;
    temp1->prev->next = temp1->next;
    temp1->next->prev = temp1->prev;
    fprintf(hyper,"rem_wcet@@ T[%d][%d] %f = %f - (%f-%f)\n",(temp1->job).id,(temp1->job).release_time/(temp1->job).period,rem_wcet,((temp1->job).max_computation_time) , next_highest_plausible(temp1), (temp1->job).plausible_time);
    z = create_node(z);
    (z->job).id = (temp1->job).id;
    (z->job).release_time = (temp1->job).release_time;
    (z->job).max_computation_time = rem_wcet;
    (z->job).deadline = (min->job).plausible_time;
    (z->job).period = (temp1->job).period;
    (z->job).plausible_time = (float)((min->job).plausible_time - rem_wcet);
    (z->job).start_time = (float)temp1->job.release_time;
    (z->job).slack = 0;
    (z->job).execution_time = 0;
    z->job.instance = temp1->job.instance;
    fprintf(hyper,"moving T[%d][%d]** (r-%d, dd-%d, plau-%f)\n",z->job.id,z->job.release_time/z->job.period,z->job.release_time,z->job.deadline,z->job.plausible_time);
    Enqueue_Hyper(z);
   }
   else
   {
    fprintf(hyper,"rem_wcet T[%d][%d] %f = %f - (%f-%f)\n",(temp1->job).id,(temp1->job).release_time/(temp1->job).period,rem_wcet,((temp1->job).max_computation_time) , next_highest_plausible(temp1), (temp1->job).plausible_time);
    z = create_node(z);
    (z->job).id = (temp1->job).id;
    (z->job).release_time = (temp1->job).release_time;
    (z->job).max_computation_time = rem_wcet;
    (z->job).deadline = (min->job).plausible_time;
    (z->job).period = (temp1->job).period;
    (z->job).plausible_time = (float)((min->job).plausible_time - rem_wcet);
    (z->job).start_time = (float)temp1->job.release_time;
    (z->job).slack = 0;
    (z->job).execution_time = 0;
    z->job.instance = temp1->job.instance;
    fprintf(hyper,"Enqueued T[%d][%d]** (r-%d, dd-%d, plau-%f, abs rem-%f)\n",z->job.id,z->job.release_time/z->job.period,z->job.release_time,z->job.deadline,z->job.plausible_time,z->job.abs_rem);
    Enqueue_Hyper(z);
   }
  }
  temp = temp->prev;
  printf("(%d) ",temp->job.deadline);
printf("done\n");
 }
 temp->job.plausible_time > (temp->next->job.plausible_time-temp->job.max_computation_time) ? temp->job.plausible_time = temp->next->job.plausible_time-temp->job.max_computation_time : 1;
 fprintf(hyper,"2nd last job %f<> %f\n",temp->job.plausible_time , (temp->next->job.plausible_time-temp->job.max_computation_time));
 while(temp->job.plausible_time < temp->prev->job.release_time+temp->prev->job.max_computation_time)
 {
  printf("STILL GG\n\n");
 }
 temp = temp->prev;
 temp->job.plausible_time > (temp->next->job.plausible_time-temp->job.max_computation_time) ? temp->job.plausible_time = temp->next->job.plausible_time-temp->job.max_computation_time : 1;
 fprintf(hyper,"last job %f <> %f\n",temp->job.plausible_time , (temp->next->job.plausible_time-temp->job.max_computation_time));
}


decompiled_code:
int Calc_Urgent_Time_Hyper()
{
__int64 v0; // rax
unsigned int *i; // rbx

fprintf(
fp_plau,
"T[%d][%d]\t%d >\t%f\t%d\t(%f)\n",
**(unsigned int **)Q_Hyper,
(unsigned int)(*(_DWORD *)(*(_QWORD *)Q_Hyper + 4LL) / *(_DWORD *)(*(_QWORD *)Q_Hyper + 16LL)),
*(unsigned int *)(*(_QWORD *)Q_Hyper + 4LL),
*(float *)(*(_QWORD *)Q_Hyper + 36LL),
*(unsigned int *)(*(_QWORD *)Q_Hyper + 8LL),
*(float *)(*(_QWORD *)Q_Hyper + 12LL));
v0 = *(_QWORD *)Q_Hyper;
for ( i = *(unsigned int **)(*(_QWORD *)Q_Hyper + 56LL); i; i = (unsigned int *)*((_QWORD *)i + 7) )
{
*((float *)i + 10) = fmaxf(
*(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL),
*((float *)i + 10));
LODWORD(v0) = fprintf(
fp_plau,
"T[%d][%d]\t%d >\t%f\t%d\t(%f)\n",
*i,
(unsigned int)((int)i[1] / (int)i[4]),
i[1],
*((float *)i + 9),
i[2],
*((float *)i + 3));
}
return v0;
}

canonical_decompiled_code:
int func6()
{
__int64 v0; // rax
unsigned int *i; // rbx

fprintf(
fp_plau,
"T[%d][%d]\t%d >\t%f\t%d\t(%f)\n",
**(unsigned int **)Q_Hyper,
(unsigned int)(*(_DWORD *)(*(_QWORD *)Q_Hyper + 4LL) / *(_DWORD *)(*(_QWORD *)Q_Hyper + 16LL)),
*(unsigned int *)(*(_QWORD *)Q_Hyper + 4LL),
*(float *)(*(_QWORD *)Q_Hyper + 36LL),
*(unsigned int *)(*(_QWORD *)Q_Hyper + 8LL),
*(float *)(*(_QWORD *)Q_Hyper + 12LL));
v0 = *(_QWORD *)Q_Hyper;
for ( i = *(unsigned int **)(*(_QWORD *)Q_Hyper + 56LL); i; i = (unsigned int *)*((_QWORD *)i + 7) )
{
*((float *)i + 10) = fmaxf(
*(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL),
*((float *)i + 10));
LODWORD(v0) = fprintf(
fp_plau,
"T[%d][%d]\t%d >\t%f\t%d\t(%f)\n",
*i,
(unsigned int)((int)i[1] / (int)i[4]),
i[1],
*((float *)i + 9),
i[2],
*((float *)i + 3));
}
return v0;
}

original_code:
void Calc_Urgent_Time_Hyper()
{
 node *temp;
 temp = Q_Hyper->front;
 fprintf(fp_plau,"T[%d][%d]\t%d >\t%f\t%d\t(%f)\n",(temp->job).id,temp->job.release_time/temp->job.period,(temp->job).release_time,(temp->job).plausible_time,(temp->job).deadline,temp->job.max_computation_time);
 temp = Q_Hyper->front->next;
 node *temp1;
 while(temp != ((void *)0))
 {
  temp1 = temp->prev;
  (temp->job).start_time = ((temp1->job).start_time + (temp1->job).max_computation_time)>(temp->job).start_time?((temp1->job).start_time + (temp1->job).max_computation_time):(temp->job).start_time;
  fprintf(fp_plau,"T[%d][%d]\t%d >\t%f\t%d\t(%f)\n",(temp->job).id,temp->job.release_time/temp->job.period,(temp->job).release_time,(temp->job).plausible_time,(temp->job).deadline,temp->job.max_computation_time);
  temp = temp->next;
 }
}

canonical_original_code:
void Calc_Urgent_Time_Hyper()
{
 struct node *temp;
 temp = Q_Hyper->front;
 fprintf(fp_plau,"T[%d][%d]\t%d >\t%f\t%d\t(%f)\n",(temp->job).id,temp->job.release_time/temp->job.period,(temp->job).release_time,(temp->job).plausible_time,(temp->job).deadline,temp->job.max_computation_time);
 temp = Q_Hyper->front->next;
 struct node *temp1;
 while(temp != ((void *)0))
 {
  temp1 = temp->prev;
  (temp->job).start_time = ((temp1->job).start_time + (temp1->job).max_computation_time)>(temp->job).start_time?((temp1->job).start_time + (temp1->job).max_computation_time):(temp->job).start_time;
  fprintf(fp_plau,"T[%d][%d]\t%d >\t%f\t%d\t(%f)\n",(temp->job).id,temp->job.release_time/temp->job.period,(temp->job).release_time,(temp->job).plausible_time,(temp->job).deadline,temp->job.max_computation_time);
  temp = temp->next;
 }
}


decompiled_code:
int Calc_Slack()
{
__int64 v0; // rbx
int result; // eax
unsigned int *i; // rbx
float v3; // xmm0_4

v0 = *(_QWORD *)Q_Hyper;
result = fprintf(fpout, "Slack T[%d] is %f\n", **(unsigned int **)Q_Hyper, *(float *)(*(_QWORD *)Q_Hyper + 44LL));
for ( i = *(unsigned int **)(v0 + 56); i; i = (unsigned int *)*((_QWORD *)i + 7) )
{
v3 = *((float *)i + 10) - (float)(*(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL));
*((float *)i + 11) = v3;
result = fprintf(fpout, "Slack T[%d] is %f\n", *i, v3);
}
return result;
}

canonical_decompiled_code:
int func7()
{
__int64 v0; // rbx
int result; // eax
unsigned int *i; // rbx
float v3; // xmm0_4

v0 = *(_QWORD *)Q_Hyper;
result = fprintf(fpout, "Slack T[%d] is %f\n", **(unsigned int **)Q_Hyper, *(float *)(*(_QWORD *)Q_Hyper + 44LL));
for ( i = *(unsigned int **)(v0 + 56); i; i = (unsigned int *)*((_QWORD *)i + 7) )
{
v3 = *((float *)i + 10) - (float)(*(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL));
*((float *)i + 11) = v3;
result = fprintf(fpout, "Slack T[%d] is %f\n", *i, v3);
}
return result;
}

original_code:
void Calc_Slack()
{
 node *temp;
 temp = Q_Hyper->front;
 fprintf(fpout,"Slack T[%d] is %f\n",(temp->job).id,(temp->job).slack);
 node *temp1;
 temp = temp->next;
 while(temp != ((void *)0))
 {
  temp1 = temp->prev;
  (temp->job).slack = (temp->job).start_time - ((temp1->job).start_time + (temp1->job).max_computation_time);
  fprintf(fpout,"Slack T[%d] is %f\n",(temp->job).id,(temp->job).slack);
  temp = temp->next;
 }
}

canonical_original_code:
void Calc_Slack()
{
 struct node *temp;
 temp = Q_Hyper->front;
 fprintf(fpout,"Slack T[%d] is %f\n",(temp->job).id,(temp->job).slack);
 struct node *temp1;
 temp = temp->next;
 while(temp != ((void *)0))
 {
  temp1 = temp->prev;
  (temp->job).slack = (temp->job).start_time - ((temp1->job).start_time + (temp1->job).max_computation_time);
  fprintf(fpout,"Slack T[%d] is %f\n",(temp->job).id,(temp->job).slack);
  temp = temp->next;
 }
}


decompiled_code:
int Print_Queue_Hyper()
{
int result; // eax
__int64 i; // rbx

result = Q_Hyper;
for ( i = *(_QWORD *)Q_Hyper; i; i = *(_QWORD *)(i + 56) )
{
printf(
"T[] : %d\t%d\t%d\t%f\n",
*(unsigned int *)(i + 4),
*(unsigned int *)(i + 8),
*(unsigned int *)(i + 16),
*(float *)(i + 12));
result = fflush(stdout);
}
return result;
}

canonical_decompiled_code:
int func8()
{
int result; // eax
__int64 i; // rbx

result = Q_Hyper;
for ( i = *(_QWORD *)Q_Hyper; i; i = *(_QWORD *)(i + 56) )
{
printf(
"T[] : %d\t%d\t%d\t%f\n",
*(unsigned int *)(i + 4),
*(unsigned int *)(i + 8),
*(unsigned int *)(i + 16),
*(float *)(i + 12));
result = fflush(stdout);
}
return result;
}

original_code:
void Print_Queue_Hyper()
{
 node *temp;
 temp = Q_Hyper->front;
 while(temp != ((void *)0))
 {
  printf("T[] : %d\t%d\t%d\t%f\n",(temp->job).release_time, (temp->job).deadline, (temp->job).period, (temp->job).max_computation_time);
  fflush(stdout);
  temp = temp->next;
 }
}

canonical_original_code:
void Print_Queue_Hyper()
{
 struct node *temp;
 temp = Q_Hyper->front;
 while(temp != ((void *)0))
 {
  printf("T[] : %d\t%d\t%d\t%f\n",(temp->job).release_time, (temp->job).deadline, (temp->job).period, (temp->job).max_computation_time);
  fflush(stdout);
  temp = temp->next;
 }
}


decompiled_code:
_QWORD *create_Queue()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
Q = (__int64)result;
*result = 0LL;
result[1] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
Q = (__int64)result;
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
void create_Queue()
{
 Q = (Queue *)malloc(sizeof(Queue));
 Q->front = ((void *)0);
 Q->rear = ((void *)0);
}

canonical_original_code:
void create_Queue()
{
 Q = (struct Queue *)malloc(sizeof(Queue));
 Q->front = ((void *)0);
 Q->rear = ((void *)0);
}


IsEmpty

decompiled_code:
_BOOL8 IsEmpty()
{
_BOOL8 result; // rax

result = 0LL;
if ( !*(_QWORD *)Q )
result = *(_QWORD *)(Q + 8) == 0LL;
return result;
}

canonical_decompiled_code:
_BOOL8 func1()
{
_BOOL8 result; // rax

result = 0LL;
if ( !*(_QWORD *)Q )
result = *(_QWORD *)(Q + 8) == 0LL;
return result;
}

canonical_original_code:
enum Bool IsEmpty()
{
 if(Q->front == ((void *)0) && Q->rear == ((void *)0))
 return True;
 else
 return False;
}

return_type: enum Bool { True=1, False=0 }


decompiled_code:
_QWORD *create_node()
{
_QWORD *result; // rax

result = malloc(0x48uLL);
result[7] = 0LL;
result[8] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *result; // rax

result = malloc(0x48uLL);
result[7] = 0LL;
result[8] = 0LL;
return result;
}

original_code:
node *create_node(node *z)
{
 z = (node *)malloc(sizeof(node));
 z->next = ((void *)0);
 z->prev = ((void *)0);
 return z;
}

canonical_original_code:
struct node *create_node(struct node *z)
{
 z = (struct node *)malloc(sizeof(node));
 z->next = ((void *)0);
 z->prev = ((void *)0);
 return z;
}

variable_types:
z
struct node *

return_type: struct node { struct job_instance { int id; int release_time; int deadline; float max_computation_time; int period; float remaining_time; float abs_rem; float ui; float invocation; float plausible_time; float start_time; float slack; float execution_time; int instance; } job; struct node *next; struct node *prev; } *


Enqueue

original_code:
void Enqueue(node *z)
{
 node *y;
 node *x;
 x = Q->front;
 y = ((void *)0);
 if(Q->front == ((void *)0) && Q->rear == ((void *)0))
 {
  Q->front = z;
  Q->rear = z;
 }
 else
 {
  while(x!=((void *)0) && (x->job).deadline <= (z->job).deadline)
  {
   if((x->job).deadline == (z->job).deadline && x->job.release_time>z->job.release_time) {
    break;
   }
   y = x;
   x = x->next;
  }
  if(y == ((void *)0))
  {
   z->next = Q->front;
   Q->front->prev = z;
   Q->front = z;
  }
  else if(x == ((void *)0))
  {
   Q->rear->next = z;
   z->prev = Q->rear;
   Q->rear = z;
  }
  else
  {
   z->next = y->next;
   z->next->prev = z;
   y->next = z;
   z->prev = y;
  }
 }
}

canonical_original_code:
void Enqueue(struct node *z)
{
 struct node *y;
 struct node *x;
 x = Q->front;
 y = ((void *)0);
 if(Q->front == ((void *)0) && Q->rear == ((void *)0))
 {
  Q->front = z;
  Q->rear = z;
 }
 else
 {
  while(x!=((void *)0) && (x->job).deadline <= (z->job).deadline)
  {
   if((x->job).deadline == (z->job).deadline && x->job.release_time>z->job.release_time) {
    break;
   }
   y = x;
   x = x->next;
  }
  if(y == ((void *)0))
  {
   z->next = Q->front;
   Q->front->prev = z;
   Q->front = z;
  }
  else if(x == ((void *)0))
  {
   Q->rear->next = z;
   z->prev = Q->rear;
   Q->rear = z;
  }
  else
  {
   z->next = y->next;
   z->next->prev = z;
   y->next = z;
   z->prev = y;
  }
 }
}


Dequeue

decompiled_code:
_QWORD *Dequeue()
{
_QWORD *result; // rax

result = (_QWORD *)Q;
if ( *(_QWORD *)Q == *(_QWORD *)(Q + 8) )
{
*(_QWORD *)(Q + 8) = 0LL;
*result = 0LL;
}
else
{
*(_QWORD *)Q = *(_QWORD *)(*(_QWORD *)Q + 56LL);
result = *(_QWORD **)Q;
*(_QWORD *)(*(_QWORD *)Q + 64LL) = 0LL;
}
return result;
}

canonical_decompiled_code:
_QWORD *func4()
{
_QWORD *result; // rax

result = (_QWORD *)Q;
if ( *(_QWORD *)Q == *(_QWORD *)(Q + 8) )
{
*(_QWORD *)(Q + 8) = 0LL;
*result = 0LL;
}
else
{
*(_QWORD *)Q = *(_QWORD *)(*(_QWORD *)Q + 56LL);
result = *(_QWORD **)Q;
*(_QWORD *)(*(_QWORD *)Q + 64LL) = 0LL;
}
return result;
}

original_code:
void Dequeue()
{
 if(Q->front == Q->rear)
 {
  Q->front = Q->rear = ((void *)0);
 }
 else
 {
  Q->front = Q->front->next;
  Q->front->prev = ((void *)0);
 }
}


decompiled_code:
__int64 Print_Current_Status()
{
unsigned int *v0; // rbx
int v1; // ebp
__int64 result; // rax

v0 = *(unsigned int **)Q;
if ( *(_QWORD *)Q )
{
fwrite("Current Status of ready Queue : ", 1uLL, 0x20uLL, fpout);
v1 = 0;
do
{
++v1;
fprintf(fpout, "T[%d]\t", *v0);
v0 = (unsigned int *)*((_QWORD *)v0 + 7);
}
while ( v0 );
fprintf(fpout, "\nsize=%d\n", (unsigned int)v1);
result = 1LL;
if ( no_of_tasks < v1 )
{
fwrite("overflow ur buffer making all ur data suffer\n", 1uLL, 0x2DuLL, fpout);
result = 1LL;
}
}
else
{
fprintf(fpout, "Current Status of ready Queue : CPU IDLE size(%d)\n\n\n", 0LL);
result = 0LL;
if ( *(float *)&time != *(float *)&decision_pt )
{
fprintf(fp_excel_sched, "%f\t%f\tIdle\tExecute\tMIN_FREQ\n", *(float *)&time, *(float *)&decision_pt);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
unsigned int *v0; // rbx
int v1; // ebp
__int64 result; // rax

v0 = *(unsigned int **)Q;
if ( *(_QWORD *)Q )
{
fwrite("Current Status of ready Queue : ", 1uLL, 0x20uLL, fpout);
v1 = 0;
do
{
++v1;
fprintf(fpout, "T[%d]\t", *v0);
v0 = (unsigned int *)*((_QWORD *)v0 + 7);
}
while ( v0 );
fprintf(fpout, "\nsize=%d\n", (unsigned int)v1);
result = 1LL;
if ( no_of_tasks < v1 )
{
fwrite("overflow ur buffer making all ur data suffer\n", 1uLL, 0x2DuLL, fpout);
result = 1LL;
}
}
else
{
fprintf(fpout, "Current Status of ready Queue : CPU IDLE size(%d)\n\n\n", 0LL);
result = 0LL;
if ( *(float *)&time != *(float *)&decision_pt )
{
fprintf(fp_excel_sched, "%f\t%f\tIdle\tExecute\tMIN_FREQ\n", *(float *)&time, *(float *)&decision_pt);
result = 0LL;
}
}
return result;
}

original_code:
int Print_Current_Status()
{
 node *temp;
 temp = Q->front;
 int count=0;
 if(temp == ((void *)0))
 {
  fprintf(fpout,"Current Status of ready Queue : CPU IDLE size(%d)\n\n\n",count);
  if(time!=decision_pt)
   fprintf(fp_excel_sched,"%f\t%f\tIdle\tExecute\tMIN_FREQ\n",time,decision_pt);
  return 0;
 }
 fprintf(fpout,"Current Status of ready Queue : ");
 while(temp!=((void *)0))
 {
  count++;
  fprintf(fpout,"T[%d]\t",(temp->job).id);
  temp = temp->next;
 }
 fprintf(fpout,"\nsize=%d\n",count);
 if(count>no_of_tasks) fprintf(fpout,"overflow ur buffer making all ur data suffer\n");
 return 1;
}

canonical_original_code:
int Print_Current_Status()
{
 struct node *temp;
 temp = Q->front;
 int count = 0;
 if(temp == ((void *)0))
 {
  fprintf(fpout,"Current Status of ready Queue : CPU IDLE size(%d)\n\n\n",count);
  if(time!=decision_pt)
   fprintf(fp_excel_sched,"%f\t%f\tIdle\tExecute\tMIN_FREQ\n",time,decision_pt);
  return 0;
 }
 fprintf(fpout,"Current Status of ready Queue : ");
 while(temp!=((void *)0))
 {
  count++;
  fprintf(fpout,"T[%d]\t",(temp->job).id);
  temp = temp->next;
 }
 fprintf(fpout,"\nsize=%d\n",count);
 if(count>no_of_tasks) fprintf(fpout,"overflow ur buffer making all ur data suffer\n");
 return 1;
}

variable_types: count int

return_type: int


decompiled_code:
int Calc_Plausible_Time()
{
unsigned int *v0; // rbx
float i; // xmm0_4
__int64 v3; // rax
float v4; // xmm0_4

v0 = *(unsigned int **)Q;
fflush(stdout);
if ( v0 == *(unsigned int **)(Q + 8) )
{
v0 = *(unsigned int **)(Q + 8);
}
else
{
do
{
v3 = *((_QWORD *)v0 + 7);
for ( i = *(float *)(v3 + 36); ; i = fminf(*(float *)(v3 + 36), i) )
{
v3 = *(_QWORD *)(v3 + 56);
if ( !v3 )
break;
}
v4 = fminf(i - *((float *)v0 + 3), *((float *)v0 + 9));
*((float *)v0 + 9) = v4;
fprintf(fpout, "Plau T[%d] is %f\n", *v0, v4);
v0 = (unsigned int *)*((_QWORD *)v0 + 7);
}
while ( *(unsigned int **)(Q + 8) != v0 );
}
return fprintf(fpout, "Plau T[%d] is %f\n", *v0, *((float *)v0 + 9));
}

canonical_decompiled_code:
int func6()
{
unsigned int *v0; // rbx
float i; // xmm0_4
__int64 v3; // rax
float v4; // xmm0_4

v0 = *(unsigned int **)Q;
fflush(stdout);
if ( v0 == *(unsigned int **)(Q + 8) )
{
v0 = *(unsigned int **)(Q + 8);
}
else
{
do
{
v3 = *((_QWORD *)v0 + 7);
for ( i = *(float *)(v3 + 36); ; i = fminf(*(float *)(v3 + 36), i) )
{
v3 = *(_QWORD *)(v3 + 56);
if ( !v3 )
break;
}
v4 = fminf(i - *((float *)v0 + 3), *((float *)v0 + 9));
*((float *)v0 + 9) = v4;
fprintf(fpout, "Plau T[%d] is %f\n", *v0, v4);
v0 = (unsigned int *)*((_QWORD *)v0 + 7);
}
while ( *(unsigned int **)(Q + 8) != v0 );
}
return fprintf(fpout, "Plau T[%d] is %f\n", *v0, *((float *)v0 + 9));
}

original_code:
void Calc_Plausible_Time()
{
 node *temp;
 node *temp1;
 temp = Q->front;
 float min_plausible_time;
 fflush(stdout);
 while(temp != Q->rear)
 {
  temp1 = temp->next;
  min_plausible_time = (temp1->job).plausible_time;
  while(temp1 != ((void *)0))
  {
   if((temp1->job).plausible_time < min_plausible_time)
    min_plausible_time = (temp1->job).plausible_time;
   temp1 = temp1->next;
  }
  (temp->job).plausible_time = (min_plausible_time - (temp->job).max_computation_time)<(temp->job).plausible_time?(min_plausible_time - (temp->job).max_computation_time):(temp->job).plausible_time;
  fprintf(fpout,"Plau T[%d] is %f\n",(temp->job).id,(temp->job).plausible_time);
  temp = temp->next;
 }
 fprintf(fpout,"Plau T[%d] is %f\n",(temp->job).id,(temp->job).plausible_time);
}

canonical_original_code:
void Calc_Plausible_Time()
{
 struct node *temp;
 struct node *temp1;
 temp = Q->front;
 float min_plausible_time;
 fflush(stdout);
 while(temp != Q->rear)
 {
  temp1 = temp->next;
  min_plausible_time = (temp1->job).plausible_time;
  while(temp1 != ((void *)0))
  {
   if((temp1->job).plausible_time < min_plausible_time)
    min_plausible_time = (temp1->job).plausible_time;
   temp1 = temp1->next;
  }
  (temp->job).plausible_time = (min_plausible_time - (temp->job).max_computation_time)<(temp->job).plausible_time?(min_plausible_time - (temp->job).max_computation_time):(temp->job).plausible_time;
  fprintf(fpout,"Plau T[%d] is %f\n",(temp->job).id,(temp->job).plausible_time);
  temp = temp->next;
 }
 fprintf(fpout,"Plau T[%d] is %f\n",(temp->job).id,(temp->job).plausible_time);
}


decompiled_code:
int Calc_Urgent_Time()
{
__int64 v0; // rax
unsigned int *i; // rbx
float v2; // xmm0_4

fprintf(
fpout,
"URGE time of T[%d] is %f and rls time %d\n",
**(unsigned int **)Q,
*(float *)(*(_QWORD *)Q + 40LL),
*(unsigned int *)(*(_QWORD *)Q + 4LL));
v0 = *(_QWORD *)Q;
for ( i = *(unsigned int **)(*(_QWORD *)Q + 56LL); i; i = (unsigned int *)*((_QWORD *)i + 7) )
{
v2 = *(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL);
*((float *)i + 10) = v2;
LODWORD(v0) = fprintf(fpout, "URGE time of T[%d] is %f and rls time %d\n", *i, v2, i[1]);
}
return v0;
}

canonical_decompiled_code:
int func7()
{
__int64 v0; // rax
unsigned int *i; // rbx
float v2; // xmm0_4

fprintf(
fpout,
"URGE time of T[%d] is %f and rls time %d\n",
**(unsigned int **)Q,
*(float *)(*(_QWORD *)Q + 40LL),
*(unsigned int *)(*(_QWORD *)Q + 4LL));
v0 = *(_QWORD *)Q;
for ( i = *(unsigned int **)(*(_QWORD *)Q + 56LL); i; i = (unsigned int *)*((_QWORD *)i + 7) )
{
v2 = *(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL);
*((float *)i + 10) = v2;
LODWORD(v0) = fprintf(fpout, "URGE time of T[%d] is %f and rls time %d\n", *i, v2, i[1]);
}
return v0;
}

original_code:
void Calc_Urgent_Time()
{
 node *temp;
 temp = Q->front;
 fprintf(fpout,"URGE time of T[%d] is %f and rls time %d\n",(temp->job).id,(temp->job).start_time,(temp->job).release_time);
 temp = Q->front->next;
 node *temp1;
 while(temp != ((void *)0))
 {
  temp1 = temp->prev;
  (temp->job).start_time = (temp1->job).start_time + (temp1->job).max_computation_time;
  fprintf(fpout,"URGE time of T[%d] is %f and rls time %d\n",(temp->job).id,(temp->job).start_time,(temp->job).release_time);
  temp = temp->next;
 }
}

canonical_original_code:
void Calc_Urgent_Time()
{
 struct node *temp;
 temp = Q->front;
 fprintf(fpout,"URGE time of T[%d] is %f and rls time %d\n",(temp->job).id,(temp->job).start_time,(temp->job).release_time);
 temp = Q->front->next;
 struct node *temp1;
 while(temp != ((void *)0))
 {
  temp1 = temp->prev;
  (temp->job).start_time = (temp1->job).start_time + (temp1->job).max_computation_time;
  fprintf(fpout,"URGE time of T[%d] is %f and rls time %d\n",(temp->job).id,(temp->job).start_time,(temp->job).release_time);
  temp = temp->next;
 }
}


decompiled_code:
int Print_Queue()
{
int result; // eax
__int64 i; // rbx

result = Q;
for ( i = *(_QWORD *)Q; i; i = *(_QWORD *)(i + 56) )
result = printf(
"T[] : %d\t%d\t%d\t%f\n",
*(unsigned int *)(i + 4),
*(unsigned int *)(i + 8),
*(unsigned int *)(i + 16),
*(float *)(i + 12));
return result;
}

canonical_decompiled_code:
int func8()
{
int result; // eax
__int64 i; // rbx

result = Q;
for ( i = *(_QWORD *)Q; i; i = *(_QWORD *)(i + 56) )
result = printf(
"T[] : %d\t%d\t%d\t%f\n",
*(unsigned int *)(i + 4),
*(unsigned int *)(i + 8),
*(unsigned int *)(i + 16),
*(float *)(i + 12));
return result;
}

original_code:
void Print_Queue()
{
 node *temp;
 temp = Q->front;
 while(temp != ((void *)0))
 {
  printf("T[] : %d\t%d\t%d\t%f\n",(temp->job).release_time, (temp->job).deadline, (temp->job).period, (temp->job).max_computation_time);
  temp = temp->next;
 }
}

canonical_original_code:
void Print_Queue()
{
 struct node *temp;
 temp = Q->front;
 while(temp != ((void *)0))
 {
  printf("T[] : %d\t%d\t%d\t%f\n",(temp->job).release_time, (temp->job).deadline, (temp->job).period, (temp->job).max_computation_time);
  temp = temp->next;
 }
}


compare

repo: sahusoft/homework

decompiled_code:
int __fastcall compare(const void *a1, const void *a2)
{
const char *v2; // rbp
const char *v3; // rbx
__int64 v5[2]; // [rsp+0h] [rbp-58h] BYREF
int v6; // [rsp+10h] [rbp-48h]
char v7; // [rsp+14h] [rbp-44h]
char dest[8]; // [rsp+20h] [rbp-38h] BYREF
__int64 v9; // [rsp+28h] [rbp-30h]
int v10; // [rsp+30h] [rbp-28h]
char v11; // [rsp+34h] [rbp-24h]

*(_QWORD *)dest = 0LL;
v9 = 0LL;
v10 = 0;
v11 = 0;
v5[0] = 0LL;
v5[1] = 0LL;
v6 = 0;
v7 = 0;
v2 = *(const char **)a1;
strcpy(dest, *(const char **)a1);
v3 = *(const char **)a2;
strcat(dest, *(const char **)a2);
strcpy((char *)v5, v3);
strcat((char *)v5, v2);
return strcmp(dest, (const char *)v5);
}

canonical_decompiled_code:
int __fastcall func7(const void *a1, const void *a2)
{
const char *v2; // rbp
const char *v3; // rbx
__int64 v5[2]; // [rsp+0h] [rbp-58h] BYREF
int v6; // [rsp+10h] [rbp-48h]
char v7; // [rsp+14h] [rbp-44h]
char dest[8]; // [rsp+20h] [rbp-38h] BYREF
__int64 v9; // [rsp+28h] [rbp-30h]
int v10; // [rsp+30h] [rbp-28h]
char v11; // [rsp+34h] [rbp-24h]

*(_QWORD *)dest = 0LL;
v9 = 0LL;
v10 = 0;
v11 = 0;
v5[0] = 0LL;
v5[1] = 0LL;
v6 = 0;
v7 = 0;
v2 = *(const char **)a1;
strcpy(dest, *(const char **)a1);
v3 = *(const char **)a2;
strcat(dest, *(const char **)a2);
strcpy((char *)v5, v3);
strcat((char *)v5, v2);
return strcmp(dest, (const char *)v5);
}

original_code:
int compare(const void *a, const void *b)
{
 char tmp1[2*10 + 1] = {0};
 char tmp2[2*10 + 1] = {0};
 strcpy(tmp1, *(const char **)a);
 strcat(tmp1, *(const char **)b);
 strcpy(tmp2, *(const char **)b);
 strcat(tmp2, *(const char **)a);
 return strcmp(tmp1, tmp2);
}

canonical_original_code:
int compare(void *a, void *b)
{
 char tmp1[-1] = {0};
 char tmp2[-1] = {0};
 strcpy(tmp1, *(char **)a);
 strcat(tmp1, *(char **)b);
 strcpy(tmp2, *(char **)b);
 strcat(tmp2, *(char **)a);
 return strcmp(tmp1, tmp2);
}

variable_types:
a
void *

variable_types:
b
void *


decompiled_code:
__int64 __fastcall number_connect(__int64 a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp
__int64 i; // rbx
char *v5; // rax
void **v6; // rbx

v2 = malloc(8LL * a2);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = v2;
if ( a2 <= 0 )
{
qsort(v2, a2, 8uLL, compare);
}
else
{
for ( i = 0LL; i != a2; sprintf(v5, "%d", *(unsigned int *)(a1 + 4 * i++)) )
{
v5 = (char *)malloc(0xBuLL);
v3[i] = v5;
}
qsort(v3, a2, 8uLL, compare);
v6 = (void **)v3;
do
{
printf("%s", (const char *)*v6);
free(*v6++);
}
while ( v6 != &v3[a2] );
}
puts("\r");
free(v3);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp
__int64 i; // rbx
char *v5; // rax
void **v6; // rbx

v2 = malloc(8LL * a2);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = v2;
if ( a2 <= 0 )
{
qsort(v2, a2, 8uLL, compare);
}
else
{
for ( i = 0LL; i != a2; sprintf(v5, "%d", *(unsigned int *)(a1 + 4 * i++)) )
{
v5 = (char *)malloc(0xBuLL);
v3[i] = v5;
}
qsort(v3, a2, 8uLL, compare);
v6 = (void **)v3;
do
{
printf("%s", (const char *)*v6);
free(*v6++);
}
while ( v6 != &v3[a2] );
}
puts("\r");
free(v3);
return 0LL;
}

original_code:
int number_connect(int *numbers, int len)
{
 char **num_strs = ((void *)0);
 int i = 0;
 num_strs = (char **)malloc(len * sizeof(char *));
 if(((void *)0) == num_strs)
  return -1;
 for(i = 0; i < len; i++) {
  num_strs[i] = (char *)malloc((10 + 1));
  sprintf(num_strs[i],"%d",numbers[i]);
 }
 qsort(num_strs, len, sizeof(char *), compare);
 for(i = 0; i < len; i++) {
  printf("%s", num_strs[i]);
  free(num_strs[i]);
 }
 printf("\r\n");
 if(num_strs)
  free(num_strs);
 return 0;
}

variable_types:
numbers
int *

variable_types: len int

variable_types: i int


main

canonical_name: main

original_code:
int main(int argc, char **argv)
{
 int numbers[10] = {3, 32, 321, 19, 2, 3, 9, 99883312,111, 121};
 int i = 0;
 for(i = 0; i < 10; i++)
  printf("%d ", numbers[i]);
 printf("\r\n");
 number_connect(numbers, 10);
 return 0;
}

variable_types:
argv
char **

variable_types:
numbers
int [10]


p

repo: sahusoft/test

decompiled_code:
__int64 __fastcall p(int a1)
{
unsigned int v1; // ebx
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = -65536;
sops.sem_flg = 0;
if ( semop(a1, &sops, 1uLL) != -1 )
return 0;
v1 = -1;
perror("semop P");
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
unsigned int v1; // ebx
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = -65536;
sops.sem_flg = 0;
if ( semop(a1, &sops, 1uLL) != -1 )
return 0;
v1 = -1;
perror("semop P");
return v1;
}

original_code:
int p(int sem_id)
{
 struct sembuf sem_p;
 memset(&sem_p, 0, sizeof(struct sembuf));
 sem_p.sem_num = 0;
 sem_p.sem_op = -1;
 if(semop(sem_id, &sem_p, 1) == -1) {
  perror("semop P");
  return -1;
 }
 return 0;
}

variable_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


v

decompiled_code:
__int64 __fastcall v(int a1)
{
unsigned int v1; // ebx
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = 0x10000;
sops.sem_flg = 0;
if ( semop(a1, &sops, 1uLL) != -1 )
return 0;
v1 = -1;
perror("semop P");
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
unsigned int v1; // ebx
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = 0x10000;
sops.sem_flg = 0;
if ( semop(a1, &sops, 1uLL) != -1 )
return 0;
v1 = -1;
perror("semop P");
return v1;
}

original_code:
int v(int sem_id)
{
 struct sembuf sem_v;
 memset(&sem_v, 0, sizeof(struct sembuf));
 sem_v.sem_num = 0;
 sem_v.sem_op = 1;
 if(semop(sem_id, &sem_v, 1) == -1) {
  perror("semop P");
  return -1;
 }
 return 0;
}

user_defined_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


main

repo: sailfish-sdk/xdg-helper

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rax
const char *v4; // rax
const char *v5; // rax

xdg_helper_init(argc, argv, envp);
v3 = (const char *)xdg_helper_get(0LL);
printf("Config path: '%s'\n", v3);
v4 = (const char *)xdg_helper_get(1LL);
printf("Data path: '%s'\n", v4);
v5 = (const char *)xdg_helper_get(2LL);
printf("Cache path: '%s'\n", v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rax
const char *v4; // rax
const char *v5; // rax

func8(argc, argv, envp);
v3 = (const char *)func9(0LL);
printf("Config path: '%s'\n", v3);
v4 = (const char *)func9(1LL);
printf("Data path: '%s'\n", v4);
v5 = (const char *)func9(2LL);
printf("Cache path: '%s'\n", v5);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    xdg_helper_init(argc, argv);
    printf("Config path: '%s'\n", xdg_helper_get(XDG_HELPER_CONFIG_PATH));
    printf("Data path: '%s'\n", xdg_helper_get(XDG_HELPER_DATA_PATH));
    printf("Cache path: '%s'\n", xdg_helper_get(XDG_HELPER_CACHE_PATH));
    return 0;
}


decompiled_code:
int __fastcall determine_path(char *s, const char *a2, const char *a3, const char *a4)
{
int result; // eax
const char *v7; // rbp
char *v8; // rax
__uid_t v9; // eax
const char *v10; // rbp
__uid_t v11; // eax
struct passwd *v12; // rax

if ( a2 )
return snprintf(s, 0x1000uLL, "%s/%s", a2, (const char *)appname);
if ( getenv("HOME") )
{
v7 = (const char *)appname;
v8 = getenv("HOME");
result = snprintf(s, 0x1000uLL, "%s/%s/%s", v8, a3, v7);
}
else
{
v9 = getuid();
if ( getpwuid(v9) )
{
v10 = (const char *)appname;
v11 = getuid();
v12 = getpwuid(v11);
result = snprintf(s, 0x1000uLL, "%s/%s/%s", v12->pw_dir, a3, v10);
}
else
{
result = snprintf(s, 0x1000uLL, "%s/%s", a4, (const char *)appname);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(char *s, const char *a2, const char *a3, const char *a4)
{
int result; // eax
const char *v7; // rbp
char *v8; // rax
__uid_t v9; // eax
const char *v10; // rbp
__uid_t v11; // eax
struct passwd *v12; // rax

if ( a2 )
return snprintf(s, 0x1000uLL, "%s/%s", a2, (const char *)appname);
if ( getenv("HOME") )
{
v7 = (const char *)appname;
v8 = getenv("HOME");
result = snprintf(s, 0x1000uLL, "%s/%s/%s", v8, a3, v7);
}
else
{
v9 = getuid();
if ( getpwuid(v9) )
{
v10 = (const char *)appname;
v11 = getuid();
v12 = getpwuid(v11);
result = snprintf(s, 0x1000uLL, "%s/%s/%s", v12->pw_dir, a3, v10);
}
else
{
result = snprintf(s, 0x1000uLL, "%s/%s", a4, (const char *)appname);
}
}
return result;
}

original_code:
static void determine_path(char *target, const char *xdg_base,
        const char *home_fallback, const char *fallback)
{
    if (xdg_base) {
        snprintf(target, 4096, "%s/%s", xdg_base, appname);
    } else if (getenv("HOME")) {
        snprintf(target, 4096, "%s/%s/%s", getenv("HOME"),
                home_fallback, appname);
    } else if (getpwuid(getuid())) {
        snprintf(target, 4096, "%s/%s/%s", getpwuid(getuid())->pw_dir,
                home_fallback, appname);
    } else {
        snprintf(target, 4096, "%s/%s", fallback, appname);
    }
}

canonical_original_code:
static void determine_path(char *target, char *xdg_base, char *home_fallback, char *fallback)
{
    if (xdg_base) {
        snprintf(target, 4096, "%s/%s", xdg_base, appname);
    } else if (getenv("HOME")) {
        snprintf(target, 4096, "%s/%s/%s", getenv("HOME"),
                home_fallback, appname);
    } else if (getpwuid(getuid())) {
        snprintf(target, 4096, "%s/%s/%s", getpwuid(getuid())->pw_dir,
                home_fallback, appname);
    } else {
        snprintf(target, 4096, "%s/%s", fallback, appname);
    }
}

variable_types:
target
char *

variable_types:
fallback
char *


decompiled_code:
int __fastcall xdg_helper_init(__int64 a1, const char **a2)
{
const char *v2; // rbx
char *v3; // rax
char *v4; // rax
char *v5; // rax
char *v6; // rax

v2 = *a2;
v3 = strrchr(*a2, 47);
if ( v3 )
v2 = v3 + 1;
appname = (__int64)v2;
v4 = getenv("XDG_CONFIG_HOME");
determine_path(paths, v4, ".config", "config");
v5 = getenv("XDG_DATA_HOME");
determine_path(s, v5, ".local/share", "data");
v6 = getenv("XDG_CACHE_HOME");
return determine_path(byte_4060A0, v6, ".cache", "cache");
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, const char **a2)
{
const char *v2; // rbx
char *v3; // rax
char *v4; // rax
char *v5; // rax
char *v6; // rax

v2 = *a2;
v3 = strrchr(*a2, 47);
if ( v3 )
v2 = v3 + 1;
appname = (__int64)v2;
v4 = getenv("XDG_CONFIG_HOME");
func7(paths, v4, ".config", "config");
v5 = getenv("XDG_DATA_HOME");
func7(s, v5, ".local/share", "data");
v6 = getenv("XDG_CACHE_HOME");
return func7(byte_4060A0, v6, ".cache", "cache");
}

original_code:
void xdg_helper_init(int argc, char **argv)
{
    const char *slash = strrchr(argv[0], '/');
    appname = slash ? (slash + 1) : argv[0];
    determine_path(paths[0], getenv("XDG_CONFIG_HOME"), ".config", "config");
    determine_path(paths[1], getenv("XDG_DATA_HOME"), ".local/share", "data");
    determine_path(paths[2], getenv("XDG_CACHE_HOME"), ".cache", "cache");
}

canonical_original_code:
void xdg_helper_init(int argc, char **argv)
{
    char *slash = strrchr(argv[0], '/');
    appname = slash ? (slash + 1) : argv[0];
    determine_path(paths[0], getenv("XDG_CONFIG_HOME"), ".config", "config");
    determine_path(paths[1], getenv("XDG_DATA_HOME"), ".local/share", "data");
    determine_path(paths[2], getenv("XDG_CACHE_HOME"), ".cache", "cache");
}

variable_types: argc int

variable_types:
slash
char *


decompiled_code:
char *__fastcall xdg_helper_get(unsigned int a1)
{
char *result; // rax

result = 0LL;
if ( a1 <= 2 )
result = &paths[4096 * (unsigned __int64)a1];
return result;
}

canonical_decompiled_code:
char *__fastcall func9(unsigned int a1)
{
char *result; // rax

result = 0LL;
if ( a1 <= 2 )
result = &paths[4096 * (unsigned __int64)a1];
return result;
}

original_code:
const char *xdg_helper_get(enum xdg_helper_path_t which)
{
    return (which < 0 || which > XDG_HELPER_CACHE_PATH) ? 0 : paths[which];
}

variable_types: enum xdg_helper_path_t { XDG_HELPER_CONFIG_PATH=0, XDG_HELPER_DATA_PATH=1, XDG_HELPER_CACHE_PATH=2 }

return_type: char *


repo: saintkepha/airtraf

decompiled_code:
_QWORD *initialize_p802_11b_parser()
{
_QWORD *result; // rax

result = malloc(0x48uLL);
info = (__int64)result;
if ( !result )
{
perror("malloc: initialize_p802_11b_parser()");
exit(-1);
}
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
result[6] = 0LL;
result[7] = 0LL;
result[8] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(0x48uLL);
info = (__int64)result;
if ( !result )
{
perror("malloc: initialize_p802_11b_parser()");
exit(-1);
}
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
result[6] = 0LL;
result[7] = 0LL;
result[8] = 0LL;
return result;
}

original_code:
void initialize_p802_11b_parser()
{
  if (((void *)0) == (info = malloc(sizeof(struct p802_11b_info)))){
    perror("malloc: initialize_p802_11b_parser()");
    exit(-1);
  }
  memset(info, 0, sizeof(struct p802_11b_info));
}

user_defined_types: struct p802_11b_info { unsigned char type; unsigned short subtype; unsigned char datatype; unsigned char wep; unsigned char status; unsigned char *bssid; unsigned char *da; unsigned char *sa; unsigned char channel; unsigned char ssid[32]; }


decompiled_code:
int __fastcall parse_ap_info(__int64 a1, int a2)
{
int i; // er12
int result; // eax
int v4; // er13
int v5; // ebx

for ( i = 6; i; --i )
{
result = *(unsigned __int8 *)(a1 + a2 + 1);
v4 = (unsigned __int8)result;
v5 = a2 + 2;
if ( (unsigned __int8)result > 0x20u )
break;
if ( *(_BYTE *)(a1 + a2) )
{
if ( *(_BYTE *)(a1 + a2) == 3 )
{
result = info;
*(_BYTE *)(info + 32) = *(_BYTE *)(a1 + v5);
return result;
}
}
else
{
result = snprintf((char *)(info + 33), (unsigned __int8)(result + 1), "%s", (const char *)(a1 + v5));
}
a2 = v4 + v5;
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, int a2)
{
int i; // er12
int result; // eax
int v4; // er13
int v5; // ebx

for ( i = 6; i; --i )
{
result = *(unsigned __int8 *)(a1 + a2 + 1);
v4 = (unsigned __int8)result;
v5 = a2 + 2;
if ( (unsigned __int8)result > 0x20u )
break;
if ( *(_BYTE *)(a1 + a2) )
{
if ( *(_BYTE *)(a1 + a2) == 3 )
{
result = info;
*(_BYTE *)(info + 32) = *(_BYTE *)(a1 + v5);
return result;
}
}
else
{
result = snprintf((char *)(info + 33), (unsigned __int8)(result + 1), "%s", (const char *)(a1 + v5));
}
a2 = v4 + v5;
}
return result;
}

original_code:
void parse_ap_info(wlan_hdr_t *hdr, int offset)
{
  __u8 temp_num;
  __u8 *packet;
  int info_ptr, tag_number, tag_length, loop_count;
  tag_number = 0;
  tag_length = 0;
  loop_count = 0;
  info_ptr = offset;
  packet = (__u8*)hdr;
  if (0) printf("parse_ap_info(): processing access point data\n");
  while(tag_number != 3){
    loop_count++;
    if (loop_count > 6){
      return;
    }
    tag_number = packet[info_ptr];
    info_ptr++;
    tag_length = packet[info_ptr];
    info_ptr++;
    if(tag_length > 32){
      return;
    }
    if (0) printf("tag_number = %d, tag_length = %d\n",tag_number,tag_length);
    if(tag_number == 0){
      temp_num = (tag_length & 0xff)+1;
      snprintf(info->ssid,temp_num,"%s",&packet[info_ptr]);
    }
    if(tag_number == 3){
   info->channel = packet[info_ptr];
    }
    info_ptr += tag_length;
  }
  if (0) printf("parse_ap_info(): channel=%d\n",info->channel);
}

canonical_original_code:
void parse_ap_info(struct wlan_hdr_t *hdr, int offset)
{
  unsigned char temp_num;
  unsigned char *packet;
  int info_ptr; int tag_number; int tag_length; int loop_count;
  tag_number = 0;
  tag_length = 0;
  loop_count = 0;
  info_ptr = offset;
  packet = (unsigned char *)hdr;
  if (0) printf("parse_ap_info(): processing access point data\n");
  while(tag_number != 3){
    loop_count++;
    if (loop_count > 6){
      return;
    }
    tag_number = packet[info_ptr];
    info_ptr++;
    tag_length = packet[info_ptr];
    info_ptr++;
    if(tag_length > 32){
      return;
    }
    if (0) printf("tag_number = %d, tag_length = %d\n",tag_number,tag_length);
    if(tag_number == 0){
      temp_num = (tag_length & 0xff)+1;
      snprintf(info->ssid,temp_num,"%s",&packet[info_ptr]);
    }
    if(tag_number == 3){
   info->channel = packet[info_ptr];
    }
    info_ptr += tag_length;
  }
  if (0) printf("parse_ap_info(): channel=%d\n",info->channel);
}

variable_types: struct wlan_hdr_t { unsigned short frame_control; unsigned short duration_id; unsigned char mac1[6]; unsigned char mac2[6]; unsigned char mac3[6]; unsigned short sequence; unsigned char mac4[6]; } *

variable_types: offset int

variable_types:
packet
unsigned char *


decompiled_code:
__int64 __fastcall parse_mgmt(__int64 a1)
{
__int64 result; // rax

result = info;
*(_QWORD *)(info + 16) = a1 + 4;
*(_QWORD *)(result + 24) = a1 + 10;
*(_QWORD *)(result + 8) = a1 + 16;
*(_BYTE *)(result + 6) = 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax

result = info;
*(_QWORD *)(info + 16) = a1 + 4;
*(_QWORD *)(result + 24) = a1 + 10;
*(_QWORD *)(result + 8) = a1 + 16;
*(_BYTE *)(result + 6) = 1;
return result;
}

original_code:
void parse_mgmt(wlan_hdr_t *packet)
{
  if (0) printf("parse_mgmt(): processing mgmt frame\n");
  info->da=(__u8 *)&packet->mac1;
  info->sa=(__u8 *)&packet->mac2;
  info->bssid=(__u8 *)&packet->mac3;
  if (0) printf("da: %s   sa: %s   bssid: %s\n",
      hexdump((__u8*)info->da, 6),
      hexdump((__u8*)info->sa, 6),
      hexdump((__u8*)info->bssid, 6));
  info->status = 1;
  if (0) printf("parse_mgmt(): exiting...\n");
  return;
}

canonical_original_code:
void parse_mgmt(struct wlan_hdr_t *packet)
{
  if (0) printf("parse_mgmt(): processing mgmt frame\n");
  info->da=(unsigned char *)&packet->mac1;
  info->sa=(unsigned char *)&packet->mac2;
  info->bssid=(unsigned char *)&packet->mac3;
  if (0) printf("da: %s   sa: %s   bssid: %s\n",
      hexdump((unsigned char *)info->da, 6),
      hexdump((unsigned char *)info->sa, 6),
      hexdump((unsigned char *)info->bssid, 6));
  info->status = 1;
  if (0) printf("parse_mgmt(): exiting...\n");
  return;
}

user_defined_types: struct wlan_hdr_t { unsigned short frame_control; unsigned short duration_id; unsigned char mac1[6]; unsigned char mac2[6]; unsigned char mac3[6]; unsigned short sequence; unsigned char mac4[6]; }


decompiled_code:
__int64 __fastcall parse_ctrl(__int64 a1)
{
__int64 result; // rax

result = info;
*(_QWORD *)(info + 16) = a1 + 4;
*(_BYTE *)(result + 6) = 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax

result = info;
*(_QWORD *)(info + 16) = a1 + 4;
*(_BYTE *)(result + 6) = 1;
return result;
}

original_code:
void parse_ctrl(wlan_hdr_t *packet)
{
  if (0) printf("parse_ctrl(): processing control frame\n");
  info->da=(__u8 *)&packet->mac1;
  info->status = 1;
  if (0) printf("handlecontrol: exiting...\n");
  return;
}

canonical_original_code:
void parse_ctrl(struct wlan_hdr_t *packet)
{
  if (0) printf("parse_ctrl(): processing control frame\n");
  info->da=(unsigned char *)&packet->mac1;
  info->status = 1;
  if (0) printf("handlecontrol: exiting...\n");
  return;
}


original_code:
void parse_data(wlan_hdr_t *hdr)
{
  frame_control_t *fc;
  __u8 tofrom;
  if (0) printf("parse_data(): processing data packet\n");
  fc = (frame_control_t *) &hdr->frame_control;
  tofrom = (fc->toDS << 1) | fc->fromDS;
  switch (tofrom)
    {
    case 0:
      info->datatype = 1;
      info->da=(__u8 *)&hdr->mac1;
      info->sa=(__u8 *)&hdr->mac2;
      info->bssid=(__u8 *)&hdr->mac3;
      break;
    case 1:
      info->datatype = 2;
      info->da=(__u8 *)&hdr->mac1;
      info->sa=(__u8 *)&hdr->mac3;
      info->bssid=(__u8 *)&hdr->mac2;
      break;
    case 2:
      info->datatype = 3;
      info->da=(__u8 *)&hdr->mac3;
      info->sa=(__u8 *)&hdr->mac2;
      info->bssid=(__u8 *)&hdr->mac1;
      break;
    case 3:
      info->datatype = 4;
      break;
    }
  info->status = 1;
  if (0) printf("parse_data(): exiting...\n");
  return;
}

canonical_original_code:
void parse_data(struct wlan_hdr_t *hdr)
{
  struct frame_control_t *fc;
  unsigned char tofrom;
  if (0) printf("parse_data(): processing data packet\n");
  fc = (struct frame_control_t *) &hdr->frame_control;
  tofrom = (fc->toDS << 1) | fc->fromDS;
  switch (tofrom)
    {
    case 0:
      info->datatype = 1;
      info->da=(unsigned char *)&hdr->mac1;
      info->sa=(unsigned char *)&hdr->mac2;
      info->bssid=(unsigned char *)&hdr->mac3;
      break;
    case 1:
      info->datatype = 2;
      info->da=(unsigned char *)&hdr->mac1;
      info->sa=(unsigned char *)&hdr->mac3;
      info->bssid=(unsigned char *)&hdr->mac2;
      break;
    case 2:
      info->datatype = 3;
      info->da=(unsigned char *)&hdr->mac3;
      info->sa=(unsigned char *)&hdr->mac2;
      info->bssid=(unsigned char *)&hdr->mac1;
      break;
    case 3:
      info->datatype = 4;
      break;
    }
  info->status = 1;
  if (0) printf("parse_data(): exiting...\n");
  return;
}

variable_types: struct frame_control_t { unsigned char version; unsigned char type; unsigned char subtype; unsigned char toDS; unsigned char fromDS; unsigned char morefrag; unsigned char retry; unsigned char pwr; unsigned char moredata; unsigned char wep; unsigned char rsvd; } *

variable_types:
tofrom
unsigned char


decompiled_code:
__int64 parse_other()
{
__int64 result; // rax

result = info;
*(_BYTE *)(info + 6) = 0;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax

result = info;
*(_BYTE *)(info + 6) = 0;
return result;
}

original_code:
void parse_other(wlan_hdr_t *packet)
{
  info->status = 0;
}

canonical_original_code:
void parse_other(struct wlan_hdr_t *packet)
{
  info->status = 0;
}


original_code:
struct p802_11b_info *parse_p802_11b_hdr(wlan_hdr_t *hdr)
{
  frame_control_t *fc;
  memset(info, 0, sizeof(struct p802_11b_info));
  fc = (frame_control_t *)&hdr->frame_control;
  if (0) printf("parse_p802_11b_hdr():entering\n");
  info->type = fc->type;
  info->subtype = fc->subtype;
  info->wep = fc->wep;
  switch(fc->type)
    {
    case 0:
      switch(fc->subtype)
 {
 case 8:
 case 5:
   parse_ap_info(hdr, sizeof(wlan_hdr_t) + 6);
   break;
 }
      parse_mgmt(hdr);
      break;
    case 1:
      parse_ctrl(hdr);
      break;
    case 2:
      parse_data(hdr);
      break;
    default:
      parse_other(hdr);
      break;
    }
  return (info);
}

canonical_original_code:
struct p802_11b_info *parse_p802_11b_hdr(struct wlan_hdr_t *hdr)
{
  struct frame_control_t *fc;
  memset(info, 0, sizeof(struct p802_11b_info));
  fc = (struct frame_control_t *)&hdr->frame_control;
  if (0) printf("parse_p802_11b_hdr():entering\n");
  info->type = fc->type;
  info->subtype = fc->subtype;
  info->wep = fc->wep;
  switch(fc->type)
    {
    case 0:
      switch(fc->subtype)
 {
 case 8:
 case 5:
   parse_ap_info(hdr, sizeof(wlan_hdr_t) + 6);
   break;
 }
      parse_mgmt(hdr);
      break;
    case 1:
      parse_ctrl(hdr);
      break;
    case 2:
      parse_data(hdr);
      break;
    default:
      parse_other(hdr);
      break;
    }
  return (info);
}

return_type: struct p802_11b_info { unsigned char type; unsigned short subtype; unsigned char datatype; unsigned char wep; unsigned char status; unsigned char *bssid; unsigned char *da; unsigned char *sa; unsigned char channel; unsigned char ssid[32]; } *

user_defined_types: struct frame_control_t { unsigned char version; unsigned char type; unsigned char subtype; unsigned char toDS; unsigned char fromDS; unsigned char morefrag; unsigned char retry; unsigned char pwr; unsigned char moredata; unsigned char wep; unsigned char rsvd; }


original_code:
struct p802_11b_info *parse_hfa384x_hdr(prism2_hdr_t *hdr)
{
  frame_control_t *fc;
  int descript_size = sizeof(hfa384x_descript_t);
  void *wlan_hdr;
  wlan_hdr = (void *)((char *)hdr + descript_size);
  if (0) printf("parse_hfa384x_hdr(): entering...\n");
  memset(info, 0, sizeof(struct p802_11b_info));
  fc = (frame_control_t *)&hdr->frame_control;
  info->type = fc->type;
  info->subtype = fc->subtype;
  info->wep = fc->wep;
  switch(fc->type)
    {
    case 0:
      switch(fc->subtype)
 {
 case 8:
 case 5:
   parse_ap_info(wlan_hdr, sizeof(prism2_hdr_t) - descript_size + 6);
   break;
 }
      parse_mgmt((wlan_hdr_t *)wlan_hdr);
      break;
    case 1:
      parse_ctrl((wlan_hdr_t *)wlan_hdr);
      break;
    case 2:
      parse_data((wlan_hdr_t *)wlan_hdr);
      break;
    default:
      parse_other((wlan_hdr_t *)wlan_hdr);
      break;
    }
  return (info);
}

canonical_original_code:
struct p802_11b_info *parse_hfa384x_hdr(struct prism2_hdr_t *hdr)
{
  struct frame_control_t *fc;
  int descript_size = sizeof(hfa384x_descript_t);
  void *wlan_hdr;
  wlan_hdr = (void *)((char *)hdr + descript_size);
  if (0) printf("parse_hfa384x_hdr(): entering...\n");
  memset(info, 0, sizeof(struct p802_11b_info));
  fc = (struct frame_control_t *)&hdr->frame_control;
  info->type = fc->type;
  info->subtype = fc->subtype;
  info->wep = fc->wep;
  switch(fc->type)
    {
    case 0:
      switch(fc->subtype)
 {
 case 8:
 case 5:
   parse_ap_info(wlan_hdr, sizeof(prism2_hdr_t) - descript_size + 6);
   break;
 }
      parse_mgmt((struct wlan_hdr_t *)wlan_hdr);
      break;
    case 1:
      parse_ctrl((struct wlan_hdr_t *)wlan_hdr);
      break;
    case 2:
      parse_data((struct wlan_hdr_t *)wlan_hdr);
      break;
    default:
      parse_other((struct wlan_hdr_t *)wlan_hdr);
      break;
    }
  return (info);
}

variable_types: struct prism2_hdr_t { struct hfa384x_descript_t { unsigned short status; unsigned int time; unsigned char silence; unsigned char signal; unsigned char rate; unsigned char rxflow; unsigned int reserved; } frame_descriptor; unsigned short frame_control; unsigned short duration_id; unsigned char mac1[6]; unsigned char mac2[6]; unsigned char mac3[6]; unsigned short sequence; unsigned char mac4[6]; unsigned short data_len; unsigned char dst_addr[6]; unsigned char src_addr[6]; unsigned short len; unsigned char crap[6]; } *

user_defined_types: struct prism2_hdr_t { struct hfa384x_descript_t frame_descriptor; unsigned short frame_control; unsigned short duration_id; unsigned char mac1[6]; unsigned char mac2[6]; unsigned char mac3[6]; unsigned short sequence; unsigned char mac4[6]; unsigned short data_len; unsigned char dst_addr[6]; unsigned char src_addr[6]; unsigned short len; unsigned char crap[6]; }