// File: /workspace/github_c_makefile_star2_O1/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 0x1c794
movl $0x2, %ecx
movq %r15, %rdx
movq 0x8(%rdx), %rdx
decl %ecx
cmpb $0x1, 0x10(%rdx)
je 0x1c780
testl %ecx, %ecx
je 0x1caa7
leaq 0x8(%r15), %r13
cmpb $0x1, %al
leaq 0x2425f(%rip), %rax     # 0x40a00
movq %rax, %rcx
cmoveq %r13, %rcx
movq (%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
cmovneq %rax, %rcx
movq (%rcx), %rbx
cmpb $0x3, 0x10(%rbx)
jne 0x1cb30
cmpb $0x1, 0x10(%r15)
movq %rax, %rcx
cmoveq %r13, %rcx
movq (%rcx), %rcx
movb 0x10(%rcx), %dl
addq $0x8, %rcx
cmpb $0x1, %dl
movq %rax, %rsi
cmoveq %rcx, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1c7fa
cmpb $0x1, %dl
leaq 0x2420d(%rip), %rax     # 0x40a00
cmoveq %rcx, %rax
movq (%rax), %rax
movq (%rax), %rdi
callq 0x8b01
callq 0x95e2
callq 0x8b78
movq %rax, %r14
movq %rax, %rdi
callq 0x1433e
testl %eax, %eax
je 0x1cb24
movq %r14, %rdi
callq 0x8b01
callq 0xeb5b
cmpb $0x1, 0x10(%r15)
leaq 0x241c8(%rip), %rdx     # 0x40a00
movq %rdx, %rcx
cmoveq %r13, %rcx
movl %eax, %r14d
movq (%rcx), %rax
movb 0x10(%rax), %cl
addq $0x8, %rax
cmpb $0x1, %cl
movq %rdx, %rsi
cmoveq %rax, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
movq %rdx, %rsi
jne 0x1c877
cmpb $0x1, %cl
leaq 0x24194(%rip), %rsi     # 0x40a00
cmoveq %rax, %rsi
movq (%rsi), %rsi
addq $0x8, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1c8b2
cmpb $0x1, %cl
leaq 0x24176(%rip), %rdx     # 0x40a00
movq %rdx, %rsi
cmoveq %rax, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1c8af
cmpb $0x1, %cl
leaq 0x2415c(%rip), %rcx     # 0x40a00
cmoveq %rax, %rcx
movq (%rcx), %rdx
addq $0x8, %rdx
movq (%rdx), %rdx
movq (%rdx), %rdi
callq 0x8b01
callq 0x95e2
callq 0x8b78
movq %rax, %r12
movq %rax, %rdi
callq 0x1433e
testl %eax, %eax
je 0x1cb24
movq %r12, %rdi
callq 0x8b01
callq 0xeb5b
cmpb $0x1, 0x10(%r15)
leaq 0x24110(%rip), %rdx     # 0x40a00
cmovneq %rdx, %r13
movl %eax, -0x2c(%rbp)
movq (%r13), %rax
movb 0x10(%rax), %cl
addq $0x8, %rax
cmpb $0x1, %cl
movq %rdx, %rsi
cmoveq %rax, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
movq %rdx, %rsi
jne 0x1c92d
cmpb $0x1, %cl
leaq 0x240de(%rip), %rsi     # 0x40a00
cmoveq %rax, %rsi
movq (%rsi), %rsi
addq $0x8, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
movq %rdx, %rsi
jne 0x1c96f
cmpb $0x1, %cl
leaq 0x240bd(%rip), %rsi     # 0x40a00
movq %rsi, %rdi
cmoveq %rax, %rdi
movq (%rdi), %rdi
cmpb $0x1, 0x10(%rdi)
jne 0x1c968
cmpb $0x1, %cl
leaq 0x240a3(%rip), %rsi     # 0x40a00
cmoveq %rax, %rsi
movq (%rsi), %rsi
addq $0x8, %rsi
movq (%rsi), %rsi
addq $0x8, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1c9ec
cmpb $0x1, %cl
leaq 0x2407e(%rip), %rdx     # 0x40a00
movq %rdx, %rsi
cmoveq %rax, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
movq %rdx, %rsi
jne 0x1c9aa
cmpb $0x1, %cl
leaq 0x24061(%rip), %rsi     # 0x40a00
cmoveq %rax, %rsi
movq (%rsi), %rsi
addq $0x8, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1c9e9
cmpb $0x1, %cl
leaq 0x24043(%rip), %rdx     # 0x40a00
movq %rdx, %rsi
cmoveq %rax, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1c9e2
cmpb $0x1, %cl
leaq 0x24029(%rip), %rcx     # 0x40a00
cmoveq %rax, %rcx
movq (%rcx), %rdx
addq $0x8, %rdx
movq (%rdx), %rdx
addq $0x8, %rdx
movq (%rdx), %rdx
movq (%rdx), %r12
movq %rbx, %rdi
callq 0xe73e
movl 0x1d8ba(%rip), %r13d    # 0x3a2b8
movl %r14d, %edi
callq 0xacbe
callq 0x8b78
cmpb $0x3, 0x10(%rbx)
jne 0x1cb18
movq 0x23fe4(%rip), %rcx     # 0x40a00
movl 0x8(%rbx), %edx
leaq 0xea0ca(%rip), %rsi     # 0x106af0
movq %rax, (%rsi,%rdx,8)
movl 0x8(%rbx), %eax
leaq 0xef51c(%rip), %rdx     # 0x10bf50
movq %rcx, (%rdx,%rax,8)
movq %r12, %rdi
callq 0x8b01
callq 0x95ac
cmpl -0x2c(%rbp), %r14d
je 0x1ca76
setl %r15b
movl 0x1d863(%rip), %eax     # 0x3a2b8
subl %r13d, %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jne 0x1ca69
movl $0x3e8, %edi            # imm = 0x3E8
callq 0xa8bb
movzbl %r15b, %eax
leal (%r14,%rax,2), %r14d
decl %r14d
jmp 0x1c9fe
movl 0x1d83c(%rip), %edi     # 0x3a2b8
subl %r13d, %edi
callq 0xa8bb
callq 0x8b78
movq %rax, %rbx
callq 0xe7a4
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8b01
addq $0x8, %r15
cmpb $0x1, %al
leaq 0x23f4c(%rip), %rax     # 0x40a00
cmovneq %rax, %r15
movq (%r15), %rcx
cmpb $0x1, 0x10(%rcx)
cmoveq %rcx, %rax
movq (%rax), %rdi
callq 0x8b01
callq 0x95e2
callq 0x8b78
movq %rax, %rbx
cmpb $0x7, 0x10(%rax)
jne 0x1ca91
movq (%rbx), %rax
movslq 0x64(%rax), %r14
testq %r14, %r14
jle 0x1cb02
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x8b01
incq %r15
cmpq %r15, %r14
jne 0x1caed
movl %r14d, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa8bb
leaq 0xe45b(%rip), %rdi      # 0x2af7a
callq 0x77c8
leaq 0xde00(%rip), %rdi      # 0x2a92b
callq 0x77c8
leaq 0xddda(%rip), %rdi      # 0x2a911
callq 0x77c8