#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__ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double culcPai(const int multiplier) {
  double xVal, yVal, distance, totalPoints = multiplier * 1000, pointsIn = 0;
  int index;
  srand(time(NULL));
  for (index = 0; index < totalPoints; index++) {
    xVal = (double)rand() / RAND_MAX;
    yVal = (double)rand() / RAND_MAX;
    distance = (xVal * xVal) + (yVal * yVal);
    distance = distance * distance;
    if (distance <= 1)
      pointsIn++;
  }
  return (4 * (pointsIn / totalPoints));
}


x86 assembly (clang, -O0):
<culcPai>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
imul   $0x3e8,-0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x34(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    121e <culcPai+0xee>
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e57(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e3b(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe1a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     120b <culcPai+0xdb>
movsd  0xe07(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1210 <culcPai+0xe0>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116a <culcPai+0x3a>
movsd  -0x30(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
movsd  0xdd0(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<culcPai>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebx
imul   $0x3e8,%edi,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %ebx,%ebx
jle    1209 <culcPai+0xd9>
xorpd  %xmm1,%xmm1
mov    $0x1,%ebx
mov    0x2e79(%rip),%r14
nop
movapd %xmm1,0x20(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
movapd %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
movapd 0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm0,%xmm2
mulsd  %xmm2,%xmm2
movsd  0xe3e(%rip),%xmm1
cmpnlesd %xmm1,%xmm2
movapd %xmm2,%xmm3
movapd %xmm2,%xmm4
movapd 0x20(%rsp),%xmm0
andpd  %xmm0,%xmm3
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
andnpd %xmm0,%xmm4
add    $0x1,%ebx
movsd  0x8(%rsp),%xmm2
ucomisd %xmm1,%xmm2
movapd %xmm4,%xmm0
orpd   %xmm3,%xmm0
movapd %xmm0,%xmm1
ja     1170 <culcPai+0x40>
jmp    120d <culcPai+0xdd>
xorpd  %xmm0,%xmm0
divsd  0x8(%rsp),%xmm0
mulsd  0xded(%rip),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define double @culcPai(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 %0, i32* %2
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 1000
%11 = sitofp i32 %10 to double
store double %11, double* %6
store double 0.000000e+00, double* %7
%12 = call i32 @time(i32* null)
%13 = call i32 @srand(i32 %12)
store i32 0, i32* %8
br label %14
14: ; preds = %43, %1
%15 = load i32, i32* %8
%16 = sitofp i32 %15 to double
%17 = load double, double* %6
%18 = fcmp olt double %16, %17
br i1 %18, label %19, label %46
19: ; preds = %14
%20 = call i64 (...) @rand()
%21 = sitofp i64 %20 to double
%22 = load double, double* @RAND_MAX
%23 = fdiv double %21, %22
store double %23, double* %3
%24 = call i64 (...) @rand()
%25 = sitofp i64 %24 to double
%26 = load double, double* @RAND_MAX
%27 = fdiv double %25, %26
store double %27, double* %4
%28 = load double, double* %3
%29 = load double, double* %3
%30 = load double, double* %4
%31 = load double, double* %4
%32 = fmul double %30, %31
%33 = call double @llvm.fmuladd.f64(double %28, double %29, double %32)
store double %33, double* %5
%34 = load double, double* %5
%35 = load double, double* %5
%36 = fmul double %34, %35
store double %36, double* %5
%37 = load double, double* %5
%38 = fcmp ole double %37, 1.000000e+00
br i1 %38, label %39, label %42
39: ; preds = %19
%40 = load double, double* %7
%41 = fadd double %40, 1.000000e+00
store double %41, double* %7
br label %42
42: ; preds = %39, %19
br label %43
43: ; preds = %42
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
br label %14
46: ; preds = %14
%47 = load double, double* %7
%48 = load double, double* %6
%49 = fdiv double %47, %48
%50 = fmul double 4.000000e+00, %49
ret double %50
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define double @culcPai(i32 %0) {
%2 = mul nsw i32 %0, 1000
%3 = sitofp i32 %2 to double
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %27
7: ; preds = %1, %7
%8 = phi i32 [ %24, %7 ], [ 0, %1 ]
%9 = phi double [ %23, %7 ], [ 0.000000e+00, %1 ]
%10 = tail call i64 (...) @rand()
%11 = sitofp i64 %10 to double
%12 = load double, double* @RAND_MAX
%13 = fdiv double %11, %12
%14 = tail call i64 (...) @rand()
%15 = sitofp i64 %14 to double
%16 = load double, double* @RAND_MAX
%17 = fdiv double %15, %16
%18 = fmul double %17, %17
%19 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %18)
%20 = fmul double %19, %19
%21 = fcmp ugt double %20, 1.000000e+00
%22 = fadd double %9, 1.000000e+00
%23 = select i1 %21, double %9, double %22
%24 = add nuw nsw i32 %8, 1
%25 = sitofp i32 %24 to double
%26 = fcmp olt double %25, %3
br i1 %26, label %7, label %27
27: ; preds = %7, %1
%28 = phi double [ 0.000000e+00, %1 ], [ %23, %7 ]
%29 = fdiv double %28, %3
%30 = fmul double %29, 4.000000e+00
ret double %30
}