#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 min(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sleep(int);
int main() {
  int drop = 0, mini, nsec, cap, count = 0, i, inp[25], process;
  printf("Enter bucket size :");
  scanf("%d", &cap);
  printf("Enter transmission rate :");
  scanf("%d", &process);
  printf("Enter The duration of simulation in seconds : ");
  scanf("%d", &nsec);
  for (i = 0; i < nsec; i++) {
    printf("Enter packet size at %d sec : ", i + 1);
    scanf("%d", &inp[i]);
  }
  printf("\nSecond|Packet Recieved|Packet Sent|Packet Left|Packet Dropped|\n");
  printf("--------------------------------------------------------------\n");
  for (i = 0; i < nsec || count != 0; i++) {
    if (i < nsec)
      count += inp[i];
    if (count > cap) {
      drop = count - cap;
      count = cap;
    }
    printf("%d", i + 1);
    if (i < nsec)
      printf("\t%d", inp[i]);
    else
      printf("\t0");
    mini = min(count, process);
    printf("\t\t%d", mini);
    count = count - mini;
    printf("\t\t%d", count);
    printf("\t\t%d\n", drop);
    drop = 0;
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf8d(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf6f(%rip),%rdi
lea    -0x84(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4e(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    120d <main+0xcd>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1c(%rbp),%rax
lea    -0x80(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xf08(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c4 <main+0x84>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    $0x1,%al
cmp    -0x10(%rbp),%ecx
mov    %al,-0x85(%rbp)
jl     1251 <main+0x111>
cmpl   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x85(%rbp)
mov    -0x85(%rbp),%al
test   $0x1,%al
jne    1264 <main+0x124>
jmp    134e <main+0x20e>
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    127e <main+0x13e>
movslq -0x1c(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1299 <main+0x159>
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12d4 <main+0x194>
movslq -0x1c(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e2 <main+0x1a2>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x84(%rbp),%esi
call   1040 <min@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1230 <main+0xf0>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf0e(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1209 <main+0xb9>
lea    0x10(%rsp),%rbx
lea    0xe94(%rip),%r14
lea    0xeb1(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
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
call   1060 <scanf@plt>
movslq 0x4(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11e0 <main+0x90>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    1315 <main+0x1c5>
mov    $0x1,%al
lea    0xe4a(%rip),%rbx
xor    %r14d,%r14d
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
test   $0x1,%al
je     1249 <main+0xf9>
add    0x10(%rsp,%r14,4),%r13d
mov    0xc(%rsp),%eax
mov    %r13d,%ebp
sub    %eax,%ebp
mov    $0x0,%ecx
cmovle %ecx,%ebp
cmovg  %eax,%r13d
lea    0x1(%r14),%r12
lea    0xe18(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x4(%rsp),%rax
cmp    %rax,%r14
jge    12a0 <main+0x150>
mov    0x10(%rsp,%r14,4),%esi
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12ae <main+0x15e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xdd5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r13d,%edi
call   1050 <min@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%esi
sub    %r15d,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xda4(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    0x4(%rsp),%ecx
cmp    %r12d,%ecx
setg   %al
mov    %r12,%r14
sub    %r15d,%r13d
jne    1240 <main+0xf0>
mov    %r12,%r14
cmp    %r12d,%ecx
jg     1240 <main+0xf0>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter bucket size :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Enter transmission rate :\00"
@.str.3 = [47 x i8] c"Enter The duration of simulation in seconds : \00"
@.str.4 = [31 x i8] c"Enter packet size at %d sec : \00"
@.str.5 = [65 x i8] c"\0ASecond|Packet Recieved|Packet Sent|Packet Left|Packet Dropped|\0A\00"
@.str.6 = [64 x i8] c"--------------------------------------------------------------\0A\00"
@.str.7 = [4 x i8] c"\09%d\00"
@.str.8 = [3 x i8] c"\090\00"
@.str.9 = [5 x i8] c"\09\09%d\00"
@.str.10 = [6 x i8] c"\09\09%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [25 x i32]
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 0, i32* %7
br label %16
16: ; preds = %28, %0
%17 = load i32, i32* %7
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %16
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [25 x i32], [25 x i32]* %8, i64 0, i64 %25
%27 = call i32 @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* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %16
31: ; preds = %16
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %7
br label %34
34: ; preds = %92, %31
%35 = load i32, i32* %7
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %41, label %38
38: ; preds = %34
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
br label %41
41: ; preds = %38, %34
%42 = phi i1 [ true, %34 ], [ %40, %38 ]
br i1 %42, label %43, label %95
43: ; preds = %41
%44 = load i32, i32* %7
%45 = load i32, i32* %4
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %54
47: ; preds = %43
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [25 x i32], [25 x i32]* %8, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %6
%53 = add nsw i32 %52, %51
store i32 %53, i32* %6
br label %54
54: ; preds = %47, %43
%55 = load i32, i32* %6
%56 = load i32, i32* %5
%57 = icmp sgt i32 %55, %56
br i1 %57, label %58, label %63
58: ; preds = %54
%59 = load i32, i32* %6
%60 = load i32, i32* %5
%61 = sub nsw i32 %59, %60
store i32 %61, i32* %2
%62 = load i32, i32* %5
store i32 %62, i32* %6
br label %63
63: ; preds = %58, %54
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %7
%68 = load i32, i32* %4
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %76
70: ; preds = %63
%71 = load i32, i32* %7
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [25 x i32], [25 x i32]* %8, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %74)
br label %78
76: ; preds = %63
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %78
78: ; preds = %76, %70
%79 = load i32, i32* %6
%80 = load i32, i32* %9
%81 = call i32 @min(i32 %79, i32 %80)
store i32 %81, i32* %3
%82 = load i32, i32* %3
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %82)
%84 = load i32, i32* %6
%85 = load i32, i32* %3
%86 = sub nsw i32 %84, %85
store i32 %86, i32* %6
%87 = load i32, i32* %6
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %87)
%89 = load i32, i32* %2
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 %89)
store i32 0, i32* %2
%91 = call i32 @sleep(i32 1)
br label %92
92: ; preds = %78
%93 = load i32, i32* %7
%94 = add nsw i32 %93, 1
store i32 %94, i32* %7
br label %34
95: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter bucket size :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Enter transmission rate :\00"
@.str.3 = [47 x i8] c"Enter The duration of simulation in seconds : \00"
@.str.4 = [31 x i8] c"Enter packet size at %d sec : \00"
@.str.7 = [4 x i8] c"\09%d\00"
@.str.8 = [3 x i8] c"\090\00"
@.str.9 = [5 x i8] c"\09\09%d\00"
@.str.10 = [6 x i8] c"\09\09%d\0A\00"
@str = [64 x i8] c"\0ASecond|Packet Recieved|Packet Sent|Packet Left|Packet Dropped|\00"
@str.11 = [63 x i8] c"--------------------------------------------------------------\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [25 x i32]
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [25 x i32]* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %0, %17
%18 = phi i64 [ %19, %17 ], [ 0, %0 ]
%19 = add nuw nsw i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %18
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %19, %25
br i1 %26, label %17, label %27
27: ; preds = %17, %0
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.11, i64 0, i64 0))
%30 = load i32, i32* %1
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %71
32: ; preds = %27, %59
%33 = phi i64 [ %47, %59 ], [ 0, %27 ]
%34 = phi i1 [ %68, %59 ], [ true, %27 ]
%35 = phi i32 [ %63, %59 ], [ 0, %27 ]
br i1 %34, label %36, label %40
36: ; preds = %32
%37 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %33
%38 = load i32, i32* %37
%39 = add nsw i32 %38, %35
br label %40
40: ; preds = %36, %32
%41 = phi i32 [ %39, %36 ], [ %35, %32 ]
%42 = load i32, i32* %2
%43 = icmp sgt i32 %41, %42
%44 = sub nsw i32 %41, %42
%45 = select i1 %43, i32 %44, i32 0
%46 = select i1 %43, i32 %42, i32 %41
%47 = add nuw i64 %33, 1
%48 = trunc i64 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %1
%51 = sext i32 %50 to i64
%52 = icmp slt i64 %33, %51
br i1 %52, label %53, label %57
53: ; preds = %40
%54 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %33
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %55)
br label %59
57: ; preds = %40
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %59
59: ; preds = %57, %53
%60 = load i32, i32* %4
%61 = call i32 @min(i32 %46, i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %61)
%63 = sub nsw i32 %46, %61
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %63)
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 %45)
%66 = call i32 @sleep(i32 1)
%67 = load i32, i32* %1
%68 = icmp sgt i32 %67, %48
%69 = icmp ne i32 %63, 0
%70 = or i1 %69, %68
br i1 %70, label %32, label %71
71: ; preds = %59, %27
ret i32 0
}