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


x86 assembly (clang, -O0):
<tanh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11cb <tanh+0xab>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe97(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1185 <tanh+0x65>
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121e <tanh+0xfe>
movsd  -0x10(%rbp),%xmm0
call   1030 <sinh@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cosh@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121e <tanh+0xfe>
movsd  -0x10(%rbp),%xmm0
movsd  0xe28(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11f4 <tanh+0xd4>
movsd  0xe1e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121e <tanh+0xfe>
movsd  -0x10(%rbp),%xmm0
call   1030 <sinh@plt>
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    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tanh>:
sub    $0x28,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1149 <tanh+0x29>
movsd  0xee2(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1160 <tanh+0x40>
movsd  0xecc(%rip),%xmm0
add    $0x28,%rsp
ret
ucomisd 0xeb7(%rip),%xmm0
jbe    117d <tanh+0x5d>
movsd  0xea5(%rip),%xmm0
add    $0x28,%rsp
ret
xorpd  0xeb8(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
call   1030 <sinh@plt>
xorpd  0xea5(%rip),%xmm0
jmp    1188 <tanh+0x68>
movapd %xmm0,0x10(%rsp)
call   1030 <sinh@plt>
movapd %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
call   1040 <cosh@plt>
movapd (%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
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp olt double %4, 0.000000e+00
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = load double, double* %3
%8 = fneg double %7
store double %8, double* %3
%9 = load double, double* %3
%10 = fcmp ogt double %9, 2.100000e+01
br i1 %10, label %11, label %12
11: ; preds = %6
store double -1.000000e+00, double* %2
br label %29
12: ; preds = %6
%13 = load double, double* %3
%14 = call double @sinh(double %13)
%15 = fneg double %14
%16 = load double, double* %3
%17 = call double @cosh(double %16)
%18 = fdiv double %15, %17
store double %18, double* %2
br label %29
19: ; preds = %1
%20 = load double, double* %3
%21 = fcmp ogt double %20, 2.100000e+01
br i1 %21, label %22, label %23
22: ; preds = %19
store double 1.000000e+00, double* %2
br label %29
23: ; preds = %19
%24 = load double, double* %3
%25 = call double @sinh(double %24)
%26 = load double, double* %3
%27 = call double @cosh(double %26)
%28 = fdiv double %25, %27
store double %28, double* %2
br label %29
29: ; preds = %23, %22, %12, %11
%30 = load double, double* %2
ret double %30
}

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