#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*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int i, dice[6];
  srand(time(NULL));
  for (i = 0; i < 6; i++) {
    dice[i] = 0;
  }
  for (i = 0; i < 1000; i++) {
    switch (rand() % 6 + 1) {
    case 1:
      dice[0]++;
      break;
    case 2:
      dice[1]++;
      break;
    case 3:
      dice[2]++;
      break;
    case 4:
      dice[3]++;
      break;
    case 5:
      dice[4]++;
      break;
    case 6:
      dice[5]++;
      break;
    }
  }
  printf("Input: \n (none) \n");
  printf("Output: \n");
  for (i = 0; i < 6; i++) {
    printf("%d appeared %d time(s). \n", i + 1, dice[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    118a <main+0x4a>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x20(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1166 <main+0x26>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    124a <main+0x10a>
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rcx
imul   $0x2aaaaaab,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     1237 <main+0xf7>
mov    -0x28(%rbp),%rax
lea    0xe21(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1237 <main+0xf7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1237 <main+0xf7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1237 <main+0xf7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1237 <main+0xf7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1237 <main+0xf7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    123c <main+0xfc>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1191 <main+0x51>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    12a1 <main+0x161>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    126d <main+0x12d>
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
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x3e8,%r14d
lea    0xe8a(%rip),%r15
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r12d,%r12d
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
jmp    11a6 <main+0x56>
addl   $0x1,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%r14d
je     11f4 <main+0xa4>
xor    %eax,%eax
call   1070 <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    $0x5,%eax
ja     11a0 <main+0x50>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
add    $0x1,%ebp
jmp    11a0 <main+0x50>
add    $0x1,%ebx
jmp    11a0 <main+0x50>
add    $0x1,%r13d
jmp    11a0 <main+0x50>
add    $0x1,%r12d
jmp    11a0 <main+0x50>
addl   $0x1,(%rsp)
jmp    11a0 <main+0x50>
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe05(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    (%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    0x4(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Input: \0A (none) \0A\00"
@.str.1 = [10 x i8] c"Output: \0A\00"
@.str.2 = [26 x i8] c"%d appeared %d time(s). \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [6 x i32]
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i32 0, i32* %2
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 6
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %11
store i32 0, i32* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %6
16: ; preds = %6
store i32 0, i32* %2
br label %17
17: ; preds = %49, %16
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 1000
br i1 %19, label %20, label %52
20: ; preds = %17
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 6
%23 = add nsw i32 %22, 1
switch i32 %23, label %48 [
i32 1, label %24
i32 2, label %28
i32 3, label %32
i32 4, label %36
i32 5, label %40
i32 6, label %44
]
24: ; preds = %20
%25 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
br label %48
28: ; preds = %20
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
br label %48
32: ; preds = %20
%33 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %33
br label %48
36: ; preds = %20
%37 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%38 = load i32, i32* %37
%39 = add nsw i32 %38, 1
store i32 %39, i32* %37
br label %48
40: ; preds = %20
%41 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
store i32 %43, i32* %41
br label %48
44: ; preds = %20
%45 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
store i32 %47, i32* %45
br label %48
48: ; preds = %20, %44, %40, %36, %32, %28, %24
br label %49
49: ; preds = %48
%50 = load i32, i32* %2
%51 = add nsw i32 %50, 1
store i32 %51, i32* %2
br label %17
52: ; preds = %17
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %55
55: ; preds = %66, %52
%56 = load i32, i32* %2
%57 = icmp slt i32 %56, 6
br i1 %57, label %58, label %69
58: ; preds = %55
%59 = load i32, i32* %2
%60 = add nsw i32 %59, 1
%61 = load i32, i32* %2
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %60, i32 %64)
br label %66
66: ; preds = %58
%67 = load i32, i32* %2
%68 = add nsw i32 %67, 1
store i32 %68, i32* %2
br label %55
69: ; preds = %55
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [26 x i8] c"%d appeared %d time(s). \0A\00"
@str = [17 x i8] c"Input: \0A (none) \00"
@str.3 = [9 x i8] c"Output: \00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %25
%4 = phi i32 [ 0, %0 ], [ %26, %25 ]
%5 = phi i32 [ 0, %0 ], [ %27, %25 ]
%6 = phi i32 [ 0, %0 ], [ %28, %25 ]
%7 = phi i32 [ 0, %0 ], [ %29, %25 ]
%8 = phi i32 [ 0, %0 ], [ %30, %25 ]
%9 = phi i32 [ 0, %0 ], [ %31, %25 ]
%10 = phi i32 [ 0, %0 ], [ %32, %25 ]
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 6
switch i32 %12, label %25 [
i32 0, label %13
i32 1, label %15
i32 2, label %17
i32 3, label %19
i32 4, label %21
i32 5, label %23
]
13: ; preds = %3
%14 = add nsw i32 %4, 1
br label %25
15: ; preds = %3
%16 = add nsw i32 %5, 1
br label %25
17: ; preds = %3
%18 = add nsw i32 %6, 1
br label %25
19: ; preds = %3
%20 = add nsw i32 %7, 1
br label %25
21: ; preds = %3
%22 = add nsw i32 %8, 1
br label %25
23: ; preds = %3
%24 = add nsw i32 %9, 1
br label %25
25: ; preds = %13, %15, %17, %19, %21, %23, %3
%26 = phi i32 [ %14, %13 ], [ %4, %15 ], [ %4, %17 ], [ %4, %19 ], [ %4, %21 ], [ %4, %23 ], [ %4, %3 ]
%27 = phi i32 [ %5, %13 ], [ %16, %15 ], [ %5, %17 ], [ %5, %19 ], [ %5, %21 ], [ %5, %23 ], [ %5, %3 ]
%28 = phi i32 [ %6, %13 ], [ %6, %15 ], [ %18, %17 ], [ %6, %19 ], [ %6, %21 ], [ %6, %23 ], [ %6, %3 ]
%29 = phi i32 [ %7, %13 ], [ %7, %15 ], [ %7, %17 ], [ %20, %19 ], [ %7, %21 ], [ %7, %23 ], [ %7, %3 ]
%30 = phi i32 [ %8, %13 ], [ %8, %15 ], [ %8, %17 ], [ %8, %19 ], [ %22, %21 ], [ %8, %23 ], [ %8, %3 ]
%31 = phi i32 [ %9, %13 ], [ %9, %15 ], [ %9, %17 ], [ %9, %19 ], [ %9, %21 ], [ %24, %23 ], [ %9, %3 ]
%32 = add nuw nsw i32 %10, 1
%33 = icmp eq i32 %32, 1000
br i1 %33, label %34, label %3
34: ; preds = %25
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.3, i64 0, i64 0))
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %26)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %27)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %28)
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 %29)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 %30)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 %31)
ret i32 0
}