#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 const exp(double);
double fabs(double);
double sqrt(double);
double standard_normal_CDF(double x) {
  const double a1 = 0.254829592;
  const double a2 = -0.284496736;
  const double a3 = 1.421413741;
  const double a4 = -1.453152027;
  const double a5 = 1.061405429;
  const double p = 0.3275911;
  int sign = 1;
  if (x < 0)
    sign = -1;
  x = fabs(x) / sqrt(2.0);
  double t = 1.0 / (1.0 + p * x);
  double y =
      1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-x * x);
  return 0.5 * (1.0 + sign * y);
}


x86 assembly (clang, -O0):
<standard_normal_CDF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xef3(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xede(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1197 <standard_normal_CDF+0x77>
movl   $0xffffffff,-0x3c(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xead(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe8c(%rip),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  0xe29(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe55(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe49(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xe03(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdff(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf2(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xde5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdd8(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd89(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xd6a(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xd56(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<standard_normal_CDF>:
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
ucomisd %xmm0,%xmm1
seta   %bl
andpd  0xed6(%rip),%xmm0
divsd  0xefe(%rip),%xmm0
movsd  0xefe(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xefa(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xeec(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xee8(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xee4(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xee0(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xedc(%rip),%xmm1
movsd  %xmm1,(%rsp)
movapd 0xe77(%rip),%xmm1
xorpd  %xmm0,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  (%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm2
movsd  0xe7f(%rip),%xmm1
movapd %xmm1,%xmm0
subsd  %xmm2,%xmm0
lea    0xe50(%rip),%rax
mulsd  (%rax,%rbx,8),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe8f(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @standard_normal_CDF(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store double %0, double* %2
store double 0x3FD04F20C6EC5A7E, double* %3
store double 0xBFD23531CC3C1469, double* %4
store double 0x3FF6BE1C55BAE157, double* %5
store double 0xBFF7401C57014C39, double* %6
store double 0x3FF0FB844255A12D, double* %7
store double 0x3FD4F740A93D7B8C, double* %8
store i32 1, i32* %9
%12 = load double, double* %2
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 -1, i32* %9
br label %15
15: ; preds = %14, %1
%16 = load double, double* %2
%17 = call double @llvm.fabs.f64(double %16)
%18 = call double @sqrt(double 2.000000e+00)
%19 = fdiv double %17, %18
store double %19, double* %2
%20 = load double, double* %2
%21 = call double @llvm.fmuladd.f64(double 0x3FD4F740A93D7B8C, double %20, double 1.000000e+00)
%22 = fdiv double 1.000000e+00, %21
store double %22, double* %10
%23 = load double, double* %10
%24 = call double @llvm.fmuladd.f64(double 0x3FF0FB844255A12D, double %23, double 0xBFF7401C57014C39)
%25 = load double, double* %10
%26 = call double @llvm.fmuladd.f64(double %24, double %25, double 0x3FF6BE1C55BAE157)
%27 = load double, double* %10
%28 = call double @llvm.fmuladd.f64(double %26, double %27, double 0xBFD23531CC3C1469)
%29 = load double, double* %10
%30 = call double @llvm.fmuladd.f64(double %28, double %29, double 0x3FD04F20C6EC5A7E)
%31 = load double, double* %10
%32 = fmul double %30, %31
%33 = load double, double* %2
%34 = fneg double %33
%35 = load double, double* %2
%36 = fmul double %34, %35
%37 = call double @exp(double %36)
%38 = fneg double %32
%39 = call double @llvm.fmuladd.f64(double %38, double %37, double 1.000000e+00)
store double %39, double* %11
%40 = load i32, i32* %9
%41 = sitofp i32 %40 to double
%42 = load double, double* %11
%43 = call double @llvm.fmuladd.f64(double %41, double %42, double 1.000000e+00)
%44 = fmul double 5.000000e-01, %43
ret double %44
}

LLVM IR (-O2):
define double @standard_normal_CDF(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = select i1 %2, double -1.000000e+00, double 1.000000e+00
%4 = tail call double @llvm.fabs.f64(double %0)
%5 = fdiv double %4, 0x3FF6A09E667F3BCD
%6 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FD4F740A93D7B8C, double 1.000000e+00)
%7 = fdiv double 1.000000e+00, %6
%8 = tail call double @llvm.fmuladd.f64(double %7, double 0x3FF0FB844255A12D, double 0xBFF7401C57014C39)
%9 = tail call double @llvm.fmuladd.f64(double %8, double %7, double 0x3FF6BE1C55BAE157)
%10 = tail call double @llvm.fmuladd.f64(double %9, double %7, double 0xBFD23531CC3C1469)
%11 = tail call double @llvm.fmuladd.f64(double %10, double %7, double 0x3FD04F20C6EC5A7E)
%12 = fneg double %5
%13 = fmul double %5, %12
%14 = tail call double @exp(double %13)
%15 = fneg double %11
%16 = fmul double %7, %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double %14, double 1.000000e+00)
%18 = tail call double @llvm.fmuladd.f64(double %3, double %17, double 1.000000e+00)
%19 = fmul double %18, 5.000000e-01
ret double %19
}