#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 /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  srand(time(0));
  int histogram[6] = {0};
  int numberOfExperiments = 30;
  for (int i = 0; i < numberOfExperiments; ++i) {
    ++histogram[rand() % 6];
  }
  printf("Histograma de %d lançamentos\n", numberOfExperiments);
  for (int i = 0; i < 6; ++i) {
    printf("%d - ", i + 1);
    while (histogram[i]--) {
      printf("*");
    }
    puts("");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
movl   $0x1e,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11d2 <main+0x72>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x20(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    119b <main+0x3b>
mov    -0x24(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jge    124f <main+0xef>
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x2c(%rbp),%rcx
mov    -0x20(%rbp,%rcx,4),%eax
mov    %eax,%edx
add    $0xffffffff,%edx
mov    %edx,-0x20(%rbp,%rcx,4)
cmp    $0x0,%eax
je     1235 <main+0xd5>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1208 <main+0xa8>
lea    0xde2(%rip),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ea <main+0x8a>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    $0x1e,%ebx
nopl   0x0(%rax,%rax,1)
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
cltq
addl   $0x1,(%rsp,%rax,4)
add    $0xffffffff,%ebx
jne    1180 <main+0x30>
lea    0xe4a(%rip),%rdi
mov    $0x1e,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe56(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%ebx
test   %ebx,%ebx
je     11ef <main+0x9f>
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11e0 <main+0x90>
movl   $0xffffffff,(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe18(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%ebx
test   %ebx,%ebx
je     122f <main+0xdf>
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1220 <main+0xd0>
movl   $0xffffffff,0x4(%rsp)
ff
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdd7(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%ebx
test   %ebx,%ebx
je     126f <main+0x11f>
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1260 <main+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd9f(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     12af <main+0x15f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    12a0 <main+0x150>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd5f(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%ebx
test   %ebx,%ebx
je     12ef <main+0x19f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    12e0 <main+0x190>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd1f(%rip),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%ebx
test   %ebx,%ebx
je     132f <main+0x1df>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1320 <main+0x1d0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Histograma de %d lan\C3\A7amentos\0A\00"
@.str.1 = [6 x i8] c"%d - \00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @time(i32 0)
%7 = call i32 @srand(i32 %6)
%8 = bitcast [6 x i32]* %2 to i8*
store i32 30, i32* %3
store i32 0, i32* %4
br label %9
9: ; preds = %20, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %2, 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 = %13
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %9
23: ; preds = %9
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %24)
store i32 0, i32* %5
br label %26
26: ; preds = %44, %23
%27 = load i32, i32* %5
%28 = icmp slt i32 %27, 6
br i1 %28, label %29, label %47
29: ; preds = %26
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %40, %29
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = add nsw i32 %37, -1
store i32 %38, i32* %36
%39 = icmp ne i32 %37, 0
br i1 %39, label %40, label %42
40: ; preds = %33
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %33
42: ; preds = %33
%43 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %26
47: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Histograma de %d lan\C3\A7amentos\0A\00"
@.str.1 = [6 x i8] c"%d - \00"
define i32 @main() {
%1 = alloca [6 x i32]
%2 = tail call i32 @time(i32 0)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast [6 x i32]* %1 to i8*
br label %11
5: ; preds = %11
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 30)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 1)
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %26, label %21
11: ; preds = %0, %11
%12 = phi i32 [ 0, %0 ], [ %19, %11 ]
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
%19 = add nuw nsw i32 %12, 1
%20 = icmp eq i32 %19, 30
br i1 %20, label %5, label %11
21: ; preds = %5, %21
%22 = phi i32 [ %23, %21 ], [ %9, %5 ]
%23 = add nsw i32 %22, -1
%24 = tail call i32 @putchar(i32 42)
%25 = icmp eq i32 %23, 0
br i1 %25, label %26, label %21
26: ; preds = %21, %5
store i32 -1, i32* %8
%27 = tail call i32 @putchar(i32 10)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 2)
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 1
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %26, %32
%33 = phi i32 [ %34, %32 ], [ %30, %26 ]
%34 = add nsw i32 %33, -1
%35 = tail call i32 @putchar(i32 42)
%36 = icmp eq i32 %34, 0
br i1 %36, label %37, label %32
37: ; preds = %32, %26
store i32 -1, i32* %29
%38 = tail call i32 @putchar(i32 10)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 3)
%40 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 2
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, 0
br i1 %42, label %48, label %43
43: ; preds = %37, %43
%44 = phi i32 [ %45, %43 ], [ %41, %37 ]
%45 = add nsw i32 %44, -1
%46 = tail call i32 @putchar(i32 42)
%47 = icmp eq i32 %45, 0
br i1 %47, label %48, label %43
48: ; preds = %43, %37
%49 = tail call i32 @putchar(i32 10)
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 4)
%51 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 3
%52 = load i32, i32* %51
%53 = icmp eq i32 %52, 0
br i1 %53, label %59, label %54
54: ; preds = %48, %54
%55 = phi i32 [ %56, %54 ], [ %52, %48 ]
%56 = add nsw i32 %55, -1
%57 = tail call i32 @putchar(i32 42)
%58 = icmp eq i32 %56, 0
br i1 %58, label %59, label %54
59: ; preds = %54, %48
%60 = tail call i32 @putchar(i32 10)
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%62 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 4
%63 = load i32, i32* %62
%64 = icmp eq i32 %63, 0
br i1 %64, label %70, label %65
65: ; preds = %59, %65
%66 = phi i32 [ %67, %65 ], [ %63, %59 ]
%67 = add nsw i32 %66, -1
%68 = tail call i32 @putchar(i32 42)
%69 = icmp eq i32 %67, 0
br i1 %69, label %70, label %65
70: ; preds = %65, %59
%71 = tail call i32 @putchar(i32 10)
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6)
%73 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 5
%74 = load i32, i32* %73
%75 = icmp eq i32 %74, 0
br i1 %75, label %81, label %76
76: ; preds = %70, %76
%77 = phi i32 [ %78, %76 ], [ %74, %70 ]
%78 = add nsw i32 %77, -1
%79 = tail call i32 @putchar(i32 42)
%80 = icmp eq i32 %78, 0
br i1 %80, label %81, label %76
81: ; preds = %76, %70
%82 = tail call i32 @putchar(i32 10)
ret i32 0
}