#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 roll;
  int face;
  int frequency[7] = {0};
  srand(time(NULL));
  for (roll = 1; roll <= 6000; roll++) {
    face = 1 + rand() % 6;
    ++frequency[face];
  }
  printf("%s   %s\n", "Face", "Frequency");
  for (face = 1; face < 7; face++) {
    printf("%d      %d\n", face, frequency[face]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1040 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x1770,-0x8(%rbp)
jg     11c5 <main+0x75>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
movslq -0xc(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1186 <main+0x36>
lea    0xe34(%rip),%rdi
lea    0xe36(%rip),%rsi
lea    0xe34(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jge    1219 <main+0xc9>
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e8 <main+0x98>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0xc(%rsp)
movaps %xmm0,(%rsp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x1770,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <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
cltq
addl   $0x1,0x4(%rsp,%rax,4)
add    $0xffffffff,%ebx
jne    1170 <main+0x30>
lea    0xe59(%rip),%rdi
lea    0xe5b(%rip),%rsi
lea    0xe59(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
lea    0xe51(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s %s\0A\00"
@.str.1 = [5 x i8] c"Face\00"
@.str.2 = [10 x i8] c"Frequency\00"
@.str.3 = [12 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [7 x i32]
store i32 0, i32* %1
%5 = bitcast [7 x i32]* %4 to i8*
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
store i32 1, i32* %2
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 6000
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 6
%14 = add nsw i32 1, %13
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1
store i32 %19, i32* %17
br label %20
20: ; preds = %11
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %8
23: ; preds = %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %25
25: ; preds = %35, %23
%26 = load i32, i32* %3
%27 = icmp slt i32 %26, 7
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i32, i32* %3
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %33)
br label %35
35: ; preds = %28
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %25
38: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s %s\0A\00"
@.str.1 = [5 x i8] c"Face\00"
@.str.2 = [10 x i8] c"Frequency\00"
@.str.3 = [12 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 1, %0 ], [ %14, %5 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 6
%9 = add nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %11
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, 6001
br i1 %15, label %16, label %5
16: ; preds = %5
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%18 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 1
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %19)
%21 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 2
%22 = load i32, i32* %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %22)
%24 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 3
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %25)
%27 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 4
%28 = load i32, i32* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %28)
%30 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 5
%31 = load i32, i32* %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %31)
%33 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 6
%34 = load i32, i32* %33
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 %34)
ret i32 0
}