#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 *, ...);
void main() {
  int bt[50], p[50], qt, gt;
  int i, j, n, k, flag;
  printf("Enter Quantum time\n");
  scanf("%d", &qt);
  printf("Enter number of process\n");
  scanf("%d", &n);
  scanf("Enter brust times:\n");
  for (i = 0; i < n; i++) {
    printf("Brust Time for Process %d:", i + 1);
    scanf("%d", &bt[i]);
  }
  j = 0;
  gt = 0;
  int a = qt;
  flag = 1;
  while (flag) {
    if ((bt[j] != 0) && (bt[j] >= qt)) {
      bt[j] = bt[j] - qt;
      gt = gt + qt;
      j++;
      printf(" P%d  %d\n", j, gt);
    } else if ((bt[j] != 0) && (bt[j] < qt)) {
      gt = gt + bt[j];
      bt[j] = 0;
      j++;
      printf(" P%d  %d\n", j, gt);
    } else
      j++;
    for (k = 0; k < n; k++) {
      if (bt[k] == 0)
        flag = 0;
      else
        break;
    }
    if (j == n) {
      j = 0;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x1b4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    11e9 <main+0xc9>
mov    -0x1ac(%rbp),%esi
add    $0x1,%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1ac(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    1189 <main+0x69>
movl   $0x0,-0x1b0(%rbp)
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a4(%rbp),%eax
mov    %eax,-0x1c0(%rbp)
movl   $0x1,-0x1bc(%rbp)
cmpl   $0x0,-0x1bc(%rbp)
je     13cd <main+0x2ad>
movslq -0x1b0(%rbp),%rax
cmpl   $0x0,-0xd0(%rbp,%rax,4)
je     12b1 <main+0x191>
movslq -0x1b0(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%eax
cmp    -0x1a4(%rbp),%eax
jl     12b1 <main+0x191>
movslq -0x1b0(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%ecx
sub    -0x1a4(%rbp),%ecx
movslq -0x1b0(%rbp),%rax
mov    %ecx,-0xd0(%rbp,%rax,4)
mov    -0x1a8(%rbp),%eax
add    -0x1a4(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%esi
mov    -0x1a8(%rbp),%edx
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    134e <main+0x22e>
movslq -0x1b0(%rbp),%rax
cmpl   $0x0,-0xd0(%rbp,%rax,4)
je     133a <main+0x21a>
movslq -0x1b0(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%eax
cmp    -0x1a4(%rbp),%eax
jge    133a <main+0x21a>
mov    -0x1a8(%rbp),%eax
movslq -0x1b0(%rbp),%rcx
add    -0xd0(%rbp,%rcx,4),%eax
mov    %eax,-0x1a8(%rbp)
movslq -0x1b0(%rbp),%rax
movl   $0x0,-0xd0(%rbp,%rax,4)
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%esi
mov    -0x1a8(%rbp),%edx
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1349 <main+0x229>
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
jmp    134e <main+0x22e>
movl   $0x0,-0x1b8(%rbp)
mov    -0x1b8(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    13ac <main+0x28c>
movslq -0x1b8(%rbp),%rax
cmpl   $0x0,-0xd0(%rbp,%rax,4)
jne    138e <main+0x26e>
movl   $0x0,-0x1bc(%rbp)
jmp    1393 <main+0x273>
jmp    13ac <main+0x28c>
jmp    1398 <main+0x278>
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
jmp    1358 <main+0x238>
mov    -0x1b0(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jne    13c8 <main+0x2a8>
movl   $0x0,-0x1b0(%rbp)
jmp    1213 <main+0xf3>
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
lea    0xeae(%rip),%rbx
xor    %r12d,%r12d
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11db <main+0xab>
lea    0x10(%rsp),%rbx
lea    0xe77(%rip),%r14
lea    0xe59(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
add    $0x1,%rbp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11b0 <main+0x80>
lea    0xe50(%rip),%r14
xor    %ebp,%ebp
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movslq %eax,%rbx
mov    0x10(%rsp,%rbx,4),%ecx
test   %ecx,%ecx
je     1220 <main+0xf0>
mov    0xc(%rsp),%eax
mov    %ecx,%edx
sub    %eax,%edx
jge    1230 <main+0x100>
add    %ecx,%ebp
movl   $0x0,0x10(%rsp,%rbx,4)
jmp    1236 <main+0x106>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%eax
jmp    1249 <main+0x119>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edx,0x10(%rsp,%rbx,4)
add    %eax,%ebp
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
jle    1258 <main+0x128>
cmpl   $0x0,0x10(%rsp)
je     1270 <main+0x140>
xor    %edx,%edx
cmp    %ecx,%eax
cmove  %r12d,%eax
test   %dl,%dl
je     11f0 <main+0xc0>
jmp    1294 <main+0x164>
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%edx
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %rdx,%rcx
je     1294 <main+0x164>
cmpl   $0x0,0x10(%rsp,%rdx,4)
lea    0x1(%rdx),%rdx
je     1280 <main+0x150>
mov    $0x1,%dl
jmp    125a <main+0x12a>
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter Quantum time\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"Enter number of process\0A\00"
@.str.3 = [20 x i8] c"Enter brust times:\0A\00"
@.str.4 = [27 x i8] c"Brust Time for Process %d:\00"
@.str.5 = [10 x i8] c" P%d %d\0A\00"
define void @main() {
%1 = alloca [50 x i32]
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %16
16: ; preds = %28, %0
%17 = load i32, i32* %5
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %16
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %25
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %20
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %16
31: ; preds = %16
store i32 0, i32* %6
store i32 0, i32* %4
%32 = load i32, i32* %3
store i32 %32, i32* %10
store i32 1, i32* %9
br label %33
33: ; preds = %121, %31
%34 = load i32, i32* %9
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %122
36: ; preds = %33
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %67
42: ; preds = %36
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %3
%48 = icmp sge i32 %46, %47
br i1 %48, label %49, label %67
49: ; preds = %42
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = load i32, i32* %3
%55 = sub nsw i32 %53, %54
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %57
store i32 %55, i32* %58
%59 = load i32, i32* %4
%60 = load i32, i32* %3
%61 = add nsw i32 %59, %60
store i32 %61, i32* %4
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
%64 = load i32, i32* %6
%65 = load i32, i32* %4
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %64, i32 %65)
br label %99
67: ; preds = %42, %36
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %95
73: ; preds = %67
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = load i32, i32* %3
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %95
80: ; preds = %73
%81 = load i32, i32* %4
%82 = load i32, i32* %6
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = add nsw i32 %81, %85
store i32 %86, i32* %4
%87 = load i32, i32* %6
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %88
store i32 0, i32* %89
%90 = load i32, i32* %6
%91 = add nsw i32 %90, 1
store i32 %91, i32* %6
%92 = load i32, i32* %6
%93 = load i32, i32* %4
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %92, i32 %93)
br label %98
95: ; preds = %73, %67
%96 = load i32, i32* %6
%97 = add nsw i32 %96, 1
store i32 %97, i32* %6
br label %98
98: ; preds = %95, %80
br label %99
99: ; preds = %98, %49
store i32 0, i32* %8
br label %100
100: ; preds = %113, %99
%101 = load i32, i32* %8
%102 = load i32, i32* %7
%103 = icmp slt i32 %101, %102
br i1 %103, label %104, label %116
104: ; preds = %100
%105 = load i32, i32* %8
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %106
%108 = load i32, i32* %107
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %111
110: ; preds = %104
store i32 0, i32* %9
br label %112
111: ; preds = %104
br label %116
112: ; preds = %110
br label %113
113: ; preds = %112
%114 = load i32, i32* %8
%115 = add nsw i32 %114, 1
store i32 %115, i32* %8
br label %100
116: ; preds = %111, %100
%117 = load i32, i32* %6
%118 = load i32, i32* %7
%119 = icmp eq i32 %117, %118
br i1 %119, label %120, label %121
120: ; preds = %116
store i32 0, i32* %6
br label %121
121: ; preds = %120, %116
br label %33
122: ; preds = %33
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"Enter brust times:\0A\00"
@.str.4 = [27 x i8] c"Brust Time for Process %d:\00"
@.str.5 = [10 x i8] c" P%d %d\0A\00"
@str = [19 x i8] c"Enter Quantum time\00"
@str.6 = [24 x i8] c"Enter number of process\00"
define void @main() {
%1 = alloca [50 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [50 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %0, %14
%15 = phi i64 [ %16, %14 ], [ 0, %0 ]
%16 = add nuw nsw i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %15
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %16, %22
br i1 %23, label %14, label %24
24: ; preds = %14, %0
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
br label %26
26: ; preds = %24, %64
%27 = phi i32 [ %49, %64 ], [ 0, %24 ]
%28 = phi i32 [ %67, %64 ], [ 0, %24 ]
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %45, label %33
33: ; preds = %26
%34 = load i32, i32* %2
%35 = icmp slt i32 %31, %34
br i1 %35, label %41, label %36
36: ; preds = %33
%37 = sub nsw i32 %31, %34
store i32 %37, i32* %30
%38 = add nsw i32 %34, %27
%39 = add nsw i32 %28, 1
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %39, i32 %38)
br label %47
41: ; preds = %33
%42 = add nsw i32 %31, %27
store i32 0, i32* %30
%43 = add nsw i32 %28, 1
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %43, i32 %42)
br label %47
45: ; preds = %26
%46 = add nsw i32 %28, 1
br label %47
47: ; preds = %41, %45, %36
%48 = phi i32 [ %39, %36 ], [ %43, %41 ], [ %46, %45 ]
%49 = phi i32 [ %38, %36 ], [ %42, %41 ], [ %27, %45 ]
%50 = load i32, i32* %3
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %64
52: ; preds = %47
%53 = zext i32 %50 to i64
%54 = load i32, i32* %25
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %64
56: ; preds = %52, %59
%57 = phi i64 [ %63, %59 ], [ 1, %52 ]
%58 = icmp eq i64 %57, %53
br i1 %58, label %68, label %59
59: ; preds = %56
%60 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %57
%61 = load i32, i32* %60
%62 = icmp eq i32 %61, 0
%63 = add nuw nsw i64 %57, 1
br i1 %62, label %56, label %64
64: ; preds = %59, %52, %47
%65 = phi i1 [ false, %52 ], [ false, %47 ], [ true, %59 ]
%66 = icmp eq i32 %48, %50
%67 = select i1 %66, i32 0, i32 %48
br i1 %65, label %68, label %26
68: ; preds = %64, %56
ret void
}