#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 rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int user_input;
  int counter = 0;
  int x;
  int ones = 0;
  int twos = 0;
  int threes = 0;
  int fours = 0;
  int fives = 0;
  int sixes = 0;
  printf("Roll the die how many times?\n");
  scanf("%d", &user_input);
  srand(time(NULL));
  while (counter <= user_input) {
    x = rand() % 6 + 1;
    counter++;
    if (x == 1) {
      ones++;
    } else if (x == 2) {
      twos++;
    } else if (x == 3) {
      threes++;
    } else if (x == 4) {
      fours++;
    } else if (x == 5) {
      fives++;
    } else {
      sixes++;
    }
  }
  printf("ones:%d\n", ones);
  printf("twos:%d\n", twos);
  printf("threes:%d\n", threes);
  printf("fours:%d\n", fours);
  printf("fives:%d\n", fives);
  printf("sixes:%d\n", sixes);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1282 <main+0x132>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1200 <main+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    127d <main+0x12d>
cmpl   $0x2,-0x10(%rbp)
jne    1218 <main+0xc8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1278 <main+0x128>
cmpl   $0x3,-0x10(%rbp)
jne    1230 <main+0xe0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1273 <main+0x123>
cmpl   $0x4,-0x10(%rbp)
jne    1248 <main+0xf8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    126e <main+0x11e>
cmpl   $0x5,-0x10(%rbp)
jne    1260 <main+0x110>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1269 <main+0x119>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    126e <main+0x11e>
jmp    1273 <main+0x123>
jmp    1278 <main+0x128>
jmp    127d <main+0x12d>
jmp    11be <main+0x6e>
mov    -0x14(%rbp),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1070 <scanf@plt>
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmpl   $0x0,0x14(%rsp)
mov    $0x0,%ebp
mov    $0x0,%r13d
mov    $0x0,%r12d
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
js     125a <main+0xfa>
mov    $0xffffffff,%r14d
lea    0xe2c(%rip),%r15
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    120b <main+0xab>
addl   $0x1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14d
cmp    0x14(%rsp),%r14d
jge    125a <main+0xfa>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x4,%eax
ja     11f0 <main+0x90>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
add    $0x1,%ebx
jmp    1200 <main+0xa0>
add    $0x1,%ebp
jmp    1200 <main+0xa0>
add    $0x1,%r13d
jmp    1200 <main+0xa0>
add    $0x1,%r12d
jmp    1200 <main+0xa0>
addl   $0x1,0xc(%rsp)
jmp    1200 <main+0xa0>
lea    0xdb6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdaf(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xda8(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xda2(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd9b(%rip),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd93(%rip),%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Roll the die how many times?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"ones:%d\0A\00"
@.str.3 = [9 x i8] c"twos:%d\0A\00"
@.str.4 = [11 x i8] c"threes:%d\0A\00"
@.str.5 = [10 x i8] c"fours:%d\0A\00"
@.str.6 = [10 x i8] c"fives:%d\0A\00"
@.str.7 = [10 x i8] c"sixes:%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 i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 @time(i32* null)
%14 = call i32 @srand(i32 %13)
br label %15
15: ; preds = %61, %0
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %62
19: ; preds = %15
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %61
30: ; preds = %19
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %60
36: ; preds = %30
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 3
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %59
42: ; preds = %36
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 4
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %58
48: ; preds = %42
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 5
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %57
54: ; preds = %48
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %57
57: ; preds = %54, %51
br label %58
58: ; preds = %57, %45
br label %59
59: ; preds = %58, %39
br label %60
60: ; preds = %59, %33
br label %61
61: ; preds = %60, %27
br label %15
62: ; preds = %15
%63 = load i32, i32* %5
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %6
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %7
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %8
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %69)
%71 = load i32, i32* %9
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %71)
%73 = load i32, i32* %10
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %73)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"ones:%d\0A\00"
@.str.3 = [9 x i8] c"twos:%d\0A\00"
@.str.4 = [11 x i8] c"threes:%d\0A\00"
@.str.5 = [10 x i8] c"fours:%d\0A\00"
@.str.6 = [10 x i8] c"fives:%d\0A\00"
@.str.7 = [10 x i8] c"sixes:%d\0A\00"
@str = [29 x i8] c"Roll the die how many times?\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %41, label %9
9: ; preds = %0, %32
%10 = phi i32 [ %38, %32 ], [ 0, %0 ]
%11 = phi i32 [ %37, %32 ], [ 0, %0 ]
%12 = phi i32 [ %36, %32 ], [ 0, %0 ]
%13 = phi i32 [ %35, %32 ], [ 0, %0 ]
%14 = phi i32 [ %34, %32 ], [ 0, %0 ]
%15 = phi i32 [ %33, %32 ], [ 0, %0 ]
%16 = phi i32 [ %19, %32 ], [ 0, %0 ]
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 6
%19 = add nuw nsw i32 %16, 1
switch i32 %18, label %30 [
i32 0, label %20
i32 1, label %22
i32 2, label %24
i32 3, label %26
i32 4, label %28
]
20: ; preds = %9
%21 = add nsw i32 %15, 1
br label %32
22: ; preds = %9
%23 = add nsw i32 %14, 1
br label %32
24: ; preds = %9
%25 = add nsw i32 %13, 1
br label %32
26: ; preds = %9
%27 = add nsw i32 %12, 1
br label %32
28: ; preds = %9
%29 = add nsw i32 %11, 1
br label %32
30: ; preds = %9
%31 = add nsw i32 %10, 1
br label %32
32: ; preds = %22, %26, %30, %28, %24, %20
%33 = phi i32 [ %21, %20 ], [ %15, %22 ], [ %15, %24 ], [ %15, %26 ], [ %15, %28 ], [ %15, %30 ]
%34 = phi i32 [ %14, %20 ], [ %23, %22 ], [ %14, %24 ], [ %14, %26 ], [ %14, %28 ], [ %14, %30 ]
%35 = phi i32 [ %13, %20 ], [ %13, %22 ], [ %25, %24 ], [ %13, %26 ], [ %13, %28 ], [ %13, %30 ]
%36 = phi i32 [ %12, %20 ], [ %12, %22 ], [ %12, %24 ], [ %27, %26 ], [ %12, %28 ], [ %12, %30 ]
%37 = phi i32 [ %11, %20 ], [ %11, %22 ], [ %11, %24 ], [ %11, %26 ], [ %29, %28 ], [ %11, %30 ]
%38 = phi i32 [ %10, %20 ], [ %10, %22 ], [ %10, %24 ], [ %10, %26 ], [ %10, %28 ], [ %31, %30 ]
%39 = load i32, i32* %1
%40 = icmp slt i32 %16, %39
br i1 %40, label %9, label %41
41: ; preds = %32, %0
%42 = phi i32 [ 0, %0 ], [ %33, %32 ]
%43 = phi i32 [ 0, %0 ], [ %34, %32 ]
%44 = phi i32 [ 0, %0 ], [ %35, %32 ]
%45 = phi i32 [ 0, %0 ], [ %36, %32 ]
%46 = phi i32 [ 0, %0 ], [ %37, %32 ]
%47 = phi i32 [ 0, %0 ], [ %38, %32 ]
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %46)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %47)
ret i32 0
}