#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 acos(double);
double erfc(double);
double exp(double);
double sqrt(double);
double ntail(double zval) {
  double pi, t;
  double p, q, d;
  if (zval == 0.0)
    return 0.5;
  if (zval < 0.0)
    return (1.0 - ntail(-zval));
  if (zval < 20) {
    t = zval / sqrt(2.0);
    q = erfc(t) / 2.0;
    return q;
  }
  pi = 2.0 * acos(0.0);
  t = exp(-0.5 * zval * zval);
  t /= (sqrt(2.0 * pi) * zval);
  return t;
}


x86 assembly (clang, -O0):
<ntail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1187 <ntail+0x37>
jp     1187 <ntail+0x37>
movsd  0xea3(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129e <ntail+0x14e>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11cf <ntail+0x7f>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <ntail@plt>
movaps %xmm0,%xmm1
movsd  0xe57(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129e <ntail+0x14e>
movsd  0xe29(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1234 <ntail+0xe4>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe14(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1070 <erfc@plt>
movsd  0xdec(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129e <ntail+0x14e>
xorps  %xmm0,%xmm0
call   1040 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xdc1(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdb8(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xd94(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ntail>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1151 <ntail+0x21>
jp     1151 <ntail+0x21>
movsd  0xeb4(%rip),%xmm0
add    $0x18,%rsp
ret
ucomisd %xmm1,%xmm0
jbe    117d <ntail+0x4d>
xorpd  0xed1(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <ntail@plt>
movapd %xmm0,%xmm1
movsd  0xeb4(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xe83(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a9 <ntail+0x79>
divsd  0xe8d(%rip),%xmm1
movapd %xmm1,%xmm0
call   1050 <erfc@plt>
mulsd  0xe5c(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0xe5f(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm1,(%rsp)
call   1040 <exp@plt>
movapd (%rsp),%xmm1
mulsd  0xe48(%rip),%xmm1
divsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @ntail(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
%9 = load double, double* %3
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %1
store double 5.000000e-01, double* %2
br label %47
12: ; preds = %1
%13 = load double, double* %3
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load double, double* %3
%17 = fneg double %16
%18 = call double @ntail(double %17)
%19 = fsub double 1.000000e+00, %18
store double %19, double* %2
br label %47
20: ; preds = %12
%21 = load double, double* %3
%22 = fcmp olt double %21, 2.000000e+01
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load double, double* %3
%25 = call double @sqrt(double 2.000000e+00)
%26 = fdiv double %24, %25
store double %26, double* %5
%27 = load double, double* %5
%28 = call double @erfc(double %27)
%29 = fdiv double %28, 2.000000e+00
store double %29, double* %7
%30 = load double, double* %7
store double %30, double* %2
br label %47
31: ; preds = %20
%32 = call double @acos(double 0.000000e+00)
%33 = fmul double 2.000000e+00, %32
store double %33, double* %4
%34 = load double, double* %3
%35 = fmul double -5.000000e-01, %34
%36 = load double, double* %3
%37 = fmul double %35, %36
%38 = call double @exp(double %37)
store double %38, double* %5
%39 = load double, double* %4
%40 = fmul double 2.000000e+00, %39
%41 = call double @sqrt(double %40)
%42 = load double, double* %3
%43 = fmul double %41, %42
%44 = load double, double* %5
%45 = fdiv double %44, %43
store double %45, double* %5
%46 = load double, double* %5
store double %46, double* %2
br label %47
47: ; preds = %31, %23, %15, %11
%48 = load double, double* %2
ret double %48
}

LLVM IR (-O2):
define double @ntail(double %0) {
%2 = fcmp oeq double %0, 0.000000e+00
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = fcmp olt double %0, 0.000000e+00
br i1 %4, label %7, label %11
5: ; preds = %13, %17, %1, %7
%6 = phi double [ %10, %7 ], [ %16, %13 ], [ %22, %17 ], [ 5.000000e-01, %1 ]
ret double %6
7: ; preds = %3
%8 = fneg double %0
%9 = tail call double @ntail(double %8)
%10 = fsub double 1.000000e+00, %9
br label %5
11: ; preds = %3
%12 = fcmp olt double %0, 2.000000e+01
br i1 %12, label %13, label %17
13: ; preds = %11
%14 = fdiv double %0, 0x3FF6A09E667F3BCD
%15 = tail call double @erfc(double %14)
%16 = fmul double %15, 5.000000e-01
br label %5
17: ; preds = %11
%18 = fmul double %0, -5.000000e-01
%19 = fmul double %18, %0
%20 = tail call double @exp(double %19)
%21 = fmul double %0, 0x40040D931FF62705
%22 = fdiv double %20, %21
br label %5
}