#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 INFINITY;
float expf(float);
float tanhf(float x) {
  float x0;
  float x1;
  if (x == INFINITY) {
    return (1.0);
  }
  if (x == -INFINITY) {
    return (-1.0);
  }
  x0 = expf(x);
  x1 = 1.0 / x0;
  return ((x0 - x1) / (x0 + x1));
}


x86 assembly (clang, -O0):
<tanhf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
mov    0x2ebf(%rip),%rax
ucomiss (%rax),%xmm0
jne    114a <tanhf+0x3a>
jp     114a <tanhf+0x3a>
movss  0xecc(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d2 <tanhf+0xc2>
movss  -0x8(%rbp),%xmm0
mov    0x2e92(%rip),%rax
movss  (%rax),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
ucomiss %xmm1,%xmm0
jne    1188 <tanhf+0x78>
jp     1188 <tanhf+0x78>
movss  0xe8a(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d2 <tanhf+0xc2>
movss  -0x8(%rbp),%xmm0
call   1030 <expf@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe58(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
addss  -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tanhf>:
push   %rax
mov    0x2ed0(%rip),%rax
movss  (%rax),%xmm1
ucomiss %xmm0,%xmm1
jne    112d <tanhf+0x1d>
jp     112d <tanhf+0x1d>
movss  0xed5(%rip),%xmm0
pop    %rax
ret
xorps  0xedc(%rip),%xmm1
ucomiss %xmm0,%xmm1
jne    1145 <tanhf+0x35>
jp     1145 <tanhf+0x35>
movss  0xec1(%rip),%xmm0
pop    %rax
ret
call   1030 <expf@plt>
movaps %xmm0,%xmm1
movss  0xeab(%rip),%xmm2
divss  %xmm0,%xmm2
subss  %xmm2,%xmm0
addss  %xmm1,%xmm2
divss  %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@INFINITY = global float 0.000000e+00
define float @tanhf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %3
%6 = load float, float* %3
%7 = load float, float* @INFINITY
%8 = fcmp oeq float %6, %7
br i1 %8, label %9, label %10
9: ; preds = %1
store float 1.000000e+00, float* %2
br label %30
10: ; preds = %1
%11 = load float, float* %3
%12 = load float, float* @INFINITY
%13 = fneg float %12
%14 = fcmp oeq float %11, %13
br i1 %14, label %15, label %16
15: ; preds = %10
store float -1.000000e+00, float* %2
br label %30
16: ; preds = %10
%17 = load float, float* %3
%18 = call float @expf(float %17)
store float %18, float* %4
%19 = load float, float* %4
%20 = fpext float %19 to double
%21 = fdiv double 1.000000e+00, %20
%22 = fptrunc double %21 to float
store float %22, float* %5
%23 = load float, float* %4
%24 = load float, float* %5
%25 = fsub float %23, %24
%26 = load float, float* %4
%27 = load float, float* %5
%28 = fadd float %26, %27
%29 = fdiv float %25, %28
store float %29, float* %2
br label %30
30: ; preds = %16, %15, %9
%31 = load float, float* %2
ret float %31
}

LLVM IR (-O2):
@INFINITY = global float 0.000000e+00
define float @tanhf(float %0) {
%2 = load float, float* @INFINITY
%3 = fcmp oeq float %2, %0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = fneg float %2
%6 = fcmp oeq float %5, %0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call float @expf(float %0)
%9 = fdiv float 1.000000e+00, %8
%10 = fsub float %8, %9
%11 = fadd float %8, %9
%12 = fdiv float %10, %11
br label %13
13: ; preds = %4, %1, %7
%14 = phi float [ %12, %7 ], [ 1.000000e+00, %1 ], [ -1.000000e+00, %4 ]
ret float %14
}