// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x30fd0(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0xe572
decl %eax
movl %eax, 0x30fb8(%rip)     # 0x3f2b8
leaq 0x3a2b9(%rip), %r15     # 0x485c0
movq (%r15,%rax,8), %rbx
movb 0x10(%rbx), %r14b
cmpb $0x7, %r14b
jne 0xe38c
movq %rbx, %rdi
callq 0x9638
movq %rax, %rbx
movq (%rax), %rax
movslq 0x64(%rax), %r14
testq %r14, %r14
jle 0xe376
xorl %r12d, %r12d
movl $0xfffe795f, %r13d      # imm = 0xFFFE795F
movq (%rbx), %rax
movq 0x68(%rax,%r12,8), %rdi
callq 0x8ba5
callq 0xe2d4
movl 0x30f6b(%rip), %eax     # 0x3f2b8
leal (%rax,%r13), %ecx
cmpl %r13d, %ecx
jbe 0xe572
decl %eax
movl %eax, 0x30f56(%rip)     # 0x3f2b8
movq (%r15,%rax,8), %rax
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r12,8)
incq %r12
cmpq %r12, %r14
jne 0xe335
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
jne 0xe3b8
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
je 0xe3e4
movq 0x34de1(%rip), %rdi     # 0x431a0
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8b7d
cmpb $0x5, %r14b
jne 0xe439
movq %rbx, %rdi
callq 0x8ba5
callq 0x9128
movapd 0x1bd21(%rip), %xmm1    # 0x2a120
andpd %xmm0, %xmm1
movsd 0x1bd25(%rip), %xmm2    # 0x2a130
ucomisd %xmm1, %xmm2
jbe 0xe435
callq 0x7060
movsd %xmm0, -0x30(%rbp)
callq 0x74dc
movb $0x5, 0x10(%rax)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %rax, %rdi
jmp 0xe379
movb 0x10(%rbx), %r14b
cmpb $0x5, %r14b
je 0xe44f
movq %rbx, %rdi
callq 0xca1c
testl %eax, %eax
je 0xe4e8
callq 0x74dc
movb $0x5, %r14b
movb %r14b, 0x10(%rax)
movabsq $0x3ff0000000000000, %r15 # imm = 0x3FF0000000000000
movq %r15, (%rax)
movq %rax, %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xadb3
callq 0xcbe3
callq 0x74dc
movb %r14b, 0x10(%rax)
movq %r15, (%rax)
movq %rax, %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
callq 0xbfb4
callq 0xcbe3
callq 0xbfb4
callq 0x74dc
movb %r14b, 0x10(%rax)
movabsq $0x3fe0000000000000, %rcx # imm = 0x3FE0000000000000
movq %rcx, (%rax)
movq %rax, %rdi
callq 0x8ba5
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xacef
movq %rbx, %rdi
callq 0xb477
testl %eax, %eax
je 0xe500
movq 0x34c45(%rip), %rdi     # 0x43140
jmp 0xe379
movq %rbx, %rdi
callq 0xac49
testl %eax, %eax
je 0xe531
movq %rbx, %rdi
callq 0x8ba5
callq 0xa1a2
callq 0xe2d4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa1a2
cmpb $0x1, %r14b
leaq 0x374c4(%rip), %rax     # 0x45a00
movq %rax, %rcx
cmoveq %rbx, %rcx
movq (%rcx), %rcx
cmpq 0x3878b(%rip), %rcx     # 0x46cd8
jne 0xe3b8
addq $0x8, %rbx
cmpb $0x1, %r14b
cmovneq %rax, %rbx
movq (%rbx), %rcx
cmpb $0x1, 0x10(%rcx)
cmoveq %rcx, %rax
movq (%rax), %rdi
jmp 0xe379
leaq 0x209c8(%rip), %rdi     # 0x2ef41
callq 0x780b