#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 *, double);
scalar_t__ simulate();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, const char *const argv[]) {
  int count = 0;
  srand(time(NULL));
  for (int sim = 0; sim < 1000000; ++sim) {
    if (simulate()) {
      ++count;
    }
  }
  double death_prob = ((double)count / (double)1000000);
  printf("Death: %.4f\n", 100.0 * death_prob);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0xf4240,-0x18(%rbp)
jge    11ae <main+0x6e>
mov    $0x0,%al
call   1030 <simulate@plt>
cmp    $0x0,%rax
je     119b <main+0x5b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a0 <main+0x60>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <main+0x34>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe34(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [13 x i8] c"Death: %.4f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%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, 1000000
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = call i64 (...) @simulate()
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %20
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %11
24: ; preds = %11
%25 = load i32, i32* %6
%26 = sitofp i32 %25 to double
%27 = fdiv double %26, 1.000000e+06
store double %27, double* %8
%28 = load double, double* %8
%29 = fmul double 1.000000e+02, %28
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Death: %.4f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
br label %10
5: ; preds = %10
%6 = sitofp i32 %16 to double
%7 = fdiv double %6, 1.000000e+06
%8 = fmul double %7, 1.000000e+02
%9 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %8)
ret i32 0
10: ; preds = %2, %10
%11 = phi i32 [ 0, %2 ], [ %16, %10 ]
%12 = phi i32 [ 0, %2 ], [ %17, %10 ]
%13 = tail call i64 (...) @simulate()
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %11, %15
%17 = add nuw nsw i32 %12, 1
%18 = icmp eq i32 %17, 1000000
br i1 %18, label %5, label %10
}