#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 DBL_EPSILON;
int /*<<< orphan*/ assert(int);
double sqrt(double);
double unitcdf(double);
double normcdf(double x, double mean, double var) {
  assert(var >= 0);
  if (var - 1 < DBL_EPSILON)
    return unitcdf(x - mean);
  return unitcdf((x - mean) / sqrt(var));
}


x86 assembly (clang, -O0):
<normcdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  -0x20(%rbp),%xmm1
movsd  0xe93(%rip),%xmm0
subsd  %xmm0,%xmm1
mov    0x2e70(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    119f <normcdf+0x6f>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1040 <unitcdf@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11ce <normcdf+0x9e>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1040 <unitcdf@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normcdf>:
sub    $0x18,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
xorpd  %xmm0,%xmm0
xor    %edi,%edi
ucomisd %xmm0,%xmm2
setae  %dil
call   1030 <assert@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xe9a(%rip),%xmm2
addsd  %xmm0,%xmm2
mov    0x2e77(%rip),%rax
movsd  (%rax),%xmm1
ucomisd %xmm2,%xmm1
movsd  (%rsp),%xmm1
subsd  0x10(%rsp),%xmm1
ja     11a9 <normcdf+0x79>
ucomisd 0xe7a(%rip),%xmm0
jb     1196 <normcdf+0x66>
sqrtsd %xmm0,%xmm0
jmp    11a5 <normcdf+0x75>
movsd  %xmm1,(%rsp)
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
jmp    1040 <unitcdf@plt>

LLVM IR (-O0):
@DBL_EPSILON = global double 0.000000e+00
define double @normcdf(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%8 = load double, double* %7
%9 = fcmp oge double %8, 0.000000e+00
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load double, double* %7
%13 = fsub double %12, 1.000000e+00
%14 = load double, double* @DBL_EPSILON
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %21
16: ; preds = %3
%17 = load double, double* %5
%18 = load double, double* %6
%19 = fsub double %17, %18
%20 = call double @unitcdf(double %19)
store double %20, double* %4
br label %29
21: ; preds = %3
%22 = load double, double* %5
%23 = load double, double* %6
%24 = fsub double %22, %23
%25 = load double, double* %7
%26 = call double @sqrt(double %25)
%27 = fdiv double %24, %26
%28 = call double @unitcdf(double %27)
store double %28, double* %4
br label %29
29: ; preds = %21, %16
%30 = load double, double* %4
ret double %30
}

LLVM IR (-O2):
@DBL_EPSILON = global double 0.000000e+00
define double @normcdf(double %0, double %1, double %2) {
%4 = fcmp oge double %2, 0.000000e+00
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = fadd double %2, -1.000000e+00
%8 = load double, double* @DBL_EPSILON
%9 = fcmp olt double %7, %8
%10 = fsub double %0, %1
br i1 %9, label %14, label %11
11: ; preds = %3
%12 = tail call double @sqrt(double %2)
%13 = fdiv double %10, %12
br label %14
14: ; preds = %3, %11
%15 = phi double [ %13, %11 ], [ %10, %3 ]
%16 = tail call double @unitcdf(double %15)
ret double %16
}