// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]eigenmath/eigenmath.c
// Function: power_numbers
void
power_numbers(struct atom *BASE, struct atom *EXPO)
{
	int h, i, j, n;
	uint32_t *a, *b;
	struct atom *p1, *p2;

	// n^0

	if (iszero(EXPO)) {
		push_integer(1);
		return;
	}

	// 0^n

	if (iszero(BASE)) {
		if (isnegativenumber(EXPO)) {
			if (shuntflag)
				errorflag = 1;
			else
				stopf("divide by zero");
		}
		push_integer(0);
		return;
	}

	// 1^n

	if (isplusone(BASE)) {
		push_integer(1);
		return;
	}

	// n^1

	if (isplusone(EXPO)) {
		push(BASE);
		return;
	}

	if (isdouble(BASE) || isdouble(EXPO)) {
		power_double(BASE, EXPO);
		return;
	}

	// integer exponent?

	if (isinteger(EXPO)) {
		a = mpow(BASE->u.q.a, EXPO->u.q.a);
		b = mpow(BASE->u.q.b, EXPO->u.q.a);
		if (isnegativenumber(BASE) && (EXPO->u.q.a[0] & 1))
			if (isnegativenumber(EXPO))
				push_bignum(MMINUS, b, a); // reciprocate
			else
				push_bignum(MMINUS, a, b);
		else
			if (isnegativenumber(EXPO))
				push_bignum(MPLUS, b, a); // reciprocate
			else
				push_bignum(MPLUS, a, b);
		return;
	}

	// exponent is a root

	h = tos;

	// put factors on stack

	push_symbol(POWER);
	push(BASE);
	push(EXPO);
	list(3);

	factor_factor();

	// normalize factors

	n = tos - h; // fix n now, stack can grow

	for (i = 0; i < n; i++) {
		p1 = stack[h + i];
		if (car(p1) == symbol(POWER)) {
			BASE = cadr(p1);
			EXPO = caddr(p1);
			power_numbers_factor(BASE, EXPO);
			stack[h + i] = pop(); // fill hole
		}
	}

	// combine numbers (leaves radicals on stack)

	p1 = one;

	for (i = h; i < tos; i++) {
		p2 = stack[i];
		if (isnum(p2)) {
			push(p1);
			push(p2);
			multiply();
			p1 = pop();
			for (j = i + 1; j < tos; j++)
				stack[j - 1] = stack[j];
			tos--;
			i--;
		}
	}

	// finalize

	n = tos - h;

	if (n == 0 || !isplusone(p1)) {
		push(p1);
		n++;
	}

	if (n == 1)
		return;

	sort_factors(n);
	list(n);
	push_symbol(MULTIPLY);
	swap();
	cons(); // prepend MULTIPLY to list
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0xa641
testl %eax, %eax
je 0x1787c
pushq $0x1
popq %rdi
jmp 0x178ad
movq %r14, %rdi
callq 0xa641
testl %eax, %eax
je 0x178c0
movq %rbx, %rdi
callq 0x8c2a
testl %eax, %eax
je 0x178ab
cmpl $0x0, 0xf7b19(%rip)     # 0x10f3b4
je 0x17b4b
movl $0x1, 0xf7b05(%rip)     # 0x10f3b0
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa426
movq %r14, %rdi
callq 0xa95a
testl %eax, %eax
jne 0x17877
movq %rbx, %rdi
callq 0xa95a
testl %eax, %eax
je 0x178ee
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x861b
cmpb $0x5, 0x10(%r14)
je 0x178fb
cmpb $0x5, 0x10(%rbx)
jne 0x17914
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17f4a
movq %rbx, %rdi
callq 0x8b5d
testl %eax, %eax
je 0x17964
movq (%r14), %rdi
movq (%rbx), %rsi
callq 0x81cc
movq %rax, %r15
movq 0x8(%r14), %rdi
movq (%rbx), %rsi
callq 0x81cc
movq %rax, %r12
movq %r14, %rdi
callq 0x8c2a
testl %eax, %eax
je 0x17955
movq (%rbx), %rax
testb $0x1, (%rax)
jne 0x17ae9
movq %rbx, %rdi
callq 0x8c2a
xorl %edi, %edi
jmp 0x17af4
movslq 0x2093d(%rip), %r15     # 0x382a8
movq 0x2992e(%rip), %rdi     # 0x412a0
callq 0x861b
movq %r14, %rdi
callq 0x861b
movq %rbx, %rdi
callq 0x861b
pushq $0x3
popq %rdi
callq 0x85eb
callq 0x1540f
movl 0x2090e(%rip), %ebx     # 0x382a8
subl %r15d, %ebx
xorl %r14d, %r14d
testl %ebx, %ebx
cmovlel %r14d, %ebx
movq %r15, -0x30(%rbp)
shlq $0x3, %r15
leaq 0x29bfb(%rip), %r13     # 0x415b0
leaq 0x27034(%rip), %rsi     # 0x3e9f0
cmpq %r14, %rbx
je 0x17a4a
leaq (%r15,%r14,8), %rax
movq (%r13,%rax), %rax
movb 0x10(%rax), %cl
cmpb $0x1, %cl
movq %rsi, %rdx
cmoveq %rax, %rdx
movq (%rdx), %rdx
cmpq 0x298bb(%rip), %rdx     # 0x412a0
jne 0x17a42
addq $0x8, %rax
cmpb $0x1, %cl
cmovneq %rsi, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x17a08
movq (%rax), %rdi
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jmp 0x17a16
movq 0x26fe1(%rip), %rax     # 0x3e9f0
cmpb $0x1, 0x10(%rax)
movq %rax, %rdi
movq %rsi, %rcx
jne 0x17a1e
movq %rax, %rcx
leaq (,%r14,8), %r12
movq (%rcx), %rsi
callq 0x17ff6
callq 0x868d
addq %r15, %r12
movq %rax, (%r13,%r12)
leaq 0x26fae(%rip), %rsi     # 0x3e9f0
incq %r14
jmp 0x179bc
movq 0xed077(%rip), %rdi     # 0x104ac8
movl 0x20851(%rip), %ebx     # 0x382a8
movq -0x30(%rbp), %rax
movl %eax, %r12d
cmpl %ebx, %r12d
jge 0x17aba
movslq %r12d, %r14
movq (%r13,%r14,8), %r15
movb 0x10(%r15), %al
andb $-0x2, %al
cmpb $0x4, %al
jne 0x17ab5
callq 0x861b
movq %r15, %rdi
callq 0x861b
callq 0x9fae
callq 0x868d
movq %rax, %rdi
movslq 0x20812(%rip), %rbx     # 0x382a8
incq %r14
cmpq %rbx, %r14
jge 0x17aaa
movq (%r13,%r14,8), %rax
movq %rax, -0x8(%r13,%r14,8)
jmp 0x17a96
decl %ebx
movl %ebx, 0x207f6(%rip)     # 0x382a8
decl %r12d
incl %r12d
jmp 0x17a5e
subl -0x30(%rbp), %ebx
je 0x17ace
movq %rdi, %r14
callq 0xa95a
movq %r14, %rdi
testl %eax, %eax
jne 0x17ad5
callq 0x861b
incl %ebx
cmpl $0x1, %ebx
jne 0x17b19
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x8c2a
pushq $0x1
popq %rdi
testl %eax, %eax
je 0x17b00
movq %r12, %rsi
movq %r15, %rdx
jmp 0x17b06
movq %r15, %rsi
movq %r12, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb015
movl %ebx, %edi
callq 0x162a3
movl %ebx, %edi
callq 0x85eb
movq 0x2976a(%rip), %rdi     # 0x41298
callq 0x861b
callq 0xa49b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x865c
leaq 0xb694(%rip), %rdi      # 0x231e6
callq 0x7756