#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 */
int /*<<< orphan*/ finite(double);
scalar_t__ isnan(double);
double p_gamma(double, double, double);
double q_gamma(double, double, double);
double erfc(double x) {
  if (!finite(x)) {
    if (isnan(x))
      return x;
    return (x > 0 ? 0.0 : 2.0);
  }
  if (x >= 0)
    return q_gamma(0.5, x * x, 0.572364942924700087071713675675);
  else
    return 1 + p_gamma(0.5, x * x, 0.572364942924700087071713675675);
}


x86 assembly (clang, -O0):
<erfc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xee7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xeab(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11b3 <erfc+0x83>
movsd  -0x10(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
je     1182 <erfc+0x52>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1221 <erfc+0xf1>
movsd  -0x10(%rbp),%xmm1
xorps  %xmm3,%xmm3
movsd  0xe76(%rip),%xmm2
movaps %xmm3,%xmm0
cmpltsd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1221 <erfc+0xf1>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ee <erfc+0xbe>
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe41(%rip),%xmm0
movsd  0xe41(%rip),%xmm2
call   1040 <q_gamma@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1221 <erfc+0xf1>
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe18(%rip),%xmm0
movsd  0xe18(%rip),%xmm2
call   1030 <p_gamma@plt>
movaps %xmm0,%xmm1
movsd  0xdf8(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<erfc>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
movapd 0xec0(%rip),%xmm0
andpd  %xmm1,%xmm0
ucomisd 0xec4(%rip),%xmm0
je     117e <erfc+0x4e>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
mulsd  %xmm1,%xmm1
movsd  0xeb6(%rip),%xmm0
movsd  0xeb6(%rip),%xmm2
jae    119a <erfc+0x6a>
call   1030 <p_gamma@plt>
addsd  0xeaf(%rip),%xmm0
add    $0x18,%rsp
ret
movapd %xmm1,%xmm0
movapd %xmm1,(%rsp)
call   1050 <isnan@plt>
test   %rax,%rax
je     11a3 <erfc+0x73>
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret
add    $0x18,%rsp
jmp    1040 <q_gamma@plt>
xorpd  %xmm0,%xmm0
cmpltsd (%rsp),%xmm0
movsd  0xe7b(%rip),%xmm1
andnpd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @erfc(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = call double @llvm.fabs.f64(double %4)
%6 = fcmp one double %5, 0x7FF0000000000000
br i1 %6, label %18, label %7
7: ; preds = %1
%8 = load double, double* %3
%9 = call i64 @isnan(double %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = load double, double* %3
store double %12, double* %2
br label %32
13: ; preds = %7
%14 = load double, double* %3
%15 = fcmp ogt double %14, 0.000000e+00
%16 = zext i1 %15 to i64
%17 = select i1 %15, double 0.000000e+00, double 2.000000e+00
store double %17, double* %2
br label %32
18: ; preds = %1
%19 = load double, double* %3
%20 = fcmp oge double %19, 0.000000e+00
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load double, double* %3
%23 = load double, double* %3
%24 = fmul double %22, %23
%25 = call double @q_gamma(double 5.000000e-01, double %24, double 0x3FE250D048E7A1BD)
store double %25, double* %2
br label %32
26: ; preds = %18
%27 = load double, double* %3
%28 = load double, double* %3
%29 = fmul double %27, %28
%30 = call double @p_gamma(double 5.000000e-01, double %29, double 0x3FE250D048E7A1BD)
%31 = fadd double 1.000000e+00, %30
store double %31, double* %2
br label %32
32: ; preds = %26, %21, %13, %11
%33 = load double, double* %2
ret double %33
}

LLVM IR (-O2):
define double @erfc(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
%3 = fcmp ueq double %2, 0x7FF0000000000000
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = tail call i64 @isnan(double %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = fcmp ogt double %0, 0.000000e+00
%9 = select i1 %8, double 0.000000e+00, double 2.000000e+00
br label %18
10: ; preds = %1
%11 = fcmp ult double %0, 0.000000e+00
%12 = fmul double %0, %0
br i1 %11, label %15, label %13
13: ; preds = %10
%14 = tail call double @q_gamma(double 5.000000e-01, double %12, double 0x3FE250D048E7A1BD)
br label %18
15: ; preds = %10
%16 = tail call double @p_gamma(double 5.000000e-01, double %12, double 0x3FE250D048E7A1BD)
%17 = fadd double %16, 1.000000e+00
br label %18
18: ; preds = %4, %15, %13, %7
%19 = phi double [ %14, %13 ], [ %17, %15 ], [ %9, %7 ], [ %0, %4 ]
ret double %19
}