#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 main() {
  int processes[] = {1, 2, 3, 4};
  int n = sizeof processes / sizeof processes[0];
  int bt[] = {3, 6, 9, 3};
  int wt[n], tat[n], total_wt = 0, total_tat = 0;
  wt[0] = 0;
  for (int i = 1; i < n; i++)
    wt[i] = bt[i - 1] + wt[i - 1];
  for (int i = 0; i < n; i++)
    tat[i] = bt[i] + wt[i];
  printf("Processes\tBurst time\tWaiting time\tTurn around time \n");
  for (int i = 0; i < n; i++) {
    total_wt = total_wt + wt[i];
    total_tat = total_tat + tat[i];
    printf("%d\t\t %d \t\t %d \t\t %d\n", i + 1, bt[i], wt[i], tat[i]);
  }
  printf("Average waiting time = %f", (float)total_wt / (float)n);
  printf("\nAverage turn around time = %f", (float)total_tat / (float)n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movl   $0x4,-0x24(%rbp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x48(%rbp)
lea    0xf(,%rcx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x80(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x50(%rbp)
mov    -0x24(%rbp),%ecx
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x78(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,(%rax)
movl   $0x1,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11e1 <main+0xd1>
mov    -0x80(%rbp),%rax
mov    -0x64(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    -0x40(%rbp,%rcx,4),%edx
mov    -0x64(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
add    (%rax,%rcx,4),%edx
movslq -0x64(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11a3 <main+0x93>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1220 <main+0x110>
mov    -0x78(%rbp),%rax
mov    -0x80(%rbp),%rcx
movslq -0x68(%rbp),%rdx
mov    -0x40(%rbp,%rdx,4),%edx
movslq -0x68(%rbp),%rsi
add    (%rcx,%rsi,4),%edx
movslq -0x68(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11e8 <main+0xd8>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    129c <main+0x18c>
mov    -0x78(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    -0x5c(%rbp),%edx
movslq -0x6c(%rbp),%rsi
add    (%rcx,%rsi,4),%edx
mov    %edx,-0x5c(%rbp)
mov    -0x60(%rbp),%edx
movslq -0x6c(%rbp),%rsi
add    (%rax,%rsi,4),%edx
mov    %edx,-0x60(%rbp)
mov    -0x6c(%rbp),%esi
add    $0x1,%esi
movslq -0x6c(%rbp),%rdx
mov    -0x40(%rbp,%rdx,4),%edx
movslq -0x6c(%rbp),%rdi
mov    (%rcx,%rdi,4),%ecx
movslq -0x6c(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1235 <main+0x125>
cvtsi2ssl -0x5c(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2ssl -0x60(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdaf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
lea    0xedc(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
xor    %ecx,%ecx
mov    $0x3,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x6,%edx
mov    $0x3,%ecx
mov    $0x9,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x9,%edx
mov    $0x9,%ecx
mov    $0x12,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
mov    $0x12,%ecx
mov    $0x15,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe71(%rip),%rdi
movsd  0xe44(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe75(%rip),%rdi
movsd  0xe36(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.processes = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@__const.main.bt = [4 x i32] [i32 3, i32 6, i32 9, i32 3]
@.str = [53 x i8] c"Processes\09Burst time\09Waiting time\09Turn around time \0A\00"
@.str.1 = [21 x i8] c"%d\09\09 %d \09\09 %d \09\09 %d\0A\00"
@.str.2 = [26 x i8] c"Average waiting time = %f\00"
@.str.3 = [31 x i8] c"\0AAverage turn around time = %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
%13 = bitcast [4 x i32]* %2 to i8*
store i32 4, i32* %3
%14 = bitcast [4 x i32]* %4 to i8*
%15 = load i32, i32* %3
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %5
%18 = alloca i32, i64 %16
store i64 %16, i64* %6
%19 = load i32, i32* %3
%20 = zext i32 %19 to i64
%21 = alloca i32, i64 %20
store i64 %20, i64* %7
store i32 0, i32* %8
store i32 0, i32* %9
%22 = getelementptr inbounds i32, i32* %18, i64 0
store i32 0, i32* %22
store i32 1, i32* %10
br label %23
23: ; preds = %42, %0
%24 = load i32, i32* %10
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %45
27: ; preds = %23
%28 = load i32, i32* %10
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = load i32, i32* %10
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %18, i64 %35
%37 = load i32, i32* %36
%38 = add nsw i32 %32, %37
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %18, i64 %40
store i32 %38, i32* %41
br label %42
42: ; preds = %27
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
store i32 %44, i32* %10
br label %23
45: ; preds = %23
store i32 0, i32* %11
br label %46
46: ; preds = %63, %45
%47 = load i32, i32* %11
%48 = load i32, i32* %3
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %66
50: ; preds = %46
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %18, i64 %56
%58 = load i32, i32* %57
%59 = add nsw i32 %54, %58
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %21, i64 %61
store i32 %59, i32* %62
br label %63
63: ; preds = %50
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 1
store i32 %65, i32* %11
br label %46
66: ; preds = %46
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %12
br label %68
68: ; preds = %100, %66
%69 = load i32, i32* %12
%70 = load i32, i32* %3
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %103
72: ; preds = %68
%73 = load i32, i32* %8
%74 = load i32, i32* %12
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %18, i64 %75
%77 = load i32, i32* %76
%78 = add nsw i32 %73, %77
store i32 %78, i32* %8
%79 = load i32, i32* %9
%80 = load i32, i32* %12
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %21, i64 %81
%83 = load i32, i32* %82
%84 = add nsw i32 %79, %83
store i32 %84, i32* %9
%85 = load i32, i32* %12
%86 = add nsw i32 %85, 1
%87 = load i32, i32* %12
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %88
%90 = load i32, i32* %89
%91 = load i32, i32* %12
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %18, i64 %92
%94 = load i32, i32* %93
%95 = load i32, i32* %12
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %21, i64 %96
%98 = load i32, i32* %97
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %86, i32 %90, i32 %94, i32 %98)
br label %100
100: ; preds = %72
%101 = load i32, i32* %12
%102 = add nsw i32 %101, 1
store i32 %102, i32* %12
br label %68
103: ; preds = %68
%104 = load i32, i32* %8
%105 = sitofp i32 %104 to float
%106 = load i32, i32* %3
%107 = sitofp i32 %106 to float
%108 = fdiv float %105, %107
%109 = fpext float %108 to double
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %109)
%111 = load i32, i32* %9
%112 = sitofp i32 %111 to float
%113 = load i32, i32* %3
%114 = sitofp i32 %113 to float
%115 = fdiv float %112, %114
%116 = fpext float %115 to double
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %116)
store i32 0, i32* %1
%118 = load i8*, i8** %5
%119 = load i32, i32* %1
ret i32 %119
}

LLVM IR (-O2):
@.str.1 = [21 x i8] c"%d\09\09 %d \09\09 %d \09\09 %d\0A\00"
@.str.2 = [26 x i8] c"Average waiting time = %f\00"
@.str.3 = [31 x i8] c"\0AAverage turn around time = %f\00"
@str = [52 x i8] c"Processes\09Burst time\09Waiting time\09Turn around time \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 3, i32 0, i32 3)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 6, i32 3, i32 9)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 9, i32 9, i32 18)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 3, i32 18, i32 21)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double 7.500000e+00)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double 1.275000e+01)
ret i32 0
}