// File: /workspace/github_c_makefile_star2_O3/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 0xb477
testl %eax, %eax
je 0x1c08b
movq 0xefa4f(%rip), %rdi     # 0x10bad8
jmp 0x1c106
movq %r14, %rdi
callq 0xb477
testl %eax, %eax
je 0x1c0ad
movzbl 0x10(%rbx), %eax
cmpl $0x5, %eax
je 0x1c0de
cmpl $0x4, %eax
jne 0x1c0ff
cmpb $0x1, 0x12(%rbx)
je 0x1c0e8
jmp 0x1c0ff
movq %r14, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
jne 0x1c082
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
je 0x1c119
movq %r14, %rdi
jmp 0x1c106
xorpd %xmm0, %xmm0
ucomisd (%rbx), %xmm0
jbe 0x1c0ff
cmpl $0x0, 0xfa2d5(%rip)     # 0x1163c4
je 0x1c47b
movl $0x1, 0xfa2c1(%rip)     # 0x1163c0
movq 0x2703a(%rip), %rdi     # 0x43140
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
cmpb $0x5, 0x10(%r14)
je 0x1c12e
movzbl 0x10(%rbx), %eax
cmpl $0x4, %eax
je 0x1c147
cmpl $0x5, %eax
jne 0x1c197
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c8a1
movq 0x8(%rbx), %rax
cmpl $0x1, -0x4(%rax)
jne 0x1c197
cmpl $0x1, (%rax)
jne 0x1c197
movq (%r14), %rdi
movq (%rbx), %rsi
callq 0x85a7
movq %rax, %r15
movq 0x8(%r14), %rdi
movq (%rbx), %rsi
callq 0x85a7
movzbl 0x10(%r14), %ecx
cmpl $0x5, %ecx
je 0x1c3e8
cmpl $0x4, %ecx
jne 0x1c3fb
cmpb $0x1, 0x12(%r14)
je 0x1c3f3
jmp 0x1c3fb
movl 0x2311a(%rip), %r15d    # 0x3f2b8
movq 0x2c10b(%rip), %rdi     # 0x482b0
callq 0x8ba5
movq %r14, %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movl $0x3, %edi
callq 0x8b7d
callq 0x190c2
movl 0x230e9(%rip), %ebx     # 0x3f2b8
movl %ebx, %eax
subl %r15d, %eax
movl %r15d, -0x2c(%rbp)
jle 0x1c2a4
movslq %r15d, %r14
movl %eax, %r15d
movq 0x2c0c5(%rip), %rax     # 0x482b0
shlq $0x3, %r14
xorl %r13d, %r13d
leaq 0x2c3c7(%rip), %rdi     # 0x485c0
leaq 0x29800(%rip), %r12     # 0x45a00
leaq (%r14,%r13,8), %rcx
movq (%rdi,%rcx), %rcx
movb 0x10(%rcx), %dl
cmpb $0x1, %dl
movq %r12, %rsi
cmoveq %rcx, %rsi
cmpq %rax, (%rsi)
jne 0x1c298
addq $0x8, %rcx
cmpb $0x1, %dl
cmovneq %r12, %rcx
movq (%rcx), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1c23b
movq (%rax), %rdi
movq 0x8(%rax), %rax
cmpb $0x1, 0x10(%rax)
jmp 0x1c249
movq 0x297be(%rip), %rax     # 0x45a00
cmpb $0x1, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rcx
jne 0x1c251
movq %rax, %rcx
movq (%rcx), %rsi
callq 0x1c986
movl 0x23059(%rip), %ebx     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rbx,%rcx), %eax
cmpl %ecx, %eax
jbe 0x1c46f
leaq (,%r13,8), %rcx
movq 0x2c032(%rip), %rax     # 0x482b0
decl %ebx
movl %ebx, 0x23032(%rip)     # 0x3f2b8
leaq 0x2c333(%rip), %rdi     # 0x485c0
movq (%rdi,%rbx,8), %rdx
addq %r14, %rcx
movq %rdx, (%rdi,%rcx)
incq %r13
cmpq %r13, %r15
jne 0x1c200
movq 0xef82d(%rip), %r14     # 0x10bad8
movl -0x2c(%rbp), %eax
cmpl %ebx, %eax
jge 0x1c353
leaq 0x2c303(%rip), %r13     # 0x485c0
movl %eax, %r12d
movslq %r12d, %rax
movq (%r13,%rax,8), %r15
movb 0x10(%r15), %al
andb $-0x2, %al
cmpb $0x4, %al
jne 0x1c347
movq %r14, %rdi
callq 0x8ba5
movq %r15, %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xacef
movl 0x22fc6(%rip), %ebx     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rbx,%rcx), %eax
cmpl %ecx, %eax
jbe 0x1c46f
leal -0x1(%rbx), %ecx
movq (%r13,%rcx,8), %r14
leal 0x1(%r12), %eax
cmpl %ecx, %eax
jge 0x1c33b
cltq
leaq (,%rax,8), %rax
addq %r13, %rax
leal -0x2(%rbx), %ecx
movl %r12d, %edx
movq (%rax), %rsi
movslq %edx, %rdx
movq %rsi, (%r13,%rdx,8)
incl %edx
addq $0x8, %rax
cmpl %edx, %ecx
jne 0x1c326
addl $-0x2, %ebx
movl %ebx, 0x22f74(%rip)     # 0x3f2b8
decl %r12d
incl %r12d
cmpl %ebx, %r12d
jl 0x1c2c0
subl -0x2c(%rbp), %ebx
je 0x1c36e
movq %r14, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
jne 0x1c378
movq %r14, %rdi
callq 0x8ba5
incl %ebx
cmpl $0x1, %ebx
jne 0x1c38c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x22f25(%rip), %rax     # 0x3f2b8
leaq 0x2c226(%rip), %rcx     # 0x485c0
leaq (%rcx,%rax,8), %rdi
movslq %ebx, %rsi
leaq (,%rsi,8), %rax
subq %rax, %rdi
leaq -0x1dee(%rip), %rcx     # 0x1a5c5
movl $0x8, %edx
callq 0x70a0
movl %ebx, %edi
callq 0x8b7d
movq 0x2bedd(%rip), %rdi     # 0x482a8
callq 0x8ba5
callq 0xb238
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8be6
xorpd %xmm0, %xmm0
ucomisd (%r14), %xmm0
jbe 0x1c3fb
movq (%rbx), %rcx
testb $0x1, (%rcx)
jne 0x1c43e
movzbl 0x10(%rbx), %ecx
cmpl $0x5, %ecx
je 0x1c419
cmpl $0x4, %ecx
jne 0x1c423
cmpb $0x1, 0x12(%rbx)
jne 0x1c423
xorl %edi, %edi
movq %rax, %rsi
movq %r15, %rdx
jmp 0x1c42b
xorpd %xmm0, %xmm0
ucomisd (%rbx), %xmm0
ja 0x1c40f
xorl %edi, %edi
movq %r15, %rsi
movq %rax, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbf3e
movzbl 0x10(%rbx), %edx
cmpl $0x5, %edx
je 0x1c459
cmpl $0x4, %edx
jne 0x1c468
cmpb $0x1, 0x12(%rbx)
jne 0x1c468
movl $0x1, %edi
jmp 0x1c411
movq %rcx, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x1c452
movl $0x1, %edi
jmp 0x1c425
leaq 0x12acb(%rip), %rdi     # 0x2ef41
callq 0x780b
leaq 0xdd2c(%rip), %rdi      # 0x2a1ae
callq 0x780b