#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 */

/* Variables and functions */
int /*<<< orphan*/ FCFS();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int choice;
  printf("\t\t\t\t Welcome to CPU-SCH by axay47");
  printf("\n\n\nSelect Type of Scheduling\t(Using Serial Number.) ");
  printf("\n\n\n1. Preemptive\n");
  printf("2. Non-Preemptive\n\n\n");
  printf("Enter Your Option : ");
  scanf("%d", &choice);
  if (choice == 1) {
    printf("\n\n\nYou have selected Preemptive.");
  } else if (choice == 2) {
    printf("\n\n\nYou have selected non-Preemptive.");
  } else {
    printf("\n\n\nInvalid Entry...");
  }
  choice = 0;
  printf("\n\n\n 1. Shortest Job First(SJF)");
  printf("\n 2. First Come First Serve(FCFS)");
  printf("\n 3. Shortest Remaining Time First(SRTF)");
  printf("\n 4. Round Robin(RR) \n\n\n");
  printf("Enter Your Option : ");
  scanf("%d", &choice);
  if (choice == 1) {
    printf("\n\n\nYou have selected SJF.");
  } else if (choice == 2) {
    printf("\n\n\nYou have selected FCFS.");
    FCFS();
  } else if (choice == 3) {
    printf("\n\n\nYou have selected SRTF.");
  } else if (choice == 4) {
    printf("\n\n\nYou have selected RR.");
  } else {
    printf("Invalid Entry... Please Try again.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
call   1040 <printf@plt>
lea    0xef9(%rip),%rdi
call   1040 <printf@plt>
lea    0xeff(%rip),%rdi
call   1040 <printf@plt>
lea    0xf08(%rip),%rdi
call   1040 <printf@plt>
lea    0xf11(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11a6 <main+0x76>
lea    0xefa(%rip),%rdi
call   1040 <printf@plt>
jmp    11d2 <main+0xa2>
cmpl   $0x2,-0x8(%rbp)
jne    11c1 <main+0x91>
lea    0xf00(%rip),%rdi
call   1040 <printf@plt>
jmp    11cd <main+0x9d>
lea    0xf14(%rip),%rdi
call   1040 <printf@plt>
jmp    11d2 <main+0xa2>
movl   $0x0,-0x8(%rbp)
lea    0xf10(%rip),%rdi
call   1040 <printf@plt>
lea    0xf23(%rip),%rdi
call   1040 <printf@plt>
lea    0xf39(%rip),%rdi
call   1040 <printf@plt>
lea    0xf56(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1240 <main+0x110>
lea    0xf3d(%rip),%rdi
call   1040 <printf@plt>
jmp    12b3 <main+0x183>
cmpl   $0x2,-0x8(%rbp)
jne    1262 <main+0x132>
lea    0xf3c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <FCFS@plt>
jmp    12ae <main+0x17e>
cmpl   $0x3,-0x8(%rbp)
jne    127d <main+0x14d>
lea    0xf35(%rip),%rdi
call   1040 <printf@plt>
jmp    12a9 <main+0x179>
cmpl   $0x4,-0x8(%rbp)
jne    1298 <main+0x168>
lea    0xf35(%rip),%rdi
call   1040 <printf@plt>
jmp    12a4 <main+0x174>
lea    0xf3d(%rip),%rdi
call   1040 <printf@plt>
jmp    12a9 <main+0x179>
jmp    12ae <main+0x17e>
jmp    12b3 <main+0x183>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
call   1050 <printf@plt>
lea    0xed6(%rip),%rdi
call   1050 <printf@plt>
lea    0x1067(%rip),%rdi
call   1030 <puts@plt>
lea    0x106c(%rip),%rdi
call   1030 <puts@plt>
lea    0xee7(%rip),%r14
mov    %r14,%rdi
call   1050 <printf@plt>
lea    0xeed(%rip),%rbx
lea    0xc(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
lea    0xef3(%rip),%rcx
lea    0xf11(%rip),%rdx
cmove  %rcx,%rdx
cmp    $0x1,%eax
lea    0xebd(%rip),%rdi
cmovne %rdx,%rdi
call   1050 <printf@plt>
movl   $0x0,0xc(%rsp)
lea    0xeff(%rip),%rdi
call   1050 <printf@plt>
lea    0xf12(%rip),%rdi
call   1050 <printf@plt>
lea    0xf28(%rip),%rdi
call   1050 <printf@plt>
lea    0xff6(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     123b <main+0xfb>
lea    0xdd7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf0a(%rip),%rdi
jmp    1269 <main+0x129>
lea    0xf6a(%rip),%rdi
jmp    1269 <main+0x129>
lea    0xf12(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <FCFS@plt>
jmp    126e <main+0x12e>
lea    0xf18(%rip),%rdi
jmp    1269 <main+0x129>
lea    0xf2a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"\09\09\09\09 Welcome to CPU-SCH by axay47\00"
@.str.1 = [53 x i8] c"\0A\0A\0ASelect Type of Scheduling\09(Using Serial Number.) \00"
@.str.2 = [18 x i8] c"\0A\0A\0A1. Preemptive\0A\00"
@.str.3 = [21 x i8] c"2. Non-Preemptive\0A\0A\0A\00"
@.str.4 = [21 x i8] c"Enter Your Option : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [33 x i8] c"\0A\0A\0AYou have selected Preemptive.\00"
@.str.7 = [37 x i8] c"\0A\0A\0AYou have selected non-Preemptive.\00"
@.str.8 = [20 x i8] c"\0A\0A\0AInvalid Entry...\00"
@.str.9 = [31 x i8] c"\0A\0A\0A 1. Shortest Job First(SJF)\00"
@.str.10 = [34 x i8] c"\0A 2. First Come First Serve(FCFS)\00"
@.str.11 = [41 x i8] c"\0A 3. Shortest Remaining Time First(SRTF)\00"
@.str.12 = [25 x i8] c"\0A 4. Round Robin(RR) \0A\0A\0A\00"
@.str.13 = [26 x i8] c"\0A\0A\0AYou have selected SJF.\00"
@.str.14 = [27 x i8] c"\0A\0A\0AYou have selected FCFS.\00"
@.str.15 = [27 x i8] c"\0A\0A\0AYou have selected SRTF.\00"
@.str.16 = [25 x i8] c"\0A\0A\0AYou have selected RR.\00"
@.str.17 = [35 x i8] c"Invalid Entry... Please Try again.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %21
13: ; preds = %0
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %20
18: ; preds = %13
%19 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
br label %21
21: ; preds = %20, %11
store i32 0, i32* %2
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%25 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0))
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %21
%31 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
br label %53
32: ; preds = %21
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 2
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0))
%37 = call i32 (...) @FCFS()
br label %52
38: ; preds = %32
%39 = load i32, i32* %2
%40 = icmp eq i32 %39, 3
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0))
br label %51
43: ; preds = %38
%44 = load i32, i32* %2
%45 = icmp eq i32 %44, 4
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0))
br label %50
48: ; preds = %43
%49 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.17, i64 0, i64 0))
br label %50
50: ; preds = %48, %46
br label %51
51: ; preds = %50, %41
br label %52
52: ; preds = %51, %35
br label %53
53: ; preds = %52, %30
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"\09\09\09\09 Welcome to CPU-SCH by axay47\00"
@.str.1 = [53 x i8] c"\0A\0A\0ASelect Type of Scheduling\09(Using Serial Number.) \00"
@.str.4 = [21 x i8] c"Enter Your Option : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [33 x i8] c"\0A\0A\0AYou have selected Preemptive.\00"
@.str.7 = [37 x i8] c"\0A\0A\0AYou have selected non-Preemptive.\00"
@.str.8 = [20 x i8] c"\0A\0A\0AInvalid Entry...\00"
@.str.9 = [31 x i8] c"\0A\0A\0A 1. Shortest Job First(SJF)\00"
@.str.10 = [34 x i8] c"\0A 2. First Come First Serve(FCFS)\00"
@.str.11 = [41 x i8] c"\0A 3. Shortest Remaining Time First(SRTF)\00"
@.str.13 = [26 x i8] c"\0A\0A\0AYou have selected SJF.\00"
@.str.14 = [27 x i8] c"\0A\0A\0AYou have selected FCFS.\00"
@.str.15 = [27 x i8] c"\0A\0A\0AYou have selected SRTF.\00"
@.str.16 = [25 x i8] c"\0A\0A\0AYou have selected RR.\00"
@.str.17 = [35 x i8] c"Invalid Entry... Please Try again.\00"
@str = [17 x i8] c"\0A\0A\0A1. Preemptive\00"
@str.18 = [20 x i8] c"2. Non-Preemptive\0A\0A\00"
@str.19 = [24 x i8] c"\0A 4. Round Robin(RR) \0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.18, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 2
%11 = select i1 %10, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0)
%12 = icmp eq i32 %9, 1
%13 = select i1 %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %11
%14 = call i32 @printf(i8* dereferenceable(1) %13)
store i32 0, i32* %1
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.19, i64 0, i64 0))
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
switch i32 %21, label %31 [
i32 1, label %22
i32 2, label %24
i32 3, label %27
i32 4, label %29
]
22: ; preds = %0
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
br label %33
24: ; preds = %0
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0))
%26 = call i32 (...) @FCFS()
br label %33
27: ; preds = %0
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0))
br label %33
29: ; preds = %0
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0))
br label %33
31: ; preds = %0
%32 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.17, i64 0, i64 0))
br label %33
33: ; preds = %24, %29, %31, %27, %22
ret i32 0
}