#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 *, ...);
void display_statistics(int time_quantum, int time, int wait_time,
                        int turnaround_time, int no_of_processes,
                        int sequence[], int sequence_count) {
  int counter;
  printf("---------------------------------------------------------------------"
         "\n");
  printf("                               STATISTICS                            "
         "\n");
  printf("---------------------------------------------------------------------"
         "\n");
  printf("Time Quantum for Round-Robin     : %d\n", time_quantum);
  printf("Sequence of processes execution  : ");
  for (counter = 0; counter < sequence_count; counter++) {
    printf("P[%d] ", sequence[counter]);
  }
  printf("\n");
  printf("Total Exceution Time             : %d\n", time);
  printf("Average Waiting Time             : %.2f\n",
         wait_time * 1.0 / no_of_processes);
  printf("Average Turnaround Time          : %.2f\n",
         turnaround_time * 1.0 / no_of_processes);
  printf("\n-------------------------------------------------------------------"
         "--\n");
  printf("\n");
}


x86 assembly (clang, -O0):
<display_statistics>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
lea    0xfe5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    11b2 <display_statistics+0xa2>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xefd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117f <display_statistics+0x6f>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe22(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xed6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xdfa(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xed7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_statistics>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r12
mov    %r8d,0x8(%rsp)
mov    %ecx,0x14(%rsp)
mov    %edx,0x10(%rsp)
mov    %esi,%r13d
mov    %edi,%ebp
mov    0x50(%rsp),%r15d
lea    0xfb3(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xf5d(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xe7e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15d,%r15d
jle    11c7 <display_statistics+0x97>
mov    %r15d,%ebp
lea    0xea3(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <display_statistics+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe7a(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cvtsi2sdl 0x10(%rsp),%xmm0
cvtsi2sdl 0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
divsd  %xmm1,%xmm0
lea    0xe7a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x14(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
lea    0xe86(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xee7(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [71 x i8] c"---------------------------------------------------------------------\0A\00"
@.str.1 = [71 x i8] c" STATISTICS \0A\00"
@.str.2 = [39 x i8] c"Time Quantum for Round-Robin : %d\0A\00"
@.str.3 = [36 x i8] c"Sequence of processes execution : \00"
@.str.4 = [7 x i8] c"P[%d] \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [39 x i8] c"Total Exceution Time : %d\0A\00"
@.str.7 = [41 x i8] c"Average Waiting Time : %.2f\0A\00"
@.str.8 = [41 x i8] c"Average Turnaround Time : %.2f\0A\00"
@.str.9 = [72 x i8] c"\0A---------------------------------------------------------------------\0A\00"
define void @display_statistics(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32* %5, i32** %13
store i32 %6, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %8
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %15
br label %22
22: ; preds = %33, %7
%23 = load i32, i32* %15
%24 = load i32, i32* %14
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %36
26: ; preds = %22
%27 = load i32*, i32** %13
%28 = load i32, i32* %15
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %26
%34 = load i32, i32* %15
%35 = add nsw i32 %34, 1
store i32 %35, i32* %15
br label %22
36: ; preds = %22
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%38 = load i32, i32* %9
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %10
%41 = sitofp i32 %40 to double
%42 = fmul double %41, 1.000000e+00
%43 = load i32, i32* %12
%44 = sitofp i32 %43 to double
%45 = fdiv double %42, %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), double %45)
%47 = load i32, i32* %11
%48 = sitofp i32 %47 to double
%49 = fmul double %48, 1.000000e+00
%50 = load i32, i32* %12
%51 = sitofp i32 %50 to double
%52 = fdiv double %49, %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), double %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.9, i64 0, i64 0))
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [39 x i8] c"Time Quantum for Round-Robin : %d\0A\00"
@.str.3 = [36 x i8] c"Sequence of processes execution : \00"
@.str.4 = [7 x i8] c"P[%d] \00"
@.str.6 = [39 x i8] c"Total Exceution Time : %d\0A\00"
@.str.7 = [41 x i8] c"Average Waiting Time : %.2f\0A\00"
@.str.8 = [41 x i8] c"Average Turnaround Time : %.2f\0A\00"
@str.10 = [70 x i8] c" STATISTICS \00"
@str.11 = [70 x i8] c"---------------------------------------------------------------------\00"
@str.12 = [71 x i8] c"\0A---------------------------------------------------------------------\00"
define void @display_statistics(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* nocapture %5, i32 %6) {
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.10, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.11, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp sgt i32 %6, 0
br i1 %13, label %14, label %23
14: ; preds = %7
%15 = zext i32 %6 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %21, %16 ]
%18 = getelementptr inbounds i32, i32* %5, i64 %17
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, %15
br i1 %22, label %23, label %16
23: ; preds = %16, %7
%24 = tail call i32 @putchar(i32 10)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %1)
%26 = sitofp i32 %2 to double
%27 = sitofp i32 %4 to double
%28 = fdiv double %26, %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), double %28)
%30 = sitofp i32 %3 to double
%31 = fdiv double %30, %27
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), double %31)
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str.12, i64 0, i64 0))
%34 = tail call i32 @putchar(i32 10)
ret void
}