#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 erfc(double);
double fabs(double);
double p1evl(double, double const *, int);
double polevl(double, double const *, int);
double erf(double x) {
  static const double T[] = {9.60497373987051638749E0, 9.00260197203842689217E1,
                             2.23200534594684319226E3, 7.00332514112805075473E3,
                             5.55923013010394962768E4};
  static const double U[] = {3.35617141647503099647E1, 5.21357949780152679795E2,
                             4.59432382970980127987E3, 2.26290000613890934246E4,
                             4.92673942608635921086E4};
  double y, z;
  if (fabs(x) > 1.0)
    return (1.0 - erfc(x));
  z = x * x;
  y = x * polevl(z, T, 4) / p1evl(z, U, 5);
  return (y);
}


x86 assembly (clang, -O0):
<erf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xec7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xeab(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1182 <erf+0x52>
movsd  -0x10(%rbp),%xmm0
call   1040 <erfc@plt>
movaps %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f3 <erf+0xc3>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe79(%rip),%rdi
mov    $0x4,%esi
call   1030 <polevl@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe82(%rip),%rdi
mov    $0x5,%esi
call   1050 <p1evl@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<erf>:
sub    $0x28,%rsp
movapd %xmm0,%xmm1
movapd 0xec0(%rip),%xmm0
andpd  %xmm1,%xmm0
ucomisd 0xec4(%rip),%xmm0
jbe    1165 <erf+0x35>
movapd %xmm1,%xmm0
call   1040 <erfc@plt>
movsd  0xeb1(%rip),%xmm1
subsd  %xmm0,%xmm1
jmp    11b3 <erf+0x83>
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
lea    0xea6(%rip),%rdi
mov    $0x4,%esi
movapd %xmm1,(%rsp)
call   1030 <polevl@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0xeb6(%rip),%rdi
movapd 0x10(%rsp),%xmm0
mov    $0x5,%esi
call   1050 <p1evl@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@erf.T = internal constant [5 x double] [double 0x402335BF1E375D88, double 0x405681AA4E9E067F, double 0x40A17002BCB435B7, double 0x40BB5B533C72EF90, double 0x40EB2509A44213DC]
@erf.U = internal constant [5 x double] [double 0x4040C7E63FEFA6BA, double 0x40804ADD14C63AEE, double 0x40B1F252E680FD12, double 0x40D6194001017C0A, double 0x40E80E6C9DC8F567]
define double @erf(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)
%8 = fcmp ogt double %7, 1.000000e+00
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load double, double* %3
%11 = call double @erfc(double %10)
%12 = fsub double 1.000000e+00, %11
store double %12, double* %2
br label %25
13: ; preds = %1
%14 = load double, double* %3
%15 = load double, double* %3
%16 = fmul double %14, %15
store double %16, double* %5
%17 = load double, double* %3
%18 = load double, double* %5
%19 = call double @polevl(double %18, double* getelementptr inbounds ([5 x double], [5 x double]* @erf.T, i64 0, i64 0), i32 4)
%20 = fmul double %17, %19
%21 = load double, double* %5
%22 = call double @p1evl(double %21, double* getelementptr inbounds ([5 x double], [5 x double]* @erf.U, i64 0, i64 0), i32 5)
%23 = fdiv double %20, %22
store double %23, double* %4
%24 = load double, double* %4
store double %24, double* %2
br label %25
25: ; preds = %13, %9
%26 = load double, double* %2
ret double %26
}

LLVM IR (-O2):
@erf.T = internal constant [5 x double] [double 0x402335BF1E375D88, double 0x405681AA4E9E067F, double 0x40A17002BCB435B7, double 0x40BB5B533C72EF90, double 0x40EB2509A44213DC]
@erf.U = internal constant [5 x double] [double 0x4040C7E63FEFA6BA, double 0x40804ADD14C63AEE, double 0x40B1F252E680FD12, double 0x40D6194001017C0A, double 0x40E80E6C9DC8F567]
define double @erf(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
%3 = fcmp ogt double %2, 1.000000e+00
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call double @erfc(double %0)
%6 = fsub double 1.000000e+00, %5
br label %13
7: ; preds = %1
%8 = fmul double %0, %0
%9 = tail call double @polevl(double %8, double* getelementptr inbounds ([5 x double], [5 x double]* @erf.T, i64 0, i64 0), i32 4)
%10 = fmul double %9, %0
%11 = tail call double @p1evl(double %8, double* getelementptr inbounds ([5 x double], [5 x double]* @erf.U, i64 0, i64 0), i32 5)
%12 = fdiv double %10, %11
br label %13
13: ; preds = %7, %4
%14 = phi double [ %6, %4 ], [ %12, %7 ]
ret double %14
}