// File: /workspace/github_c_makefile_star2_O0/georgeweigt[P]eigenmath/eigenmath.c
// Function: cosfunc
void
cosfunc(void)
{
	int i, n;
	double d;
	struct atom *p1, *p2, *X, *Y;

	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]);
			cosfunc();
			p1->u.tensor->elem[i] = pop();
		}
		push(p1);
		return;
	}

	if (isdouble(p1)) {
		push(p1);
		d = pop_double();
		d = cos(d);
		push_double(d);
		return;
	}

	// cos(z) = 1/2 exp(i z) + 1/2 exp(-i z)

	if (isdoublez(p1)) {
		push_double(0.5);
		push(imaginaryunit);
		push(p1);
		multiply();
		expfunc();
		push(imaginaryunit);
		negate();
		push(p1);
		multiply();
		expfunc();
		add();
		multiply();
		return;
	}

	// cos(-x) = cos(x)

	if (isnegativeterm(p1)) {
		push(p1);
		negate();
		cosfunc();
		return;
	}

	if (car(p1) == symbol(ADD)) {
		cosfunc_sum(p1);
		return;
	}

	// cos(arctan(y,x)) = x (x^2 + y^2)^(-1/2)

	if (car(p1) == symbol(ARCTAN)) {
		X = caddr(p1);
		Y = cadr(p1);
		push(X);
		push(X);
		push(X);
		multiply();
		push(Y);
		push(Y);
		multiply();
		add();
		push_rational(-1, 2);
		power();
		multiply();
		return;
	}

	// cos(arcsin(x)) = sqrt(1 - x^2)

	if (car(p1) == symbol(ARCSIN)) {
		push_integer(1);
		push(cadr(p1));
		push_integer(2);
		power();
		subtract();
		push_rational(1, 2);
		power();
		return;
	}

	// n pi ?

	push(p1);
	push_symbol(PI);
	divide();
	p2 = pop();

	if (!isnum(p2)) {
		push_symbol(COS);
		push(p1);
		list(2);
		return;
	}

	if (isdouble(p2)) {
		push(p2);
		d = pop_double();
		d = cos(d * M_PI);
		push_double(d);
		return;
	}

	push(p2); // nonnegative by cos(-x) = cos(x) above
	push_integer(180);
	multiply();
	p2 = pop();

	if (!isinteger(p2)) {
		push_symbol(COS);
		push(p1);
		list(2);
		return;
	}

	push(p2);
	push_integer(360);
	modfunc();
	n = pop_integer();

	switch (n) {
	case 90:
	case 270:
		push_integer(0);
		break;
	case 60:
	case 300:
		push_rational(1, 2);
		break;
	case 120:
	case 240:
		push_rational(-1, 2);
		break;
	case 45:
	case 315:
		push_rational(1, 2);
		push_integer(2);
		push_rational(1, 2);
		power();
		multiply();
		break;
	case 135:
	case 225:
		push_rational(-1, 2);
		push_integer(2);
		push_rational(1, 2);
		power();
		multiply();
		break;
	case 30:
	case 330:
		push_rational(1, 2);
		push_integer(3);
		push_rational(1, 2);
		power();
		multiply();
		break;
	case 150:
	case 210:
		push_rational(-1, 2);
		push_integer(3);
		push_rational(1, 2);
		power();
		multiply();
		break;
	case 0:
		push_integer(1);
		break;
	case 180:
		push_integer(-1);
		break;
	default:
		push_symbol(COS);
		push(p1);
		list(2);
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
callq 0x91d0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x7, %eax
jne 0x14285
movq -0x18(%rbp), %rdi
callq 0xa550
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl 0x64(%rax), %eax
movl %eax, -0x8(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x14277
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x4(%rbp), %rcx
movq 0x68(%rax,%rcx,8), %rdi
callq 0x9110
callq 0x141f0
callq 0x91d0
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x4(%rbp), %rcx
movq %rdx, 0x68(%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x14232
movq -0x18(%rbp), %rdi
callq 0x9110
jmp 0x14a41
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x5, %eax
jne 0x142c3
movq -0x18(%rbp), %rdi
callq 0x9110
callq 0x9af0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x7170
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0xe5e0
jmp 0x14a41
movq -0x18(%rbp), %rdi
callq 0xf370
cmpl $0x0, %eax
je 0x14330
movsd 0x30def(%rip), %xmm0    # 0x450c8
callq 0xe5e0
movq 0x1107fb(%rip), %rdi    # 0x124ae0
callq 0x9110
movq -0x18(%rbp), %rdi
callq 0x9110
callq 0xc280
callq 0x14a50
movq 0x1107dc(%rip), %rdi    # 0x124ae0
callq 0x9110
callq 0xb4b0
movq -0x18(%rbp), %rdi
callq 0x9110
callq 0xc280
callq 0x14a50
callq 0xc660
callq 0xc280
jmp 0x14a41
movq -0x18(%rbp), %rdi
callq 0xc2b0
cmpl $0x0, %eax
je 0x14356
movq -0x18(%rbp), %rdi
callq 0x9110
callq 0xb4b0
callq 0x141f0
jmp 0x14a41
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x14370
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x1437b
movq 0x4a689(%rip), %rax     # 0x5ea00
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq 0x4cf1a(%rip), %rax     # 0x612a0
jne 0x14396
movq -0x18(%rbp), %rdi
callq 0x14a70
jmp 0x14a41
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x143b0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x143bb
movq 0x4a649(%rip), %rax     # 0x5ea00
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq 0x47dd2(%rip), %rax     # 0x5c198
jne 0x145c2
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x143e7
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x143f2
movq 0x4a612(%rip), %rax     # 0x5ea00
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x14433
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x1441a
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x14425
movq 0x4a5df(%rip), %rax     # 0x5ea00
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x1443e
movq 0x4a5c6(%rip), %rax     # 0x5ea00
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x144ca
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x14466
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x14471
movq 0x4a593(%rip), %rax     # 0x5ea00
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x144b2
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x14499
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x144a4
movq 0x4a560(%rip), %rax     # 0x5ea00
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x144bd
movq 0x4a547(%rip), %rax     # 0x5ea00
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x144d5
movq 0x4a52f(%rip), %rax     # 0x5ea00
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x144f8
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x14503
movq 0x4a501(%rip), %rax     # 0x5ea00
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x1454f
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x1452e
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x1453c
movq 0x4a4cb(%rip), %rax     # 0x5ea00
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0x1455d
movq 0x4a4aa(%rip), %rax     # 0x5ea00
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x9110
movq -0x28(%rbp), %rdi
callq 0x9110
movq -0x28(%rbp), %rdi
callq 0x9110
callq 0xc280
movq -0x30(%rbp), %rdi
callq 0x9110
movq -0x30(%rbp), %rdi
callq 0x9110
callq 0xc280
callq 0xc660
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xb840
callq 0xb8b0
callq 0xc280
jmp 0x14a41
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x145df
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0x145ed
movq 0x4a41a(%rip), %rax     # 0x5ea00
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq 0x47b8d(%rip), %rax     # 0x5c188
jne 0x146cd
movl $0x1, %edi
callq 0xca50
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x14629
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0x14637
movq 0x4a3d0(%rip), %rax     # 0x5ea00
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x14686
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x14665
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa8(%rbp)
jmp 0x14673
movq 0x4a394(%rip), %rax     # 0x5ea00
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x14694
movq 0x4a373(%rip), %rax     # 0x5ea00
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
callq 0xca50
callq 0xb8b0
callq 0xe7e0
movl $0x1, %edi
movl $0x2, %esi
callq 0xb840
callq 0xb8b0
jmp 0x14a41
movq -0x18(%rbp), %rdi
callq 0x9110
movq 0x4a973(%rip), %rdi     # 0x5f050
callq 0x9110
callq 0x117a0
callq 0x91d0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x4, %eax
je 0x1472e
movq -0x20(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x5, %eax
je 0x1472e
movq 0x480df(%rip), %rdi     # 0x5c7f0
callq 0x9110
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
callq 0x90d0
jmp 0x14a41
movq -0x20(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x5, %eax
jne 0x14774
movq -0x20(%rbp), %rdi
callq 0x9110
callq 0x9af0
movsd %xmm0, -0x10(%rbp)
movsd 0x3094a(%rip), %xmm0    # 0x450a0
mulsd -0x10(%rbp), %xmm0
callq 0x7170
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0xe5e0
jmp 0x14a41
movq -0x20(%rbp), %rdi
callq 0x9110
movl $0xb4, %edi
callq 0xca50
callq 0xc280
callq 0x91d0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x9bc0
cmpl $0x0, %eax
jne 0x147c7
movq 0x48046(%rip), %rdi     # 0x5c7f0
callq 0x9110
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
callq 0x90d0
jmp 0x14a41
movq -0x20(%rbp), %rdi
callq 0x9110
movl $0x168, %edi            # imm = 0x168
callq 0xca50
callq 0x14c60
callq 0x13520
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0xb4(%rbp)
testl %eax, %eax
je 0x14a0a
jmp 0x147fa
movl -0xb4(%rbp), %eax
subl $0x1e, %eax
je 0x149a2
jmp 0x1480b
movl -0xb4(%rbp), %eax
subl $0x2d, %eax
je 0x14934
jmp 0x1481c
movl -0xb4(%rbp), %eax
subl $0x3c, %eax
je 0x1490c
jmp 0x1482d
movl -0xb4(%rbp), %eax
subl $0x5a, %eax
je 0x14900
jmp 0x1483e
movl -0xb4(%rbp), %eax
subl $0x78, %eax
je 0x14920
jmp 0x1484f
movl -0xb4(%rbp), %eax
subl $0x87, %eax
je 0x1496b
jmp 0x14862
movl -0xb4(%rbp), %eax
subl $0x96, %eax
je 0x149d6
jmp 0x14875
movl -0xb4(%rbp), %eax
subl $0xb4, %eax
je 0x14a16
jmp 0x14888
movl -0xb4(%rbp), %eax
subl $0xd2, %eax
je 0x149d6
jmp 0x1489b
movl -0xb4(%rbp), %eax
subl $0xe1, %eax
je 0x1496b
jmp 0x148ae
movl -0xb4(%rbp), %eax
subl $0xf0, %eax
je 0x14920
jmp 0x148bd
movl -0xb4(%rbp), %eax
subl $0x10e, %eax            # imm = 0x10E
je 0x14900
jmp 0x148cc
movl -0xb4(%rbp), %eax
subl $0x12c, %eax            # imm = 0x12C
je 0x1490c
jmp 0x148db
movl -0xb4(%rbp), %eax
subl $0x13b, %eax            # imm = 0x13B
je 0x14934
jmp 0x148ea
movl -0xb4(%rbp), %eax
subl $0x14a, %eax            # imm = 0x14A
je 0x149a2
jmp 0x14a22
xorl %edi, %edi
callq 0xca50
jmp 0x14a41
movl $0x1, %edi
movl $0x2, %esi
callq 0xb840
jmp 0x14a41
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xb840
jmp 0x14a41
movl $0x1, %edi
movl $0x2, %esi
callq 0xb840
movl $0x2, %edi
callq 0xca50
movl $0x1, %edi
movl $0x2, %esi
callq 0xb840
callq 0xb8b0
callq 0xc280
jmp 0x14a41
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xb840
movl $0x2, %edi
callq 0xca50
movl $0x1, %edi
movl $0x2, %esi
callq 0xb840
callq 0xb8b0
callq 0xc280
jmp 0x14a41
movl $0x1, %edi
movl $0x2, %esi
callq 0xb840
movl $0x3, %edi
callq 0xca50
movl $0x1, %edi
movl $0x2, %esi
callq 0xb840
callq 0xb8b0
callq 0xc280
jmp 0x14a41
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xb840
movl $0x3, %edi
callq 0xca50
movl $0x1, %edi
movl $0x2, %esi
callq 0xb840
callq 0xb8b0
callq 0xc280
jmp 0x14a41
movl $0x1, %edi
callq 0xca50
jmp 0x14a41
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
jmp 0x14a41
movq 0x47dc7(%rip), %rdi     # 0x5c7f0
callq 0x9110
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
callq 0x90d0
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)