#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 f_abs(float);
float f_tanh(float x) {
  double xa = f_abs(x);
  double x2 = xa * xa;
  double x3 = xa * x2;
  double x4 = x2 * x2;
  double x7 = x3 * x4;
  double res = (1.0 - 1.0 / (1.0 + xa + x2 + 0.58576695 * x3 + 0.55442112 * x4 +
                             0.057481508 * x7));
  return (x > 0 ? res : -res);
}


x86 assembly (clang, -O0):
<f_tanh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <f_abs@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe90(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe91(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe74(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xe57(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe33(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11f6 <f_tanh+0xe6>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1217 <f_tanh+0x107>
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_tanh>:
push   %rax
movss  %xmm0,0x4(%rsp)
call   1030 <f_abs@plt>
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm2,%xmm3
movsd  0xecc(%rip),%xmm1
addsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm2
movapd %xmm3,%xmm4
mulsd  %xmm2,%xmm4
mulsd  0xeb8(%rip),%xmm3
addsd  %xmm0,%xmm3
mulsd  0xeb4(%rip),%xmm2
addsd  %xmm3,%xmm2
mulsd  0xeb0(%rip),%xmm4
addsd  %xmm2,%xmm4
movapd %xmm1,%xmm0
divsd  %xmm4,%xmm0
subsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
movss  0x4(%rsp),%xmm2
ucomiss %xmm0,%xmm2
ja     118f <f_tanh+0x7f>
xorpd  0xe91(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @f_tanh(float %0) {
%2 = alloca float
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store float %0, float* %2
%9 = load float, float* %2
%10 = call double @f_abs(float %9)
store double %10, double* %3
%11 = load double, double* %3
%12 = load double, double* %3
%13 = fmul double %11, %12
store double %13, double* %4
%14 = load double, double* %3
%15 = load double, double* %4
%16 = fmul double %14, %15
store double %16, double* %5
%17 = load double, double* %4
%18 = load double, double* %4
%19 = fmul double %17, %18
store double %19, double* %6
%20 = load double, double* %5
%21 = load double, double* %6
%22 = fmul double %20, %21
store double %22, double* %7
%23 = load double, double* %3
%24 = fadd double 1.000000e+00, %23
%25 = load double, double* %4
%26 = fadd double %24, %25
%27 = load double, double* %5
%28 = call double @llvm.fmuladd.f64(double 0x3FE2BE9A54AA7C40, double %27, double %26)
%29 = load double, double* %6
%30 = call double @llvm.fmuladd.f64(double 0x3FE1BDD15C5392FA, double %29, double %28)
%31 = load double, double* %7
%32 = call double @llvm.fmuladd.f64(double 0x3FAD6E3759F832C6, double %31, double %30)
%33 = fdiv double 1.000000e+00, %32
%34 = fsub double 1.000000e+00, %33
store double %34, double* %8
%35 = load float, float* %2
%36 = fcmp ogt float %35, 0.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %1
%38 = load double, double* %8
br label %42
39: ; preds = %1
%40 = load double, double* %8
%41 = fneg double %40
br label %42
42: ; preds = %39, %37
%43 = phi double [ %38, %37 ], [ %41, %39 ]
%44 = fptrunc double %43 to float
ret float %44
}

LLVM IR (-O2):
define float @f_tanh(float %0) {
%2 = tail call double @f_abs(float %0)
%3 = fmul double %2, %2
%4 = fmul double %2, %3
%5 = fmul double %3, %3
%6 = fmul double %4, %5
%7 = fadd double %2, 1.000000e+00
%8 = fadd double %7, %3
%9 = tail call double @llvm.fmuladd.f64(double %4, double 0x3FE2BE9A54AA7C40, double %8)
%10 = tail call double @llvm.fmuladd.f64(double %5, double 0x3FE1BDD15C5392FA, double %9)
%11 = tail call double @llvm.fmuladd.f64(double %6, double 0x3FAD6E3759F832C6, double %10)
%12 = fdiv double 1.000000e+00, %11
%13 = fsub double 1.000000e+00, %12
%14 = fcmp ogt float %0, 0.000000e+00
%15 = fneg double %13
%16 = select i1 %14, double %13, double %15
%17 = fptrunc double %16 to float
ret float %17
}