// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x32b6f(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0xca10
decl %eax
movl %eax, 0x32b57(%rip)     # 0x3f2b8
leaq 0x3be58(%rip), %r14     # 0x485c0
movq (%r14,%rax,8), %rbx
movzbl 0x10(%rbx), %eax
cmpl $0x5, %eax
je 0xc7e7
cmpl $0x7, %eax
jne 0xc818
movq %rbx, %rdi
callq 0x9638
movq %rax, %rbx
movq (%rax), %rax
movslq 0x64(%rax), %r15
testq %r15, %r15
jle 0xc7df
xorl %r12d, %r12d
movl $0xfffe795f, %r13d      # imm = 0xFFFE795F
movq (%rbx), %rax
movq 0x68(%rax,%r12,8), %rdi
callq 0x8ba5
callq 0xc735
movl 0x32b02(%rip), %eax     # 0x3f2b8
leal (%rax,%r13), %ecx
cmpl %r13d, %ecx
jbe 0xca10
decl %eax
movl %eax, 0x32aed(%rip)     # 0x3f2b8
movq (%r14,%rax,8), %rax
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xc79e
movq %rbx, %rdi
jmp 0xc8e4
movq %rbx, %rdi
callq 0x8ba5
callq 0x9128
movapd 0x1d924(%rip), %xmm1    # 0x2a120
andpd %xmm0, %xmm1
movsd 0x1d928(%rip), %xmm2    # 0x2a130
ucomisd %xmm1, %xmm2
jae 0xc8c5
cmpb $0x5, 0x10(%rbx)
je 0xc828
movq %rbx, %rdi
callq 0xca1c
testl %eax, %eax
je 0xc8f7
callq 0x74dc
movb $0x5, 0x10(%rax)
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq %rax, %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xacef
callq 0xbfb4
movl $0x1, %edi
movl $0x2, %esi
callq 0xa533
callq 0xa573
movq 0xff260(%rip), %rdi     # 0x10bae0
callq 0x8ba5
movl $0x2, %edi
callq 0xacef
movq %rbx, %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xadb3
callq 0xcbe3
movq 0xff233(%rip), %rdi     # 0x10bae0
callq 0x8ba5
movl $0x2, %edi
callq 0xacef
movq 0x109b2d(%rip), %rdi    # 0x1163f0
jmp 0xc92c
callq 0x7180
movsd %xmm0, -0x30(%rbp)
callq 0x74dc
movb $0x5, 0x10(%rax)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
movq %rbx, %rdi
callq 0xd095
testl %eax, %eax
je 0xc90a
movl $0x1, %edi
jmp 0xc91b
movq %rbx, %rdi
callq 0xd12d
testl %eax, %eax
je 0xc949
movl $0x3, %edi
movl $0x4, %esi
callq 0xa533
movq 0x39724(%rip), %rdi     # 0x46050
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 0xc961
movl $0x1, %edi
movl $0x2, %esi
jmp 0xc920
movq %rbx, %rdi
movl $0x1, %esi
movl $0x2, %edx
callq 0xd1c4
testl %eax, %eax
je 0xc983
movl $0x1, %edi
movl $0x3, %esi
jmp 0xc920
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
je 0xc9a5
movq 0x367a0(%rip), %rdi     # 0x43140
jmp 0xc8e4
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x2, %edx
callq 0xd1c4
testl %eax, %eax
je 0xc9c2
movl $0x2, %edi
jmp 0xc97c
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
je 0xc9e4
movq 0x39671(%rip), %rdi     # 0x46050
jmp 0xc8e4
movq 0x3678d(%rip), %rdi     # 0x43178
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
leaq 0x2252a(%rip), %rdi     # 0x2ef41
callq 0x780b