#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;
float INFINITY;
double __fast_log1p(float);
int /*<<< orphan*/ errno;
float fabsf(float);
scalar_t__ isnan(float);
float nanf(char *);
float atanhf(float x) {
  float z;
  if (isnan(x))
    return x;
  z = fabsf(x);
  if (z == 1.0) {
    errno = ERANGE;
    return (x > 0 ? INFINITY : -INFINITY);
  }
  if (z > 1.0) {
    errno = EDOM;
    return nanf("");
  }
  z = 0.5 * __fast_log1p((z + z) / (1.0 - z));
  return x >= 0 ? z : -z;
}


x86 assembly (clang, -O0):
<atanhf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1160 <atanhf+0x30>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12c6 <atanhf+0x196>
movss  -0x8(%rbp),%xmm0
movaps 0xea4(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11fa <atanhf+0xca>
jp     11fa <atanhf+0xca>
mov    0x2e3b(%rip),%rax
mov    (%rax),%ecx
mov    0x2e22(%rip),%rax
mov    %ecx,(%rax)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11ce <atanhf+0x9e>
mov    0x2e28(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11eb <atanhf+0xbb>
mov    0x2e13(%rip),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12c6 <atanhf+0x196>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdf5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    123d <atanhf+0x10d>
mov    0x2dc4(%rip),%rax
mov    (%rax),%ecx
mov    0x2da3(%rip),%rax
mov    %ecx,(%rax)
lea    0xdf2(%rip),%rdi
call   1030 <nanf@plt>
movss  %xmm0,-0x4(%rbp)
jmp    12c6 <atanhf+0x196>
movss  -0xc(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xda4(%rip),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <__fast_log1p@plt>
movaps %xmm0,%xmm1
movsd  0xd90(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     12a5 <atanhf+0x175>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    12bc <atanhf+0x18c>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atanhf>:
sub    $0x18,%rsp
movaps %xmm0,(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
je     114b <atanhf+0x1b>
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret
movaps 0xeae(%rip),%xmm0
movaps (%rsp),%xmm3
andps  %xmm3,%xmm0
ucomiss 0xec0(%rip),%xmm0
jne    1195 <atanhf+0x65>
jp     1195 <atanhf+0x65>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    0x2e54(%rip),%rcx
mov    %eax,(%rcx)
mov    0x2e6b(%rip),%rax
movss  (%rax),%xmm0
movaps 0xe88(%rip),%xmm1
xorps  %xmm0,%xmm1
xorps  %xmm2,%xmm2
cmpltss %xmm3,%xmm2
jmp    1205 <atanhf+0xd5>
ucomiss 0xe84(%rip),%xmm0
jbe    11c0 <atanhf+0x90>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    0x2e1a(%rip),%rcx
mov    %eax,(%rcx)
lea    0xe81(%rip),%rdi
add    $0x18,%rsp
jmp    1030 <nanf@plt>
cvtss2sd %xmm0,%xmm1
addss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe54(%rip),%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <__fast_log1p@plt>
mulsd  0xe43(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movaps 0xe18(%rip),%xmm1
xorps  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
cmpless (%rsp),%xmm2
andps  %xmm2,%xmm0
andnps %xmm1,%xmm2
orps   %xmm0,%xmm2
movaps %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@ERANGE = global i32 0
@errno = global i32 0
@INFINITY = global float 0.000000e+00
@EDOM = global i32 0
@.str = [1 x i8] zeroinitializer
define float @atanhf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
store float %0, float* %3
%5 = load float, float* %3
%6 = call i64 @isnan(float %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load float, float* %3
store float %9, float* %2
br label %56
10: ; preds = %1
%11 = load float, float* %3
%12 = call float @llvm.fabs.f32(float %11)
store float %12, float* %4
%13 = load float, float* %4
%14 = fpext float %13 to double
%15 = fcmp oeq double %14, 1.000000e+00
br i1 %15, label %16, label %27
16: ; preds = %10
%17 = load i32, i32* @ERANGE
store i32 %17, i32* @errno
%18 = load float, float* %3
%19 = fcmp ogt float %18, 0.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load float, float* @INFINITY
br label %25
22: ; preds = %16
%23 = load float, float* @INFINITY
%24 = fneg float %23
br label %25
25: ; preds = %22, %20
%26 = phi float [ %21, %20 ], [ %24, %22 ]
store float %26, float* %2
br label %56
27: ; preds = %10
%28 = load float, float* %4
%29 = fpext float %28 to double
%30 = fcmp ogt double %29, 1.000000e+00
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* @EDOM
store i32 %32, i32* @errno
%33 = call float @nanf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store float %33, float* %2
br label %56
34: ; preds = %27
%35 = load float, float* %4
%36 = load float, float* %4
%37 = fadd float %35, %36
%38 = fpext float %37 to double
%39 = load float, float* %4
%40 = fpext float %39 to double
%41 = fsub double 1.000000e+00, %40
%42 = fdiv double %38, %41
%43 = fptrunc double %42 to float
%44 = call double @__fast_log1p(float %43)
%45 = fmul double 5.000000e-01, %44
%46 = fptrunc double %45 to float
store float %46, float* %4
%47 = load float, float* %3
%48 = fcmp oge float %47, 0.000000e+00
br i1 %48, label %49, label %51
49: ; preds = %34
%50 = load float, float* %4
br label %54
51: ; preds = %34
%52 = load float, float* %4
%53 = fneg float %52
br label %54
54: ; preds = %51, %49
%55 = phi float [ %50, %49 ], [ %53, %51 ]
store float %55, float* %2
br label %56
56: ; preds = %54, %31, %25, %8
%57 = load float, float* %2
ret float %57
}

LLVM IR (-O2):
@ERANGE = global i32 0
@errno = global i32 0
@INFINITY = global float 0.000000e+00
@EDOM = global i32 0
@.str = [1 x i8] zeroinitializer
define float @atanhf(float %0) {
%2 = tail call i64 @isnan(float %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %31
4: ; preds = %1
%5 = tail call float @llvm.fabs.f32(float %0)
%6 = fpext float %5 to double
%7 = fcmp oeq float %5, 1.000000e+00
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = load i32, i32* @ERANGE
store i32 %9, i32* @errno
%10 = fcmp ogt float %0, 0.000000e+00
%11 = load float, float* @INFINITY
%12 = fneg float %11
%13 = select i1 %10, float %11, float %12
br label %31
14: ; preds = %4
%15 = fcmp ogt float %5, 1.000000e+00
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = load i32, i32* @EDOM
store i32 %17, i32* @errno
%18 = tail call float @nanf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %31
19: ; preds = %14
%20 = fadd float %5, %5
%21 = fpext float %20 to double
%22 = fsub double 1.000000e+00, %6
%23 = fdiv double %21, %22
%24 = fptrunc double %23 to float
%25 = tail call double @__fast_log1p(float %24)
%26 = fmul double %25, 5.000000e-01
%27 = fptrunc double %26 to float
%28 = fcmp oge float %0, 0.000000e+00
%29 = fneg float %27
%30 = select i1 %28, float %27, float %29
br label %31
31: ; preds = %1, %19, %16, %8
%32 = phi float [ %13, %8 ], [ %18, %16 ], [ %30, %19 ], [ %0, %1 ]
ret float %32
}