#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 erf(double);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
double sqrt(double);
double normalcdf(double x, double mu, double sigma) {
  double oup, t;
  if (sigma < 0.) {
    printf("Standard Deviation (Sigma) must be non-negative");
    exit(1);
  }
  t = (x - mu) / (sqrt(2.0) * sigma);
  oup = 0.5 * (1. + erf(t));
  return oup;
}


x86 assembly (clang, -O0):
<normalcdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    117b <normalcdf+0x3b>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe7e(%rip),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <erf@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe45(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe31(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalcdf>:
push   %rax
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm3
ja     1169 <normalcdf+0x39>
subsd  %xmm1,%xmm0
mulsd  0xeb9(%rip),%xmm2
divsd  %xmm2,%xmm0
call   1040 <erf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xea9(%rip),%xmm0
mulsd  0xea9(%rip),%xmm0
pop    %rax
ret
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"Standard Deviation (Sigma) must be non-negative\00"
define double @normalcdf(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %6
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %3
%15 = load double, double* %4
%16 = load double, double* %5
%17 = fsub double %15, %16
%18 = call double @sqrt(double 2.000000e+00)
%19 = load double, double* %6
%20 = fmul double %18, %19
%21 = fdiv double %17, %20
store double %21, double* %8
%22 = load double, double* %8
%23 = call i32 @erf(double %22)
%24 = sitofp i32 %23 to double
%25 = fadd double 1.000000e+00, %24
%26 = fmul double 5.000000e-01, %25
store double %26, double* %7
%27 = load double, double* %7
ret double %27
}

LLVM IR (-O2):
@.str = [48 x i8] c"Standard Deviation (Sigma) must be non-negative\00"
define double @normalcdf(double %0, double %1, double %2) {
%4 = fcmp olt double %2, 0.000000e+00
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %3
%9 = fsub double %0, %1
%10 = fmul double %2, 0x3FF6A09E667F3BCD
%11 = fdiv double %9, %10
%12 = tail call i32 @erf(double %11)
%13 = sitofp i32 %12 to double
%14 = fadd double %13, 1.000000e+00
%15 = fmul double %14, 5.000000e-01
ret double %15
}