#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 */
int /*<<< orphan*/ EDOM;
int /*<<< orphan*/ ERANGE;
long double INFINITY;
long double __fast_log1pl(long double);
int /*<<< orphan*/ errno;
long double fabsl(long double);
scalar_t__ isnan(long double);
long double nanl(char *);
long double atanhl(long double x) {
  long double z;
  if (isnan(x))
    return x;
  z = fabsl(x);
  if (z == 1.0L) {
    errno = ERANGE;
    return (x > 0 ? INFINITY : -INFINITY);
  }
  if (z > 1.0L) {
    errno = EDOM;
    return nanl("");
  }
  z = 0.5L * __fast_log1pl((z + z) / (1.0L - z));
  return x >= 0 ? z : -z;
}


x86 assembly (clang, -O0):
<atanhl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <isnan@plt>
cmp    $0x0,%rax
je     1160 <atanhl+0x30>
fldt   -0x20(%rbp)
fstpt  -0x10(%rbp)
jmp    1263 <atanhl+0x133>
fldt   -0x20(%rbp)
fabs
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11d6 <atanhl+0xa6>
jp     11d6 <atanhl+0xa6>
jmp    1184 <atanhl+0x54>
mov    0x2e4d(%rip),%rax
mov    (%rax),%ecx
mov    0x2e34(%rip),%rax
mov    %ecx,(%rax)
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    11bd <atanhl+0x8d>
jmp    11ac <atanhl+0x7c>
mov    0x2e35(%rip),%rax
fldt   (%rax)
fstpt  -0x3c(%rbp)
jmp    11cb <atanhl+0x9b>
mov    0x2e24(%rip),%rax
fldt   (%rax)
fchs
fstpt  -0x3c(%rbp)
fldt   -0x3c(%rbp)
fstpt  -0x10(%rbp)
jmp    1263 <atanhl+0x133>
fldt   -0x30(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1212 <atanhl+0xe2>
jmp    11ec <atanhl+0xbc>
mov    0x2ded(%rip),%rax
mov    (%rax),%ecx
mov    0x2dcc(%rip),%rax
mov    %ecx,(%rax)
lea    0xdff(%rip),%rdi
call   1040 <nanl@plt>
fstpt  -0x10(%rbp)
jmp    1263 <atanhl+0x133>
fldt   -0x30(%rbp)
fld    %st(0)
fadd   %st(1),%st
fld1
fsubp  %st,%st(2)
fdivp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <__fast_log1pl@plt>
flds   0xdd1(%rip)
fmulp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     1255 <atanhl+0x125>
jmp    124a <atanhl+0x11a>
fldt   -0x30(%rbp)
fstpt  -0x48(%rbp)
jmp    125d <atanhl+0x12d>
fldt   -0x30(%rbp)
fchs
fstpt  -0x48(%rbp)
fldt   -0x48(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atanhl>:
sub    $0x28,%rsp
fldt   0x30(%rsp)
fld    %st(0)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
call   1050 <isnan@plt>
test   %rax,%rax
je     1154 <atanhl+0x24>
fldt   0x1c(%rsp)
add    $0x28,%rsp
ret
fldt   0x1c(%rsp)
fld    %st(0)
fabs
fld1
fxch   %st(1)
fucomi %st(1),%st
jne    1195 <atanhl+0x65>
jp     1195 <atanhl+0x65>
fstp   %st(0)
fstp   %st(0)
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    0x2e4e(%rip),%rcx
mov    %eax,(%rcx)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
mov    0x2e5d(%rip),%rax
fldt   (%rax)
fld    %st(0)
fchs
fcmovnbe %st(1),%st
jmp    11e7 <atanhl+0xb7>
fstp   %st(2)
jbe    11bf <atanhl+0x8f>
fstp   %st(1)
fstp   %st(0)
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
mov    0x2e1b(%rip),%rcx
mov    %eax,(%rcx)
lea    0xe4e(%rip),%rdi
add    $0x28,%rsp
jmp    1040 <nanl@plt>
fld    %st(1)
fadd   %st(2),%st
fxch   %st(1)
fsubp  %st,%st(2)
fdivp  %st,%st(1)
fstpt  (%rsp)
call   1030 <__fast_log1pl@plt>
fmuls  0xe29(%rip)
fldz
fldt   0x1c(%rsp)
fucomip %st(1),%st
fstp   %st(0)
fld    %st(0)
fchs
fcmovnb %st(1),%st
fstp   %st(1)
add    $0x28,%rsp
ret

LLVM IR (-O0):
@ERANGE = global i32 0
@errno = global i32 0
@INFINITY = global x86_fp80 0xK00000000000000000000
@EDOM = global i32 0
@.str = [1 x i8] zeroinitializer
define x86_fp80 @atanhl(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %3
%5 = load x86_fp80, x86_fp80* %3
%6 = call i64 @isnan(x86_fp80 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load x86_fp80, x86_fp80* %3
store x86_fp80 %9, x86_fp80* %2
br label %50
10: ; preds = %1
%11 = load x86_fp80, x86_fp80* %3
%12 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %11)
store x86_fp80 %12, x86_fp80* %4
%13 = load x86_fp80, x86_fp80* %4
%14 = fcmp oeq x86_fp80 %13, 0xK3FFF8000000000000000
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = load i32, i32* @ERANGE
store i32 %16, i32* @errno
%17 = load x86_fp80, x86_fp80* %3
%18 = fcmp ogt x86_fp80 %17, 0xK00000000000000000000
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load x86_fp80, x86_fp80* @INFINITY
br label %24
21: ; preds = %15
%22 = load x86_fp80, x86_fp80* @INFINITY
%23 = fneg x86_fp80 %22
br label %24
24: ; preds = %21, %19
%25 = phi x86_fp80 [ %20, %19 ], [ %23, %21 ]
store x86_fp80 %25, x86_fp80* %2
br label %50
26: ; preds = %10
%27 = load x86_fp80, x86_fp80* %4
%28 = fcmp ogt x86_fp80 %27, 0xK3FFF8000000000000000
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* @EDOM
store i32 %30, i32* @errno
%31 = call x86_fp80 @nanl(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store x86_fp80 %31, x86_fp80* %2
br label %50
32: ; preds = %26
%33 = load x86_fp80, x86_fp80* %4
%34 = load x86_fp80, x86_fp80* %4
%35 = fadd x86_fp80 %33, %34
%36 = load x86_fp80, x86_fp80* %4
%37 = fsub x86_fp80 0xK3FFF8000000000000000, %36
%38 = fdiv x86_fp80 %35, %37
%39 = call x86_fp80 @__fast_log1pl(x86_fp80 %38)
%40 = fmul x86_fp80 0xK3FFE8000000000000000, %39
store x86_fp80 %40, x86_fp80* %4
%41 = load x86_fp80, x86_fp80* %3
%42 = fcmp oge x86_fp80 %41, 0xK00000000000000000000
br i1 %42, label %43, label %45
43: ; preds = %32
%44 = load x86_fp80, x86_fp80* %4
br label %48
45: ; preds = %32
%46 = load x86_fp80, x86_fp80* %4
%47 = fneg x86_fp80 %46
br label %48
48: ; preds = %45, %43
%49 = phi x86_fp80 [ %44, %43 ], [ %47, %45 ]
store x86_fp80 %49, x86_fp80* %2
br label %50
50: ; preds = %48, %29, %24, %8
%51 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %51
}

LLVM IR (-O2):
@ERANGE = global i32 0
@errno = global i32 0
@INFINITY = global x86_fp80 0xK00000000000000000000
@EDOM = global i32 0
@.str = [1 x i8] zeroinitializer
define x86_fp80 @atanhl(x86_fp80 %0) {
%2 = tail call i64 @isnan(x86_fp80 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %27
4: ; preds = %1
%5 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %0)
%6 = fcmp oeq x86_fp80 %5, 0xK3FFF8000000000000000
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = load i32, i32* @ERANGE
store i32 %8, i32* @errno
%9 = fcmp ogt x86_fp80 %0, 0xK00000000000000000000
%10 = load x86_fp80, x86_fp80* @INFINITY
%11 = fneg x86_fp80 %10
%12 = select i1 %9, x86_fp80 %10, x86_fp80 %11
br label %27
13: ; preds = %4
%14 = fcmp ogt x86_fp80 %5, 0xK3FFF8000000000000000
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = load i32, i32* @EDOM
store i32 %16, i32* @errno
%17 = tail call x86_fp80 @nanl(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %27
18: ; preds = %13
%19 = fadd x86_fp80 %5, %5
%20 = fsub x86_fp80 0xK3FFF8000000000000000, %5
%21 = fdiv x86_fp80 %19, %20
%22 = tail call x86_fp80 @__fast_log1pl(x86_fp80 %21)
%23 = fmul x86_fp80 %22, 0xK3FFE8000000000000000
%24 = fcmp oge x86_fp80 %0, 0xK00000000000000000000
%25 = fneg x86_fp80 %23
%26 = select i1 %24, x86_fp80 %23, x86_fp80 %25
br label %27
27: ; preds = %1, %18, %15, %7
%28 = phi x86_fp80 [ %12, %7 ], [ %17, %15 ], [ %26, %18 ], [ %0, %1 ]
ret x86_fp80 %28
}