#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 dice();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  srand(time(0));
  static int times[6], total;
  for (int i = 0; i < 1000; i++)
    times[dice() - 1]++;
  printf("\nEl dado de la fortuna ha hablado!\n");
  for (int i = 0; i < 6; i++) {
    printf("Lado %d: %d veces\n", i + 1, times[i]);
    total += times[i];
  }
  printf("Total: %d\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    11a3 <main+0x63>
mov    $0x0,%al
call   1030 <dice@plt>
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2ecb(%rip),%rax
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
lea    0x2ebe(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1164 <main+0x24>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    120c <main+0xcc>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
movslq -0xc(%rbp),%rcx
lea    0x2e7d(%rip),%rax
mov    (%rax,%rcx,4),%edx
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0xc(%rbp),%rcx
lea    0x2e61(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    0x2e70(%rip),%eax
mov    %eax,0x2e6a(%rip)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b8 <main+0x78>
mov    0x2e56(%rip),%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x3e8,%ebx
lea    0x2ef2(%rip),%r14
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <dice@plt>
cltq
addl   $0x1,-0x4(%r14,%rax,4)
add    $0xffffffff,%ebx
jne    1170 <main+0x20>
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
mov    0x2eca(%rip),%edx
lea    0xe63(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2eae(%rip),%eax
add    %eax,0x2ec0(%rip)
mov    0x2ea6(%rip),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e91(%rip),%eax
add    %eax,0x2e9f(%rip)
mov    0x2e89(%rip),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e74(%rip),%eax
add    %eax,0x2e7e(%rip)
mov    0x2e6c(%rip),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e57(%rip),%eax
add    %eax,0x2e5d(%rip)
mov    0x2e4f(%rip),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e3a(%rip),%eax
add    %eax,0x2e3c(%rip)
mov    0x2e32(%rip),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e21(%rip),%esi
add    0x2e17(%rip),%esi
mov    %esi,0x2e15(%rip)
lea    0xda9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@main.times = internal global [6 x i32] zeroinitializer
@main.total = internal global i32 0
@.str = [36 x i8] c"\0AEl dado de la fortuna ha hablado!\0A\00"
@.str.1 = [19 x i8] c"Lado %d: %d veces\0A\00"
@.str.2 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32 0)
%5 = call i32 @srand(i32 %4)
store i32 0, i32* %2
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1000
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = call i32 (...) @dice()
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [6 x i32], [6 x i32]* @main.times, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
store i32 %15, i32* %13
br label %16
16: ; preds = %9
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %6
19: ; preds = %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %21
21: ; preds = %38, %19
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 6
br i1 %23, label %24, label %41
24: ; preds = %21
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [6 x i32], [6 x i32]* @main.times, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %30)
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [6 x i32], [6 x i32]* @main.times, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = load i32, i32* @main.total
%37 = add nsw i32 %36, %35
store i32 %37, i32* @main.total
br label %38
38: ; preds = %24
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %21
41: ; preds = %21
%42 = load i32, i32* @main.total
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %42)
ret i32 0
}

LLVM IR (-O2):
@main.times = internal unnamed_addr global [6 x i32] zeroinitializer
@main.total = internal unnamed_addr global i32 0
@.str.1 = [19 x i8] c"Lado %d: %d veces\0A\00"
@.str.2 = [11 x i8] c"Total: %d\0A\00"
@str = [35 x i8] c"\0AEl dado de la fortuna ha hablado!\00"
define i32 @main() {
%1 = tail call i32 @time(i32 0)
%2 = tail call i32 @srand(i32 %1)
br label %36
3: ; preds = %36
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%5 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %5)
%7 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 0)
%8 = load i32, i32* @main.total
%9 = add nsw i32 %8, %7
store i32 %9, i32* @main.total
%10 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 1)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %10)
%12 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 1)
%13 = load i32, i32* @main.total
%14 = add nsw i32 %13, %12
store i32 %14, i32* @main.total
%15 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 2)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %15)
%17 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 2)
%18 = load i32, i32* @main.total
%19 = add nsw i32 %18, %17
store i32 %19, i32* @main.total
%20 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 3)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %20)
%22 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 3)
%23 = load i32, i32* @main.total
%24 = add nsw i32 %23, %22
store i32 %24, i32* @main.total
%25 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 4)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %25)
%27 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 4)
%28 = load i32, i32* @main.total
%29 = add nsw i32 %28, %27
store i32 %29, i32* @main.total
%30 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 5)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %30)
%32 = load i32, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @main.times, i64 0, i64 5)
%33 = load i32, i32* @main.total
%34 = add nsw i32 %33, %32
store i32 %34, i32* @main.total
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %34)
ret i32 0
36: ; preds = %0, %36
%37 = phi i32 [ 0, %0 ], [ %44, %36 ]
%38 = tail call i32 (...) @dice()
%39 = add nsw i32 %38, -1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [6 x i32], [6 x i32]* @main.times, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
store i32 %43, i32* %41
%44 = add nuw nsw i32 %37, 1
%45 = icmp eq i32 %44, 1000
br i1 %45, label %3, label %36
}