#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*/ exp(int);
double fabs(double);
double log1p(int /*<<< orphan*/);
double atanh_th_th(double x, double y) {
  double yy, xx, xm, ym, res;
  int isigne;
  if (x * y >= 0)
    isigne = 1;
  else
    isigne = -1;
  xx = fabs(x);
  yy = fabs(y);
  if (xx < yy) {
    xm = xx;
    ym = yy;
  } else {
    xm = yy;
    ym = xx;
  }
  res = xm - .5 * log1p(exp(-2 * (ym - xm))) + .5 * log1p(exp(-2 * (xx + yy)));
  return ((double)isigne) * res;
}


x86 assembly (clang, -O0):
<atanh_th_th>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1155 <atanh_th_th+0x35>
movl   $0x1,-0x3c(%rbp)
jmp    115c <atanh_th_th+0x3c>
movl   $0xffffffff,-0x3c(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xe98(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xe83(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b3 <atanh_th_th+0x93>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11c7 <atanh_th_th+0xa7>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movsd  0xe35(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
mov    %eax,%edi
call   1040 <log1p@plt>
movsd  -0x50(%rbp),%xmm1
movsd  0xe1c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
movsd  0xdf5(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
mov    %eax,%edi
call   1040 <log1p@plt>
movsd  -0x48(%rbp),%xmm1
movsd  0xdcc(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atanh_th_th>:
sub    $0x48,%rsp
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm2,0x30(%rsp)
movapd 0xec6(%rip),%xmm2
andpd  %xmm2,%xmm0
movapd %xmm0,0x20(%rsp)
andpd  %xmm2,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm2
maxsd  %xmm0,%xmm2
minsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
subsd  %xmm0,%xmm2
mulsd  0xeb5(%rip),%xmm2
cvttsd2si %xmm2,%edi
call   1030 <exp@plt>
mov    %eax,%edi
call   1040 <log1p@plt>
mulsd  0xea5(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
mulsd  0xe7f(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
mov    %eax,%edi
call   1040 <log1p@plt>
mulsd  0xe77(%rip),%xmm0
addsd  (%rsp),%xmm0
movapd 0xe4a(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
cmpnlesd 0x30(%rsp),%xmm1
movapd %xmm1,%xmm3
andnpd %xmm0,%xmm3
andpd  %xmm2,%xmm1
orpd   %xmm3,%xmm1
movapd %xmm1,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @atanh_th_th(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double %0, double* %3
store double %1, double* %4
%11 = load double, double* %3
%12 = load double, double* %4
%13 = fmul double %11, %12
%14 = fcmp oge double %13, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 1, i32* %10
br label %17
16: ; preds = %2
store i32 -1, i32* %10
br label %17
17: ; preds = %16, %15
%18 = load double, double* %3
%19 = call double @llvm.fabs.f64(double %18)
store double %19, double* %6
%20 = load double, double* %4
%21 = call double @llvm.fabs.f64(double %20)
store double %21, double* %5
%22 = load double, double* %6
%23 = load double, double* %5
%24 = fcmp olt double %22, %23
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load double, double* %6
store double %26, double* %7
%27 = load double, double* %5
store double %27, double* %8
br label %31
28: ; preds = %17
%29 = load double, double* %5
store double %29, double* %7
%30 = load double, double* %6
store double %30, double* %8
br label %31
31: ; preds = %28, %25
%32 = load double, double* %7
%33 = load double, double* %8
%34 = load double, double* %7
%35 = fsub double %33, %34
%36 = fmul double -2.000000e+00, %35
%37 = fptosi double %36 to i32
%38 = call i32 @exp(i32 %37)
%39 = call double @log1p(i32 %38)
%40 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %39, double %32)
%41 = load double, double* %6
%42 = load double, double* %5
%43 = fadd double %41, %42
%44 = fmul double -2.000000e+00, %43
%45 = fptosi double %44 to i32
%46 = call i32 @exp(i32 %45)
%47 = call double @log1p(i32 %46)
%48 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %47, double %40)
store double %48, double* %9
%49 = load i32, i32* %10
%50 = sitofp i32 %49 to double
%51 = load double, double* %9
%52 = fmul double %50, %51
ret double %52
}

LLVM IR (-O2):
define double @atanh_th_th(double %0, double %1) {
%3 = fmul double %0, %1
%4 = fcmp ult double %3, 0.000000e+00
%5 = tail call double @llvm.fabs.f64(double %0)
%6 = tail call double @llvm.fabs.f64(double %1)
%7 = fcmp olt double %5, %6
%8 = select i1 %7, double %6, double %5
%9 = select i1 %7, double %5, double %6
%10 = fsub double %8, %9
%11 = fmul double %10, -2.000000e+00
%12 = fptosi double %11 to i32
%13 = tail call i32 @exp(i32 %12)
%14 = tail call double @log1p(i32 %13)
%15 = tail call double @llvm.fmuladd.f64(double %14, double -5.000000e-01, double %9)
%16 = fadd double %5, %6
%17 = fmul double %16, -2.000000e+00
%18 = fptosi double %17 to i32
%19 = tail call i32 @exp(i32 %18)
%20 = tail call double @log1p(i32 %19)
%21 = tail call double @llvm.fmuladd.f64(double %20, double 5.000000e-01, double %15)
%22 = fneg double %21
%23 = select i1 %4, double %22, double %21
ret double %23
}