#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 */
double RAND_MAX;
scalar_t__ pow(double, int);
int /*<<< orphan*/ printf(char *, double);
scalar_t__ rand();
int sqrt(scalar_t__);
main() {
  int times = 100000000;
  int in_count = 0;
  while (times-- > 0)
    if (sqrt(pow(((double)rand() / (RAND_MAX + 1.0)), 2) +
             pow(((double)rand() / (RAND_MAX + 1.0)), 2)) -
            1 <
        0)
      in_count++;
  printf("%f\n", 4.0 * in_count / 100000000);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5f5e100,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    11f5 <main+0xb5>
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
movsd  0xe8b(%rip),%xmm1
mov    0x2e5c(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
movsd  0xe5a(%rip),%xmm1
mov    0x2e2b(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    -0x18(%rbp),%rdi
add    %rax,%rdi
call   1050 <sqrt@plt>
sub    $0x1,%eax
cmp    $0x0,%eax
jge    11f0 <main+0xb0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <main+0x1d>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe06(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdf2(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x5f5e101,%ebp
mov    0x2e95(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%r14),%xmm1
movsd  0xe84(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%r14),%xmm1
addsd  0xe53(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1050 <sqrt@plt>
xor    %ecx,%ecx
test   %eax,%eax
setle  %cl
add    %ecx,%r15d
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1160 <main+0x20>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mulsd  0xe20(%rip),%xmm0
divsd  0xe20(%rip),%xmm0
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 100000000, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %28, %0
%5 = load i32, i32* %2
%6 = add nsw i32 %5, -1
store i32 %6, i32* %2
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %29
8: ; preds = %4
%9 = call i64 (...) @rand()
%10 = sitofp i64 %9 to double
%11 = load double, double* @RAND_MAX
%12 = fadd double %11, 1.000000e+00
%13 = fdiv double %10, %12
%14 = call i64 @pow(double %13, i32 2)
%15 = call i64 (...) @rand()
%16 = sitofp i64 %15 to double
%17 = load double, double* @RAND_MAX
%18 = fadd double %17, 1.000000e+00
%19 = fdiv double %16, %18
%20 = call i64 @pow(double %19, i32 2)
%21 = add nsw i64 %14, %20
%22 = call i32 @sqrt(i64 %21)
%23 = sub nsw i32 %22, 1
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %8
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %28
28: ; preds = %25, %8
br label %4
29: ; preds = %4
%30 = load i32, i32* %3
%31 = sitofp i32 %30 to double
%32 = fmul double 4.000000e+00, %31
%33 = fdiv double %32, 1.000000e+08
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %33)
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %21, %1 ]
%3 = phi i32 [ 100000000, %0 ], [ %4, %1 ]
%4 = add nsw i32 %3, -1
%5 = tail call i64 (...) @rand()
%6 = sitofp i64 %5 to double
%7 = load double, double* @RAND_MAX
%8 = fadd double %7, 1.000000e+00
%9 = fdiv double %6, %8
%10 = tail call i64 @pow(double %9, i32 2)
%11 = tail call i64 (...) @rand()
%12 = sitofp i64 %11 to double
%13 = load double, double* @RAND_MAX
%14 = fadd double %13, 1.000000e+00
%15 = fdiv double %12, %14
%16 = tail call i64 @pow(double %15, i32 2)
%17 = add nsw i64 %16, %10
%18 = tail call i32 @sqrt(i64 %17)
%19 = icmp slt i32 %18, 1
%20 = zext i1 %19 to i32
%21 = add nuw nsw i32 %2, %20
%22 = icmp ugt i32 %3, 1
br i1 %22, label %1, label %23
23: ; preds = %1
%24 = sitofp i32 %21 to double
%25 = fmul double %24, 4.000000e+00
%26 = fdiv double %25, 1.000000e+08
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %26)
ret i32 0
}