// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0xaece
testl %eax, %eax
je 0x1a0c1
movq 0xeca1c(%rip), %rdi     # 0x106ad8
jmp 0x1a142
movq %r14, %rdi
callq 0xaece
testl %eax, %eax
je 0x1a0e4
movzbl 0x10(%rbx), %eax
cmpl $0x5, %eax
je 0x1a115
cmpl $0x4, %eax
jne 0x1a13b
cmpb $0x1, 0x12(%rbx)
sete %al
jmp 0x1a120
movq %r14, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
jne 0x1a0b5
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
je 0x1a155
movq %r14, %rdi
jmp 0x1a142
xorpd %xmm0, %xmm0
ucomisd (%rbx), %xmm0
seta %al
testb %al, %al
je 0x1a13b
cmpl $0x0, 0xf7299(%rip)     # 0x1113c4
je 0x1a482
movl $0x1, 0xf7285(%rip)     # 0x1113c0
movq 0x23ffe(%rip), %rdi     # 0x3e140
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8b01
cmpb $0x5, 0x10(%r14)
je 0x1a16a
movzbl 0x10(%rbx), %eax
cmpl $0x4, %eax
je 0x1a183
cmpl $0x5, %eax
jne 0x1a1d0
movq %r14, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a860
movq 0x8(%rbx), %rax
cmpl $0x1, -0x4(%rax)
jne 0x1a1d0
cmpl $0x1, (%rax)
jne 0x1a1d0
movq (%r14), %rdi
movq (%rbx), %rsi
callq 0x851d
movq %rax, %r15
movq 0x8(%r14), %rdi
movq (%rbx), %rsi
callq 0x851d
movzbl 0x10(%r14), %ecx
cmpl $0x5, %ecx
je 0x1a3eb
cmpl $0x4, %ecx
jne 0x1a403
cmpb $0x1, 0x12(%r14)
sete %cl
jmp 0x1a3f7
movl 0x200e1(%rip), %r15d    # 0x3a2b8
movq 0x290d2(%rip), %rdi     # 0x432b0
callq 0x8b01
movq %r14, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x3, %edi
callq 0x8ad9
callq 0x1752f
movl 0x200b0(%rip), %eax     # 0x3a2b8
movl %r15d, -0x2c(%rbp)
subl %r15d, %eax
jle 0x1a2bd
movslq -0x2c(%rbp), %rbx
movl %eax, %esi
shlq $0x3, %rbx
xorl %r12d, %r12d
leaq 0x29397(%rip), %r14     # 0x435c0
leaq 0x267d0(%rip), %r15     # 0x40a00
movq %rsi, -0x38(%rbp)
leaq (%rbx,%r12,8), %rax
movq (%r14,%rax), %rax
movb 0x10(%rax), %cl
cmpb $0x1, %cl
movq %r15, %rdx
cmoveq %rax, %rdx
movq (%rdx), %rdx
cmpq 0x2905d(%rip), %rdx     # 0x432b0
jne 0x1a2b1
addq $0x8, %rax
cmpb $0x1, %cl
cmovneq %r15, %rax
movq (%rax), %rax
movb 0x10(%rax), %dl
leaq 0x8(%rax), %rcx
cmpb $0x1, %dl
cmovneq %r15, %rax
movq %r15, %rsi
cmoveq %rcx, %rsi
movq (%rsi), %rsi
cmpb $0x1, 0x10(%rsi)
movq %r15, %rsi
jne 0x1a28e
cmpb $0x1, %dl
cmovneq %r15, %rcx
movq (%rcx), %rsi
leaq (,%r12,8), %r13
movq (%rax), %rdi
movq (%rsi), %rsi
callq 0x1a945
callq 0x8b78
addq %rbx, %r13
movq %rax, (%r14,%r13)
movq -0x38(%rbp), %rsi
incq %r12
cmpq %r12, %rsi
jne 0x1a234
movq 0xec814(%rip), %rbx     # 0x106ad8
movl 0x1ffed(%rip), %r14d    # 0x3a2b8
leaq 0x292ee(%rip), %r12     # 0x435c0
movl -0x2c(%rbp), %r15d
cmpl %r14d, %r15d
jge 0x1a35a
movl %r15d, %r13d
movslq %r13d, %rax
movq (%r12,%rax,8), %r14
movb 0x10(%r14), %al
andb $-0x2, %al
cmpb $0x4, %al
jne 0x1a34b
movq %rbx, %rdi
callq 0x8b01
movq %r14, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
callq 0x8b78
movq %rax, %rbx
movl 0x1ffa1(%rip), %eax     # 0x3a2b8
leal 0x1(%r13), %ecx
cmpl %eax, %ecx
jge 0x1a340
movslq %ecx, %rcx
leaq (%r12,%rcx,8), %rcx
leal -0x1(%rax), %edx
movl %r13d, %esi
movq (%rcx), %rdi
movslq %esi, %rsi
movq %rdi, (%r12,%rsi,8)
incl %esi
addq $0x8, %rcx
cmpl %esi, %edx
jne 0x1a32c
decl %eax
movl %eax, 0x1ff70(%rip)     # 0x3a2b8
decl %r13d
incl %r13d
movl 0x1ff63(%rip), %r14d    # 0x3a2b8
cmpl %r14d, %r13d
jl 0x1a2de
subl %r15d, %r14d
je 0x1a375
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
jne 0x1a380
movq %rbx, %rdi
callq 0x8b01
incl %r14d
cmpl $0x1, %r14d
jne 0x1a395
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x1ff1c(%rip), %rax     # 0x3a2b8
leaq (%r12,%rax,8), %rdi
movslq %r14d, %rsi
leaq (,%rsi,8), %rax
subq %rax, %rdi
leaq -0x1b0b(%rip), %rcx     # 0x188aa
movl $0x8, %edx
callq 0x70a0
movl %r14d, %edi
callq 0x8ad9
movq 0x28eda(%rip), %rdi     # 0x432a8
callq 0x8b01
callq 0xad38
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8b47
xorpd %xmm0, %xmm0
ucomisd (%r14), %xmm0
seta %cl
testb %cl, %cl
je 0x1a403
movq (%rbx), %rcx
testb $0x1, (%rcx)
jne 0x1a44e
movzbl 0x10(%rbx), %ecx
cmpl $0x5, %ecx
je 0x1a41a
cmpl $0x4, %ecx
jne 0x1a433
cmpb $0x1, 0x12(%rbx)
sete %cl
jmp 0x1a425
xorpd %xmm0, %xmm0
ucomisd (%rbx), %xmm0
seta %cl
testb %cl, %cl
je 0x1a433
xorl %edi, %edi
movq %rax, %rsi
movq %r15, %rdx
jmp 0x1a43b
xorl %edi, %edi
movq %r15, %rsi
movq %rax, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb9f7
movzbl 0x10(%rbx), %ecx
cmpl $0x5, %ecx
je 0x1a465
cmpl $0x4, %ecx
jne 0x1a47b
cmpb $0x1, 0x12(%rbx)
sete %cl
jmp 0x1a470
xorpd %xmm0, %xmm0
ucomisd (%rbx), %xmm0
seta %cl
testb %cl, %cl
je 0x1a47b
movl $0x1, %edi
jmp 0x1a42b
movl $0x1, %edi
jmp 0x1a435
leaq 0xbd05(%rip), %rdi      # 0x2618e
callq 0x77c8