#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 fabs(double);
double sqrt(double);
double mcestimate_error(double N, double p1, double p2) {
  double pmean, n1;
  if (N <= 1)
    return p1;
  pmean = p1 / N;
  n1 = N - 1;
  return sqrt((N / n1) * fabs(p2 - pmean * pmean));
}


x86 assembly (clang, -O0):
<mcestimate_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  0xed1(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1149 <mcestimate_error+0x39>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bf <mcestimate_error+0xaf>
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm3
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movaps 0xe63(%rip),%xmm2
pand   %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mcestimate_error>:
movsd  0xee8(%rip),%xmm3
ucomisd %xmm0,%xmm3
jae    1157 <mcestimate_error+0x47>
divsd  %xmm0,%xmm1
movsd  0xede(%rip),%xmm3
addsd  %xmm0,%xmm3
divsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm2
andpd  0xece(%rip),%xmm2
mulsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     115c <mcestimate_error+0x4c>
xorps  %xmm1,%xmm1
sqrtsd %xmm2,%xmm1
movapd %xmm1,%xmm0
ret
movapd %xmm2,%xmm0
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @mcestimate_error(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%10 = load double, double* %5
%11 = fcmp ole double %10, 1.000000e+00
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = load double, double* %6
store double %13, double* %4
br label %31
14: ; preds = %3
%15 = load double, double* %6
%16 = load double, double* %5
%17 = fdiv double %15, %16
store double %17, double* %8
%18 = load double, double* %5
%19 = fsub double %18, 1.000000e+00
store double %19, double* %9
%20 = load double, double* %5
%21 = load double, double* %9
%22 = fdiv double %20, %21
%23 = load double, double* %7
%24 = load double, double* %8
%25 = load double, double* %8
%26 = fneg double %24
%27 = call double @llvm.fmuladd.f64(double %26, double %25, double %23)
%28 = call double @llvm.fabs.f64(double %27)
%29 = fmul double %22, %28
%30 = call double @sqrt(double %29)
store double %30, double* %4
br label %31
31: ; preds = %14, %12
%32 = load double, double* %4
ret double %32
}

LLVM IR (-O2):
define double @mcestimate_error(double %0, double %1, double %2) {
%4 = fcmp ugt double %0, 1.000000e+00
br i1 %4, label %5, label %14
5: ; preds = %3
%6 = fdiv double %1, %0
%7 = fadd double %0, -1.000000e+00
%8 = fdiv double %0, %7
%9 = fneg double %6
%10 = tail call double @llvm.fmuladd.f64(double %9, double %6, double %2)
%11 = tail call double @llvm.fabs.f64(double %10)
%12 = fmul double %8, %11
%13 = tail call double @sqrt(double %12)
br label %14
14: ; preds = %3, %5
%15 = phi double [ %13, %5 ], [ %1, %3 ]
ret double %15
}