// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]eigenmath/eigenmath.c
// Function: arctanh
void
arctanh(void)
{
	int i, n;
	double d;
	struct atom *p1;

	p1 = pop();

	if (istensor(p1)) {
		p1 = copy_tensor(p1);
		n = p1->u.tensor->nelem;
		for (i = 0; i < n; i++) {
			push(p1->u.tensor->elem[i]);
			arctanh();
			p1->u.tensor->elem[i] = pop();
		}
		push(p1);
		return;
	}

	if (isplusone(p1) || isminusone(p1)) {
		push_symbol(ARCTANH);
		push(p1);
		list(2);
		return;
	}

	if (isdouble(p1)) {
		push(p1);
		d = pop_double();
		if (-1.0 < d && d < 1.0) {
			d = atanh(d);
			push_double(d);
			return;
		}
	}

	// arctanh(z) = 1/2 log(1 + z) - 1/2 log(1 - z)

	if (isdouble(p1) || isdoublez(p1)) {
		push_double(1.0);
		push(p1);
		add();
		logfunc();
		push_double(1.0);
		push(p1);
		subtract();
		logfunc();
		subtract();
		push_double(0.5);
		multiply();
		return;
	}

	if (iszero(p1)) {
		push_integer(0);
		return;
	}

	// arctanh(-x) = -arctanh(x)

	if (isnegativeterm(p1)) {
		push(p1);
		negate();
		arctanh();
		negate();
		return;
	}

	if (car(p1) == symbol(TANH)) {
		push(cadr(p1));
		return;
	}

	push_symbol(ARCTANH);
	push(p1);
	list(2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
callq 0x868d
movq %rax, %rbx
movb 0x10(%rax), %r14b
cmpb $0x7, %r14b
jne 0xcad3
movq %rbx, %rdi
callq 0x8f1b
movq %rax, %rbx
movq (%rax), %rax
movl 0x64(%rax), %r14d
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
cmpq %r15, %r14
je 0xcb11
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x861b
callq 0xca72
callq 0x868d
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r15,8)
incq %r15
jmp 0xcaaa
movq %rbx, %rdi
callq 0xa95a
testl %eax, %eax
jne 0xcaeb
movq %rbx, %rdi
callq 0xbfac
testl %eax, %eax
je 0xcb23
movq 0x2f69e(%rip), %rdi     # 0x3c190
callq 0x861b
movq %rbx, %rdi
callq 0x861b
pushq $0x2
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x85eb
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x861b
cmpb $0x5, %r14b
jne 0xcb68
movq %rbx, %rdi
callq 0x861b
callq 0x8ae1
movapd 0x165e2(%rip), %xmm1    # 0x23120
andpd %xmm0, %xmm1
movsd 0x165f6(%rip), %xmm2    # 0x23140
ucomisd %xmm1, %xmm2
jbe 0xcb64
callq 0x7060
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xaf59
movb 0x10(%rbx), %r14b
cmpb $0x5, %r14b
je 0xcb7a
movq %rbx, %rdi
callq 0xb876
testl %eax, %eax
je 0xcbd9
movsd 0x165be(%rip), %xmm0    # 0x23140
callq 0xaf59
movq %rbx, %rdi
callq 0x861b
callq 0xa1f6
callq 0xba1b
movsd 0x1659f(%rip), %xmm0    # 0x23140
callq 0xaf59
movq %rbx, %rdi
callq 0x861b
callq 0xb07f
callq 0xba1b
callq 0xb07f
movsd 0x1659b(%rip), %xmm0    # 0x23160
callq 0xaf59
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x9fae
movq %rbx, %rdi
callq 0xa641
testl %eax, %eax
je 0xcbf6
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa426
movq %rbx, %rdi
callq 0x9fd6
testl %eax, %eax
je 0xcc23
movq %rbx, %rdi
callq 0x861b
callq 0x975f
callq 0xca72
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x975f
cmpb $0x1, %r14b
leaq 0x31dc2(%rip), %rax     # 0x3e9f0
movq %rax, %rcx
cmoveq %rbx, %rcx
movq (%rcx), %rcx
cmpq 0x33089(%rip), %rcx     # 0x3fcc8
jne 0xcaeb
addq $0x8, %rbx
cmpb $0x1, %r14b
cmovneq %rax, %rbx
movq (%rbx), %rcx
cmpb $0x1, 0x10(%rcx)
cmoveq %rcx, %rax
movq (%rax), %rdi
jmp 0xcb14