// File: /workspace/github_c_makefile_star2_O3/georgeweigt[P]eigenmath/eigenmath.c
// Function: eval_product
void
eval_product(struct atom *p1)
{
	int h, i, j, k, n;
	struct atom *p2, *p3;

	// product of tensor elements?

	if (lengthf(p1) == 2) {
		push(cadr(p1));
		evalf();
		p1 = pop();
		if (!istensor(p1)) {
			push(p1);
			return;
		}
		n = p1->u.tensor->nelem;
		for (i = 0; i < n; i++)
			push(p1->u.tensor->elem[i]);
		multiply_factors(n);
		return;
	}

	p2 = cadr(p1);
	if (!isusersymbol(p2))
		stopf("product: index symbol err");

	push(caddr(p1));
	evalf();
	p3 = pop();
	if (!issmallinteger(p3))
		stopf("product: index range err");
	push(p3);
	j = pop_integer();

	push(cadddr(p1));
	evalf();
	p3 = pop();
	if (!issmallinteger(p3))
		stopf("product: index range err");
	push(p3);
	k = pop_integer();

	p1 = caddddr(p1);

	save_symbol(p2);

	h = tos;

	for (;;) {
		push_integer(j);
		p3 = pop();
		set_symbol(p2, p3, symbol(NIL));
		push(p1);
		evalg();
		if (j == k)
			break;
		if (j < k)
			j++;
		else
			j--;
		if (tos - h == 1000)
			multiply_factors(1000); // to prevent stack overflow
	}

	multiply_factors(tos - h);

	p1 = pop();
	restore_symbol();
	push(p1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movb 0x10(%rdi), %al
cmpb $0x1, %al
jne 0x1ea52
movl $0x2, %ecx
movq %r15, %rdx
movq 0x8(%rdx), %rdx
decl %ecx
cmpb $0x1, 0x10(%rdx)
je 0x1ea3e
testl %ecx, %ecx
je 0x1eb70
leaq 0x8(%r15), %r13
cmpb $0x1, %al
leaq 0x26fa1(%rip), %rax     # 0x45a00
movq %rax, %rcx
cmoveq %r13, %rcx
movq (%rcx), %rcx
movb 0x10(%rcx), %dl
cmpb $0x1, %dl
movq %rax, %rsi
cmoveq %rcx, %rsi
movq (%rsi), %rbx
cmpb $0x3, 0x10(%rbx)
jne 0x1eee0
cmpb $0x1, %dl
jne 0x1ea8e
movq 0x8(%rcx), %rcx
jmp 0x1ea95
movq 0x26f6b(%rip), %rcx     # 0x45a00
cmpb $0x1, 0x10(%rcx)
jne 0x1ea9e
movq %rcx, %rax
movq (%rax), %rdi
callq 0x8ba5
callq 0x96e2
movl 0x20807(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x1eebc
decl %eax
movl %eax, 0x207ef(%rip)     # 0x3f2b8
leaq 0x29af0(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %r14
movq %r14, %rdi
callq 0x15ac2
testl %eax, %eax
je 0x1eed4
movq %r14, %rdi
callq 0x8ba5
callq 0xf8e6
cmpb $0x1, 0x10(%r15)
leaq 0x26f03(%rip), %rcx     # 0x45a00
movq %rcx, %rdx
cmoveq %r13, %rdx
movl %eax, %r14d
movq (%rdx), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1eb20
movq 0x8(%rax), %rdx
cmpb $0x1, 0x10(%rdx)
jne 0x1eb48
movq 0x8(%rdx), %rdx
jmp 0x1eb4f
movq 0x26ed9(%rip), %rax     # 0x45a00
cmpb $0x1, 0x10(%rax)
jne 0x1ec07
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1ec07
movq 0x26eba(%rip), %rax     # 0x45a00
jmp 0x1eb5d
movq 0x26eb1(%rip), %rdx     # 0x45a00
cmpb $0x1, 0x10(%rdx)
jne 0x1ec07
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1ebfd
addq $0x8, %rax
jmp 0x1ec04
movq 0x8(%r15), %rax
cmpb $0x1, 0x10(%rax)
leaq 0x26e81(%rip), %rcx     # 0x45a00
cmoveq %rax, %rcx
movq (%rcx), %rdi
callq 0x8ba5
callq 0x96e2
movl 0x20722(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x1eebc
decl %eax
movl %eax, 0x2070a(%rip)     # 0x3f2b8
leaq 0x29a0b(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rbx
cmpb $0x7, 0x10(%rbx)
jne 0x1ee9a
movq (%rbx), %rax
movslq 0x64(%rax), %r14
testq %r14, %r14
jle 0x1ebe7
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x8ba5
incq %r15
cmpq %r15, %r14
jne 0x1ebd2
movl %r14d, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xacef
leaq 0x26dfc(%rip), %rax     # 0x45a00
movq (%rax), %rcx
movq (%rcx), %rdi
callq 0x8ba5
callq 0x96e2
movl 0x2069e(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x1eebc
decl %eax
movl %eax, 0x20686(%rip)     # 0x3f2b8
leaq 0x29987(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %r12
movq %r12, %rdi
callq 0x15ac2
testl %eax, %eax
je 0x1eed4
movq %r12, %rdi
callq 0x8ba5
callq 0xf8e6
cmpb $0x1, 0x10(%r15)
leaq 0x26d9a(%rip), %rcx     # 0x45a00
cmovneq %rcx, %r13
movl %eax, -0x2c(%rbp)
movq (%r13), %rax
movb 0x10(%rax), %dl
cmpb $0x1, %dl
jne 0x1ec96
movq 0x8(%rax), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1eccb
movq 0x8(%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
je 0x1ecd8
leaq 0x26d6c(%rip), %rsi     # 0x45a00
jmp 0x1eced
movq 0x26d63(%rip), %rsi     # 0x45a00
cmpb $0x1, 0x10(%rsi)
jne 0x1edad
movq 0x8(%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
movq 0x26d4a(%rip), %rsi     # 0x45a00
movb 0x10(%rsi), %dil
jne 0x1ed01
cmpb $0x1, %dil
je 0x1ece2
leaq 0x26d37(%rip), %rsi     # 0x45a00
jmp 0x1ece6
movq 0x26d2e(%rip), %rsi     # 0x45a00
cmpb $0x1, 0x10(%rsi)
jne 0x1ed2f
movq 0x8(%rax), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1ecc2
addq $0x8, %rsi
movq (%rsi), %rsi
addq $0x8, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1edad
cmpb $0x1, %dl
jne 0x1ed0b
jmp 0x1ed3c
cmpb $0x1, %dil
jne 0x1edad
movq 0x26cee(%rip), %rcx     # 0x45a00
leaq 0x26ce7(%rip), %rax     # 0x45a00
cmpb $0x1, 0x10(%rcx)
jne 0x1edaa
movq 0x8(%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
je 0x1ed7f
jmp 0x1edaa
movq 0x26cca(%rip), %rsi     # 0x45a00
cmpb $0x1, 0x10(%rsi)
jne 0x1edad
movq 0x8(%rax), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x1ed69
movq 0x8(%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x1eda3
cmpb $0x1, %dl
jne 0x1ed7f
movq 0x8(%rax), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x1eeb0
addq $0x8, %rax
jmp 0x1ed93
leaq 0x26c90(%rip), %rax     # 0x45a00
movq 0x26c89(%rip), %rcx     # 0x45a00
cmpb $0x1, 0x10(%rcx)
je 0x1ed9a
jmp 0x1edaa
leaq 0x26c7a(%rip), %rax     # 0x45a00
movq 0x26c73(%rip), %rcx     # 0x45a00
cmpb $0x1, 0x10(%rcx)
jne 0x1ed9a
movq (%rax), %rax
addq $0x8, %rax
movq (%rax), %rax
addq $0x8, %rax
jmp 0x1edaa
leaq 0x26c56(%rip), %rax     # 0x45a00
movq (%rax), %rcx
movq (%rcx), %r12
movq %rbx, %rdi
callq 0xf3a6
movl 0x204f9(%rip), %r13d    # 0x3f2b8
movl %r14d, %edi
callq 0xb1be
movl 0x204eb(%rip), %eax     # 0x3f2b8
leal -0x186a1(%rax), %ecx
cmpl $0xfffe7960, %ecx       # imm = 0xFFFE7960
jb 0x1eebc
decl %eax
movl %eax, 0x204d1(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rbx)
jne 0x1eec8
movq 0x26c08(%rip), %rcx     # 0x45a00
movl %eax, %eax
leaq 0x297bf(%rip), %rdx     # 0x485c0
movq (%rdx,%rax,8), %rax
movl 0x8(%rbx), %edx
leaq 0xecce1(%rip), %rsi     # 0x10baf0
movq %rax, (%rsi,%rdx,8)
movl 0x8(%rbx), %eax
leaq 0xf2133(%rip), %rdx     # 0x110f50
movq %rcx, (%rdx,%rax,8)
movq %r12, %rdi
callq 0x8ba5
callq 0x96a4
cmpl -0x2c(%rbp), %r14d
je 0x1ee62
setl %r15b
movl 0x2047a(%rip), %eax     # 0x3f2b8
subl %r13d, %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jne 0x1ee52
movl $0x3e8, %edi            # imm = 0x3E8
callq 0xacef
movzbl %r15b, %eax
leal (%r14,%rax,2), %r14d
decl %r14d
jmp 0x1edbf
movl 0x20450(%rip), %edi     # 0x3f2b8
subl %r13d, %edi
callq 0xacef
movl 0x20442(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x1eebc
decl %eax
movl %eax, 0x2042e(%rip)     # 0x3f2b8
leaq 0x2972f(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rbx
callq 0xf40c
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
leaq 0x26b49(%rip), %rax     # 0x45a00
jmp 0x1ed9a
leaq 0x1007e(%rip), %rdi     # 0x2ef41
callq 0x780b
leaq 0x100cb(%rip), %rdi     # 0x2ef9a
callq 0x780b
leaq 0xfa70(%rip), %rdi      # 0x2e94b
callq 0x780b
leaq 0xfa4a(%rip), %rdi      # 0x2e931
callq 0x780b