#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 randBetween(int, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  srand(time(0));
  int numberOfThrows;
  printf("Quantos lançamentos? ");
  scanf("%d", &numberOfThrows);
  int n = 0;
  for (int i = 0; i < numberOfThrows; ++i) {
    if (randBetween(1, 6) == 6) {
      ++n;
    }
  }
  printf("A face seis saiu %d vezes.\n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d9 <main+0x89>
mov    $0x1,%edi
mov    $0x6,%esi
call   1070 <randBetween@plt>
cmp    $0x6,%eax
jne    11c6 <main+0x76>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cb <main+0x7b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1199 <main+0x49>
mov    -0xc(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11b2 <main+0x62>
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   (%rax)
mov    $0x1,%edi
mov    $0x6,%esi
call   1070 <randBetween@plt>
xor    %ecx,%ecx
cmp    $0x6,%eax
sete   %cl
add    %ecx,%ebx
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1190 <main+0x40>
lea    0xe61(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Quantos lan\C3\A7amentos? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"A face seis saiu %d vezes.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32 0)
%6 = call i32 @srand(i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
store i32 0, i32* %4
br label %9
9: ; preds = %20, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = call i32 @randBetween(i32 1, i32 6)
%15 = icmp eq i32 %14, 6
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %13
br label %20
20: ; preds = %19
%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 ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Quantos lan\C3\A7amentos? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"A face seis saiu %d vezes.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @time(i32 0)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %12, %0
%10 = phi i32 [ 0, %0 ], [ %18, %12 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret i32 0
12: ; preds = %0, %12
%13 = phi i32 [ %19, %12 ], [ 0, %0 ]
%14 = phi i32 [ %18, %12 ], [ 0, %0 ]
%15 = call i32 @randBetween(i32 1, i32 6)
%16 = icmp eq i32 %15, 6
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %14, %17
%19 = add nuw nsw i32 %13, 1
%20 = load i32, i32* %1
%21 = icmp slt i32 %19, %20
br i1 %21, label %12, label %9
}