#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*/ add_burst_time(struct times **, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int get_algorithm(char *);
int /*<<< orphan*/ output_algorithm(struct times **, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char algor[10];
  int quanta = 0, check = 0, timeRetrieve = 1, processCount = 1, tempNum = 0;
  struct times *burstList = 0;
  printf("Welcome to the Job Scheduler Computer.\nWhat algorithm would you "
         "like to use\n");
  scanf("%s", algor);
  check = get_algorithm(algor);
  if (check) {
    if (check == 4) {
      printf("What is the time quanta for %s scheduling\n", algor);
      scanf("%d", &quanta);
    }
    while (timeRetrieve == 1) {
      if (processCount <= 63) {
        printf("Process %d (P%d) – What is the burst time?\n", processCount,
               processCount);
        scanf("%d", &tempNum);
        if (!feof(stdin)) {
          add_burst_time(&burstList, tempNum);
        } else {
          printf("Input terminated\n");
          timeRetrieve = 0;
        }
      } else {
        timeRetrieve = 0;
        fclose(stdin);
      }
      processCount++;
    }
    output_algorithm(&burstList, check, quanta);
  } else {
    printf("You didn't enter a valid algorithm. Process terminated!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xe(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0xe(%rbp),%rdi
call   1030 <get_algorithm@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     12c6 <main+0x156>
cmpl   $0x4,-0x18(%rbp)
jne    120e <main+0x9e>
lea    -0xe(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe78(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
jmp    1213 <main+0xa3>
cmpl   $0x1,-0x1c(%rbp)
jne    12b2 <main+0x142>
cmpl   $0x3f,-0x20(%rbp)
jg     128f <main+0x11f>
mov    -0x20(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe39(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
jne    1275 <main+0x105>
mov    -0x24(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   1040 <add_burst_time@plt>
jmp    128a <main+0x11a>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    12a4 <main+0x134>
movl   $0x0,-0x1c(%rbp)
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1213 <main+0xa3>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    -0x30(%rbp),%rdi
call   1090 <output_algorithm@plt>
jmp    12d4 <main+0x164>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe46(%rip),%rdi
lea    0x1e(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    %rbx,%rdi
call   1030 <get_algorithm@plt>
test   %eax,%eax
je     1275 <main+0xf5>
mov    %eax,0xc(%rsp)
cmp    $0x4,%eax
jne    1208 <main+0x88>
lea    0xe1a(%rip),%rdi
lea    0x1e(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe32(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xe22(%rip),%r15
lea    0xe18(%rip),%r12
lea    0x4(%rsp),%rbx
mov    0x2dc6(%rip),%r14
lea    0x10(%rsp),%r13
xor    %ebp,%ebp
nopl   0x0(%rax)
add    $0x1,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    (%r14),%edi
call   1080 <feof@plt>
test   %eax,%eax
jne    1283 <main+0x103>
mov    0x4(%rsp),%esi
mov    %r13,%rdi
call   1050 <add_burst_time@plt>
cmp    $0x3f,%ebp
jb     1230 <main+0xb0>
mov    (%r14),%edi
call   1060 <fclose@plt>
jmp    128f <main+0x10f>
lea    0xe2f(%rip),%rdi
call   1040 <puts@plt>
jmp    12a1 <main+0x121>
lea    0xe59(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%edx
lea    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
call   10a0 <output_algorithm@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.times = type { i32 }
@.str = [77 x i8] c"Welcome to the Job Scheduler Computer.\0AWhat algorithm would you like to use\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [43 x i8] c"What is the time quanta for %s scheduling\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [46 x i8] c"Process %d (P%d) \E2\80\93 What is the burst time?\0A\00"
@stdin = global i32 0
@.str.5 = [18 x i8] c"Input terminated\0A\00"
@.str.6 = [57 x i8] c"You didn't enter a valid algorithm. Process terminated!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.times*
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %5
store i32 1, i32* %6
store i32 0, i32* %7
store %struct.times* null, %struct.times** %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = call i32 @get_algorithm(i8* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %54
16: ; preds = %0
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 4
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
br label %23
23: ; preds = %19, %16
br label %24
24: ; preds = %47, %23
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %50
27: ; preds = %24
%28 = load i32, i32* %6
%29 = icmp sle i32 %28, 63
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = load i32, i32* %6
%32 = load i32, i32* %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %32)
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%35 = load i32, i32* @stdin
%36 = call i32 @feof(i32 %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %30
%39 = load i32, i32* %7
%40 = call i32 @add_burst_time(%struct.times** %8, i32 %39)
br label %43
41: ; preds = %30
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %5
br label %43
43: ; preds = %41, %38
br label %47
44: ; preds = %27
store i32 0, i32* %5
%45 = load i32, i32* @stdin
%46 = call i32 @fclose(i32 %45)
br label %47
47: ; preds = %44, %43
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %24
50: ; preds = %24
%51 = load i32, i32* %4
%52 = load i32, i32* %3
%53 = call i32 @output_algorithm(%struct.times** %8, i32 %51, i32 %52)
br label %56
54: ; preds = %0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
br label %56
56: ; preds = %54, %50
ret i32 0
}

LLVM IR (-O2):
%struct.times = type { i32 }
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [43 x i8] c"What is the time quanta for %s scheduling\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [46 x i8] c"Process %d (P%d) \E2\80\93 What is the burst time?\0A\00"
@stdin = global i32 0
@str = [76 x i8] c"Welcome to the Job Scheduler Computer.\0AWhat algorithm would you like to use\00"
@str.7 = [56 x i8] c"You didn't enter a valid algorithm. Process terminated!\00"
@str.8 = [17 x i8] c"Input terminated\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.times*
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast %struct.times** %4 to i8*
store %struct.times* null, %struct.times** %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%11 = call i32 @get_algorithm(i8* %5)
switch i32 %11, label %15 [
i32 0, label %36
i32 4, label %12
]
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
br label %15
15: ; preds = %0, %12
br label %16
16: ; preds = %15, %28
%17 = phi i32 [ %31, %28 ], [ 1, %15 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 %17)
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%20 = load i32, i32* @stdin
%21 = call i32 @feof(i32 %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %16
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
br label %33
25: ; preds = %28
%26 = load i32, i32* @stdin
%27 = call i32 @fclose(i32 %26)
br label %33
28: ; preds = %16
%29 = load i32, i32* %3
%30 = call i32 @add_burst_time(%struct.times** %4, i32 %29)
%31 = add nuw nsw i32 %17, 1
%32 = icmp ult i32 %17, 63
br i1 %32, label %16, label %25
33: ; preds = %23, %25
%34 = load i32, i32* %2
%35 = call i32 @output_algorithm(%struct.times** %4, i32 %11, i32 %34)
br label %38
36: ; preds = %0
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.7, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
ret i32 0
}