#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 const);
double gauss_large(double const);
double gauss_medium(double const);
double gauss_small(double const);
double cdf_ugaussian_Q(const double x) {
  double result;
  double absx = fabs(x);
  if (absx < 1e-12) {
    result = 0.5;
    return result;
  } else if (absx < 0.66291) {
    result = gauss_small(x);
    if (x < 0.0) {
      result = fabs(result) + 0.5;
    } else {
      result = 0.5 - result;
    }
    return result;
  } else if (absx < (4.0 * 1.41421356237309504880)) {
    result = gauss_medium(x);
    if (x < 0.0) {
      result = 1.0 - result;
    }
    return result;
  } else if (x > -((-37))) {
    result = 0.0;
    return result;
  } else if (x < -((8.572))) {
    result = 1.0;
    return result;
  } else {
    result = gauss_large(x);
    if (x < 0.0) {
      result = 1.0 - result;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<cdf_ugaussian_Q>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xef7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xea6(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1181 <cdf_ugaussian_Q+0x51>
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <cdf_ugaussian_Q+0x1c8>
movsd  0xe7f(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f8 <cdf_ugaussian_Q+0xc8>
movsd  -0x10(%rbp),%xmm0
call   1050 <gauss_small@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d7 <cdf_ugaussian_Q+0xa7>
movsd  -0x18(%rbp),%xmm0
movaps 0xe83(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe67(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11e9 <cdf_ugaussian_Q+0xb9>
movsd  0xe51(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <cdf_ugaussian_Q+0x1c8>
movsd  0xe10(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1249 <cdf_ugaussian_Q+0x119>
movsd  -0x10(%rbp),%xmm0
call   1040 <gauss_medium@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    123a <cdf_ugaussian_Q+0x10a>
movsd  0xdf8(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <cdf_ugaussian_Q+0x1c8>
movsd  -0x10(%rbp),%xmm0
movsd  0xdc2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1277 <cdf_ugaussian_Q+0x147>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <cdf_ugaussian_Q+0x1c8>
movsd  0xda1(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12a6 <cdf_ugaussian_Q+0x176>
movsd  0xd96(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f8 <cdf_ugaussian_Q+0x1c8>
movsd  -0x10(%rbp),%xmm0
call   1030 <gauss_large@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12d5 <cdf_ugaussian_Q+0x1a5>
movsd  0xd5d(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12da <cdf_ugaussian_Q+0x1aa>
jmp    12df <cdf_ugaussian_Q+0x1af>
jmp    12e4 <cdf_ugaussian_Q+0x1b4>
jmp    12e9 <cdf_ugaussian_Q+0x1b9>
jmp    12ee <cdf_ugaussian_Q+0x1be>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdf_ugaussian_Q>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movapd 0xec0(%rip),%xmm0
andpd  %xmm2,%xmm0
movsd  0xedc(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    115f <cdf_ugaussian_Q+0x2f>
movsd  0xec6(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0xec9(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11b3 <cdf_ugaussian_Q+0x83>
movapd %xmm2,%xmm0
movapd %xmm2,(%rsp)
call   1050 <gauss_small@plt>
movapd 0xe7d(%rip),%xmm1
andpd  %xmm0,%xmm1
xorpd  0xe81(%rip),%xmm0
xorpd  %xmm2,%xmm2
movapd (%rsp),%xmm3
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
addsd  0xe6f(%rip),%xmm3
jmp    122e <cdf_ugaussian_Q+0xfe>
movsd  0xe7d(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11d1 <cdf_ugaussian_Q+0xa1>
movapd %xmm2,%xmm0
movapd %xmm2,(%rsp)
call   1040 <gauss_medium@plt>
jmp    1208 <cdf_ugaussian_Q+0xd8>
xorpd  %xmm0,%xmm0
ucomisd 0xe63(%rip),%xmm2
ja     1232 <cdf_ugaussian_Q+0x102>
movsd  0xe69(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    11fa <cdf_ugaussian_Q+0xca>
movsd  0xe53(%rip),%xmm0
add    $0x18,%rsp
ret
movapd %xmm2,%xmm0
movapd %xmm2,(%rsp)
call   1030 <gauss_large@plt>
movsd  0xe38(%rip),%xmm1
subsd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd (%rsp),%xmm3
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
movapd %xmm3,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @cdf_ugaussian_Q(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
%6 = load double, double* %3
%7 = call double @llvm.fabs.f64(double %6)
store double %7, double* %5
%8 = load double, double* %5
%9 = fcmp olt double %8, 0x3D719799812DEA11
br i1 %9, label %10, label %12
10: ; preds = %1
store double 5.000000e-01, double* %4
%11 = load double, double* %4
store double %11, double* %2
br label %67
12: ; preds = %1
%13 = load double, double* %5
%14 = fcmp olt double %13, 6.629100e-01
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load double, double* %3
%17 = call double @gauss_small(double %16)
store double %17, double* %4
%18 = load double, double* %3
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load double, double* %4
%22 = call double @llvm.fabs.f64(double %21)
%23 = fadd double %22, 5.000000e-01
store double %23, double* %4
br label %27
24: ; preds = %15
%25 = load double, double* %4
%26 = fsub double 5.000000e-01, %25
store double %26, double* %4
br label %27
27: ; preds = %24, %20
%28 = load double, double* %4
store double %28, double* %2
br label %67
29: ; preds = %12
%30 = load double, double* %5
%31 = fcmp olt double %30, 0x4016A09E667F3BCD
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load double, double* %3
%34 = call double @gauss_medium(double %33)
store double %34, double* %4
%35 = load double, double* %3
%36 = fcmp olt double %35, 0.000000e+00
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load double, double* %4
%39 = fsub double 1.000000e+00, %38
store double %39, double* %4
br label %40
40: ; preds = %37, %32
%41 = load double, double* %4
store double %41, double* %2
br label %67
42: ; preds = %29
%43 = load double, double* %3
%44 = fcmp ogt double %43, 3.700000e+01
br i1 %44, label %45, label %47
45: ; preds = %42
store double 0.000000e+00, double* %4
%46 = load double, double* %4
store double %46, double* %2
br label %67
47: ; preds = %42
%48 = load double, double* %3
%49 = fcmp olt double %48, 0xC02124DD2F1A9FBE
br i1 %49, label %50, label %52
50: ; preds = %47
store double 1.000000e+00, double* %4
%51 = load double, double* %4
store double %51, double* %2
br label %67
52: ; preds = %47
%53 = load double, double* %3
%54 = call double @gauss_large(double %53)
store double %54, double* %4
%55 = load double, double* %3
%56 = fcmp olt double %55, 0.000000e+00
br i1 %56, label %57, label %60
57: ; preds = %52
%58 = load double, double* %4
%59 = fsub double 1.000000e+00, %58
store double %59, double* %4
br label %60
60: ; preds = %57, %52
br label %61
61: ; preds = %60
br label %62
62: ; preds = %61
br label %63
63: ; preds = %62
br label %64
64: ; preds = %63
br label %65
65: ; preds = %64
%66 = load double, double* %4
store double %66, double* %2
br label %67
67: ; preds = %65, %50, %45, %40, %27, %10
%68 = load double, double* %2
ret double %68
}

LLVM IR (-O2):
define double @cdf_ugaussian_Q(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
%3 = fcmp olt double %2, 0x3D719799812DEA11
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = fcmp olt double %2, 6.629100e-01
br i1 %5, label %6, label %13
6: ; preds = %4
%7 = tail call double @gauss_small(double %0)
%8 = fcmp olt double %0, 0.000000e+00
%9 = tail call double @llvm.fabs.f64(double %7)
%10 = fneg double %7
%11 = select i1 %8, double %9, double %10
%12 = fadd double %11, 5.000000e-01
br label %29
13: ; preds = %4
%14 = fcmp olt double %2, 0x4016A09E667F3BCD
br i1 %14, label %15, label %20
15: ; preds = %13
%16 = tail call double @gauss_medium(double %0)
%17 = fcmp olt double %0, 0.000000e+00
%18 = fsub double 1.000000e+00, %16
%19 = select i1 %17, double %18, double %16
br label %29
20: ; preds = %13
%21 = fcmp ogt double %0, 3.700000e+01
br i1 %21, label %29, label %22
22: ; preds = %20
%23 = fcmp olt double %0, 0xC02124DD2F1A9FBE
br i1 %23, label %29, label %24
24: ; preds = %22
%25 = tail call double @gauss_large(double %0)
%26 = fcmp olt double %0, 0.000000e+00
%27 = fsub double 1.000000e+00, %25
%28 = select i1 %26, double %27, double %25
br label %29
29: ; preds = %22, %20, %1, %24, %15, %6
%30 = phi double [ %12, %6 ], [ %19, %15 ], [ %28, %24 ], [ 5.000000e-01, %1 ], [ 0.000000e+00, %20 ], [ 1.000000e+00, %22 ]
ret double %30
}