// File: /workspace/github_c_makefile_star2_O1/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 0x8b78
movq %rax, %rbx
movzbl 0x10(%rax), %eax
cmpl $0x5, %eax
je 0xc18c
cmpl $0x7, %eax
jne 0xc1b7
movq %rbx, %rdi
callq 0x953d
movq %rax, %rbx
movq (%rax), %rax
movslq 0x64(%rax), %r14
testq %r14, %r14
jle 0xc184
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x8b01
callq 0xc123
callq 0x8b78
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0xc15d
movq %rbx, %rdi
jmp 0xc2a0
movq %rbx, %rdi
callq 0x8b01
callq 0x9086
movapd 0x19f5f(%rip), %xmm1    # 0x26100
andpd %xmm0, %xmm1
movsd 0x19f63(%rip), %xmm2    # 0x26110
ucomisd %xmm1, %xmm2
jae 0xc281
cmpb $0x5, 0x10(%rbx)
je 0xc1cd
movq %rbx, %rdi
callq 0xc3a9
testl %eax, %eax
je 0xc2af
callq 0x74ec
movb $0x5, 0x10(%rax)
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq %rax, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
callq 0xba6d
movl $0x1, %edi
movl $0x2, %esi
callq 0xa1f4
callq 0xa234
movq 0xfa8bb(%rip), %rdi     # 0x106ae0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa975
callq 0xc5b0
movq 0xfa88e(%rip), %rdi     # 0x106ae0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq 0x105188(%rip), %rdi    # 0x1113f0
callq 0x8b01
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa8bb
callq 0x7180
movsd %xmm0, -0x20(%rbp)
callq 0x74ec
movb $0x5, 0x10(%rax)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8b01
movq %rbx, %rdi
callq 0xca14
testl %eax, %eax
je 0xc2c2
movl $0x1, %edi
jmp 0xc2d3
movq %rbx, %rdi
callq 0xcac2
testl %eax, %eax
je 0xc2e6
movl $0x3, %edi
movl $0x4, %esi
callq 0xa1f4
movq 0x34d6c(%rip), %rdi     # 0x41050
jmp 0xc268
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
je 0xc2fe
movl $0x1, %edi
movl $0x2, %esi
jmp 0xc2d8
movq %rbx, %rdi
movl $0x1, %esi
movl $0x2, %edx
callq 0xcb82
testl %eax, %eax
je 0xc320
movl $0x1, %edi
movl $0x3, %esi
jmp 0xc2d8
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
je 0xc342
movq 0x31e03(%rip), %rdi     # 0x3e140
jmp 0xc2a0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x2, %edx
callq 0xcb82
testl %eax, %eax
je 0xc35f
movl $0x2, %edi
jmp 0xc319
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
je 0xc381
movq 0x34cd4(%rip), %rdi     # 0x41050
jmp 0xc2a0
movq 0x31df0(%rip), %rdi     # 0x3e178
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8ad9