#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 times {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fcfs_algorithm(struct times **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rr_algorithm(struct times **, int);
int /*<<< orphan*/ sjf_algorithm(struct times **);
int /*<<< orphan*/ srt_algorithm(struct times **);
void output_algorithm(struct times **list, int choice, int quanta) {
  switch (choice) {
  case 1:
    printf("\n");
    printf("************* FIRST COME FIRST SERVED (FCFS) *************\n\n");
    printf("Scheduled Jobs\n\n");
    printf("Process\t\t\tBurst Time\t\t\tStart Time\t\t\tStop Time\n");
    fcfs_algorithm(list);
    break;
  case 2:
    printf("\n");
    printf("************* SHORTEST JOB FIRST (SJF) *************\n\n");
    printf("Scheduled Jobs\n\n");
    printf("Process\t\t\tBurst Time\t\t\tStart Time\t\t\tStop Time\n");
    sjf_algorithm(list);
    break;
  case 3:
    printf("\n");
    printf("************* SHORTEST RETURN TIME FIRST (SRT) *************\n\n");
    printf("Scheduled Jobs\n\n");
    printf("Process\t\t\tBurst Time\t\t\tStart Time\t\t\tStop Time\n");
    srt_algorithm(list);
    break;
  case 4:
    printf("\n");
    printf("************* ROUND ROBIN (R) *************\n\n");
    printf("Quanta Time: %d\n", quanta);
    printf("Scheduled Jobs\n\n");
    printf("Process\t\t\tBurst Time\t\t\tStart Time\t\t\tStop Time\n");
    rr_algorithm(list, quanta);
    break;
  }
}


x86 assembly (clang, -O0):
<output_algorithm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     12b2 <output_algorithm+0x162>
mov    -0x18(%rbp),%rax
lea    0xe7e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <fcfs_algorithm@plt>
jmp    12b2 <output_algorithm+0x162>
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <sjf_algorithm@plt>
jmp    12b2 <output_algorithm+0x162>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <srt_algorithm@plt>
jmp    12b2 <output_algorithm+0x162>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1060 <rr_algorithm@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_algorithm>:
push   %rbp
push   %rbx
push   %rax
add    $0xffffffff,%esi
cmp    $0x3,%esi
ja     11ca <output_algorithm+0x5a>
mov    %rdi,%rbx
lea    0xe7b(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf23(%rip),%rdi
call   1040 <puts@plt>
lea    0xf53(%rip),%rdi
call   1040 <puts@plt>
lea    0xf57(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <fcfs_algorithm@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
lea    0xf10(%rip),%rdi
call   1040 <puts@plt>
lea    0xf14(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <sjf_algorithm@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe30(%rip),%rdi
call   1040 <puts@plt>
lea    0xed4(%rip),%rdi
call   1040 <puts@plt>
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <srt_algorithm@plt>
mov    %edx,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdc5(%rip),%rdi
call   1040 <puts@plt>
lea    0xda8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1080 <rr_algorithm@plt>

LLVM IR (-O0):
%struct.times = type { i32 }
@.str = [2 x i8] c"\0A\00"
@.str.1 = [61 x i8] c"************* FIRST COME FIRST SERVED (FCFS) *************\0A\0A\00"
@.str.2 = [17 x i8] c"Scheduled Jobs\0A\0A\00"
@.str.3 = [47 x i8] c"Process\09\09\09Burst Time\09\09\09Start Time\09\09\09Stop Time\0A\00"
@.str.4 = [55 x i8] c"************* SHORTEST JOB FIRST (SJF) *************\0A\0A\00"
@.str.5 = [63 x i8] c"************* SHORTEST RETURN TIME FIRST (SRT) *************\0A\0A\00"
@.str.6 = [46 x i8] c"************* ROUND ROBIN (R) *************\0A\0A\00"
@.str.7 = [17 x i8] c"Quanta Time: %d\0A\00"
define void @output_algorithm(%struct.times** %0, i32 %1, i32 %2) {
%4 = alloca %struct.times**
%5 = alloca i32
%6 = alloca i32
store %struct.times** %0, %struct.times*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
switch i32 %7, label %39 [
i32 1, label %8
i32 2, label %15
i32 3, label %22
i32 4, label %29
]
8: ; preds = %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%13 = load %struct.times**, %struct.times*** %4
%14 = call i32 @fcfs_algorithm(%struct.times** %13)
br label %39
15: ; preds = %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%20 = load %struct.times**, %struct.times*** %4
%21 = call i32 @sjf_algorithm(%struct.times** %20)
br label %39
22: ; preds = %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%27 = load %struct.times**, %struct.times*** %4
%28 = call i32 @srt_algorithm(%struct.times** %27)
br label %39
29: ; preds = %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%32 = load i32, i32* %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%36 = load %struct.times**, %struct.times*** %4
%37 = load i32, i32* %6
%38 = call i32 @rr_algorithm(%struct.times** %36, i32 %37)
br label %39
39: ; preds = %3, %29, %22, %15, %8
ret void
}

LLVM IR (-O2):
%struct.times = type { i32 }
@.str.7 = [17 x i8] c"Quanta Time: %d\0A\00"
@str = [45 x i8] c"************* ROUND ROBIN (R) *************\0A\00"
@str.10 = [62 x i8] c"************* SHORTEST RETURN TIME FIRST (SRT) *************\0A\00"
@str.13 = [54 x i8] c"************* SHORTEST JOB FIRST (SJF) *************\0A\00"
@str.16 = [60 x i8] c"************* FIRST COME FIRST SERVED (FCFS) *************\0A\00"
@str.17 = [16 x i8] c"Scheduled Jobs\0A\00"
@str.18 = [46 x i8] c"Process\09\09\09Burst Time\09\09\09Start Time\09\09\09Stop Time\00"
define void @output_algorithm(%struct.times** %0, i32 %1, i32 %2) {
switch i32 %1, label %29 [
i32 1, label %4
i32 2, label %10
i32 3, label %16
i32 4, label %22
]
4: ; preds = %3
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.16, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.17, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.18, i64 0, i64 0))
%9 = tail call i32 @fcfs_algorithm(%struct.times** %0)
br label %29
10: ; preds = %3
%11 = tail call i32 @putchar(i32 10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.13, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.17, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.18, i64 0, i64 0))
%15 = tail call i32 @sjf_algorithm(%struct.times** %0)
br label %29
16: ; preds = %3
%17 = tail call i32 @putchar(i32 10)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.10, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.17, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.18, i64 0, i64 0))
%21 = tail call i32 @srt_algorithm(%struct.times** %0)
br label %29
22: ; preds = %3
%23 = tail call i32 @putchar(i32 10)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %2)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.17, i64 0, i64 0))
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.18, i64 0, i64 0))
%28 = tail call i32 @rr_algorithm(%struct.times** %0, i32 %2)
br label %29
29: ; preds = %3, %22, %16, %10, %4
ret void
}