// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %rdi, %r15
leaq 0x8(%rdi), %r12
cmpb $0x1, 0x10(%rdi)
leaq 0x22db9(%rip), %r14     # 0x45a00
movq %r14, %rax
cmoveq %r12, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmovneq %r14, %rax
movq (%rax), %rdi
callq 0x8ba5
callq 0x96e2
movl 0x1c64c(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x2300d
decl %eax
movl %eax, 0x1c634(%rip)     # 0x3f2b8
cmpb $0x1, 0x10(%r15)
movq %r14, %rcx
cmoveq %r12, %rcx
movq (%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x22c9f
movq 0x8(%rcx), %rcx
jmp 0x22ca6
movq 0x22d5a(%rip), %rcx     # 0x45a00
cmpb $0x1, 0x10(%rcx)
jne 0x22caf
movq %rcx, %r14
leaq 0x2590a(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rbx
movq (%r14), %rdi
callq 0x8ba5
callq 0x96e2
movl 0x1c5eb(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x2300d
decl %eax
movl %eax, 0x1c5d3(%rip)     # 0x3f2b8
cmpb $0x1, 0x10(%r15)
leaq 0x22d0f(%rip), %r14     # 0x45a00
movq %r14, %rcx
cmoveq %r12, %rcx
movq (%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x22d11
movq 0x8(%rcx), %rdx
cmpb $0x1, 0x10(%rdx)
jne 0x22d37
movq 0x8(%rdx), %rdx
jmp 0x22d3e
movq 0x22ce8(%rip), %rcx     # 0x45a00
cmpb $0x1, 0x10(%rcx)
movq %r14, %rdx
jne 0x22d61
movq 0x8(%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
movq %r14, %rdx
jne 0x22d61
movq 0x22ccb(%rip), %rcx     # 0x45a00
jmp 0x22d4b
movq 0x22cc2(%rip), %rdx     # 0x45a00
cmpb $0x1, 0x10(%rdx)
movq %r14, %rdx
jne 0x22d61
movq 0x8(%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x22d57
addq $0x8, %rcx
jmp 0x22d5e
leaq 0x22ca2(%rip), %rcx     # 0x45a00
movq (%rcx), %rdx
leaq 0x25858(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rax
movq %rax, -0x30(%rbp)
movq (%rdx), %rdi
callq 0x8ba5
callq 0x96e2
callq 0xf8e6
cmpb $0x1, 0x10(%r15)
cmoveq %r12, %r14
movl %eax, %r12d
movq (%r14), %rax
cmpb $0x1, 0x10(%rax)
jne 0x22da7
movq 0x8(%rax), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x22dce
movq 0x8(%rcx), %rcx
jmp 0x22dd5
movq 0x22c52(%rip), %rcx     # 0x45a00
leaq 0x22c4b(%rip), %rax     # 0x45a00
cmpb $0x1, 0x10(%rcx)
jne 0x22e02
movq 0x8(%rcx), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x22e02
movq 0x22c34(%rip), %rax     # 0x45a00
jmp 0x22ddf
movq 0x22c2b(%rip), %rcx     # 0x45a00
cmpb $0x1, 0x10(%rcx)
jne 0x22deb
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x22df4
addq $0x8, %rax
jmp 0x22dfb
leaq 0x22c0e(%rip), %rax     # 0x45a00
jmp 0x22e02
leaq 0x22c05(%rip), %rax     # 0x45a00
movq (%rax), %rax
addq $0x8, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x22e1a
movq (%rax), %rdi
callq 0x8ba5
callq 0x96e2
jmp 0x22e26
movq 0x2031f(%rip), %rdi     # 0x43140
callq 0x8ba5
movl 0x1c48b(%rip), %r15d    # 0x3f2b8
movl $0xfffe795f, %r14d      # imm = 0xFFFE795F
leal (%r15,%r14), %eax
cmpl %r14d, %eax
jbe 0x2300d
decl %r15d
movl %r15d, 0x1c46e(%rip)    # 0x3f2b8
leaq 0x2576f(%rip), %rax     # 0x485c0
movq (%rax,%r15,8), %r13
movq %rbx, %rdi
callq 0x8ba5
movq -0x30(%rbp), %rdi
callq 0x8ba5
movq %r13, -0x48(%rbp)
movq %r13, %rdi
callq 0x8ba5
callq 0x9493
callq 0x96e2
movq 0xe8c55(%rip), %rdi     # 0x10bad8
callq 0x8ba5
movl 0x1c42a(%rip), %edi     # 0x3f2b8
leal (%rdi,%r14), %eax
cmpl %r14d, %eax
jbe 0x2300d
decl %edi
movl %edi, 0x1c415(%rip)     # 0x3f2b8
testl %r12d, %r12d
jle 0x22ff7
movq %r15, -0x38(%rbp)
movl %edi, %eax
leaq 0x25707(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %r15
negl %r12d
movq %r12, -0x40(%rbp)
movq -0x30(%rbp), %r14
movl $0x1, %r12d
movq %rbx, %rdi
callq 0x8ba5
movq %r14, %r13
movq %r14, %rdi
callq 0x8ba5
callq 0x1198a
movl 0x1c3cc(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %edx       # imm = 0xFFFE795F
leal (%rax,%rdx), %ecx
cmpl %edx, %ecx
jbe 0x2300d
decl %eax
movl %eax, 0x1c3b4(%rip)     # 0x3f2b8
leaq 0x256b5(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rbx
movq 0x20bca(%rip), %rsi     # 0x43ae0
movq %rbx, %rdi
callq 0x8c99
testl %eax, %eax
jne 0x23019
movq %rbx, %rdi
callq 0xb477
testl %eax, %eax
jne 0x22fed
movq %r13, %r14
movq %r15, %rdi
callq 0x8ba5
movq %r13, %rdi
callq 0x8ba5
movq -0x48(%rbp), %r13
movq %r13, %rdi
callq 0x8ba5
callq 0xbfb4
movl $0x2, %edi
callq 0xacef
movl 0x1c34e(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %edx       # imm = 0xFFFE795F
leal (%rax,%rdx), %ecx
cmpl %edx, %ecx
jbe 0x2300d
decl %eax
movl %eax, 0x1c336(%rip)     # 0x3f2b8
leaq 0x25637(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %r15
movq %rbx, %rdi
callq 0x8ba5
movq %r14, %rdi
callq 0x8ba5
movq %r13, %rdi
callq 0x8ba5
callq 0x9493
callq 0x96e2
movq %r15, %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xacef
movl %r12d, %edi
callq 0xb1be
callq 0x15015
callq 0xe218
movq -0x40(%rbp), %rax
addl %r12d, %eax
incl %eax
movl %r12d, %ecx
incl %ecx
movl %ecx, %r12d
cmpl $0x1, %eax
jne 0x22ece
movl 0x1c2c5(%rip), %edi     # 0x3f2b8
movq -0x38(%rbp), %r15
subl %r15d, %edi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xadb3
leaq 0xbf2d(%rip), %rdi      # 0x2ef41
callq 0x780b
leaq 0xbb41(%rip), %rdi      # 0x2eb61
callq 0x780b