#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int FCFS() {
  int n, burTime[100], wTime = 0, taTime, i;
  float avg_wTime = 0, avg_taTime;
  printf("\n\n\nEnter number of Processes : ");
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    printf("\nEnter Burst Time For Process %d : ", i + 1);
    scanf("%d", &burTime[i]);
  }
  printf("\n\nProcess \t Burst Time \t Waiting Time \t Turnaround Time");
  for (i = 0; i < n; i++) {
    taTime = burTime[i] + wTime;
    printf("\n%d \t\t %d \t\t %d \t\t %d", i + 1, burTime[i], wTime, taTime);
    avg_wTime += wTime;
    avg_taTime += taTime;
    wTime += burTime[i];
  }
  printf("\nAverage waiting Time : %f ", avg_wTime / n);
  printf("\nAverage turnaround time : %f", avg_taTime / n);
}


x86 assembly (clang, -O0):
<FCFS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x1a4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1b0(%rbp)
ff
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf3a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c3 <FCFS+0xa3>
mov    -0x1ac(%rbp),%esi
add    $0x1,%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1ac(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xee5(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    1168 <FCFS+0x48>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1294 <FCFS+0x174>
movslq -0x1ac(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
add    -0x1a4(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1ac(%rbp),%esi
add    $0x1,%esi
movslq -0x1ac(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%edx
mov    -0x1a4(%rbp),%ecx
mov    -0x1a8(%rbp),%r8d
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x1a4(%rbp),%xmm0
ff
addss  -0x1b0(%rbp),%xmm0
ff
movss  %xmm0,-0x1b0(%rbp)
ff
cvtsi2ssl -0x1a8(%rbp),%xmm0
ff
addss  -0x1b4(%rbp),%xmm0
ff
movss  %xmm0,-0x1b4(%rbp)
ff
movslq -0x1ac(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
add    -0x1a4(%rbp),%eax
mov    %eax,-0x1a4(%rbp)
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    11db <FCFS+0xbb>
movss  -0x1b0(%rbp),%xmm0
ff
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1b4(%rbp),%xmm0
ff
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FCFS>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1b0,%rsp
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf4b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1199 <FCFS+0x79>
lea    0x20(%rsp),%r12
lea    0xebf(%rip),%r14
lea    0xf27(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     1170 <FCFS+0x50>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
xorps  %xmm1,%xmm1
test   %eax,%eax
jle    120c <FCFS+0xec>
lea    0xec3(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   (%rax)
movaps %xmm1,0x10(%rsp)
mov    0x20(%rsp,%rbp,4),%edx
lea    (%rdx,%rbx,1),%r15d
lea    0x1(%rbp),%r12
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebx,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
movd   %r15d,%xmm0
movd   %ebx,%xmm1
punpckldq %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm0
movaps 0x10(%rsp),%xmm1
addps  %xmm0,%xmm1
add    0x20(%rsp,%rbp,4),%ebx
movslq 0xc(%rsp),%rax
mov    %r12,%rbp
cmp    %rax,%r12
jl     11c0 <FCFS+0xa0>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movaps %xmm1,0x10(%rsp)
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe68(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0xc(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
shufps $0x55,%xmm1,%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x1b0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\0A\0A\0AEnter number of Processes : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\0AEnter Burst Time For Process %d : \00"
@.str.3 = [56 x i8] c"\0A\0AProcess \09 Burst Time \09 Waiting Time \09 Turnaround Time\00"
@.str.4 = [22 x i8] c"\0A%d \09\09 %d \09\09 %d \09\09 %d\00"
@.str.5 = [28 x i8] c"\0AAverage waiting Time : %f \00"
@.str.6 = [30 x i8] c"\0AAverage turnaround time : %f\00"
define i32 @FCFS() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
store i32 0, i32* %4
store float 0.000000e+00, float* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %6
br label %11
11: ; preds = %23, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %11
26: ; preds = %11
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %28
28: ; preds = %62, %26
%29 = load i32, i32* %6
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %65
32: ; preds = %28
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %4
%38 = add nsw i32 %36, %37
store i32 %38, i32* %5
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* %4
%49 = sitofp i32 %48 to float
%50 = load float, float* %7
%51 = fadd float %50, %49
store float %51, float* %7
%52 = load i32, i32* %5
%53 = sitofp i32 %52 to float
%54 = load float, float* %8
%55 = fadd float %54, %53
store float %55, float* %8
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = load i32, i32* %4
%61 = add nsw i32 %60, %59
store i32 %61, i32* %4
br label %62
62: ; preds = %32
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %28
65: ; preds = %28
%66 = load float, float* %7
%67 = load i32, i32* %2
%68 = sitofp i32 %67 to float
%69 = fdiv float %66, %68
%70 = fpext float %69 to double
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), double %70)
%72 = load float, float* %8
%73 = load i32, i32* %2
%74 = sitofp i32 %73 to float
%75 = fdiv float %72, %74
%76 = fpext float %75 to double
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), double %76)
%78 = load i32, i32* %1
ret i32 %78
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0A\0A\0AEnter number of Processes : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\0AEnter Burst Time For Process %d : \00"
@.str.3 = [56 x i8] c"\0A\0AProcess \09 Burst Time \09 Waiting Time \09 Turnaround Time\00"
@.str.4 = [22 x i8] c"\0A%d \09\09 %d \09\09 %d \09\09 %d\00"
@.str.5 = [28 x i8] c"\0AAverage waiting Time : %f \00"
@.str.6 = [30 x i8] c"\0AAverage turnaround time : %f\00"
define i32 @FCFS() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 x i32]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %0, %9
%10 = phi i64 [ %11, %9 ], [ 0, %0 ]
%11 = add nuw nsw i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %10
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %11, %17
br i1 %18, label %9, label %19
19: ; preds = %9, %0
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %42
23: ; preds = %19, %23
%24 = phi i64 [ %30, %23 ], [ 0, %19 ]
%25 = phi i32 [ %38, %23 ], [ 0, %19 ]
%26 = phi <2 x float> [ %36, %23 ], [ <float 0.000000e+00, float undef>, %19 ]
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %24
%28 = load i32, i32* %27
%29 = add nsw i32 %28, %25
%30 = add nuw nsw i64 %24, 1
%31 = trunc i64 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %28, i32 %25, i32 %29)
%33 = insertelement <2 x i32> poison, i32 %25, i64 0
%34 = insertelement <2 x i32> %33, i32 %29, i64 1
%35 = sitofp <2 x i32> %34 to <2 x float>
%36 = fadd <2 x float> %26, %35
%37 = load i32, i32* %27
%38 = add nsw i32 %37, %25
%39 = load i32, i32* %1
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %30, %40
br i1 %41, label %23, label %42
42: ; preds = %23, %19
%43 = phi i32 [ %21, %19 ], [ %39, %23 ]
%44 = phi <2 x float> [ <float 0.000000e+00, float undef>, %19 ], [ %36, %23 ]
%45 = sitofp i32 %43 to float
%46 = extractelement <2 x float> %44, i64 0
%47 = fdiv float %46, %45
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), double %48)
%50 = load i32, i32* %1
%51 = sitofp i32 %50 to float
%52 = extractelement <2 x float> %44, i64 1
%53 = fdiv float %52, %51
%54 = fpext float %53 to double
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), double %54)
ret i32 undef
}