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

	h = tos;

	// partition terms

	p1 = cdr(F);

	while (iscons(p1)) {
		p2 = car(p1);
		if (dependent(p2, X)) {
			if (car(p2) == symbol(MULTIPLY)) {
				push(p2);
				push(X);
				partition_term();	// push const part then push var part
			} else {
				push_integer(1);	// const part
				push(p2);		// var part
			}
		}
		p1 = cdr(p1);
	}

	// combine const parts of matching var parts

	n = tos - h;

	for (i = 0; i < n - 2; i += 2)
		for (j = i + 2; j < n; j += 2) {
			if (!equal(stack[h + i + 1], stack[h + j + 1]))
				continue;
			push(stack[h + i]); // add const parts
			push(stack[h + j]);
			add();
			stack[h + i] = pop();
			for (k = j; k < n - 2; k++)
				stack[h + k] = stack[h + k + 2];
			j -= 2; // use same j again
			n -= 2;
			tos -= 2; // pop
		}

	// push const parts, decomp var parts

	list(tos - h);
	p1 = pop();

	while (iscons(p1)) {
		push(car(p1)); // const part
		push(cadr(p1)); // var part
		push(X);
		decomp();
		p1 = cddr(p1);
	}

	// add together all constant terms

	h = tos;
	p1 = cdr(F);
	while (iscons(p1)) {
		if (!dependent(car(p1), X))
			push(car(p1));
		p1 = cdr(p1);
	}

	n = tos - h;

	if (n > 1) {
		list(n);
		push_symbol(ADD);
		swap();
		cons(); // makes ADD head of list
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r12
movl 0x26bf1(%rip), %r13d    # 0x3f2b8
leaq 0x8(%rdi), %rcx
movq %rdi, -0x48(%rbp)
cmpb $0x1, 0x10(%rdi)
leaq 0x2d326(%rip), %rax     # 0x45a00
movq %rcx, -0x50(%rbp)
cmoveq %rcx, %rax
movq (%rax), %rbx
cmpb $0x1, 0x10(%rbx)
movl %r13d, %edi
jne 0x18775
leaq 0x10(%rbx), %r14
movq (%rbx), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x18607
testl %eax, %eax
je 0x1874f
cmpb $0x1, 0x10(%r15)
leaq 0x2d2ec(%rip), %rax     # 0x45a00
cmoveq %r15, %rax
movq (%rax), %rax
cmpq 0x2fb86(%rip), %rax     # 0x482a8
je 0x1873a
movq 0xf33ad(%rip), %rdi     # 0x10bad8
callq 0x8ba5
movq %r15, %rdi
callq 0x8ba5
jmp 0x1874f
movq %r15, %rdi
callq 0x8ba5
movq %r12, %rdi
callq 0x8ba5
callq 0x17a53
addq $0x8, %rbx
cmpb $0x1, (%r14)
leaq 0x2d2a2(%rip), %rax     # 0x45a00
cmovneq %rax, %rbx
movq (%rbx), %rbx
leaq 0x10(%rbx), %r14
cmpb $0x1, 0x10(%rbx)
je 0x186f6
movl 0x26b43(%rip), %edi     # 0x3f2b8
subl %r13d, %edi
leaq 0x2fe41(%rip), %r8      # 0x485c0
cmpl $0x3, %edi
jl 0x1888d
movq %r12, -0x40(%rbp)
movslq %r13d, %rax
movq %rax, -0x58(%rbp)
leaq (%r8,%rax,8), %rbx
addq $0x10, %rbx
xorl %r15d, %r15d
movq %r13, -0x30(%rbp)
leaq 0x2(%r15), %r14
movslq %edi, %rax
cmpq %rax, %r14
movq %r14, -0x60(%rbp)
jge 0x18869
addq -0x58(%rbp), %r15
movq %rdi, -0x38(%rbp)
movq 0x8(%r8,%r15,8), %rdi
leal (%r14,%r13), %eax
movslq %eax, %r13
movq 0x8(%r8,%r13,8), %rsi
movq %r8, %r12
callq 0x8d48
testl %eax, %eax
je 0x187e8
movq -0x30(%rbp), %r13
movq %r12, %r8
movq -0x38(%rbp), %rdi
jmp 0x1885c
movq (%r12,%r15,8), %rdi
callq 0x8ba5
movq (%r12,%r13,8), %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xadb3
movl 0x26aae(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %edx       # imm = 0xFFFE795F
leal (%rax,%rdx), %ecx
cmpl %edx, %ecx
jbe 0x189d1
leal -0x1(%rax), %ecx
movq (%r12,%rcx,8), %rcx
movq %rcx, (%r12,%r15,8)
movq -0x38(%rbp), %rdi
addl $-0x2, %edi
cmpl %edi, %r14d
movq -0x30(%rbp), %r13
movq %r12, %r8
jge 0x1884f
movslq %r14d, %rcx
movslq %edi, %rdx
movq (%rbx,%rcx,8), %rsi
movq %rsi, -0x10(%rbx,%rcx,8)
incq %rcx
cmpq %rcx, %rdx
jne 0x1883e
addl $-0x2, %r14d
addl $-0x3, %eax
movl %eax, 0x26a5c(%rip)     # 0x3f2b8
addl $0x2, %r14d
cmpl %edi, %r14d
jl 0x187ba
leal -0x2(%rdi), %eax
cltq
movq -0x60(%rbp), %r15
cmpq %rax, %r15
jl 0x187a2
movq %r8, %r14
movl 0x26a34(%rip), %edi     # 0x3f2b8
subl %r13d, %edi
movq -0x40(%rbp), %r12
jmp 0x18890
movq %r8, %r14
callq 0x8b7d
movl 0x26a1d(%rip), %ebx     # 0x3f2b8
movl $0xfffe795f, %eax       # imm = 0xFFFE795F
leal (%rbx,%rax), %ecx
cmpl %eax, %ecx
jbe 0x189d1
decl %ebx
movl %ebx, 0x26a05(%rip)     # 0x3f2b8
movq (%r14,%rbx,8), %r14
cmpb $0x1, 0x10(%r14)
leaq 0x2d13d(%rip), %r15     # 0x45a00
jne 0x18925
movq (%r14), %rdi
callq 0x8ba5
cmpb $0x1, 0x10(%r14)
leaq 0x8(%r14), %rbx
movq %r15, %rax
cmoveq %rbx, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmovneq %r15, %rax
movq (%rax), %rdi
callq 0x8ba5
movq %r12, %rdi
callq 0x8ba5
callq 0x1817d
cmpb $0x1, 0x10(%r14)
cmovneq %r15, %rbx
movq (%rbx), %rax
leaq 0x8(%rax), %rcx
cmpb $0x1, 0x10(%rax)
cmovneq %r15, %rcx
movq (%rcx), %r14
cmpb $0x1, 0x10(%r14)
je 0x188c5
movl 0x26993(%rip), %ebx     # 0x3f2b8
movq -0x48(%rbp), %rax
cmpb $0x1, 0x10(%rax)
movq -0x50(%rbp), %rax
cmovneq %r15, %rax
movq (%rax), %r14
cmpb $0x1, 0x10(%r14)
movl %ebx, %edi
jne 0x18992
leaq 0x10(%r14), %r15
movq (%r14), %rdi
movq %r12, %rsi
callq 0x18607
testl %eax, %eax
jne 0x1896b
cmpb $0x1, (%r15)
leaq 0x2d0a1(%rip), %rax     # 0x45a00
cmoveq %r14, %rax
movq (%rax), %rdi
callq 0x8ba5
addq $0x8, %r14
cmpb $0x1, (%r15)
leaq 0x2d086(%rip), %rax     # 0x45a00
cmovneq %rax, %r14
movq (%r14), %r14
leaq 0x10(%r14), %r15
cmpb $0x1, 0x10(%r14)
je 0x18945
movl 0x26926(%rip), %edi     # 0x3f2b8
subl %ebx, %edi
cmpl $0x2, %edi
jl 0x189c2
callq 0x8b7d
movq 0x2f8fb(%rip), %rdi     # 0x482a0
callq 0x8ba5
callq 0xb238
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8be6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16569(%rip), %rdi     # 0x2ef41
callq 0x780b