#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 EXIT_SUCCESS;
scalar_t__ play_craps();
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  int i, num_win = 0;
  srand(time(0));
  for (i = 0; i < 1000000; ++i)
    num_win += play_craps();
  printf("Possibility of win = %lf\n", (double)num_win / 1000000);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    119a <main+0x5a>
mov    $0x0,%al
call   1060 <play_craps@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116b <main+0x2b>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe59(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0xf4240,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <play_craps@plt>
add    %eax,%ebp
add    $0xffffffff,%ebx
jne    1160 <main+0x20>
cvtsi2sd %ebp,%xmm0
divsd  0xe86(%rip),%xmm0
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Possibility of win = %lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 @time(i32 0)
%5 = call i32 @srand(i32 %4)
store i32 0, i32* %2
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1000000
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = call i64 (...) @play_craps()
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = add nsw i64 %12, %10
%14 = trunc i64 %13 to i32
store i32 %14, i32* %3
br label %15
15: ; preds = %9
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %6
18: ; preds = %6
%19 = load i32, i32* %3
%20 = sitofp i32 %19 to double
%21 = fdiv double %20, 1.000000e+06
%22 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %21)
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}

LLVM IR (-O2):
@.str = [26 x i8] c"Possibility of win = %lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @time(i32 0)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %8, %3 ]
%5 = phi i32 [ 0, %0 ], [ %9, %3 ]
%6 = tail call i64 (...) @play_craps()
%7 = trunc i64 %6 to i32
%8 = add i32 %4, %7
%9 = add nuw nsw i32 %5, 1
%10 = icmp eq i32 %9, 1000000
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = sitofp i32 %8 to double
%13 = fdiv double %12, 1.000000e+06
%14 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %13)
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}