#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 cosh(double);
double sinh(double);
double tanh(double arg) {
  double sign;
  sign = 1.;
  if (arg < 0.) {
    arg = -arg;
    sign = -1.;
  }
  if (arg > 21.)
    return (sign);
  return (sign * sinh(arg) / cosh(arg));
}


x86 assembly (clang, -O0):
<tanh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1176 <tanh+0x56>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119c <tanh+0x7c>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11dc <tanh+0xbc>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sinh@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cosh@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tanh>:
sub    $0x28,%rsp
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %cl
jbe    113b <tanh+0x1b>
xorpd  0xec5(%rip),%xmm0
mov    %cl,%al
lea    0xecc(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm1
ucomisd 0xecf(%rip),%xmm0
ja     1189 <tanh+0x69>
movapd %xmm0,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <sinh@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
call   1040 <cosh@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @tanh(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
store double 1.000000e+00, double* %4
%5 = load double, double* %3
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load double, double* %3
%9 = fneg double %8
store double %9, double* %3
store double -1.000000e+00, double* %4
br label %10
10: ; preds = %7, %1
%11 = load double, double* %3
%12 = fcmp ogt double %11, 2.100000e+01
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = load double, double* %4
store double %14, double* %2
br label %23
15: ; preds = %10
%16 = load double, double* %4
%17 = load double, double* %3
%18 = call double @sinh(double %17)
%19 = fmul double %16, %18
%20 = load double, double* %3
%21 = call double @cosh(double %20)
%22 = fdiv double %19, %21
store double %22, double* %2
br label %23
23: ; preds = %15, %13
%24 = load double, double* %2
ret double %24
}

LLVM IR (-O2):
define double @tanh(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
%5 = select i1 %2, double -1.000000e+00, double 1.000000e+00
%6 = fcmp ogt double %4, 2.100000e+01
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = tail call double @sinh(double %4)
%9 = fmul double %5, %8
%10 = tail call double @cosh(double %4)
%11 = fdiv double %9, %10
br label %12
12: ; preds = %1, %7
%13 = phi double [ %11, %7 ], [ %5, %1 ]
ret double %13
}