#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double erfnc(double x) {
  int i;
  double w;
  static double a[6] = {1.0,          0.0705230784, 0.0422820123,
                        0.0092705272, 0.0001520143, 0.0002765672};
  if (x < 0.) {
    fprintf(stderr, "Error : x < 0  in erfnc()\n");
    return 0.;
  }
  if (x == 0.)
    return 0.;
  if (x >= 10.)
    return 1.;
  w = 0.0000430638;
  for (i = 5; i >= 0; i--)
    w = w * x + a[i];
  for (i = 0; i < 4; i++)
    w *= w;
  return 1. - 1. / w;
}


x86 assembly (clang, -O0):
<erfnc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    114d <erfnc+0x3d>
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123a <erfnc+0x12a>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1172 <erfnc+0x62>
jp     1172 <erfnc+0x62>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123a <erfnc+0x12a>
movsd  -0x10(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     119b <erfnc+0x8b>
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123a <erfnc+0x12a>
movsd  0xe65(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11ee <erfnc+0xde>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e62(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11af <erfnc+0x9f>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    121c <erfnc+0x10c>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f5 <erfnc+0xe5>
movsd  0xdec(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  0xddf(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<erfnc>:
push   %rax
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jbe    1139 <erfnc+0x29>
mov    0x2ebe(%rip),%rax
mov    (%rax),%edi
lea    0xf15(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm2,%xmm2
jmp    11c9 <erfnc+0xb9>
ucomisd %xmm2,%xmm0
jne    1145 <erfnc+0x35>
jnp    11c9 <erfnc+0xb9>
ucomisd 0xebb(%rip),%xmm0
jae    11c1 <erfnc+0xb1>
movsd  0xeb9(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeb5(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeb1(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xead(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xea9(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xea5(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe61(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm1,%xmm1
movapd %xmm2,%xmm0
divsd  %xmm1,%xmm0
subsd  %xmm0,%xmm2
jmp    11c9 <erfnc+0xb9>
movsd  0xe37(%rip),%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@erfnc.a = internal global [6 x double] [double 1.000000e+00, double 0x3FB20DCCEB575BC4, double 0x3FA5A5FCE8133C57, double 0x3F82FC6D19201C06, double 0x3F23ECC0E4E05F94, double 0x3F3220071442EE6C]
@stderr = global i32 0
@.str = [27 x i8] c"Error : x < 0 in erfnc()\0A\00"
define double @erfnc(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
store double %0, double* %3
%6 = load double, double* %3
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %49
11: ; preds = %1
%12 = load double, double* %3
%13 = fcmp oeq double %12, 0.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %11
store double 0.000000e+00, double* %2
br label %49
15: ; preds = %11
%16 = load double, double* %3
%17 = fcmp oge double %16, 1.000000e+01
br i1 %17, label %18, label %19
18: ; preds = %15
store double 1.000000e+00, double* %2
br label %49
19: ; preds = %15
store double 4.306380e-05, double* %5
store i32 5, i32* %4
br label %20
20: ; preds = %31, %19
%21 = load i32, i32* %4
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load double, double* %5
%25 = load double, double* %3
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [6 x double], [6 x double]* @erfnc.a, i64 0, i64 %27
%29 = load double, double* %28
%30 = call double @llvm.fmuladd.f64(double %24, double %25, double %29)
store double %30, double* %5
br label %31
31: ; preds = %23
%32 = load i32, i32* %4
%33 = add nsw i32 %32, -1
store i32 %33, i32* %4
br label %20
34: ; preds = %20
store i32 0, i32* %4
br label %35
35: ; preds = %42, %34
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 4
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load double, double* %5
%40 = load double, double* %5
%41 = fmul double %40, %39
store double %41, double* %5
br label %42
42: ; preds = %38
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %35
45: ; preds = %35
%46 = load double, double* %5
%47 = fdiv double 1.000000e+00, %46
%48 = fsub double 1.000000e+00, %47
store double %48, double* %2
br label %49
49: ; preds = %45, %18, %14, %8
%50 = load double, double* %2
ret double %50
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Error : x < 0 in erfnc()\0A\00"
define double @erfnc(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %23
6: ; preds = %1
%7 = fcmp oeq double %0, 0.000000e+00
br i1 %7, label %23, label %8
8: ; preds = %6
%9 = fcmp ult double %0, 1.000000e+01
br i1 %9, label %10, label %23
10: ; preds = %8
%11 = tail call double @llvm.fmuladd.f64(double %0, double 4.306380e-05, double 0x3F3220071442EE6C)
%12 = tail call double @llvm.fmuladd.f64(double %11, double %0, double 0x3F23ECC0E4E05F94)
%13 = tail call double @llvm.fmuladd.f64(double %12, double %0, double 0x3F82FC6D19201C06)
%14 = tail call double @llvm.fmuladd.f64(double %13, double %0, double 0x3FA5A5FCE8133C57)
%15 = tail call double @llvm.fmuladd.f64(double %14, double %0, double 0x3FB20DCCEB575BC4)
%16 = tail call double @llvm.fmuladd.f64(double %15, double %0, double 1.000000e+00)
%17 = fmul double %16, %16
%18 = fmul double %17, %17
%19 = fmul double %18, %18
%20 = fmul double %19, %19
%21 = fdiv double 1.000000e+00, %20
%22 = fsub double 1.000000e+00, %21
br label %23
23: ; preds = %8, %6, %10, %3
%24 = phi double [ 0.000000e+00, %3 ], [ %22, %10 ], [ 0.000000e+00, %6 ], [ 1.000000e+00, %8 ]
ret double %24
}