// File: /workspace/github_c_makefile_star2_O0/georgeweigt[P]eigenmath/eigenmath.c
// Function: findroot
int
findroot(int h, int n)
{
	int i, j, m, p, q, r;
	struct atom *A, *C, *PA;

	// check constant term

	if (iszero(stack[h])) {
		push_integer(0); // root is zero
		return 1;
	}

	// eliminate denominators

	for (i = 0; i < n; i++) {
		C = stack[h + i];
		if (isinteger(C))
			continue;
		push(C);
		denominator();
		C = pop();
		for (j = 0; j < n; j++) {
			push(stack[h + j]);
			push(C);
			multiply();
			stack[h + j] = pop();
		}
	}

	p = tos;

	push(stack[h]);
	m = pop_integer();
	divisors(m); // divisors of constant term

	q = tos;

	push(stack[h + n - 1]);
	m = pop_integer();
	divisors(m); // divisors of leading coeff

	r = tos;

	for (i = p; i < q; i++) {
		for (j = q; j < r; j++) {

			// try positive A

			push(stack[i]);
			push(stack[j]);
			divide();
			A = pop();

			horner(h, n, A);

			PA = pop(); // polynomial evaluated at A

			if (iszero(PA)) {
				tos = p; // pop all
				push(A);
				return 1; // root on stack
			}

			// try negative A

			push(A);
			negate();
			A = pop();

			horner(h, n, A);

			PA = pop(); // polynomial evaluated at A

			if (iszero(PA)) {
				tos = p; // pop all
				push(A);
				return 1; // root on stack
			}
		}
	}

	tos = p; // pop all

	return 0; // no root
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x32437(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2f1aa
xorl %edi, %edi
callq 0xca50
movl $0x1, -0x4(%rbp)
jmp 0x2f3fa
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2f269
movl -0x8(%rbp), %eax
addl -0x10(%rbp), %eax
movslq %eax, %rcx
leaq 0x323f3(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x9bc0
cmpl $0x0, %eax
je 0x2f1e5
jmp 0x2f25b
movq -0x38(%rbp), %rdi
callq 0x9110
callq 0x117d0
callq 0x91d0
movq %rax, -0x38(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2f259
movl -0x8(%rbp), %eax
addl -0x14(%rbp), %eax
movslq %eax, %rcx
leaq 0x323a5(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdi
callq 0x9110
movq -0x38(%rbp), %rdi
callq 0x9110
callq 0xc280
callq 0x91d0
movq %rax, %rdx
movl -0x8(%rbp), %eax
addl -0x14(%rbp), %eax
movslq %eax, %rcx
leaq 0x32376(%rip), %rax     # 0x615c0
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2f203
jmp 0x2f25b
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x2f1b1
movl 0x29049(%rip), %eax     # 0x582b8
movl %eax, -0x1c(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x32343(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdi
callq 0x9110
callq 0x13520
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %edi
callq 0x2f520
movl 0x2901c(%rip), %eax     # 0x582b8
movl %eax, -0x20(%rbp)
movl -0x8(%rbp), %eax
addl -0xc(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x3230e(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdi
callq 0x9110
callq 0x13520
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %edi
callq 0x2f520
movl 0x28fe7(%rip), %eax     # 0x582b8
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x2f3ea
movl -0x20(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2f3da
movslq -0x10(%rbp), %rcx
leaq 0x322bd(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdi
callq 0x9110
movslq -0x14(%rbp), %rcx
leaq 0x322a9(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdi
callq 0x9110
callq 0x117a0
callq 0x91d0
movq %rax, -0x30(%rbp)
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x2f5c0
callq 0x91d0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2f372
movl -0x1c(%rbp), %eax
movl %eax, 0x28f5b(%rip)     # 0x582b8
movq -0x30(%rbp), %rdi
callq 0x9110
movl $0x1, -0x4(%rbp)
jmp 0x2f3fa
movq -0x30(%rbp), %rdi
callq 0x9110
callq 0xb4b0
callq 0x91d0
movq %rax, -0x30(%rbp)
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x2f5c0
callq 0x91d0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2f3ca
movl -0x1c(%rbp), %eax
movl %eax, 0x28f00(%rip)     # 0x582b8
movq -0x30(%rbp), %rdi
callq 0x9110
movl $0x1, -0x4(%rbp)
jmp 0x2f3fa
jmp 0x2f3cc
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2f2ec
jmp 0x2f3dc
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x2f2da
movl -0x1c(%rbp), %eax
movl %eax, 0x28ec5(%rip)     # 0x582b8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)