// File: /workspace/github_c_makefile_star2_O1/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), %r13
cmpb $0x1, 0x10(%rdi)
leaq 0x20b0b(%rip), %r12     # 0x40a00
movq %r12, %rax
cmoveq %r13, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmovneq %r12, %rax
movq (%rax), %rdi
callq 0x8b01
callq 0x95e2
callq 0x8b78
cmpb $0x1, 0x10(%r15)
movq %r12, %rcx
cmoveq %r13, %rcx
movq %rax, %rbx
movq (%rcx), %rax
movb 0x10(%rax), %cl
addq $0x8, %rax
cmpb $0x1, %cl
movq %r12, %rdx
cmoveq %rax, %rdx
movq (%rdx), %rdx
cmpb $0x1, 0x10(%rdx)
movq %r12, %rdx
jne 0x1ff59
cmpb $0x1, %cl
leaq 0x20aae(%rip), %rcx     # 0x40a00
cmoveq %rax, %rcx
movq (%rcx), %rdx
movq (%rdx), %rdi
callq 0x8b01
callq 0x95e2
callq 0x8b78
cmpb $0x1, 0x10(%r15)
movq %r12, %rcx
cmoveq %r13, %rcx
movq %rax, %r14
movq (%rcx), %rax
movb 0x10(%rax), %cl
addq $0x8, %rax
cmpb $0x1, %cl
movq %r12, %rdx
cmoveq %rax, %rdx
movq (%rdx), %rdx
cmpb $0x1, 0x10(%rdx)
movq %r12, %rdx
jne 0x1ffaf
cmpb $0x1, %cl
leaq 0x20a5c(%rip), %rdx     # 0x40a00
cmoveq %rax, %rdx
movq (%rdx), %rdx
addq $0x8, %rdx
movq (%rdx), %rdx
cmpb $0x1, 0x10(%rdx)
movq %r12, %rdx
jne 0x1ffed
cmpb $0x1, %cl
leaq 0x20a3b(%rip), %rdx     # 0x40a00
movq %rdx, %rsi
cmoveq %rax, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x1ffea
cmpb $0x1, %cl
leaq 0x20a21(%rip), %rcx     # 0x40a00
cmoveq %rax, %rcx
movq (%rcx), %rdx
addq $0x8, %rdx
movq (%rdx), %rdx
movq (%rdx), %rdi
callq 0x8b01
callq 0x95e2
callq 0xeb5b
cmpb $0x1, 0x10(%r15)
cmovneq %r12, %r13
movq %rax, -0x30(%rbp)
movq (%r13), %rax
movb 0x10(%rax), %cl
addq $0x8, %rax
cmpb $0x1, %cl
movq %r12, %rdx
cmoveq %rax, %rdx
movq (%rdx), %rdx
cmpb $0x1, 0x10(%rdx)
movq %r12, %rdx
jne 0x20042
cmpb $0x1, %cl
leaq 0x209c9(%rip), %rdx     # 0x40a00
cmoveq %rax, %rdx
movq (%rdx), %rdx
addq $0x8, %rdx
movq (%rdx), %rdx
cmpb $0x1, 0x10(%rdx)
jne 0x20081
cmpb $0x1, %cl
leaq 0x209ab(%rip), %rdx     # 0x40a00
movq %rdx, %rsi
cmoveq %rax, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
jne 0x2007a
cmpb $0x1, %cl
leaq 0x20991(%rip), %rcx     # 0x40a00
cmoveq %rax, %rcx
movq (%rcx), %rdx
addq $0x8, %rdx
movq (%rdx), %r12
addq $0x8, %r12
movq (%r12), %rax
cmpb $0x1, 0x10(%rax)
jne 0x2009a
movq (%rax), %rdi
callq 0x8b01
callq 0x95e2
jmp 0x200a6
movq 0x1e09f(%rip), %rdi     # 0x3e140
callq 0x8b01
callq 0x8b78
movq %rax, %r12
movl 0x1a204(%rip), %eax     # 0x3a2b8
movl %eax, -0x34(%rbp)
movq %rbx, %rdi
callq 0x8b01
movq %r14, %rdi
callq 0x8b01
movq %r12, %rdi
callq 0x8b01
callq 0x9402
callq 0x95e2
movq 0xe69f8(%rip), %rdi     # 0x106ad8
callq 0x8b01
callq 0x8b78
cmpl $0x0, -0x30(%rbp)
jle 0x201da
movq %rax, %r15
movq -0x30(%rbp), %rax
negl %eax
movq %rax, -0x30(%rbp)
movl $0x1, %r13d
movq %rbx, %rdi
callq 0x8b01
movq %r14, %rdi
callq 0x8b01
callq 0x10771
callq 0x8b78
movq %rax, %rbx
movq 0x1e9b5(%rip), %rsi     # 0x3eae0
movq %rax, %rdi
callq 0x8bd3
testl %eax, %eax
jne 0x201f6
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
jne 0x201da
movq %r15, %rdi
callq 0x8b01
movq %r14, %rdi
callq 0x8b01
movq %r12, %rdi
callq 0x8b01
callq 0xba6d
movl $0x2, %edi
callq 0xa8bb
callq 0x8b78
movq %rax, %r15
movq %rbx, %rdi
callq 0x8b01
movq %r14, %rdi
callq 0x8b01
movq %r12, %rdi
callq 0x8b01
callq 0x9402
callq 0x95e2
movq %r15, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movl %r13d, %edi
callq 0xacbe
callq 0x1399b
callq 0xd9a4
movq -0x30(%rbp), %rax
addl %r13d, %eax
incl %eax
movl %r13d, %ecx
incl %ecx
movl %ecx, %r13d
cmpl $0x1, %eax
jne 0x20107
movl 0x1a0d8(%rip), %edi     # 0x3a2b8
subl -0x34(%rbp), %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa975
leaq 0xa944(%rip), %rdi      # 0x2ab41
callq 0x77c8