#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct queue {
  int dummy;
};
struct process_node {
  int dummy;
};

/* Variables and functions */
struct queue *insert_process_at_end_of_queue(struct queue *, struct queue *);
struct queue *insert_sort_by_burst_duration(struct queue *, struct queue *);
struct queue *insert_sort_by_priority(struct process_node *, struct queue *,
                                      struct queue *);
struct queue *insert_sort_by_remaining_time(struct process_node *,
                                            struct queue *, struct queue *);
struct queue *insert_sort_by_timestamp(struct process_node *, struct queue *,
                                       struct queue *);
struct queue *insert_in_ready_queue(struct process_node *p, struct queue *r,
                                    struct queue *node, unsigned parameter) {
  switch (parameter) {
  case 1:
    r = insert_sort_by_timestamp(p, r, node);
    break;
  case 2:
  case 6:
  case 7:
    r = insert_process_at_end_of_queue(r, node);
    break;
  case 3:
    r = insert_sort_by_priority(p, r, node);
    break;
  case 4:
    r = insert_sort_by_burst_duration(r, node);
    break;
  case 5:
    r = insert_sort_by_remaining_time(p, r, node);
    break;
  }
  return r;
}


x86 assembly (clang, -O0):
<insert_in_ready_queue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x6,%eax
ja     1205 <insert_in_ready_queue+0xb5>
mov    -0x28(%rbp),%rax
lea    0xe79(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <insert_sort_by_timestamp@plt>
mov    %rax,-0x10(%rbp)
jmp    1205 <insert_in_ready_queue+0xb5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <insert_process_at_end_of_queue@plt>
mov    %rax,-0x10(%rbp)
jmp    1205 <insert_in_ready_queue+0xb5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <insert_sort_by_priority@plt>
mov    %rax,-0x10(%rbp)
jmp    1205 <insert_in_ready_queue+0xb5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <insert_sort_by_burst_duration@plt>
mov    %rax,-0x10(%rbp)
jmp    1205 <insert_in_ready_queue+0xb5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <insert_sort_by_remaining_time@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert_in_ready_queue>:
add    $0xffffffff,%ecx
cmp    $0x6,%ecx
ja     1173 <insert_in_ready_queue+0x23>
lea    0xea1(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1070 <insert_process_at_end_of_queue@plt>
mov    %rsi,%rax
ret
jmp    1060 <insert_sort_by_timestamp@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1030 <insert_sort_by_burst_duration@plt>
jmp    1050 <insert_sort_by_remaining_time@plt>
jmp    1040 <insert_sort_by_priority@plt>

LLVM IR (-O0):
%struct.process_node = type { i32 }
%struct.queue = type { i32 }
define %struct.queue* @insert_in_ready_queue(%struct.process_node* %0, %struct.queue* %1, %struct.queue* %2, i32 %3) {
%5 = alloca %struct.process_node*
%6 = alloca %struct.queue*
%7 = alloca %struct.queue*
%8 = alloca i32
store %struct.process_node* %0, %struct.process_node** %5
store %struct.queue* %1, %struct.queue** %6
store %struct.queue* %2, %struct.queue** %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
switch i32 %9, label %33 [
i32 1, label %10
i32 2, label %15
i32 6, label %15
i32 7, label %15
i32 3, label %19
i32 4, label %24
i32 5, label %28
]
10: ; preds = %4
%11 = load %struct.process_node*, %struct.process_node** %5
%12 = load %struct.queue*, %struct.queue** %6
%13 = load %struct.queue*, %struct.queue** %7
%14 = call %struct.queue* @insert_sort_by_timestamp(%struct.process_node* %11, %struct.queue* %12, %struct.queue* %13)
store %struct.queue* %14, %struct.queue** %6
br label %33
15: ; preds = %4, %4, %4
%16 = load %struct.queue*, %struct.queue** %6
%17 = load %struct.queue*, %struct.queue** %7
%18 = call %struct.queue* @insert_process_at_end_of_queue(%struct.queue* %16, %struct.queue* %17)
store %struct.queue* %18, %struct.queue** %6
br label %33
19: ; preds = %4
%20 = load %struct.process_node*, %struct.process_node** %5
%21 = load %struct.queue*, %struct.queue** %6
%22 = load %struct.queue*, %struct.queue** %7
%23 = call %struct.queue* @insert_sort_by_priority(%struct.process_node* %20, %struct.queue* %21, %struct.queue* %22)
store %struct.queue* %23, %struct.queue** %6
br label %33
24: ; preds = %4
%25 = load %struct.queue*, %struct.queue** %6
%26 = load %struct.queue*, %struct.queue** %7
%27 = call %struct.queue* @insert_sort_by_burst_duration(%struct.queue* %25, %struct.queue* %26)
store %struct.queue* %27, %struct.queue** %6
br label %33
28: ; preds = %4
%29 = load %struct.process_node*, %struct.process_node** %5
%30 = load %struct.queue*, %struct.queue** %6
%31 = load %struct.queue*, %struct.queue** %7
%32 = call %struct.queue* @insert_sort_by_remaining_time(%struct.process_node* %29, %struct.queue* %30, %struct.queue* %31)
store %struct.queue* %32, %struct.queue** %6
br label %33
33: ; preds = %4, %28, %24, %19, %15, %10
%34 = load %struct.queue*, %struct.queue** %6
ret %struct.queue* %34
}

LLVM IR (-O2):
%struct.process_node = type { i32 }
%struct.queue = type { i32 }
define %struct.queue* @insert_in_ready_queue(%struct.process_node* %0, %struct.queue* %1, %struct.queue* %2, i32 %3) {
switch i32 %3, label %15 [
i32 1, label %5
i32 2, label %7
i32 6, label %7
i32 7, label %7
i32 3, label %9
i32 4, label %11
i32 5, label %13
]
5: ; preds = %4
%6 = tail call %struct.queue* @insert_sort_by_timestamp(%struct.process_node* %0, %struct.queue* %1, %struct.queue* %2)
br label %15
7: ; preds = %4, %4, %4
%8 = tail call %struct.queue* @insert_process_at_end_of_queue(%struct.queue* %1, %struct.queue* %2)
br label %15
9: ; preds = %4
%10 = tail call %struct.queue* @insert_sort_by_priority(%struct.process_node* %0, %struct.queue* %1, %struct.queue* %2)
br label %15
11: ; preds = %4
%12 = tail call %struct.queue* @insert_sort_by_burst_duration(%struct.queue* %1, %struct.queue* %2)
br label %15
13: ; preds = %4
%14 = tail call %struct.queue* @insert_sort_by_remaining_time(%struct.process_node* %0, %struct.queue* %1, %struct.queue* %2)
br label %15
15: ; preds = %4, %13, %11, %9, %7, %5
%16 = phi %struct.queue* [ %1, %4 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ]
ret %struct.queue* %16
}