// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]eigenmath/eigenmath.c
// Function: arccos
void
arccos(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]);
			arccos();
			p1->u.tensor->elem[i] = pop();
		}
		push(p1);
		return;
	}

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

	// arccos(z) = -i log(z + i sqrt(1 - z^2))

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

	// arccos(1 / sqrt(2)) = 1/4 pi

	if (isoneoversqrttwo(p1)) {
		push_rational(1, 4);
		push_symbol(PI);
		multiply();
		return;
	}

	// arccos(-1 / sqrt(2)) = 3/4 pi

	if (isminusoneoversqrttwo(p1)) {
		push_rational(3, 4);
		push_symbol(PI);
		multiply();
		return;
	}

	// arccos(0) = 1/2 pi

	if (iszero(p1)) {
		push_rational(1, 2);
		push_symbol(PI);
		multiply();
		return;
	}

	// arccos(1/2) = 1/3 pi

	if (isequalq(p1, 1 ,2)) {
		push_rational(1, 3);
		push_symbol(PI);
		multiply();
		return;
	}

	// arccos(1) = 0

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

	// arccos(-1/2) = 2/3 pi

	if (isequalq(p1, -1, 2)) {
		push_rational(2, 3);
		push_symbol(PI);
		multiply();
		return;
	}

	// arccos(-1) = pi

	if (isminusone(p1)) {
		push_symbol(PI);
		return;
	}

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
callq 0x868d
movq %rax, %rbx
movzbl 0x10(%rax), %eax
cmpl $0x5, %eax
je 0xb6d3
cmpl $0x7, %eax
jne 0xb704
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 0xb6c1
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x861b
callq 0xb658
callq 0x868d
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r15,8)
incq %r15
jmp 0xb698
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x861b
movq %rbx, %rdi
callq 0x861b
callq 0x8ae1
movapd 0x17a38(%rip), %xmm1    # 0x23120
andpd %xmm0, %xmm1
movsd 0x17a4c(%rip), %xmm2    # 0x23140
ucomisd %xmm1, %xmm2
jae 0xb783
cmpb $0x5, 0x10(%rbx)
je 0xb714
movq %rbx, %rdi
callq 0xb876
testl %eax, %eax
je 0xb797
movsd 0x17a24(%rip), %xmm0    # 0x23140
callq 0xaf59
movq %rbx, %rdi
callq 0x861b
movq %rbx, %rdi
callq 0x861b
callq 0x9fae
callq 0xb07f
callq 0xba06
movq 0xf9389(%rip), %rdi     # 0x104ad0
callq 0x861b
callq 0x9fae
movq %rbx, %rdi
callq 0x861b
callq 0xa1f6
callq 0xba1b
movq 0xf9366(%rip), %rdi     # 0x104ad0
callq 0x861b
callq 0x9fae
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x975f
callq 0x7180
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xaf59
movq %rbx, %rdi
callq 0xbe16
testl %eax, %eax
je 0xb7a7
pushq $0x1
jmp 0xb7b5
movq %rbx, %rdi
callq 0xbeab
testl %eax, %eax
je 0xb7d9
pushq $0x3
popq %rdi
pushq $0x4
popq %rsi
callq 0x9a47
movq 0x3387b(%rip), %rdi     # 0x3f040
callq 0x861b
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x9fae
movq %rbx, %rdi
callq 0xa641
testl %eax, %eax
je 0xb7ec
pushq $0x1
popq %rdi
pushq $0x2
jmp 0xb7b8
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0xbf44
testl %eax, %eax
je 0xb805
pushq $0x1
popq %rdi
pushq $0x3
jmp 0xb7b8
movq %rbx, %rdi
callq 0xa95a
testl %eax, %eax
je 0xb822
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa426
pushq $-0x1
popq %rsi
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0xbf44
testl %eax, %eax
je 0xb838
pushq $0x2
jmp 0xb800
movq %rbx, %rdi
callq 0xbfac
testl %eax, %eax
je 0xb850
movq 0x337f5(%rip), %rdi     # 0x3f040
jmp 0xb6c4
movq 0x30911(%rip), %rdi     # 0x3c168
callq 0x861b
movq %rbx, %rdi
callq 0x861b
pushq $0x2
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x85eb