#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, ...);
int pi_check(unsigned long hits, unsigned long tries) {
  const double PI = 3.14159265358979323846;
  double ourpi, mean, var, delta, chisq;
  printf("%lu out of %lu darts thrown at a square board hit the inscribed "
         "circle\n",
         hits, tries);
  ourpi = 4. * hits / tries;
  printf("pi is approximately %.8g (diff = %.2g %%)\n", ourpi,
         (ourpi - PI) * 100. / PI);
  mean = tries * (PI / 4.);
  var = tries * (PI / 4.) * (1. - (PI / 4.));
  delta = hits - mean;
  chisq = delta * delta / var;
  if (chisq < 1.)
    printf("OK, # of hits less than one 'sigma' away from "
           "expectation\n(chisquared = %.2g)\n",
           chisq);
  else if (chisq < 4.)
    printf("OK, # of hits is between one and two 'sigma' away from "
           "expectation\n(chisquared = %.2g)\n",
           chisq);
  else if (chisq < 9.)
    printf("Maybe OK, # of hits is between two and three 'sigma' away from "
           "expectation\n(chisquared = %.2g)\n",
           chisq);
  else {
    printf("May not be OK, # of hits is more than three 'sigma'.  Worth "
           "looking into.\n(chisquared = %.2g)\n",
           chisq);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<pi_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movabs $0x400921fb54442d18,%rax
21 09 40
mov    %rax,-0x20(%rbp)
movq   -0x10(%rbp),%xmm0
movaps 0xf06(%rip),%xmm1
movaps %xmm1,-0x70(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xf06(%rip),%xmm1
movaps %xmm1,-0x60(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rsi
lea    0xef8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movaps -0x70(%rbp),%xmm3
movaps -0x60(%rbp),%xmm2
movq   -0x10(%rbp),%xmm0
punpckldq %xmm3,%xmm0
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe71(%rip),%xmm1
mulsd  %xmm1,%xmm0
movq   -0x18(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe47(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
movsd  0xe40(%rip),%xmm3
mulsd  %xmm3,%xmm1
divsd  %xmm2,%xmm1
lea    0xec1(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movaps -0x70(%rbp),%xmm2
movaps -0x60(%rbp),%xmm1
movq   -0x18(%rbp),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm3
unpckhpd %xmm0,%xmm0
addsd  %xmm3,%xmm0
movsd  0xe0a(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  %xmm0,-0x30(%rbp)
movq   -0x18(%rbp),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm4
unpckhpd %xmm0,%xmm0
addsd  %xmm4,%xmm0
mulsd  %xmm3,%xmm0
movsd  0xde5(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  %xmm0,-0x38(%rbp)
movq   -0x10(%rbp),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd76(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    12ad <pi_check+0x19d>
movsd  -0x48(%rbp),%xmm0
lea    0xe32(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    132c <pi_check+0x21c>
movsd  0xd53(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    12d8 <pi_check+0x1c8>
movsd  -0x48(%rbp),%xmm0
lea    0xe56(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1327 <pi_check+0x217>
movsd  0xd50(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1303 <pi_check+0x1f3>
movsd  -0x48(%rbp),%xmm0
lea    0xe83(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1322 <pi_check+0x212>
movsd  -0x48(%rbp),%xmm0
lea    0xecb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1333 <pi_check+0x223>
jmp    1327 <pi_check+0x217>
jmp    132c <pi_check+0x21c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pi_check>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
movq   %rdi,%xmm1
punpckldq 0xedb(%rip),%xmm1
subpd  0xee3(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
lea    0xf1b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xecc(%rip),%xmm0
mulsd  (%rsp),%xmm0
movq   %rbx,%xmm1
punpckldq 0xe9a(%rip),%xmm1
subpd  0xea2(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
divsd  %xmm2,%xmm0
movsd  0xe9c(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe98(%rip),%xmm1
divsd  0xe98(%rip),%xmm1
lea    0xf01(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movapd (%rsp),%xmm0
movapd 0x10(%rsp),%xmm2
mulsd  0xe7f(%rip),%xmm2
movsd  0xe7f(%rip),%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm0
divsd  %xmm1,%xmm0
xor    %ebx,%ebx
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11f2 <pi_check+0xe2>
lea    0xee3(%rip),%rdi
jmp    122c <pi_check+0x11c>
movsd  0xe26(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1209 <pi_check+0xf9>
lea    0xf1b(%rip),%rdi
jmp    122c <pi_check+0x11c>
movsd  0xe47(%rip),%xmm1
xor    %ebx,%ebx
ucomisd %xmm0,%xmm1
setbe  %bl
lea    0xf59(%rip),%rax
lea    0xfb2(%rip),%rdi
cmova  %rax,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [72 x i8] c"%lu out of %lu darts thrown at a square board hit the inscribed circle\0A\00"
@.str.1 = [43 x i8] c"pi is approximately %.8g (diff = %.2g %%)\0A\00"
@.str.2 = [79 x i8] c"OK, # of hits less than one 'sigma' away from expectation\0A(chisquared = %.2g)\0A\00"
@.str.3 = [88 x i8] c"OK, # of hits is between one and two 'sigma' away from expectation\0A(chisquared = %.2g)\0A\00"
@.str.4 = [96 x i8] c"Maybe OK, # of hits is between two and three 'sigma' away from expectation\0A(chisquared = %.2g)\0A\00"
@.str.5 = [95 x i8] c"May not be OK, # of hits is more than three 'sigma'. Worth looking into.\0A(chisquared = %.2g)\0A\00"
define i32 @pi_check(i64 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i64 %0, i64* %4
store i64 %1, i64* %5
store double 0x400921FB54442D18, double* %6
%12 = load i64, i64* %4
%13 = uitofp i64 %12 to double
%14 = load i64, i64* %5
%15 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), double %13, i64 %14)
%16 = load i64, i64* %4
%17 = uitofp i64 %16 to double
%18 = fmul double 4.000000e+00, %17
%19 = load i64, i64* %5
%20 = uitofp i64 %19 to double
%21 = fdiv double %18, %20
store double %21, double* %7
%22 = load double, double* %7
%23 = load double, double* %7
%24 = fsub double %23, 0x400921FB54442D18
%25 = fmul double %24, 1.000000e+02
%26 = fdiv double %25, 0x400921FB54442D18
%27 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), double %22, double %26)
%28 = load i64, i64* %5
%29 = uitofp i64 %28 to double
%30 = fmul double %29, 0x3FE921FB54442D18
store double %30, double* %8
%31 = load i64, i64* %5
%32 = uitofp i64 %31 to double
%33 = fmul double %32, 0x3FE921FB54442D18
%34 = fmul double %33, 0x3FCB7812AEEF4BA0
store double %34, double* %9
%35 = load i64, i64* %4
%36 = uitofp i64 %35 to double
%37 = load double, double* %8
%38 = fsub double %36, %37
store double %38, double* %10
%39 = load double, double* %10
%40 = load double, double* %10
%41 = fmul double %39, %40
%42 = load double, double* %9
%43 = fdiv double %41, %42
store double %43, double* %11
%44 = load double, double* %11
%45 = fcmp olt double %44, 1.000000e+00
br i1 %45, label %46, label %49
46: ; preds = %2
%47 = load double, double* %11
%48 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0), double %47)
br label %66
49: ; preds = %2
%50 = load double, double* %11
%51 = fcmp olt double %50, 4.000000e+00
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load double, double* %11
%54 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.3, i64 0, i64 0), double %53)
br label %65
55: ; preds = %49
%56 = load double, double* %11
%57 = fcmp olt double %56, 9.000000e+00
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load double, double* %11
%60 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.4, i64 0, i64 0), double %59)
br label %64
61: ; preds = %55
%62 = load double, double* %11
%63 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.5, i64 0, i64 0), double %62)
store i32 1, i32* %3
br label %67
64: ; preds = %58
br label %65
65: ; preds = %64, %52
br label %66
66: ; preds = %65, %46
store i32 0, i32* %3
br label %67
67: ; preds = %66, %61
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [72 x i8] c"%lu out of %lu darts thrown at a square board hit the inscribed circle\0A\00"
@.str.1 = [43 x i8] c"pi is approximately %.8g (diff = %.2g %%)\0A\00"
@.str.2 = [79 x i8] c"OK, # of hits less than one 'sigma' away from expectation\0A(chisquared = %.2g)\0A\00"
@.str.3 = [88 x i8] c"OK, # of hits is between one and two 'sigma' away from expectation\0A(chisquared = %.2g)\0A\00"
@.str.4 = [96 x i8] c"Maybe OK, # of hits is between two and three 'sigma' away from expectation\0A(chisquared = %.2g)\0A\00"
@.str.5 = [95 x i8] c"May not be OK, # of hits is more than three 'sigma'. Worth looking into.\0A(chisquared = %.2g)\0A\00"
define i32 @pi_check(i64 %0, i64 %1) {
%3 = uitofp i64 %0 to double
%4 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), double %3, i64 %1)
%5 = fmul double %3, 4.000000e+00
%6 = uitofp i64 %1 to double
%7 = fdiv double %5, %6
%8 = fadd double %7, 0xC00921FB54442D18
%9 = fmul double %8, 1.000000e+02
%10 = fdiv double %9, 0x400921FB54442D18
%11 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), double %7, double %10)
%12 = fmul double %6, 0x3FE921FB54442D18
%13 = fmul double %12, 0x3FCB7812AEEF4BA0
%14 = fsub double %3, %12
%15 = fmul double %14, %14
%16 = fdiv double %15, %13
%17 = fcmp olt double %16, 1.000000e+00
br i1 %17, label %25, label %18
18: ; preds = %2
%19 = fcmp olt double %16, 4.000000e+00
br i1 %19, label %25, label %20
20: ; preds = %18
%21 = fcmp olt double %16, 9.000000e+00
%22 = select i1 %21, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.5, i64 0, i64 0)
%23 = xor i1 %21, true
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %20, %18, %2
%26 = phi i8* [ getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([88 x i8], [88 x i8]* @.str.3, i64 0, i64 0), %18 ], [ %22, %20 ]
%27 = phi i32 [ 0, %2 ], [ 0, %18 ], [ %24, %20 ]
%28 = tail call i32 (i8*, double, ...) @printf(i8* %26, double %16)
ret i32 %27
}