#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 */
float expf(float);
float approx_erff_do(float x) {
  if (x > 3.0f) {
    return 1.0f;
  }
  float t = 1.0f / (1.0f + 0.47047f * x);
  return (1.0f -
          t * (0.3480242f + t * (-0.0958798f + t * 0.7478556f)) * expf(-x * x));
}


x86 assembly (clang, -O0):
<approx_erff_do>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xed6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1145 <approx_erff_do+0x35>
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11f9 <approx_erff_do+0xe9>
movss  -0x8(%rbp),%xmm1
movss  0xec2(%rip),%xmm0
mulss  %xmm0,%xmm1
movss  0xea6(%rip),%xmm0
addss  %xmm0,%xmm1
movss  0xe9a(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
movss  0xe82(%rip),%xmm3
mulss  %xmm3,%xmm2
movss  0xe7a(%rip),%xmm3
addss  %xmm3,%xmm2
mulss  %xmm2,%xmm1
movss  0xe62(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x8(%rbp),%xmm0
call   1030 <expf@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm1,%xmm0
movss  0xe14(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approx_erff_do>:
push   %rax
ucomiss 0xee8(%rip),%xmm0
jbe    1124 <approx_erff_do+0x14>
movss  0xee6(%rip),%xmm0
pop    %rax
ret
movss  0xed8(%rip),%xmm1
mulss  %xmm0,%xmm1
movss  0xed0(%rip),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm2
movss  %xmm2,0x4(%rsp)
movss  0xebe(%rip),%xmm1
mulss  %xmm2,%xmm1
addss  0xeb6(%rip),%xmm1
mulss  %xmm2,%xmm1
addss  0xeae(%rip),%xmm1
movss  %xmm1,(%rsp)
movaps 0xeae(%rip),%xmm1
xorps  %xmm0,%xmm1
mulss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1030 <expf@plt>
movss  (%rsp),%xmm1
mulss  0x4(%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  0xe70(%rip),%xmm0
subss  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @approx_erff_do(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
store float %0, float* %3
%5 = load float, float* %3
%6 = fcmp ogt float %5, 3.000000e+00
br i1 %6, label %7, label %8
7: ; preds = %1
store float 1.000000e+00, float* %2
br label %25
8: ; preds = %1
%9 = load float, float* %3
%10 = call float @llvm.fmuladd.f32(float 0x3FDE1C2E40000000, float %9, float 1.000000e+00)
%11 = fdiv float 1.000000e+00, %10
store float %11, float* %4
%12 = load float, float* %4
%13 = load float, float* %4
%14 = load float, float* %4
%15 = call float @llvm.fmuladd.f32(float %14, float 0x3FE7EE6EE0000000, float 0xBFB88B9420000000)
%16 = call float @llvm.fmuladd.f32(float %13, float %15, float 0x3FD6460740000000)
%17 = fmul float %12, %16
%18 = load float, float* %3
%19 = fneg float %18
%20 = load float, float* %3
%21 = fmul float %19, %20
%22 = call float @expf(float %21)
%23 = fneg float %17
%24 = call float @llvm.fmuladd.f32(float %23, float %22, float 1.000000e+00)
store float %24, float* %2
br label %25
25: ; preds = %8, %7
%26 = load float, float* %2
ret float %26
}

LLVM IR (-O2):
define float @approx_erff_do(float %0) {
%2 = fcmp ogt float %0, 3.000000e+00
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = tail call float @llvm.fmuladd.f32(float %0, float 0x3FDE1C2E40000000, float 1.000000e+00)
%5 = fdiv float 1.000000e+00, %4
%6 = tail call float @llvm.fmuladd.f32(float %5, float 0x3FE7EE6EE0000000, float 0xBFB88B9420000000)
%7 = tail call float @llvm.fmuladd.f32(float %5, float %6, float 0x3FD6460740000000)
%8 = fneg float %0
%9 = fmul float %8, %0
%10 = tail call float @expf(float %9)
%11 = fneg float %5
%12 = fmul float %7, %11
%13 = tail call float @llvm.fmuladd.f32(float %12, float %10, float 1.000000e+00)
br label %14
14: ; preds = %1, %3
%15 = phi float [ %13, %3 ], [ 1.000000e+00, %1 ]
ret float %15
}