#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 exp(double);
double activate_htan(double x) {
  double powe;
  if (x > 42.0)
    return 1.0;
  if (x < -42.0)
    return -1.0;
  powe = exp(2.0 * x);
  return (powe - 1.0) / (powe + 1.0);
}


x86 assembly (clang, -O0):
<activate_htan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1146 <activate_htan+0x36>
movsd  0xed4(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a9 <activate_htan+0x99>
movsd  0xeba(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    116b <activate_htan+0x5b>
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a9 <activate_htan+0x99>
movsd  0xea5(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe75(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<activate_htan>:
push   %rax
ucomisd 0xeef(%rip),%xmm0
jbe    1125 <activate_htan+0x15>
movsd  0xedd(%rip),%xmm0
pop    %rax
ret
movsd  0xeeb(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    113d <activate_htan+0x2d>
movsd  0xed5(%rip),%xmm0
pop    %rax
ret
addsd  %xmm0,%xmm0
call   1030 <exp@plt>
movapd %xmm0,%xmm1
movsd  0xebe(%rip),%xmm0
addsd  %xmm1,%xmm0
addsd  0xea2(%rip),%xmm1
divsd  %xmm1,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define double @activate_htan(double %0) {
%2 = fcmp ogt double %0, 4.200000e+01
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = fcmp olt double %0, -4.200000e+01
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = fmul double %0, 2.000000e+00
%7 = tail call double @exp(double %6)
%8 = fadd double %7, -1.000000e+00
%9 = fadd double %7, 1.000000e+00
%10 = fdiv double %8, %9
br label %11
11: ; preds = %3, %1, %5
%12 = phi double [ %10, %5 ], [ 1.000000e+00, %1 ], [ -1.000000e+00, %3 ]
ret double %12
}