// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]eigenmath/eigenmath.c
// Function: eval_taylor
void
eval_taylor(struct atom *p1)
{
	int h, i, n;
	struct atom *F, *X, *A, *C;

	push(cadr(p1));
	evalf();
	F = pop();

	push(caddr(p1));
	evalf();
	X = pop();

	push(cadddr(p1));
	evalf();
	n = pop_integer();

	p1 = cddddr(p1);

	if (iscons(p1)) {
		push(car(p1));
		evalf();
	} else
		push_integer(0); // default expansion point

	A = pop();

	h = tos;

	push(F);	// f(a)
	push(X);
	push(A);
	subst();
	evalf();

	push_integer(1);
	C = pop();

	for (i = 1; i <= n; i++) {

		push(F);	// f = f'
		push(X);
		derivative();
		F = pop();

		if (findf(F, symbol(DERIVATIVE)))
			stopf("taylor: derivative err");

		if (iszero(F))
			break;

		push(C);	// c = c * (x - a)
		push(X);
		push(A);
		subtract();
		multiply();
		C = pop();

		push(F);	// f(a)
		push(X);
		push(A);
		subst();
		evalf();

		push(C);
		multiply();
		push_integer(i);
		factorial();
		divide();
	}

	add_terms(tos - h);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
leaq 0x8(%rdi), %r12
cmpb $0x1, 0x10(%rdi)
leaq 0x21df3(%rip), %r14     # 0x3e9f0
movq %r14, %rax
cmoveq %r12, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmovneq %r14, %rax
movq (%rax), %rdi
callq 0x861b
callq 0x8fbb
callq 0x868d
cmpb $0x1, 0x10(%r15)
movq %r14, %rcx
cmoveq %r12, %rcx
movq %rax, %rbx
movq (%rcx), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1cc3f
movq 0x8(%rax), %rax
jmp 0x1cc46
movq 0x21daa(%rip), %rax     # 0x3e9f0
cmpb $0x1, 0x10(%rax)
movq %r14, %rcx
jne 0x1cc52
movq %rax, %rcx
movq (%rcx), %rdi
callq 0x861b
callq 0x8fbb
callq 0x868d
cmpb $0x1, 0x10(%r15)
cmoveq %r12, %r14
movq %rax, -0x30(%rbp)
movq (%r14), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1cc8a
movq 0x8(%rax), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x1ccb1
movq 0x8(%rcx), %rcx
jmp 0x1ccb8
movq 0x21d5f(%rip), %rcx     # 0x3e9f0
leaq 0x21d58(%rip), %rax     # 0x3e9f0
cmpb $0x1, 0x10(%rcx)
jne 0x1cce1
movq 0x8(%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x1cce1
movq 0x21d41(%rip), %rax     # 0x3e9f0
jmp 0x1ccc2
movq 0x21d38(%rip), %rcx     # 0x3e9f0
cmpb $0x1, 0x10(%rcx)
jne 0x1ccce
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1ccd7
addq $0x8, %rax
jmp 0x1ccde
leaq 0x21d1b(%rip), %rax     # 0x3e9f0
jmp 0x1cce1
leaq 0x21d12(%rip), %rax     # 0x3e9f0
movq (%rax), %rax
movq (%rax), %rdi
callq 0x861b
callq 0x8fbb
callq 0xd9d9
cmpb $0x1, 0x10(%r15)
leaq 0x21cf1(%rip), %rcx     # 0x3e9f0
cmovneq %rcx, %r12
movl %eax, %r14d
movq (%r12), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1cd20
movq 0x8(%rax), %rdx
cmpb $0x1, 0x10(%rdx)
jne 0x1cd40
movq 0x8(%rdx), %rdx
jmp 0x1cd47
movq 0x21cc9(%rip), %rax     # 0x3e9f0
cmpb $0x1, 0x10(%rax)
jne 0x1cd6b
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1cd6b
movq 0x21cb2(%rip), %rax     # 0x3e9f0
jmp 0x1cd51
movq 0x21ca9(%rip), %rdx     # 0x3e9f0
cmpb $0x1, 0x10(%rdx)
jne 0x1cd6b
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1cd5d
addq $0x8, %rax
jmp 0x1cd64
leaq 0x21c8c(%rip), %rax     # 0x3e9f0
movq (%rax), %rcx
addq $0x8, %rcx
movq (%rcx), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1cd83
movq (%rax), %rdi
callq 0x861b
callq 0x8fbb
jmp 0x1cd8a
xorl %edi, %edi
callq 0xa426
callq 0x868d
movq %rax, %r15
movl 0x1b510(%rip), %eax     # 0x382a8
movl %eax, -0x34(%rbp)
movq %rbx, %rdi
callq 0x861b
movq -0x30(%rbp), %rdi
callq 0x861b
movq %r15, %rdi
callq 0x861b
callq 0x8de5
callq 0x8fbb
pushq $0x1
popq %r12
movl %r12d, %edi
callq 0xa426
callq 0x868d
movq %rax, %r13
xorl %eax, %eax
testl %r14d, %r14d
cmovgl %r14d, %eax
negl %eax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %r14
movq -0x40(%rbp), %rax
addl %r12d, %eax
cmpl $0x1, %eax
je 0x1cea9
movq %rbx, %rdi
callq 0x861b
movq -0x30(%rbp), %rdi
callq 0x861b
callq 0xf24a
callq 0x868d
movq %rax, %rbx
movq 0x1fcb6(%rip), %rsi     # 0x3cad0
movq %rax, %rdi
callq 0x86d9
testl %eax, %eax
jne 0x1cec5
movq %rbx, %rdi
callq 0xa641
testl %eax, %eax
jne 0x1cea9
movq %r13, %rdi
callq 0x861b
movq %r14, %rdi
callq 0x861b
movq %r15, %rdi
callq 0x861b
callq 0xb07f
callq 0x9fae
callq 0x868d
movq %rax, %r13
movq %rbx, %rdi
callq 0x861b
movq %r14, %rdi
callq 0x861b
movq %r15, %rdi
callq 0x861b
callq 0x8de5
callq 0x8fbb
movq %r13, %rdi
callq 0x861b
callq 0x9fae
movl %r12d, %edi
callq 0xa426
callq 0x11ea2
callq 0xca0b
incl %r12d
jmp 0x1cde5
movl 0x1b3f9(%rip), %edi     # 0x382a8
subl -0x34(%rbp), %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa0fd
leaq 0xaccd(%rip), %rdi      # 0x27b99
callq 0x7756