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

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

	if (car(p1) == symbol(ADD)) {
		p1 = cdr(p1);
		h = tos;
		while (iscons(p1)) {
			push(car(p1));
			rect();
			p1 = cdr(p1);
		}
		add_terms(tos - h);
		return;
	}

	if (car(p1) == symbol(MULTIPLY)) {
		p1 = cdr(p1);
		h = tos;
		while (iscons(p1)) {
			push(car(p1));
			rect();
			p1 = cdr(p1);
		}
		multiply_factors(tos - h);
		return;
	}

	if (car(p1) != symbol(POWER)) {
		push(p1);
		return;
	}

	BASE = cadr(p1);
	EXPO = caddr(p1);

	// handle sum in exponent

	if (car(EXPO) == symbol(ADD)) {
		p1 = cdr(EXPO);
		h = tos;
		while (iscons(p1)) {
			push_symbol(POWER);
			push(BASE);
			push(car(p1));
			list(3);
			rect();
			p1 = cdr(p1);
		}
		multiply_factors(tos - h);
		return;
	}

	// return mag(p1) * cos(arg(p1)) + i sin(arg(p1)))

	push(p1);
	magfunc();

	push(p1);
	argfunc();
	p2 = pop();

	push(p2);
	cosfunc();

	push(imaginaryunit);
	push(p2);
	sinfunc();
	multiply();

	add();

	multiply();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x2951b(%rip), %r15d    # 0x3f2b8
movl $0xfffe795f, %eax       # imm = 0xFFFE795F
leal (%r15,%rax), %ecx
cmpl %eax, %ecx
jbe 0x16091
decl %r15d
movl %r15d, 0x29500(%rip)    # 0x3f2b8
leaq 0x32801(%rip), %r12     # 0x485c0
movq (%r12,%r15,8), %rbx
movzbl 0x10(%rbx), %edx
movq %rbx, %rcx
cmpl $0x1, %edx
je 0x15e42
cmpl $0x7, %edx
jne 0x15e3b
movq %rbx, %rdi
callq 0x9638
movq %rax, %rbx
movq (%rax), %rax
movslq 0x64(%rax), %r14
testq %r14, %r14
jle 0x15e78
xorl %r15d, %r15d
movl $0xfffe795f, %r13d      # imm = 0xFFFE795F
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x8ba5
callq 0x15d88
movl 0x294a8(%rip), %eax     # 0x3f2b8
leal (%rax,%r13), %ecx
cmpl %r13d, %ecx
jbe 0x16091
decl %eax
movl %eax, 0x29493(%rip)     # 0x3f2b8
movq (%r12,%rax,8), %rax
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x15df8
jmp 0x15e78
leaq 0x2fbbe(%rip), %rcx     # 0x45a00
movq 0x32457(%rip), %rax     # 0x482a0
cmpq %rax, (%rcx)
je 0x15e8e
cmpb $0x1, %dl
leaq 0x2fba8(%rip), %rcx     # 0x45a00
movq %rcx, %rsi
cmoveq %rbx, %rsi
movq (%rsi), %rsi
cmpq 0x3243f(%rip), %rsi     # 0x482a8
je 0x15eea
cmpq 0x3243e(%rip), %rsi     # 0x482b0
je 0x15f38
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
addq $0x8, %rbx
cmpb $0x1, %dl
leaq 0x2fb64(%rip), %r14     # 0x45a00
cmovneq %r14, %rbx
movq (%rbx), %rbx
cmpb $0x1, 0x10(%rbx)
movl %r15d, %edi
jne 0x15ed4
movq (%rbx), %rdi
callq 0x8ba5
callq 0x15d88
leaq 0x8(%rbx), %rax
cmpb $0x1, 0x10(%rbx)
cmovneq %r14, %rax
movq (%rax), %rbx
cmpb $0x1, 0x10(%rbx)
je 0x15eac
movl 0x293e4(%rip), %edi     # 0x3f2b8
subl %r15d, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xadb3
addq $0x8, %rbx
cmpb $0x1, %dl
leaq 0x2fb08(%rip), %r14     # 0x45a00
cmovneq %r14, %rbx
movq (%rbx), %rbx
cmpb $0x1, 0x10(%rbx)
movl %r15d, %edi
jne 0x15f30
movq (%rbx), %rdi
callq 0x8ba5
callq 0x15d88
leaq 0x8(%rbx), %rax
cmpb $0x1, 0x10(%rbx)
cmovneq %r14, %rax
movq (%rax), %rbx
cmpb $0x1, 0x10(%rbx)
je 0x15f08
movl 0x29388(%rip), %edi     # 0x3f2b8
subl %r15d, %edi
jmp 0x16002
leaq 0x8(%rbx), %rsi
cmpb $0x1, %dl
cmovneq %rcx, %rsi
movq (%rsi), %rdx
cmpb $0x1, 0x10(%rdx)
jne 0x15f59
movq (%rdx), %r14
movq 0x8(%rdx), %rdx
cmpb $0x1, 0x10(%rdx)
jmp 0x15f67
movq 0x2faa0(%rip), %rdx     # 0x45a00
cmpb $0x1, 0x10(%rdx)
movq %rdx, %r14
movq %rcx, %rsi
jne 0x15f6f
movq %rdx, %rsi
movq (%rsi), %rdx
movb 0x10(%rdx), %sil
cmpb $0x1, %sil
cmoveq %rdx, %rcx
cmpq %rax, (%rcx)
je 0x16015
movq %rbx, %rdi
callq 0x8ba5
callq 0xf5df
movq %rbx, %rdi
callq 0x8ba5
callq 0xe743
movl 0x29311(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x16091
decl %eax
movl %eax, 0x292f9(%rip)     # 0x3f2b8
movq (%r12,%rax,8), %rbx
movq %rbx, %rdi
callq 0x8ba5
callq 0x10115
movq 0xf5b09(%rip), %rdi     # 0x10bae0
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
callq 0x10ab4
movl $0x2, %edi
callq 0xacef
movl $0x2, %edi
callq 0xadb3
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xacef
addq $0x8, %rdx
cmpb $0x1, %sil
leaq 0x2f9dc(%rip), %rbx     # 0x45a00
cmovneq %rbx, %rdx
movq (%rdx), %r12
cmpb $0x1, 0x10(%r12)
movl %r15d, %edi
jne 0x15f30
movq 0x3226f(%rip), %rdi     # 0x482b0
callq 0x8ba5
movq %r14, %rdi
callq 0x8ba5
cmpb $0x1, 0x10(%r12)
movq %rbx, %rax
cmoveq %r12, %rax
movq (%rax), %rdi
callq 0x8ba5
movl $0x3, %edi
callq 0x8b7d
callq 0x15d88
leaq 0x8(%r12), %rax
cmpb $0x1, 0x10(%r12)
cmovneq %rbx, %rax
movq (%rax), %r12
cmpb $0x1, 0x10(%r12)
je 0x1603a
jmp 0x15f2a
leaq 0x18ea9(%rip), %rdi     # 0x2ef41
callq 0x780b