#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;
int /*<<< orphan*/ acos(double);
long atol(char *);
int /*<<< orphan*/ printf(char *, double, ...);
scalar_t__ tryHit(unsigned int *);
int main(int argc, char *argv[]) {
  long tries = 65536, hits = 0;
  if (argc > 1)
    tries = atol(argv[1]);
#pragma omp parallel default(none) shared(tries, hits)
  {
    unsigned int seed = 0;
    int i;
#pragma omp for reduction(+ : hits)
    for (i = 0; i < tries; i++)
      hits += tryHit(&seed);
  }
  printf("pi (exact)  = %lf\n", acos(-1.0));
  printf("pi (approx) = %lf (%ld)\n", (4.0 * hits) / tries, hits);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x10000,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1181 <main+0x41>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atol@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11bc <main+0x7c>
lea    -0x24(%rbp),%rdi
call   1050 <tryHit@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118f <main+0x4f>
movsd  0xe44(%rip),%xmm0
call   1040 <acos@plt>
cvtsi2sd %eax,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2sdq -0x20(%rbp),%xmm1
movsd  0xe17(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdq -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rsi
lea    0xe21(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    116b <main+0x2b>
mov    0x8(%rsi),%rdi
call   1060 <atol@plt>
mov    %rax,%r14
movl   $0x0,0x4(%rsp)
test   %rax,%rax
jg     1179 <main+0x39>
xor    %r12d,%r12d
jmp    11a1 <main+0x61>
movl   $0x0,0x4(%rsp)
mov    $0x10000,%r14d
xor    %r12d,%r12d
lea    0x4(%rsp),%r15
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1050 <tryHit@plt>
add    %rax,%r12
add    $0xffffffffffffffff,%rbx
jne    1190 <main+0x50>
movsd  0xe57(%rip),%xmm0
call   1040 <acos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe54(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r12,%xmm0
mulsd  0xe35(%rip),%xmm0
cvtsi2sd %r14,%xmm1
divsd  %xmm1,%xmm0
lea    0xe40(%rip),%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"pi (exact) = %lf\0A\00"
@.str.1 = [25 x i8] c"pi (approx) = %lf (%ld)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 65536, i64* %6
store i64 0, i64* %7
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @atol(i8* %15)
store i64 %16, i64* %6
br label %17
17: ; preds = %12, %2
store i32 0, i32* %8
store i32 0, i32* %9
br label %18
18: ; preds = %27, %17
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = load i64, i64* %6
%22 = icmp slt i64 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = call i64 @tryHit(i32* %8)
%25 = load i64, i64* %7
%26 = add nsw i64 %25, %24
store i64 %26, i64* %7
br label %27
27: ; preds = %23
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %18
30: ; preds = %18
%31 = call i32 @acos(double -1.000000e+00)
%32 = sitofp i32 %31 to double
%33 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %32)
%34 = load i64, i64* %7
%35 = sitofp i64 %34 to double
%36 = fmul double 4.000000e+00, %35
%37 = load i64, i64* %6
%38 = sitofp i64 %37 to double
%39 = fdiv double %36, %38
%40 = load i64, i64* %7
%41 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %39, i64 %40)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}

LLVM IR (-O2):
@.str = [19 x i8] c"pi (exact) = %lf\0A\00"
@.str.1 = [25 x i8] c"pi (approx) = %lf (%ld)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp sgt i32 %0, 1
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %13
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @atol(i8* %9)
%11 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%12 = icmp sgt i64 %10, 0
br i1 %12, label %13, label %22
13: ; preds = %5, %7
%14 = phi i64 [ 65536, %5 ], [ %10, %7 ]
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %20, %15 ]
%17 = phi i64 [ 0, %13 ], [ %19, %15 ]
%18 = call i64 @tryHit(i32* %3)
%19 = add nsw i64 %18, %17
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, %14
br i1 %21, label %22, label %15
22: ; preds = %15, %7
%23 = phi i64 [ %10, %7 ], [ %14, %15 ]
%24 = phi i64 [ 0, %7 ], [ %19, %15 ]
%25 = bitcast i32* %3 to i8*
%26 = call i32 @acos(double -1.000000e+00)
%27 = sitofp i32 %26 to double
%28 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %27)
%29 = sitofp i64 %24 to double
%30 = fmul double %29, 4.000000e+00
%31 = sitofp i64 %23 to double
%32 = fdiv double %30, %31
%33 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %32, i64 %24)
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}