// File: /workspace/github_c_makefile_star2_O1/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 0x8b78
movq %rax, %rbx
movb 0x10(%rax), %r14b
cmpb $0x7, %r14b
jne 0xda8b
movq %rbx, %rdi
callq 0x953d
movq %rax, %rbx
movq (%rax), %rax
movslq 0x64(%rax), %r14
testq %r14, %r14
jle 0xda79
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x8b01
callq 0xda1c
callq 0x8b78
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0xda52
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8b01
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
jne 0xdab7
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
je 0xdadf
movq 0x306e2(%rip), %rdi     # 0x3e1a0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8ad9
cmpb $0x5, %r14b
jne 0xdb30
movq %rbx, %rdi
callq 0x8b01
callq 0x9086
movapd 0x18606(%rip), %xmm1    # 0x26100
andpd %xmm0, %xmm1
movsd 0x1860a(%rip), %xmm2    # 0x26110
ucomisd %xmm1, %xmm2
jbe 0xdb30
callq 0x7060
movsd %xmm0, -0x20(%rbp)
callq 0x74ec
movb $0x5, 0x10(%rax)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %rax, %rdi
jmp 0xda7c
movb 0x10(%rbx), %r14b
cmpb $0x5, %r14b
je 0xdb4a
movq %rbx, %rdi
callq 0xc3a9
testl %eax, %eax
je 0xdbdf
callq 0x74ec
movb $0x5, %r14b
movb %r14b, 0x10(%rax)
movabsq $0x3ff0000000000000, %r15 # imm = 0x3FF0000000000000
movq %r15, (%rax)
movq %rax, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa975
callq 0xc5b0
callq 0x74ec
movb %r14b, 0x10(%rax)
movq %r15, (%rax)
movq %rax, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
callq 0xba6d
callq 0xc5b0
callq 0xba6d
callq 0x74ec
movb %r14b, 0x10(%rax)
movabsq $0x3fe0000000000000, %rcx # imm = 0x3FE0000000000000
movq %rcx, (%rax)
movq %rax, %rdi
callq 0x8b01
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa8bb
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
je 0xdbf7
movq 0x3054e(%rip), %rdi     # 0x3e140
jmp 0xda7c
movq %rbx, %rdi
callq 0xa813
testl %eax, %eax
je 0xdc24
movq %rbx, %rdi
callq 0x8b01
callq 0x9ec9
callq 0xda1c
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x9ec9
cmpb $0x1, %r14b
leaq 0x32dd1(%rip), %rax     # 0x40a00
movq %rax, %rcx
cmoveq %rbx, %rcx
movq (%rcx), %rcx
cmpq 0x34098(%rip), %rcx     # 0x41cd8
jne 0xdab7
addq $0x8, %rbx
cmpb $0x1, %r14b
cmovneq %rax, %rbx
movq (%rbx), %rcx
cmpb $0x1, 0x10(%rcx)
cmoveq %rcx, %rax
movq (%rax), %rdi
jmp 0xda7c