#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, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int counts[6] = {0};
  int i;
  srand(time(NULL));
  for (i = 0; i < (1000); i++) {
    counts[rand() % 6]++;
  }
  for (i = 0; i < 6; i++) {
    printf("%d times %d\n", counts[i], i + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x3e8,-0x34(%rbp)
jge    11c5 <main+0x75>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118d <main+0x3d>
movl   $0x0,-0x34(%rbp)
cmpl   $0x6,-0x34(%rbp)
jge    11fe <main+0xae>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
mov    -0x34(%rbp),%edx
add    $0x1,%edx
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11cc <main+0x7c>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x3e8,%ebx
nopl   0x0(%rax,%rax,1)
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,(%rsp,%rax,4)
add    $0xffffffff,%ebx
jne    1170 <main+0x30>
mov    (%rsp),%esi
lea    0xe57(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

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