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

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

	// sin(z) = -i/2 exp(i z) + i/2 exp(-i z)

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

	// sin(-x) = -sin(x)

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

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

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

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

	// sin(arccos(x)) = sqrt(1 - x^2)

	if (car(p1) == symbol(ARCCOS)) {
		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(SIN);
		push(p1);
		list(2);
		return;
	}

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

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

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

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
callq 0x8b78
movq %rax, %rbx
movzbl 0x10(%rax), %r15d
cmpl $0x5, %r15d
je 0xfb4b
cmpl $0x7, %r15d
jne 0xfb86
movq %rbx, %rdi
callq 0x953d
movq %rax, %rbx
movq (%rax), %rax
movslq 0x64(%rax), %r14
testq %r14, %r14
jle 0xfb46
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x8b01
callq 0xfade
callq 0x8b78
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0xfb1f
movq %rbx, %rdi
jmp 0xfb77
movq %rbx, %rdi
callq 0x8b01
callq 0x9086
callq 0x72f0
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 0xc3a9
testl %eax, %eax
je 0xfc6a
callq 0x74ec
movb $0x5, 0x10(%rax)
movabsq $-0x4020000000000000, %rcx # imm = 0xBFE0000000000000
movq %rcx, (%rax)
movq %rax, %rdi
callq 0x8b01
movq 0xf6f25(%rip), %rdi     # 0x106ae0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq 0xf6f0f(%rip), %rdi     # 0x106ae0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq 0x336d9(%rip), %rdi     # 0x432c8
callq 0x8b01
callq 0xad38
callq 0xa234
movq 0xf6edb(%rip), %rdi     # 0x106ae0
callq 0x8b01
movq 0x1017df(%rip), %rdi    # 0x1113f0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq 0x3368f(%rip), %rdi     # 0x432c8
callq 0x8b01
callq 0xad38
callq 0xa234
movq 0x1017a1(%rip), %rdi    # 0x1113f0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movl $0x2, %edi
callq 0xa975
jmp 0xfca5
movq %rbx, %rdi
callq 0xa813
testl %eax, %eax
je 0xfcb9
movq %rbx, %rdi
callq 0x8b01
movq 0x10176b(%rip), %rdi    # 0x1113f0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
callq 0xfade
movq 0x101750(%rip), %rdi    # 0x1113f0
callq 0x8b01
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa8bb
cmpb $0x1, %r15b
leaq 0x30d3c(%rip), %r14     # 0x40a00
movq %r14, %rax
cmoveq %rbx, %rax
movq (%rax), %rax
cmpq 0x335cb(%rip), %rax     # 0x432a0
je 0xfd42
cmpq 0x2e4ba(%rip), %rax     # 0x3e198
je 0xfd54
cmpq 0x2e491(%rip), %rax     # 0x3e178
je 0xfdfd
movq %rbx, %rdi
callq 0x8b01
movq 0x31354(%rip), %rdi     # 0x41050
callq 0x8b01
callq 0xd9a4
callq 0x8b78
movb 0x10(%rax), %r14b
movl %r14d, %ecx
andb $-0x2, %cl
cmpb $0x4, %cl
jne 0xffbe
movq %rax, %rdi
callq 0x8b01
cmpb $0x5, %r14b
jne 0xfe67
callq 0x9086
mulsd 0x163e3(%rip), %xmm0    # 0x26120
jmp 0xfb58
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1f01d
addq $0x8, %rbx
cmpb $0x1, %r15b
cmovneq %r14, %rbx
movq (%rbx), %rax
movb 0x10(%rax), %cl
leaq 0x8(%rax), %rdx
cmpb $0x1, %cl
movq %r14, %rsi
cmoveq %rdx, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
movq %r14, %rsi
jne 0xfd91
cmpb $0x1, %cl
leaq 0x30c76(%rip), %rsi     # 0x40a00
cmoveq %rdx, %rsi
movq (%rsi), %rsi
cmpb $0x1, %cl
movq (%rsi), %rbx
cmoveq %rax, %r14
movq (%r14), %r14
movq %r14, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq %r14, %rdi
callq 0x8b01
movq %r14, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movl $0x2, %edi
callq 0xa975
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa1f4
callq 0xa234
jmp 0xfca5
movq 0xf6cd4(%rip), %rdi     # 0x106ad8
callq 0x8b01
movq %rbx, %rax
addq $0x8, %rax
cmpb $0x1, 0x10(%rbx)
cmovneq %r14, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmoveq %rax, %r14
movq (%r14), %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xacbe
callq 0xa234
callq 0x9ec9
movl $0x2, %edi
callq 0xa975
movl $0x1, %edi
movl $0x2, %esi
callq 0xa1f4
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa234
movl $0xb4, %edi
callq 0xacbe
movl $0x2, %edi
callq 0xa8bb
callq 0x8b78
cmpb $0x4, 0x10(%rax)
jne 0xffbe
movq 0x8(%rax), %rcx
cmpl $0x1, -0x4(%rcx)
jne 0xffbe
cmpl $0x1, (%rcx)
jne 0xffbe
movq %rax, %rdi
callq 0x8b01
movl $0x168, %edi            # imm = 0x168
callq 0xacbe
callq 0xf98a
callq 0xeb5b
cmpl $0xb3, %eax
jg 0xfee4
cmpl $0x59, %eax
jg 0xff0d
cmpl $0x2c, %eax
jg 0xff42
testl %eax, %eax
je 0xffe6
cmpl $0x1e, %eax
je 0xff90
jmp 0xffbe
cmpl $0x10d, %eax            # imm = 0x10D
jg 0xff27
cmpl $0xe0, %eax
jg 0xff57
cmpl $0xb4, %eax
je 0xffe6
cmpl $0xd2, %eax
je 0xffa5
jmp 0xffbe
cmpl $0x86, %eax
jg 0xff82
cmpl $0x5a, %eax
je 0x1001c
cmpl $0x78, %eax
je 0xff50
jmp 0xffbe
cmpl $0x13a, %eax            # imm = 0x13A
jg 0xff97
cmpl $0x10e, %eax            # imm = 0x10E
je 0x10028
cmpl $0x12c, %eax            # imm = 0x12C
je 0xff69
jmp 0xffbe
cmpl $0x2d, %eax
je 0xfff2
cmpl $0x3c, %eax
jne 0xffbe
movl $0x1, %edi
jmp 0xff6e
cmpl $0xe1, %eax
je 0xfff9
cmpl $0xf0, %eax
jne 0xffbe
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa1f4
movl $0x3, %edi
jmp 0x1000d
cmpl $0x87, %eax
je 0xfff2
cmpl $0x96, %eax
jne 0xffbe
movl $0x1, %edi
jmp 0xffaa
cmpl $0x13b, %eax            # imm = 0x13B
je 0xfff9
cmpl $0x14a, %eax            # imm = 0x14A
jne 0xffbe
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa1f4
movq 0x319fb(%rip), %rdi     # 0x419c0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8ad9
movq 0x2e153(%rip), %rdi     # 0x3e140
jmp 0xfb77
movl $0x1, %edi
jmp 0xfffe
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa1f4
movl $0x2, %edi
callq 0xacbe
movl $0x1, %edi
jmp 0xfde9
movq 0xf6ab5(%rip), %rdi     # 0x106ad8
jmp 0xfb77
movq 0x1013c1(%rip), %rdi    # 0x1113f0
jmp 0xfb77