#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 fabs(double);
int log(int);
double atanh(double x) {
  int neg = x < 0;
  double z = fabs(x);
  if (z < (1.0 / (1 << (53 / 3))))
    return x;
  z = log(z > 1 ? -1 : (1 + z) / (1 - z)) / 2;
  if (neg)
    z = -z;
  return z;
}


x86 assembly (clang, -O0):
<atanh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xee4(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb3(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1167 <atanh+0x57>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1207 <atanh+0xf7>
movsd  -0x20(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1190 <atanh+0x80>
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11b3 <atanh+0xa3>
movsd  0xe70(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe63(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11fd <atanh+0xed>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atanh>:
sub    $0x18,%rsp
movapd 0xee4(%rip),%xmm3
andpd  %xmm0,%xmm3
movsd  0xef8(%rip),%xmm1
ucomisd %xmm3,%xmm1
ja     119d <atanh+0x8d>
movapd %xmm0,(%rsp)
mov    $0xffffffff,%edi
ucomisd 0xee8(%rip),%xmm3
ja     115e <atanh+0x4e>
movsd  0xede(%rip),%xmm1
movapd %xmm3,%xmm2
addsd  %xmm1,%xmm2
subsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
call   1030 <log@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xorps  %xmm3,%xmm3
cvtsi2sd %ecx,%xmm3
movapd 0xe95(%rip),%xmm1
xorpd  %xmm3,%xmm1
xorpd  %xmm2,%xmm2
movapd (%rsp),%xmm0
cmpltsd %xmm2,%xmm0
movapd %xmm0,%xmm2
andnpd %xmm3,%xmm2
andpd  %xmm1,%xmm0
orpd   %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @atanh(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
store double %0, double* %3
%6 = load double, double* %3
%7 = fcmp olt double %6, 0.000000e+00
%8 = zext i1 %7 to i32
store i32 %8, i32* %4
%9 = load double, double* %3
%10 = call double @llvm.fabs.f64(double %9)
store double %10, double* %5
%11 = load double, double* %5
%12 = fcmp olt double %11, 0x3EE0000000000000
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = load double, double* %3
store double %14, double* %2
br label %38
15: ; preds = %1
%16 = load double, double* %5
%17 = fcmp ogt double %16, 1.000000e+00
br i1 %17, label %18, label %19
18: ; preds = %15
br label %25
19: ; preds = %15
%20 = load double, double* %5
%21 = fadd double 1.000000e+00, %20
%22 = load double, double* %5
%23 = fsub double 1.000000e+00, %22
%24 = fdiv double %21, %23
br label %25
25: ; preds = %19, %18
%26 = phi double [ -1.000000e+00, %18 ], [ %24, %19 ]
%27 = fptosi double %26 to i32
%28 = call i32 @log(i32 %27)
%29 = sdiv i32 %28, 2
%30 = sitofp i32 %29 to double
store double %30, double* %5
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = load double, double* %5
%35 = fneg double %34
store double %35, double* %5
br label %36
36: ; preds = %33, %25
%37 = load double, double* %5
store double %37, double* %2
br label %38
38: ; preds = %36, %13
%39 = load double, double* %2
ret double %39
}

LLVM IR (-O2):
define double @atanh(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = fcmp olt double %3, 0x3EE0000000000000
br i1 %4, label %19, label %5
5: ; preds = %1
%6 = fcmp ogt double %3, 1.000000e+00
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = fadd double %3, 1.000000e+00
%9 = fsub double 1.000000e+00, %3
%10 = fdiv double %8, %9
%11 = fptosi double %10 to i32
br label %12
12: ; preds = %5, %7
%13 = phi i32 [ %11, %7 ], [ -1, %5 ]
%14 = tail call i32 @log(i32 %13)
%15 = sdiv i32 %14, 2
%16 = sitofp i32 %15 to double
%17 = fneg double %16
%18 = select i1 %2, double %17, double %16
br label %19
19: ; preds = %1, %12
%20 = phi double [ %18, %12 ], [ %0, %1 ]
ret double %20
}