#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 gammacdf(double, double);
double normalcdf(double x, double m, double s) {
  double z = (x - m) / s;
  if (z >= 0)
    return 0.5 + 0.5 * gammacdf(z * z / 2, 0.5);
  else
    return 0.5 - 0.5 * gammacdf(z * z / 2, 0.5);
}


x86 assembly (clang, -O0):
<normalcdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     118a <normalcdf+0x7a>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xeb1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe9d(%rip),%xmm1
call   1030 <gammacdf@plt>
movsd  0xe90(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ca <normalcdf+0xba>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe60(%rip),%xmm1
call   1030 <gammacdf@plt>
movsd  0xe4b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe47(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalcdf>:
push   %rbx
subsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
ucomisd %xmm1,%xmm0
setb   %bl
mulsd  %xmm0,%xmm0
movsd  0xece(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <gammacdf@plt>
lea    0xec6(%rip),%rax
mulsd  (%rax,%rbx,8),%xmm0
addsd  0xeb1(%rip),%xmm0
pop    %rbx
ret

LLVM IR (-O0):
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* %5
store double %1, double* %6
store double %2, double* %7
%9 = load double, double* %5
%10 = load double, double* %6
%11 = fsub double %9, %10
%12 = load double, double* %7
%13 = fdiv double %11, %12
store double %13, double* %8
%14 = load double, double* %8
%15 = fcmp oge double %14, 0.000000e+00
br i1 %15, label %16, label %23
16: ; preds = %3
%17 = load double, double* %8
%18 = load double, double* %8
%19 = fmul double %17, %18
%20 = fdiv double %19, 2.000000e+00
%21 = call double @gammacdf(double %20, double 5.000000e-01)
%22 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %21, double 5.000000e-01)
store double %22, double* %4
br label %30
23: ; preds = %3
%24 = load double, double* %8
%25 = load double, double* %8
%26 = fmul double %24, %25
%27 = fdiv double %26, 2.000000e+00
%28 = call double @gammacdf(double %27, double 5.000000e-01)
%29 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %28, double 5.000000e-01)
store double %29, double* %4
br label %30
30: ; preds = %23, %16
%31 = load double, double* %4
ret double %31
}

LLVM IR (-O2):
define double @normalcdf(double %0, double %1, double %2) {
%4 = fsub double %0, %1
%5 = fdiv double %4, %2
%6 = fcmp ult double %5, 0.000000e+00
%7 = fmul double %5, %5
%8 = fmul double %7, 5.000000e-01
%9 = tail call double @gammacdf(double %8, double 5.000000e-01)
%10 = tail call double @llvm.fmuladd.f64(double %9, double 5.000000e-01, double 5.000000e-01)
%11 = tail call double @llvm.fmuladd.f64(double %9, double -5.000000e-01, double 5.000000e-01)
%12 = select i1 %6, double %11, double %10
ret double %12
}