// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]eigenmath/eigenmath.c
// Function: reduce_radical_rational
struct atom *
reduce_radical_rational(int h, struct atom *COEF)
{
	int i, k;
	struct atom *p1, *p2, *NUMER, *DENOM, *BASE, *EXPO;

	if (isplusone(COEF) || isminusone(COEF))
		return COEF; // COEF has no factors, no cancellation is possible

	push(COEF);
	absfunc();
	p1 = pop();

	push(p1);
	numerator();
	NUMER = pop();

	push(p1);
	denominator();
	DENOM = pop();

	k = 0;

	for (i = h; i < tos; i++) {
		p1 = stack[i];
		if (!isradical(p1))
			continue;
		BASE = cadr(p1);
		EXPO = caddr(p1);
		if (isnegativenumber(EXPO)) {
			mod_integers(NUMER, BASE);
			p2 = pop();
			if (iszero(p2)) {
				push(NUMER);
				push(BASE);
				divide();
				NUMER = pop();
				push_symbol(POWER);
				push(BASE);
				push_integer(1);
				push(EXPO);
				add();
				list(3);
				stack[i] = pop();
				k++;
			}
		} else {
			mod_integers(DENOM, BASE);
			p2 = pop();
			if (iszero(p2)) {
				push(DENOM);
				push(BASE);
				divide();
				DENOM = pop();
				push_symbol(POWER);
				push(BASE);
				push_integer(-1);
				push(EXPO);
				add();
				list(3);
				stack[i] = pop();
				k++;
			}
		}
	}

	if (k) {
		push(NUMER);
		push(DENOM);
		divide();
		if (isnegativenumber(COEF))
			negate();
		COEF = pop();
	}

	return COEF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movl %edi, %r12d
movq %rsi, %rdi
callq 0xa95a
testl %eax, %eax
jne 0x167ba
movq %rbx, %rdi
callq 0xbfac
testl %eax, %eax
je 0x167cc
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, -0x48(%rbp)
movq %rbx, %rdi
callq 0x861b
callq 0x94f7
callq 0x868d
movq %rax, %r15
movq %rax, %rdi
callq 0x861b
callq 0xca1a
callq 0x868d
movq %rax, -0x40(%rbp)
movq %r15, %rdi
callq 0x861b
callq 0xca2e
callq 0x868d
movq %rax, -0x38(%rbp)
movslq %r12d, %rbx
leaq 0x2ad95(%rip), %rax     # 0x415b0
leaq (%rax,%rbx,8), %r14
movl $0x0, -0x2c(%rbp)
leaq 0x281c3(%rip), %r12     # 0x3e9f0
movslq 0x21a74(%rip), %rax     # 0x382a8
cmpq %rax, %rbx
jge 0x1696f
movq (%r14), %r15
movq %r15, %rdi
callq 0x16ac4
testl %eax, %eax
je 0x16963
leaq 0x8(%r15), %rax
cmpb $0x1, 0x10(%r15)
cmovneq %r12, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x16873
movq (%rax), %r13
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jmp 0x16881
movq 0x28176(%rip), %rax     # 0x3e9f0
cmpb $0x1, 0x10(%rax)
movq %rax, %r13
movq %r12, %rcx
jne 0x16889
movq %rax, %rcx
movq (%rcx), %r12
movq %r12, %rdi
callq 0x8c2a
testl %eax, %eax
je 0x168de
movq -0x40(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x15caf
callq 0x868d
movq %rax, %rdi
callq 0xa641
testl %eax, %eax
je 0x1695c
movq %r15, %rdi
callq 0x861b
movq %r13, %rdi
callq 0x861b
callq 0xca0b
callq 0x868d
movq %rax, -0x40(%rbp)
pushq $0x1
jmp 0x1691e
movq -0x38(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x15caf
callq 0x868d
movq %rax, %rdi
callq 0xa641
testl %eax, %eax
je 0x1695c
movq %r15, %rdi
callq 0x861b
movq %r13, %rdi
callq 0x861b
callq 0xca0b
callq 0x868d
movq %rax, -0x38(%rbp)
pushq $-0x1
popq %r15
movq 0x2a979(%rip), %rdi     # 0x412a0
callq 0x861b
movq %r13, %rdi
callq 0x861b
movl %r15d, %edi
callq 0xa426
movq %r12, %rdi
callq 0x861b
callq 0xa1f6
pushq $0x3
popq %rdi
callq 0x85eb
callq 0x868d
movq %rax, (%r14)
incl -0x2c(%rbp)
leaq 0x2808d(%rip), %r12     # 0x3e9f0
incq %rbx
addq $0x8, %r14
jmp 0x1682d
cmpl $0x0, -0x2c(%rbp)
movq -0x48(%rbp), %rbx
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %r14
je 0x167ba
callq 0x861b
movq %r14, %rdi
callq 0x861b
callq 0xca0b
movq %rbx, %rdi
callq 0x8c2a
testl %eax, %eax
je 0x169a8
callq 0x975f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x868d