original_code:
int play_one(Queue *s1, Queue *s2, coord *snake2, char *snake2dir, reward *r,Points* p)
{
  int ch;
  int set_dir2=0;
  ch=wgetch(stdscr);
  switch (ch)
  {
    case (int) 'q': return 1;
    case 259: if ((*snake2dir=='r')||(*snake2dir=='l'))
       {
        if (snake2->y==0)
         snake2->y = 21;
        else
         snake2->y--;
        *snake2dir = 'u';
        set_dir2=1;
       }
       break;
    case 258 : if ((*snake2dir=='r')||(*snake2dir=='l'))
       {
        if (snake2->y==21)
         snake2->y = 0;
        else
         snake2->y++;
        set_dir2=1;
        *snake2dir = 'd';
       }
       break;
    case 260 : if ((*snake2dir=='u')||(*snake2dir=='d'))
       {
        if (snake2->x==0)
         snake2->x = 79;
        else
         snake2->x--;
        set_dir2=1;
        *snake2dir = 'l';
       }
       break;
    case 261: if ((*snake2dir=='u')||(*snake2dir=='d'))
       {
        if (snake2->x==79)
         snake2->x = 0;
        else
         snake2->x++;
        set_dir2=1;
        *snake2dir = 'r';
       }
       break;
   }
  if (set_dir2==0)
  {
   switch(*snake2dir)
   {
    case 'l': if (snake2->x==0)
       snake2->x = 79;
      else
       snake2->x--;
      break;
    case 'r': if (snake2->x==79)
       snake2->x = 0;
      else
       snake2->x++;
      break;
    case 'u': if (snake2->y==0)
       snake2->y = 21;
      else
       snake2->y--;
      break;
    case 'd': if (snake2->y==21)
       snake2->y = 0;
      else
       snake2->y++;
      break;
   }
  }
  s2 = queue_push(s2, *snake2);
  int flag=0, i;
  for (i=0; i<r->rewnum; i++)
  {
   if ((r->rewcoord[i].x==snake2->x)&&(r->rewcoord[i].y==snake2->y))
   {
    r = mk_reward(s1, s2, r, i);
    p->s2_points++;
    flag=1;
    break;
   }
  }
  if (flag==0)
   s2 = queue_pop(s2);
 return 0;
}

canonical_original_code:
int play_one(struct Queue_ *s1, struct Queue_ *s2, struct coord_ *snake2, char *snake2dir, struct reward_ *r, struct Points_ *p)
{
  int ch;
  int set_dir2 = 0;
  ch=wgetch(stdscr);
  switch (ch)
  {
    case (int) 'q': return 1;
    case 259: if ((*snake2dir=='r')||(*snake2dir=='l'))
       {
        if (snake2->y==0)
         snake2->y = 21;
        else
         snake2->y--;
        *snake2dir = 'u';
        set_dir2=1;
       }
       break;
    case 258 : if ((*snake2dir=='r')||(*snake2dir=='l'))
       {
        if (snake2->y==21)
         snake2->y = 0;
        else
         snake2->y++;
        set_dir2=1;
        *snake2dir = 'd';
       }
       break;
    case 260 : if ((*snake2dir=='u')||(*snake2dir=='d'))
       {
        if (snake2->x==0)
         snake2->x = 79;
        else
         snake2->x--;
        set_dir2=1;
        *snake2dir = 'l';
       }
       break;
    case 261: if ((*snake2dir=='u')||(*snake2dir=='d'))
       {
        if (snake2->x==79)
         snake2->x = 0;
        else
         snake2->x++;
        set_dir2=1;
        *snake2dir = 'r';
       }
       break;
   }
  if (set_dir2==0)
  {
   switch(*snake2dir)
   {
    case 'l': if (snake2->x==0)
       snake2->x = 79;
      else
       snake2->x--;
      break;
    case 'r': if (snake2->x==79)
       snake2->x = 0;
      else
       snake2->x++;
      break;
    case 'u': if (snake2->y==0)
       snake2->y = 21;
      else
       snake2->y--;
      break;
    case 'd': if (snake2->y==21)
       snake2->y = 0;
      else
       snake2->y++;
      break;
   }
  }
  s2 = queue_push(s2, *snake2);
  int flag = 0; int i;
  for (i=0; i<r->rewnum; i++)
  {
   if ((r->rewcoord[i].x==snake2->x)&&(r->rewcoord[i].y==snake2->y))
   {
    r = mk_reward(s1, s2, r, i);
    p->s2_points++;
    flag=1;
    break;
   }
  }
  if (flag==0)
   s2 = queue_pop(s2);
 return 0;
}

variable_types: ch int

user_defined_types: struct Points_ { int s1_points; int s2_points; }


play

original_code:
int play(Queue *s1, Queue *s2, coord* snake1, coord *snake2, char *snake1dir, char *snake2dir, reward *r,Points* p )
{
  int ch;
  int set_dir1=0;
  int set_dir2=0;
  int iter;
 for (iter=0; iter<2; iter++)
 {
  ch=wgetch(stdscr);
  switch (ch)
  {
    case (int)'q': return 1;
    case (int)'w': if (((*snake1dir=='r')||(*snake1dir=='l'))&&(set_dir1==0))
       {
        if (snake1->y==0)
         snake1->y = 21;
        else
         snake1->y--;
        *snake1dir = 'u';
        set_dir1=1;
       }
       break;
    case (int)'s': if (((*snake1dir=='r')||(*snake1dir=='l'))&&(set_dir1==0))
       {
        if (snake1->y==21)
         snake1->y = 0;
        else
         snake1->y++;
        set_dir1=1;
        *snake1dir = 'd';
       }
       break;
    case (int)'a': if (((*snake1dir=='u')||(*snake1dir=='d'))&&(set_dir1==0))
       {
        if (snake1->x==0)
         snake1->x = 79;
        else
         snake1->x--;
        set_dir1=1;
        *snake1dir = 'l';
       }
       break;
    case (int)'d': if (((*snake1dir=='u')||(*snake1dir=='d'))&&(set_dir1==0))
       {
        if (snake1->x==79)
         snake1->x = 0;
        else
         snake1->x++;
        set_dir1=1;
        *snake1dir = 'r';
       }
       break;
    case 259: if (((*snake2dir=='r')||(*snake2dir=='l'))&&(set_dir2==0))
       {
        if (snake2->y==0)
         snake2->y = 21;
        else
         snake2->y--;
        *snake2dir = 'u';
        set_dir2=1;
       }
       break;
    case 258 : if (((*snake2dir=='r')||(*snake2dir=='l'))&&(set_dir2==0))
       {
        if (snake2->y==21)
         snake2->y = 0;
        else
         snake2->y++;
        set_dir2=1;
        *snake2dir = 'd';
       }
       break;
    case 260 : if (((*snake2dir=='u')||(*snake2dir=='d'))&&(set_dir2==0))
       {
        if (snake2->x==0)
         snake2->x = 79;
        else
         snake2->x--;
        set_dir2=1;
        *snake2dir = 'l';
       }
       break;
    case 261: if (((*snake2dir=='u')||(*snake2dir=='d'))&&(set_dir2==0))
       {
        if (snake2->x==79)
         snake2->x = 0;
        else
         snake2->x++;
        set_dir2=1;
        *snake2dir = 'r';
       }
       break;
   }
  }
  if (set_dir1==0)
  {
   switch(*snake1dir)
   {
    case 'l': if (snake1->x==0)
       snake1->x = 79;
      else
       snake1->x--;
      break;
    case 'r': if (snake1->x==79)
       snake1->x = 0;
      else
       snake1->x++;
      break;
    case 'u': if (snake1->y==0)
       snake1->y = 21;
      else
       snake1->y--;
      break;
    case 'd': if (snake1->y==21)
       snake1->y = 0;
      else
       snake1->y++;
      break;
   }
  }
  if (set_dir2==0)
  {
   switch(*snake2dir)
   {
    case 'l': if (snake2->x==0)
       snake2->x = 79;
      else
       snake2->x--;
      break;
    case 'r': if (snake2->x==79)
       snake2->x = 0;
      else
       snake2->x++;
      break;
    case 'u': if (snake2->y==0)
       snake2->y = 21;
      else
       snake2->y--;
      break;
    case 'd': if (snake2->y==21)
       snake2->y = 0;
      else
       snake2->y++;
      break;
   }
  }
  s1 = queue_push(s1, *snake1);
  s2 = queue_push(s2, *snake2);
  int flag=0, i, check=-1;
  for (i=0; i<r->rewnum; i++)
  {
   if ((r->rewcoord[i].x==snake2->x)&&(r->rewcoord[i].y==snake2->y))
   {
    r = mk_reward(s1, s2, r, i);
    p->s2_points++;
    flag=1;
    break;
   }
  }
  if (flag==0)
   s2 = queue_pop(s2);
  flag=0;
  coord s1_head = get_head(s1);
  for (i=0; i<r->rewnum; i++)
  {
   if ((r->rewcoord[i].x==snake1->x)&&(r->rewcoord[i].y==snake1->y))
   {
    r = mk_reward(s1, s2, r, i);
    p->s1_points++;
    flag=1;
    break;
   }
  }
  if (flag==0)
   s1 = queue_pop(s1);
 return 0;
}

canonical_original_code:
int play(struct Queue_ *s1, struct Queue_ *s2, struct coord_ *snake1, struct coord_ *snake2, char *snake1dir, char *snake2dir, struct reward_ *r, struct Points_ *p)
{
  int ch;
  int set_dir1 = 0;
  int set_dir2 = 0;
  int iter;
 for (iter=0; iter<2; iter++)
 {
  ch=wgetch(stdscr);
  switch (ch)
  {
    case (int)'q': return 1;
    case (int)'w': if (((*snake1dir=='r')||(*snake1dir=='l'))&&(set_dir1==0))
       {
        if (snake1->y==0)
         snake1->y = 21;
        else
         snake1->y--;
        *snake1dir = 'u';
        set_dir1=1;
       }
       break;
    case (int)'s': if (((*snake1dir=='r')||(*snake1dir=='l'))&&(set_dir1==0))
       {
        if (snake1->y==21)
         snake1->y = 0;
        else
         snake1->y++;
        set_dir1=1;
        *snake1dir = 'd';
       }
       break;
    case (int)'a': if (((*snake1dir=='u')||(*snake1dir=='d'))&&(set_dir1==0))
       {
        if (snake1->x==0)
         snake1->x = 79;
        else
         snake1->x--;
        set_dir1=1;
        *snake1dir = 'l';
       }
       break;
    case (int)'d': if (((*snake1dir=='u')||(*snake1dir=='d'))&&(set_dir1==0))
       {
        if (snake1->x==79)
         snake1->x = 0;
        else
         snake1->x++;
        set_dir1=1;
        *snake1dir = 'r';
       }
       break;
    case 259: if (((*snake2dir=='r')||(*snake2dir=='l'))&&(set_dir2==0))
       {
        if (snake2->y==0)
         snake2->y = 21;
        else
         snake2->y--;
        *snake2dir = 'u';
        set_dir2=1;
       }
       break;
    case 258 : if (((*snake2dir=='r')||(*snake2dir=='l'))&&(set_dir2==0))
       {
        if (snake2->y==21)
         snake2->y = 0;
        else
         snake2->y++;
        set_dir2=1;
        *snake2dir = 'd';
       }
       break;
    case 260 : if (((*snake2dir=='u')||(*snake2dir=='d'))&&(set_dir2==0))
       {
        if (snake2->x==0)
         snake2->x = 79;
        else
         snake2->x--;
        set_dir2=1;
        *snake2dir = 'l';
       }
       break;
    case 261: if (((*snake2dir=='u')||(*snake2dir=='d'))&&(set_dir2==0))
       {
        if (snake2->x==79)
         snake2->x = 0;
        else
         snake2->x++;
        set_dir2=1;
        *snake2dir = 'r';
       }
       break;
   }
  }
  if (set_dir1==0)
  {
   switch(*snake1dir)
   {
    case 'l': if (snake1->x==0)
       snake1->x = 79;
      else
       snake1->x--;
      break;
    case 'r': if (snake1->x==79)
       snake1->x = 0;
      else
       snake1->x++;
      break;
    case 'u': if (snake1->y==0)
       snake1->y = 21;
      else
       snake1->y--;
      break;
    case 'd': if (snake1->y==21)
       snake1->y = 0;
      else
       snake1->y++;
      break;
   }
  }
  if (set_dir2==0)
  {
   switch(*snake2dir)
   {
    case 'l': if (snake2->x==0)
       snake2->x = 79;
      else
       snake2->x--;
      break;
    case 'r': if (snake2->x==79)
       snake2->x = 0;
      else
       snake2->x++;
      break;
    case 'u': if (snake2->y==0)
       snake2->y = 21;
      else
       snake2->y--;
      break;
    case 'd': if (snake2->y==21)
       snake2->y = 0;
      else
       snake2->y++;
      break;
   }
  }
  s1 = queue_push(s1, *snake1);
  s2 = queue_push(s2, *snake2);
  int flag = 0; int i; int check = -1;
  for (i=0; i<r->rewnum; i++)
  {
   if ((r->rewcoord[i].x==snake2->x)&&(r->rewcoord[i].y==snake2->y))
   {
    r = mk_reward(s1, s2, r, i);
    p->s2_points++;
    flag=1;
    break;
   }
  }
  if (flag==0)
   s2 = queue_pop(s2);
  flag=0;
  struct coord_ s1_head = get_head(s1);
  for (i=0; i<r->rewnum; i++)
  {
   if ((r->rewcoord[i].x==snake1->x)&&(r->rewcoord[i].y==snake1->y))
   {
    r = mk_reward(s1, s2, r, i);
    p->s1_points++;
    flag=1;
    break;
   }
  }
  if (flag==0)
   s1 = queue_pop(s1);
 return 0;
}

variable_types: struct Queue_ { struct Node_ { struct coord_ { int x; int y; } data; struct Node_ *next; } *head; struct Node_ *tail; } *

variable_types: struct reward_ { struct coord_ rewcoord[4]; int rewnum; } *

variable_types: struct Points_ { int s1_points; int s2_points; } *

variable_types: iter int

variable_types: flag int

variable_types: i int

variable_types: check int

return_type: int

user_defined_types: struct Queue_ { struct Node_ *head; struct Node_ *tail; }

user_defined_types: struct Node_ { struct coord_ data; struct Node_ *next; }


main

canonical_name: main

repo: sahilsd/LazyEDF

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
const char *v4; // rdi
FILE *v5; // rax
const char *v6; // rdi
__int64 v7; // rbx
size_t v8; // r12
int v9; // er12
size_t v10; // r13
char *v11; // rax
__int64 v12; // rbx
__int64 v13; // rbx
double v14; // xmm0_8
__int64 v15; // r12
__int64 v16; // rbx
__int64 v17; // rdx
__int64 v18; // rbx
int v19; // er13
char **v20; // r15
char *v21; // rax
char *v22; // rdx
__int64 v23; // r8
int v24; // esi
__int64 v25; // r14
int v26; // er15
int v27; // eax
char *v28; // rdx
__int64 v29; // rdi
int v30; // eax
__int64 v31; // rdx
char *v32; // rax
int v33; // xmm0_4
__int64 v34; // r15
const char *v35; // rsi
__int64 v36; // r12
int v37; // eax
__int64 v38; // rdx
__int64 v39; // rbx
__int64 v40; // r13
FILE *v41; // rdi
unsigned int v42; // er10
int v43; // ecx
float *v44; // rdx
int v45; // xmm0_4
int v46; // eax
int v47; // esi
int v48; // xmm0_4
__int64 v49; // rsi
int v50; // xmm0_4
__int64 v51; // r9
float v52; // xmm0_4
__int64 v53; // rbx
double v54; // xmm0_8
double v55; // xmm1_8
__int64 v56; // rbx
double v57; // xmm0_8
double v58; // xmm1_8
__int64 v59; // r8
__int64 v60; // rbx
__int64 v61; // rcx
int v62; // edi
__int64 v63; // r11
__int64 v64; // r10
__int64 v65; // r9
_DWORD *v66; // rsi
int v67; // eax
__int64 v68; // rbp
__int64 v69; // rbx
__int64 v70; // rdx
double v71; // xmm0_8
double v72; // xmm7_8
double v73; // xmm6_8
double v74; // xmm5_8
double v75; // xmm4_8
double v76; // xmm3_8
double v77; // xmm2_8
double v78; // xmm1_8
__int64 j; // rbx
double v80; // xmm0_8
double v81; // xmm1_8
__int64 v83; // [rsp-10h] [rbp-68h]
__int64 i; // [rsp+8h] [rbp-50h]
int v85; // [rsp+14h] [rbp-44h]
__int64 v86; // [rsp+18h] [rbp-40h]

energy = 0;
preemptions = 0;
zzzTime = LC2;
latency = 0LL;
cache_impacts = 0;
create_Queue(argc, argv, envp);
v4 = argv[1];
sleepFlag = 0;
prev_alpha = LC2;
alpha = LC2;
operating_frequency = LC2;
finishTask = 0;
fpin = (__int64)fopen(v4, "r+");
v5 = fopen("schedule.txt", "a+");
v6 = argv[2];
fpout = v5;
fp_job = (__int64)fopen(v6, "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);
v7 = no_of_tasks;
v8 = 4LL * no_of_tasks;
t = (__int64)malloc(20LL * no_of_tasks);
job = (__int64)malloc(8 * v7);
min_exec_tasks = (__int64)malloc(v8);
max_exec_tasks = (__int64)malloc(v8);
total_exec_tasks = (__int64)malloc(v8);
avg_exec_tasks = (__int64)malloc(v8);
min_lat = (__int64)malloc(v8);
max_lat = (__int64)malloc(v8);
avg_lat = (__int64)malloc(v8);
total_lat = (__int64)malloc(v8);
fprintf(fpout, "The no. of tasks are %d\n\n\n", (unsigned int)v7);
_isoc99_fscanf(fp_freq, "%d", &no_of_freq);
v9 = no_of_freq;
v10 = 4LL * no_of_freq;
time_per_freq = (__int64)malloc(v10);
v11 = (char *)malloc(v10);
freq = (__int64)v11;
if ( v9 > 0 )
{
v12 = 0LL;
while ( 1 )
{
_isoc99_fscanf(fp_freq, "%f", &v11[4 * v12]);
v9 = no_of_freq;
*(_DWORD *)(time_per_freq + 4 * v12++) = 0;
if ( v9 <= (int)v12 )
break;
v11 = (char *)freq;
}
}
v13 = 0LL;
fprintf(fpout, "The available frequencies are %d\n", (unsigned int)v9);
if ( no_of_freq > 0 )
{
do
{
v14 = *(float *)(freq + 4 * v13++);
fprintf(fpout, "%f\n", v14);
}
while ( no_of_freq > (int)v13 );
}
v15 = 0LL;
v16 = 0LL;
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 )
{
do
{
v17 = v15 + t;
v15 += 20LL;
_isoc99_fscanf(fpin, "%d %d %d %f %d", v17, v17 + 4, v17 + 16, v17 + 12, v17 + 8);
*(_DWORD *)(min_exec_tasks + 4 * v16) = 1203982208;
*(_DWORD *)(max_exec_tasks + 4 * v16) = -943501440;
*(_DWORD *)(min_lat + 4 * v16) = 1203982208;
*(_DWORD *)(max_lat + 4 * v16++) = -943501440;
}
while ( no_of_tasks > (int)v16 );
}
v18 = 0LL;
find_hyperperiod();
for ( i = 0LL; no_of_tasks > (int)i; v18 += 20LL )
{
v86 = t;
v85 = *(_DWORD *)(t + v18 + 16);
v19 = hyperperiod / v85;
v20 = (char **)(8 * i + job);
v21 = (char *)malloc(56LL * (hyperperiod / v85));
*v20 = v21;
v22 = v21;
if ( v19 > 0 )
{
v23 = v86;
v24 = v85;
v25 = 0LL;
v26 = 0;
while ( 1 )
{
v27 = *(_DWORD *)(v23 + v18);
v28 = &v22[v25];
v29 = fp_job;
*((_DWORD *)v28 + 4) = v24;
v28 += 12;
*((_DWORD *)v28 - 3) = v27;
v30 = v26++;
*((_DWORD *)v28 - 2) = v24 * v30;
_isoc99_fscanf(v29, "%f", v28);
v31 = v25 + *(_QWORD *)(job + 8 * i) + 32;
*(_DWORD *)(v31 - 24) = v26 * *(_DWORD *)(t + v18 + 8);
_isoc99_fscanf(fp_job, "%f", v31);
v22 = *(char **)(job + 8 * i);
v32 = &v22[v25];
v25 += 56LL;
v33 = *((_DWORD *)v32 + 8);
*(_QWORD *)(v32 + 44) = 0LL;
*((_DWORD *)v32 + 5) = v33;
*((_DWORD *)v32 + 6) = v33;
*((float *)v32 + 9) = (float)*((int *)v32 + 2) - *((float *)v32 + 3);
*((float *)v32 + 10) = (float)*((int *)v32 + 1);
if ( v26 == v19 )
break;
v23 = t;
v24 = *(_DWORD *)(t + v18 + 16);
}
}
++i;
}
v34 = 0LL;
fwrite("The latencies of the tasks are : \n\n\n", 1uLL, 0x24uLL, fp_lat);
create_Hyper_Queue();
v35 = "a+";
hyper = fopen("Hyper_debug.txt", "a+");
if ( no_of_tasks > 0 )
{
do
{
v36 = 20 * v34;
v38 = (unsigned int)(hyperperiod >> 31);
LODWORD(v38) = hyperperiod % *(_DWORD *)(t + 20 * v34 + 16);
v37 = hyperperiod / *(_DWORD *)(t + 20 * v34 + 16);
if ( v37 > 0 )
{
v39 = 0LL;
v40 = 56LL * v37;
do
{
v3 = create_node(v3, v35, v38);
v41 = hyper;
v42 = *(_DWORD *)(v36 + t);
v43 = *(_DWORD *)(v36 + t + 16);
*(_DWORD *)v3 = v42;
v44 = (float *)(v39 + *(_QWORD *)(job + 8 * v34));
v39 += 56LL;
v45 = *((_DWORD *)v44 + 3);
v46 = *((_DWORD *)v44 + 1);
v47 = *((_DWORD *)v44 + 2);
*(_DWORD *)(v3 + 16) = v43;
*(_DWORD *)(v3 + 12) = v45;
v48 = *((_DWORD *)v44 + 5);
*(_DWORD *)(v3 + 8) = v47;
v49 = *((unsigned int *)v44 + 2);
*(_DWORD *)(v3 + 20) = v48;
v50 = *((_DWORD *)v44 + 8);
*(_DWORD *)(v3 + 4) = v46;
v51 = *((unsigned int *)v44 + 1);
*(_DWORD *)(v3 + 24) = v50;
v52 = (float)(int)v49 - v44[3];
*(_QWORD *)(v3 + 44) = 0LL;
*(float *)(v3 + 36) = v52;
*(float *)(v3 + 40) = (float)(int)v51;
*(_DWORD *)(v3 + 52) = v46 / v43;
v83 = v49;
v35 = "Enqueued T[%d][%d-%d] (r-%d, dd-%d, plau-%f)\n";
fprintf(
v41,
"Enqueued T[%d][%d-%d] (r-%d, dd-%d, plau-%f)\n",
v42,
v42,
(unsigned int)((int)v51 / v43),
v51,
v83,
v52);
Enqueue_Hyper(v3);
}
while ( v40 != v39 );
}
++v34;
}
while ( no_of_tasks > (int)v34 );
}
v53 = 0LL;
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 )
{
do
{
v54 = *(float *)(freq + 4 * v53);
v55 = *(float *)(time_per_freq + 4 * v53++);
fprintf(fp_time_per_freq, "Freq[%f] : %f \n\n", v54, v55);
}
while ( no_of_freq > (int)v53 );
}
v56 = 0LL;
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 )
{
do
{
v57 = *(float *)(freq + 4 * v56) * 2.4;
v58 = *(float *)(time_per_freq + 4 * v56++);
fprintf(fp_time_per_freq, "Voltage[%f] : %f \n\n", v57, v58);
}
while ( no_of_freq > (int)v56 );
}
v59 = no_of_tasks;
if ( no_of_tasks > 0 )
{
v60 = total_lat;
v61 = 0LL;
v62 = hyperperiod;
v63 = avg_lat;
v64 = total_exec_tasks;
v65 = avg_exec_tasks;
v66 = (_DWORD *)(t + 16);
do
{
v67 = v62 / *v66;
v66 += 5;
*(float *)(v63 + 4 * v61) = *(float *)(v60 + 4 * v61) / (float)v67;
*(float *)(v65 + 4 * v61) = *(float *)(v64 + 4 * v61) / (float)v67;
++v61;
}
while ( v59 != v61 );
}
v68 = 0LL;
v69 = 0LL;
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 )
{
do
{
v70 = *(unsigned int *)(v68 + t + 16);
v71 = *(float *)(v68 + t + 12);
v68 += 20LL;
v72 = *(float *)(avg_lat + 4 * v69);
v73 = *(float *)(max_lat + 4 * v69);
v74 = *(float *)(min_lat + 4 * v69);
v75 = *(float *)(avg_exec_tasks + 4 * v69);
v76 = *(float *)(total_exec_tasks + 4 * v69);
v77 = *(float *)(max_exec_tasks + 4 * v69);
v78 = *(float *)(min_exec_tasks + 4 * v69++);
fprintf(fp_output, "%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t", v70, v71, v78, v77, v76, v75, v74, v73, v72);
}
while ( no_of_tasks > (int)v69 );
}
for ( j = 0LL; no_of_freq > (int)j; ++j )
{
v80 = *(float *)(freq + 4 * j);
v81 = *(float *)(time_per_freq + 4 * j);
fprintf(fp_output, "Freq[%f] : %f \t", v80, v81);
}
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: j int

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:
__int64 Calc_Plausible_Time_Hyper_prev()
{
__int64 v0; // rbx
__int64 result; // rax
float v2; // xmm0_4

v0 = *(_QWORD *)(Q_Hyper + 8);
fflush(stdout);
result = *(_QWORD *)Q_Hyper;
if ( v0 != *(_QWORD *)Q_Hyper )
{
v2 = *(float *)(v0 + 36);
do
{
v0 = *(_QWORD *)(v0 + 64);
v2 = fminf(v2 - *(float *)(v0 + 12), *(float *)(v0 + 36));
*(float *)(v0 + 36) = v2;
}
while ( v0 != result );
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbx
__int64 result; // rax
float v2; // xmm0_4

v0 = *(_QWORD *)(Q_Hyper + 8);
fflush(stdout);
result = *(_QWORD *)Q_Hyper;
if ( v0 != *(_QWORD *)Q_Hyper )
{
v2 = *(float *)(v0 + 36);
do
{
v0 = *(_QWORD *)(v0 + 64);
v2 = fminf(v2 - *(float *)(v0 + 12), *(float *)(v0 + 36));
*(float *)(v0 + 36) = v2;
}
while ( v0 != result );
}
return result;
}

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


decompiled_code:
unsigned int **__fastcall Calc_Plausible_Time_Hyper()
{
__int64 v0; // r12
unsigned int *v1; // rbx
unsigned int **result; // rax
__int64 v3; // rbp
float v4; // xmm0_4
float v5; // xmm2_4
unsigned int *v6; // rax
float v7; // xmm2_4
float v8; // xmm0_4
float v9; // xmm1_4
float v10; // xmm3_4
int v11; // eax
float v12; // xmm1_4
unsigned int v13; // eax
float v14; // xmm0_4
float v15; // xmm1_4
float v16; // xmm0_4
float v17; // xmm1_4
int v18; // eax
unsigned int v19; // edx
__int64 v20; // rdi
float v21; // xmm0_4
unsigned int v22; // eax
float v23; // xmm0_4
__int64 v24; // rax
__int64 v25; // rdx
unsigned int *v26; // rdi

v1 = *(unsigned int **)(Q_Hyper + 8);
prev_min = 0LL;
fflush(stdout);
result = (unsigned int **)Q_Hyper;
while ( *result != v1 )
{
while ( 1 )
{
v3 = *((_QWORD *)v1 + 8);
v4 = *((float *)v1 + 9);
v5 = *(float *)(v3 + 12);
if ( (float)((float)*(int *)(v3 + 4) + v5) > v4 )
break;
v1 = (unsigned int *)*((_QWORD *)v1 + 8);
*(float *)(v3 + 36) = fminf(*(float *)(v3 + 36), v4 - v5);
LABEL_4:
if ( *result == v1 )
return result;
}
fprintf(hyper, "Breaking bad S%dE%d\n", *v1, v1[13]);
v6 = (unsigned int *)create_node(v0);
v7 = *((float *)v1 + 9);
v8 = *(float *)(v3 + 12);
v9 = (float)*(int *)(v3 + 4);
v10 = *((float *)v1 + 3);
v0 = (__int64)v6;
*v6 = *v1;
v6[1] = v1[1];
if ( (float)(v7 + v10) <= (float)(v9 + v8) )
{
v18 = *(_DWORD *)(v3 + 4);
v19 = v1[4];
v20 = v0;
*(float *)(v0 + 12) = v10;
v21 = (float)v18;
*(_DWORD *)(v0 + 8) = v18;
v22 = v1[13];
*(_DWORD *)(v0 + 16) = v19;
*(float *)(v0 + 36) = v21 - v10;
v23 = (float)(int)v1[1];
*(_DWORD *)(v0 + 52) = v22;
*(_QWORD *)(v0 + 44) = 0LL;
*(float *)(v0 + 40) = v23;
v0 = (__int64)v1;
Enqueue_Hyper(v20);
v24 = *((_QWORD *)v1 + 7);
v25 = *((_QWORD *)v1 + 8);
v26 = v1;
*(_QWORD *)(v25 + 56) = v24;
*(_QWORD *)(v24 + 64) = v25;
v1 = (unsigned int *)*((_QWORD *)v1 + 8);
free(v26);
result = (unsigned int **)Q_Hyper;
goto LABEL_4;
}
v11 = *(_DWORD *)(v3 + 4);
v12 = (float)v11;
*(_DWORD *)(v0 + 8) = v11;
*(_DWORD *)(v0 + 16) = v1[4];
v13 = v1[13];
v14 = (float)(v8 + v12) - v7;
v15 = v12 - v14;
*(float *)(v0 + 12) = v14;
v16 = (float)(int)v1[1];
*(_DWORD *)(v0 + 52) = v13;
*(_QWORD *)(v0 + 44) = 0LL;
*(float *)(v0 + 36) = v15;
*(float *)(v0 + 40) = v16;
Enqueue_Hyper(v0);
v17 = (float)*(int *)(v3 + 4);
result = (unsigned int **)Q_Hyper;
*((float *)v1 + 9) = *(float *)(v3 + 12) + v17;
*((float *)v1 + 3) = *((float *)v1 + 3) - *(float *)(v0 + 12);
v1 = (unsigned int *)*((_QWORD *)v1 + 8);
*(float *)(v3 + 36) = v17;
}
return result;
}

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
unsigned int *v3; // rbx
float v4; // xmm1_4
unsigned int *v5; // rdx
__int64 v6; // rax
float v7; // xmm2_4
_BOOL8 v8; // rdx
float v9; // xmm1_4
__int64 v10; // rax
float v11; // xmm2_4
float v12; // xmm0_4
float v13; // xmm1_4
__int64 v14; // rax
float v15; // xmm2_4
__int64 v16; // rdx
float v17; // xmm0_4
float v18; // xmm1_4
float v20; // xmm3_4
__int64 v21; // rax
float v22; // xmm0_4
FILE *v23; // r8
float v24; // xmm4_4
__int64 v25; // rdx
__int64 v26; // rax
float v27; // xmm5_4
float v28; // xmm6_4
float v29; // xmm0_4
float v30; // xmm5_4
__int64 v31; // rax
unsigned int v32; // er10
__int64 v33; // r8
signed int v34; // ecx
FILE *v35; // rdi
float v36; // xmm1_4
float v37; // xmm0_4
__int64 v38; // r9
float v39; // xmm0_4
float v40; // xmm0_4
float v41; // xmm5_4
float v42; // xmm4_4
FILE *v43; // r8
__int64 v44; // rax
unsigned int v45; // er10
__int64 v46; // r8
signed int v47; // ecx
FILE *v48; // rdi
float v49; // xmm1_4
float v50; // xmm0_4
__int64 v51; // r9
float v52; // xmm0_4
double v53; // xmm1_8
float v54; // [rsp+Ch] [rbp-2Ch]
float v55; // [rsp+Ch] [rbp-2Ch]
float v56; // [rsp+Ch] [rbp-2Ch]

prev_min = 0LL;
v2 = *(_QWORD *)(Q_Hyper + 8);
fflush(stdout);
while ( *(_QWORD *)(*(_QWORD *)Q_Hyper + 56LL) != v2 )
{
printf("plau T[%d][%d](%d)", *v0, (unsigned int)((int)v0[1] / (int)v0[4]), v0[2]);
v3 = *(unsigned int **)(v2 + 64);
v54 = *(float *)(v2 + 36);
fprintf(
hyper,
"Updated @#$ plau T[%d][%d] from %f to %f (dd-%d)\n",
*v3,
(unsigned int)((int)v3[1] / (int)v3[4]),
*((float *)v3 + 9),
fminf(v54 - *((float *)v3 + 3), *((float *)v3 + 9)),
v3[2]);
v4 = *((float *)v3 + 3);
v5 = *(unsigned int **)(v2 + 64);
min = (__int64)v3;
v6 = (__int64)v3;
v7 = fminf(v54 - v4, *((float *)v3 + 9));
*((float *)v3 + 9) = v7;
while ( (float)((float)*(int *)(v6 + 4) + v4) <= *((float *)v5 + 9) )
{
v6 = *(_QWORD *)(v6 + 64);
if ( !v6 )
{
v8 = v5 != v3;
goto LABEL_7;
}
v4 = *(float *)(v6 + 12);
}
prev_min = (__int64)v3;
v7 = *(float *)(v6 + 36);
v3 = (unsigned int *)v6;
v8 = 0LL;
min = v6;
LABEL_7:
fprintf(hyper, "***Found prev min(%d) rls T[%d][%d] = %f(%d)\n", v8, *v3, v3[13], v7, v3[2]);
v0 = *(unsigned int **)(v2 + 64);
v9 = *((float *)v0 + 9);
if ( (float)((float)*(int *)(min + 4) + *(float *)(min + 12)) <= v9 || (unsigned int *)min == v0 )
{
v2 = *(_QWORD *)(v2 + 64);
}
else
{
fprintf(
hyper,
"Changing plau T[%d][%d] from %f to %d\n\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v9,
*(unsigned int *)(min + 8));
v20 = (float)*(int *)(min + 8);
v21 = *((_QWORD *)v0 + 7);
*((float *)v0 + 9) = v20;
v22 = *(float *)(v21 + 36);
if ( v20 == v22 )
{
fwrite("______________________\n", 1uLL, 0x17uLL, hyper);
v20 = *((float *)v0 + 9);
v23 = hyper;
v22 = *(float *)(*((_QWORD *)v0 + 7) + 36LL);
v24 = *((float *)v0 + 3) - (float)((float)(int)v0[2] - v20);
*((float *)v0 + 3) = *((float *)v0 + 3) - v24;
if ( v24 >= 0.0 && v20 != v22 )
{
LABEL_26:
v40 = next_highest_plausible((__int64)v0);
v56 = v42;
fprintf(
v43,
"rem_wcet T[%d][%d] %f = %f - (%f-%f)\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v42,
v41,
v40,
v20);
v44 = create_node(v1);
v45 = *v0;
v46 = v0[1];
v1 = v44;
v47 = v0[4];
*(_DWORD *)(v44 + 4) = v46;
v48 = hyper;
*(_DWORD *)v44 = v45;
*(float *)(v44 + 12) = v56;
v49 = (float)(int)v0[1];
v50 = *(float *)(min + 36);
LODWORD(v44) = v0[13];
*(_DWORD *)(v1 + 16) = v47;
*(_QWORD *)(v1 + 44) = 0LL;
*(_DWORD *)(v1 + 52) = v44;
v51 = (unsigned int)(int)v50;
v52 = v50 - v56;
*(float *)(v1 + 40) = v49;
v53 = *(float *)(v1 + 24);
*(float *)(v1 + 36) = v52;
*(_DWORD *)(v1 + 8) = v51;
fprintf(
v48,
"Enqueued T[%d][%d]** (r-%d, dd-%d, plau-%f, abs rem-%f)\n",
v45,
(unsigned int)((int)v46 / v47),
v46,
v51,
v52,
v53);
Enqueue_Hyper(v1);
v2 = *(_QWORD *)(v2 + 64);
goto LABEL_10;
}
}
else
{
v23 = hyper;
v24 = *((float *)v0 + 3) - (float)((float)(int)v0[2] - v20);
*((float *)v0 + 3) = *((float *)v0 + 3) - v24;
if ( v24 >= 0.0 )
goto LABEL_26;
}
v55 = v24;
fprintf(v23, "can't be broken... so moving (%d)\n", v22 == v20);
v25 = *((_QWORD *)v0 + 8);
v26 = *((_QWORD *)v0 + 7);
v27 = *((float *)v0 + 3);
*(_QWORD *)(v25 + 56) = v26;
*(_QWORD *)(v26 + 64) = v25;
v28 = v55 + v27;
v29 = 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]),
v28,
v30,
v29,
*((float *)v0 + 9));
v31 = create_node(v1);
v32 = *v0;
v33 = v0[1];
v1 = v31;
v34 = v0[4];
*(_DWORD *)(v31 + 4) = v33;
v35 = hyper;
*(_DWORD *)v31 = v32;
*(float *)(v31 + 12) = v28;
v36 = (float)(int)v0[1];
v37 = *(float *)(min + 36);
LODWORD(v31) = v0[13];
*(_DWORD *)(v1 + 16) = v34;
*(_QWORD *)(v1 + 44) = 0LL;
*(_DWORD *)(v1 + 52) = v31;
v38 = (unsigned int)(int)v37;
v39 = v37 - v28;
*(float *)(v1 + 40) = v36;
*(float *)(v1 + 36) = v39;
*(_DWORD *)(v1 + 8) = v38;
fprintf(v35, "moving T[%d][%d]** (r-%d, dd-%d, plau-%f)\n", v32, (unsigned int)((int)v33 / v34), v33, v38, v39);
Enqueue_Hyper(v1);
v2 = *(_QWORD *)(v2 + 64);
}
LABEL_10:
printf("(%d) ", *(unsigned int *)(v2 + 8));
puts("done");
}
v10 = *(_QWORD *)(v2 + 56);
v11 = *(float *)(v2 + 12);
v12 = *(float *)(v2 + 36);
v13 = *(float *)(v10 + 36) - v11;
if ( v12 > v13 )
{
*(float *)(v2 + 36) = v13;
v12 = v13;
v13 = *(float *)(v10 + 36) - v11;
}
fprintf(hyper, "2nd last job %f<> %f\n", v12, v13);
while ( 1 )
{
v14 = *(_QWORD *)(v2 + 64);
v15 = *(float *)(v14 + 12);
if ( (float)((float)*(int *)(v14 + 4) + v15) <= *(float *)(v2 + 36) )
break;
puts("STILL GG\n");
}
v16 = *(_QWORD *)(v14 + 56);
v17 = *(float *)(v14 + 36);
v18 = *(float *)(v16 + 36) - v15;
if ( v17 > v18 )
{
*(float *)(v14 + 36) = v18;
v17 = v18;
v18 = *(float *)(v16 + 36) - v15;
}
return fprintf(hyper, "last job %f <> %f\n", v17, v18);
}

canonical_decompiled_code:
int __fastcall func5()
{
unsigned int *v0; // rbx
__int64 v1; // r12
__int64 v2; // rbp
unsigned int *v3; // rbx
float v4; // xmm1_4
unsigned int *v5; // rdx
__int64 v6; // rax
float v7; // xmm2_4
_BOOL8 v8; // rdx
float v9; // xmm1_4
__int64 v10; // rax
float v11; // xmm2_4
float v12; // xmm0_4
float v13; // xmm1_4
__int64 v14; // rax
float v15; // xmm2_4
__int64 v16; // rdx
float v17; // xmm0_4
float v18; // xmm1_4
float v20; // xmm3_4
__int64 v21; // rax
float v22; // xmm0_4
FILE *v23; // r8
float v24; // xmm4_4
__int64 v25; // rdx
__int64 v26; // rax
float v27; // xmm5_4
float v28; // xmm6_4
float v29; // xmm0_4
float v30; // xmm5_4
__int64 v31; // rax
unsigned int v32; // er10
__int64 v33; // r8
signed int v34; // ecx
FILE *v35; // rdi
float v36; // xmm1_4
float v37; // xmm0_4
__int64 v38; // r9
float v39; // xmm0_4
float v40; // xmm0_4
float v41; // xmm5_4
float v42; // xmm4_4
FILE *v43; // r8
__int64 v44; // rax
unsigned int v45; // er10
__int64 v46; // r8
signed int v47; // ecx
FILE *v48; // rdi
float v49; // xmm1_4
float v50; // xmm0_4
__int64 v51; // r9
float v52; // xmm0_4
double v53; // xmm1_8
float v54; // [rsp+Ch] [rbp-2Ch]
float v55; // [rsp+Ch] [rbp-2Ch]
float v56; // [rsp+Ch] [rbp-2Ch]

prev_min = 0LL;
v2 = *(_QWORD *)(Q_Hyper + 8);
fflush(stdout);
while ( *(_QWORD *)(*(_QWORD *)Q_Hyper + 56LL) != v2 )
{
printf("plau T[%d][%d](%d)", *v0, (unsigned int)((int)v0[1] / (int)v0[4]), v0[2]);
v3 = *(unsigned int **)(v2 + 64);
v54 = *(float *)(v2 + 36);
fprintf(
hyper,
"Updated @#$ plau T[%d][%d] from %f to %f (dd-%d)\n",
*v3,
(unsigned int)((int)v3[1] / (int)v3[4]),
*((float *)v3 + 9),
fminf(v54 - *((float *)v3 + 3), *((float *)v3 + 9)),
v3[2]);
v4 = *((float *)v3 + 3);
v5 = *(unsigned int **)(v2 + 64);
min = (__int64)v3;
v6 = (__int64)v3;
v7 = fminf(v54 - v4, *((float *)v3 + 9));
*((float *)v3 + 9) = v7;
while ( (float)((float)*(int *)(v6 + 4) + v4) <= *((float *)v5 + 9) )
{
v6 = *(_QWORD *)(v6 + 64);
if ( !v6 )
{
v8 = v5 != v3;
goto LABEL_7;
}
v4 = *(float *)(v6 + 12);
}
prev_min = (__int64)v3;
v7 = *(float *)(v6 + 36);
v3 = (unsigned int *)v6;
v8 = 0LL;
min = v6;
LABEL_7:
fprintf(hyper, "***Found prev min(%d) rls T[%d][%d] = %f(%d)\n", v8, *v3, v3[13], v7, v3[2]);
v0 = *(unsigned int **)(v2 + 64);
v9 = *((float *)v0 + 9);
if ( (float)((float)*(int *)(min + 4) + *(float *)(min + 12)) <= v9 || (unsigned int *)min == v0 )
{
v2 = *(_QWORD *)(v2 + 64);
}
else
{
fprintf(
hyper,
"Changing plau T[%d][%d] from %f to %d\n\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v9,
*(unsigned int *)(min + 8));
v20 = (float)*(int *)(min + 8);
v21 = *((_QWORD *)v0 + 7);
*((float *)v0 + 9) = v20;
v22 = *(float *)(v21 + 36);
if ( v20 == v22 )
{
fwrite("______________________\n", 1uLL, 0x17uLL, hyper);
v20 = *((float *)v0 + 9);
v23 = hyper;
v22 = *(float *)(*((_QWORD *)v0 + 7) + 36LL);
v24 = *((float *)v0 + 3) - (float)((float)(int)v0[2] - v20);
*((float *)v0 + 3) = *((float *)v0 + 3) - v24;
if ( v24 >= 0.0 && v20 != v22 )
{
LABEL_26:
v40 = func1((__int64)v0);
v56 = v42;
fprintf(
v43,
"rem_wcet T[%d][%d] %f = %f - (%f-%f)\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v42,
v41,
v40,
v20);
v44 = create_node(v1);
v45 = *v0;
v46 = v0[1];
v1 = v44;
v47 = v0[4];
*(_DWORD *)(v44 + 4) = v46;
v48 = hyper;
*(_DWORD *)v44 = v45;
*(float *)(v44 + 12) = v56;
v49 = (float)(int)v0[1];
v50 = *(float *)(min + 36);
LODWORD(v44) = v0[13];
*(_DWORD *)(v1 + 16) = v47;
*(_QWORD *)(v1 + 44) = 0LL;
*(_DWORD *)(v1 + 52) = v44;
v51 = (unsigned int)(int)v50;
v52 = v50 - v56;
*(float *)(v1 + 40) = v49;
v53 = *(float *)(v1 + 24);
*(float *)(v1 + 36) = v52;
*(_DWORD *)(v1 + 8) = v51;
fprintf(
v48,
"Enqueued T[%d][%d]** (r-%d, dd-%d, plau-%f, abs rem-%f)\n",
v45,
(unsigned int)((int)v46 / v47),
v46,
v51,
v52,
v53);
func3(v1);
v2 = *(_QWORD *)(v2 + 64);
goto LABEL_10;
}
}
else
{
v23 = hyper;
v24 = *((float *)v0 + 3) - (float)((float)(int)v0[2] - v20);
*((float *)v0 + 3) = *((float *)v0 + 3) - v24;
if ( v24 >= 0.0 )
goto LABEL_26;
}
v55 = v24;
fprintf(v23, "can't be broken... so moving (%d)\n", v22 == v20);
v25 = *((_QWORD *)v0 + 8);
v26 = *((_QWORD *)v0 + 7);
v27 = *((float *)v0 + 3);
*(_QWORD *)(v25 + 56) = v26;
*(_QWORD *)(v26 + 64) = v25;
v28 = v55 + v27;
v29 = func1((__int64)v0);
fprintf(
hyper,
"rem_wcet@@ T[%d][%d] %f = %f - (%f-%f)\n",
*v0,
(unsigned int)((int)v0[1] / (int)v0[4]),
v28,
v30,
v29,
*((float *)v0 + 9));
v31 = create_node(v1);
v32 = *v0;
v33 = v0[1];
v1 = v31;
v34 = v0[4];
*(_DWORD *)(v31 + 4) = v33;
v35 = hyper;
*(_DWORD *)v31 = v32;
*(float *)(v31 + 12) = v28;
v36 = (float)(int)v0[1];
v37 = *(float *)(min + 36);
LODWORD(v31) = v0[13];
*(_DWORD *)(v1 + 16) = v34;
*(_QWORD *)(v1 + 44) = 0LL;
*(_DWORD *)(v1 + 52) = v31;
v38 = (unsigned int)(int)v37;
v39 = v37 - v28;
*(float *)(v1 + 40) = v36;
*(float *)(v1 + 36) = v39;
*(_DWORD *)(v1 + 8) = v38;
fprintf(v35, "moving T[%d][%d]** (r-%d, dd-%d, plau-%f)\n", v32, (unsigned int)((int)v33 / v34), v33, v38, v39);
func3(v1);
v2 = *(_QWORD *)(v2 + 64);
}
LABEL_10:
printf("(%d) ", *(unsigned int *)(v2 + 8));
puts("done");
}
v10 = *(_QWORD *)(v2 + 56);
v11 = *(float *)(v2 + 12);
v12 = *(float *)(v2 + 36);
v13 = *(float *)(v10 + 36) - v11;
if ( v12 > v13 )
{
*(float *)(v2 + 36) = v13;
v12 = v13;
v13 = *(float *)(v10 + 36) - v11;
}
fprintf(hyper, "2nd last job %f<> %f\n", v12, v13);
while ( 1 )
{
v14 = *(_QWORD *)(v2 + 64);
v15 = *(float *)(v14 + 12);
if ( (float)((float)*(int *)(v14 + 4) + v15) <= *(float *)(v2 + 36) )
break;
puts("STILL GG\n");
}
v16 = *(_QWORD *)(v14 + 56);
v17 = *(float *)(v14 + 36);
v18 = *(float *)(v16 + 36) - v15;
if ( v17 > v18 )
{
*(float *)(v14 + 36) = v18;
v17 = v18;
v18 = *(float *)(v16 + 36) - v15;
}
return fprintf(hyper, "last job %f <> %f\n", v17, v18);
}

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
__int64 v2; // r8
__int64 v3; // r9
FILE *v4; // rdi
double v5; // xmm1_8
unsigned int v6; // eax
__int64 v7; // rdx

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) )
{
v2 = i[1];
v3 = i[2];
v4 = fp_plau;
v5 = *((float *)i + 3);
v6 = (int)i[1] / (int)i[4];
v7 = *i;
*((float *)i + 10) = fmaxf(
*(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL),
*((float *)i + 10));
LODWORD(v0) = fprintf(v4, "T[%d][%d]\t%d >\t%f\t%d\t(%f)\n", v7, v6, v2, *((float *)i + 9), v3, v5);
}
return v0;
}

canonical_decompiled_code:
int func6()
{
__int64 v0; // rax
unsigned int *i; // rbx
__int64 v2; // r8
__int64 v3; // r9
FILE *v4; // rdi
double v5; // xmm1_8
unsigned int v6; // eax
__int64 v7; // rdx

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) )
{
v2 = i[1];
v3 = i[2];
v4 = fp_plau;
v5 = *((float *)i + 3);
v6 = (int)i[1] / (int)i[4];
v7 = *i;
*((float *)i + 10) = fmaxf(
*(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL),
*((float *)i + 10));
LODWORD(v0) = fprintf(v4, "T[%d][%d]\t%d >\t%f\t%d\t(%f)\n", v7, v6, v2, *((float *)i + 9), v3, v5);
}
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()
{
unsigned int *v0; // rbx
double i; // xmm0_8
float v2; // xmm0_4
int result; // eax

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

canonical_decompiled_code:
int func7()
{
unsigned int *v0; // rbx
double i; // xmm0_8
float v2; // xmm0_4
int result; // eax

v0 = *(unsigned int **)Q_Hyper;
for ( i = *(float *)(*(_QWORD *)Q_Hyper + 44LL); ; i = v2 )
{
result = fprintf(fpout, "Slack T[%d] is %f\n", *v0, i);
v0 = (unsigned int *)*((_QWORD *)v0 + 7);
if ( !v0 )
break;
v2 = *((float *)v0 + 10) - (float)(*(float *)(*((_QWORD *)v0 + 8) + 40LL) + *(float *)(*((_QWORD *)v0 + 8) + 12LL));
*((float *)v0 + 11) = v2;
}
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
__int64 v1; // rdx

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

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

result = (_QWORD *)Q;
if ( *(_QWORD *)Q == *(_QWORD *)(Q + 8) )
{
*(_QWORD *)(Q + 8) = 0LL;
*result = 0LL;
}
else
{
v1 = *(_QWORD *)(*(_QWORD *)Q + 56LL);
*(_QWORD *)Q = v1;
*(_QWORD *)(v1 + 64) = 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
unsigned int v2; // er12

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

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

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

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


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

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

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

v0 = *(unsigned int **)Q;
fflush(stdout);
for ( ; *(unsigned int **)(Q + 8) != v0; v0 = (unsigned int *)*((_QWORD *)v0 + 7) )
{
v1 = *((_QWORD *)v0 + 7);
for ( i = *(float *)(v1 + 36); ; i = fminf(*(float *)(v1 + 36), i) )
{
v1 = *(_QWORD *)(v1 + 56);
if ( !v1 )
break;
}
v3 = fminf(i - *((float *)v0 + 3), *((float *)v0 + 9));
v4 = *v0;
v5 = fpout;
*((float *)v0 + 9) = v3;
fprintf(v5, "Plau T[%d] is %f\n", v4, v3);
}
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
__int64 v2; // rcx
__int64 v3; // rdx
FILE *v4; // rdi
float v5; // 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 = i[1];
v3 = *i;
v4 = fpout;
v5 = *(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL);
*((float *)i + 10) = v5;
LODWORD(v0) = fprintf(v4, "URGE time of T[%d] is %f and rls time %d\n", v3, v5, v2);
}
return v0;
}

canonical_decompiled_code:
int func7()
{
__int64 v0; // rax
unsigned int *i; // rbx
__int64 v2; // rcx
__int64 v3; // rdx
FILE *v4; // rdi
float v5; // 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 = i[1];
v3 = *i;
v4 = fpout;
v5 = *(float *)(*((_QWORD *)i + 8) + 40LL) + *(float *)(*((_QWORD *)i + 8) + 12LL);
*((float *)i + 10) = v5;
LODWORD(v0) = fprintf(v4, "URGE time of T[%d] is %f and rls time %d\n", v3, v5, v2);
}
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;
 }
}


main

repo: sahusoft/homework

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]


compare

decompiled_code:
int __fastcall compare(const void *a1, const void *a2)
{
const char *v2; // rbp
char *v3; // rax
const char *v4; // r12
char *v5; // rax
__int128 v7; // [rsp+0h] [rbp-58h] BYREF
int v8; // [rsp+10h] [rbp-48h]
char v9; // [rsp+14h] [rbp-44h]
char dest[16]; // [rsp+20h] [rbp-38h] BYREF
int v11; // [rsp+30h] [rbp-28h]
char v12; // [rsp+34h] [rbp-24h]

v2 = *(const char **)a1;
v7 = 0LL;
*(_OWORD *)dest = 0LL;
v8 = 0;
v9 = 0;
v11 = 0;
v12 = 0;
v3 = stpcpy((char *)&v7, v2);
v4 = *(const char **)a2;
strcpy(v3, *(const char **)a2);
v5 = stpcpy(dest, v4);
strcpy(v5, v2);
return strcmp((const char *)&v7, dest);
}

canonical_decompiled_code:
int __fastcall func7(const void *a1, const void *a2)
{
const char *v2; // rbp
char *v3; // rax
const char *v4; // r12
char *v5; // rax
__int128 v7; // [rsp+0h] [rbp-58h] BYREF
int v8; // [rsp+10h] [rbp-48h]
char v9; // [rsp+14h] [rbp-44h]
char dest[16]; // [rsp+20h] [rbp-38h] BYREF
int v11; // [rsp+30h] [rbp-28h]
char v12; // [rsp+34h] [rbp-24h]

v2 = *(const char **)a1;
v7 = 0LL;
*(_OWORD *)dest = 0LL;
v8 = 0;
v9 = 0;
v11 = 0;
v12 = 0;
v3 = stpcpy((char *)&v7, v2);
v4 = *(const char **)a2;
strcpy(v3, *(const char **)a2);
v5 = stpcpy(dest, v4);
strcpy(v5, v2);
return strcmp((const char *)&v7, dest);
}

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; // r12
__int64 v4; // rbx
char *v5; // rax
__int64 v6; // rdx
const char **v7; // rbp
const char **v8; // rbx
const char *v9; // rsi

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

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // r12
__int64 v4; // rbx
char *v5; // rax
__int64 v6; // rdx
const char **v7; // rbp
const char **v8; // rbx
const char *v9; // rsi

v2 = malloc(8LL * a2);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = v2;
if ( a2 <= 0 )
{
qsort(v2, a2, 8uLL, compare);
}
else
{
v4 = 0LL;
do
{
v5 = (char *)malloc(0xBuLL);
v6 = *(unsigned int *)(a1 + 4 * v4);
v3[v4++] = v5;
sprintf(v5, "%d", v6);
}
while ( v4 != a2 );
qsort(v3, a2, 8uLL, compare);
v7 = (const char **)v3;
v8 = (const char **)&v3[v4];
do
{
v9 = *v7++;
printf("%s", v9);
free((void *)*(v7 - 1));
}
while ( v8 != v7 );
}
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


p

repo: sahusoft/test

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

sops.sem_num = 0;
sops.sem_op = -1;
sops.sem_flg = 0;
if ( semop(a1, &sops, 1uLL) != -1 )
return 0LL;
perror("semop P");
return 0xFFFFFFFFLL;
}

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

sops.sem_num = 0;
sops.sem_op = -1;
sops.sem_flg = 0;
if ( semop(a1, &sops, 1uLL) != -1 )
return 0LL;
perror("semop P");
return 0xFFFFFFFFLL;
}

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)
{
struct sembuf sops; // [rsp+1Ah] [rbp-Eh] BYREF

sops.sem_num = 0;
sops.sem_op = 1;
sops.sem_flg = 0;
if ( semop(a1, &sops, 1uLL) != -1 )
return 0LL;
perror("semop P");
return 0xFFFFFFFFLL;
}

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

sops.sem_num = 0;
sops.sem_op = 1;
sops.sem_flg = 0;
if ( semop(a1, &sops, 1uLL) != -1 )
return 0LL;
perror("semop P");
return 0xFFFFFFFFLL;
}

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)
{
const char *v4; // r8
const char *v5; // rcx
const char *v9; // r12
char *v10; // rcx
__uid_t v11; // eax
__uid_t v12; // eax

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

canonical_decompiled_code:
int __fastcall func7(char *s, const char *a2, const char *a3, const char *a4)
{
const char *v4; // r8
const char *v5; // rcx
const char *v9; // r12
char *v10; // rcx
__uid_t v11; // eax
__uid_t v12; // eax

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

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 *