// File: /workspace/github_c_makefile_star2_O0/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
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x297f0
movl $0x1, %edi
callq 0xca50
jmp 0x29d27
movq -0x8(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2983b
movq -0x10(%rbp), %rdi
callq 0x9e30
cmpl $0x0, %eax
je 0x2982f
cmpl $0x0, 0x105bb1(%rip)    # 0x12f3c4
je 0x29821
movl $0x1, 0x105ba1(%rip)    # 0x12f3c0
jmp 0x2982d
leaq 0x1b936(%rip), %rdi     # 0x4515e
callq 0x78d0
jmp 0x2982f
xorl %edi, %edi
callq 0xca50
jmp 0x29d27
movq -0x8(%rbp), %rdi
callq 0xd4c0
cmpl $0x0, %eax
je 0x29858
movl $0x1, %edi
callq 0xca50
jmp 0x29d27
movq -0x10(%rbp), %rdi
callq 0xd4c0
cmpl $0x0, %eax
je 0x29874
movq -0x8(%rbp), %rdi
callq 0x9110
jmp 0x29d27
movq -0x8(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x5, %eax
je 0x2988e
movq -0x10(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x5, %eax
jne 0x298a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2a830
jmp 0x29d27
movq -0x10(%rbp), %rdi
callq 0x9bc0
cmpl $0x0, %eax
je 0x2996b
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x8a20
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x8a20
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9e30
cmpl $0x0, %eax
je 0x29936
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x29936
movq -0x10(%rbp), %rdi
callq 0x9e30
cmpl $0x0, %eax
je 0x29922
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x1, %edi
callq 0xe740
jmp 0x29934
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl $0x1, %edi
callq 0xe740
jmp 0x29966
movq -0x10(%rbp), %rdi
callq 0x9e30
cmpl $0x0, %eax
je 0x29955
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
xorl %edi, %edi
callq 0xe740
jmp 0x29964
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
xorl %edi, %edi
callq 0xe740
jmp 0x29966
jmp 0x29d27
movl 0x2e947(%rip), %eax     # 0x582b8
movl %eax, -0x14(%rbp)
movq 0x37935(%rip), %rdi     # 0x612b0
callq 0x9110
movq -0x8(%rbp), %rdi
callq 0x9110
movq -0x10(%rbp), %rdi
callq 0x9110
movl $0x3, %edi
callq 0x90d0
callq 0x247f0
movl 0x2e911(%rip), %eax     # 0x582b8
subl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x29bf0
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
movslq %eax, %rcx
leaq 0x37bf0(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x299f2
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x299fd
movq 0x35007(%rip), %rax     # 0x5ea00
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq 0x378a8(%rip), %rax     # 0x612b0
jne 0x29be0
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29a29
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x29a34
movq 0x34fd0(%rip), %rax     # 0x5ea00
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29a74
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29a5c
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x29a67
movq 0x34f9d(%rip), %rax     # 0x5ea00
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x29a7f
movq 0x34f85(%rip), %rax     # 0x5ea00
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29aa2
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x29aad
movq 0x34f57(%rip), %rax     # 0x5ea00
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29aee
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29ad5
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x29ae0
movq 0x34f24(%rip), %rax     # 0x5ea00
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x29af9
movq 0x34f0b(%rip), %rax     # 0x5ea00
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29b9e
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29b25
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x29b30
movq 0x34ed4(%rip), %rax     # 0x5ea00
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29b7d
movq -0x38(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x29b5b
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x29b69
movq 0x34e9e(%rip), %rax     # 0x5ea00
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0x29b8b
movq 0x34e7c(%rip), %rax     # 0x5ea00
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0x29bac
movq 0x34e5b(%rip), %rax     # 0x5ea00
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2a920
callq 0x91d0
movq %rax, %rdx
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
movslq %eax, %rcx
leaq 0x379e4(%rip), %rax     # 0x615c0
movq %rdx, (%rax,%rcx,8)
jmp 0x29be2
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x299b4
movq 0xfaee1(%rip), %rax     # 0x124ad8
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl 0x2e6ae(%rip), %eax     # 0x582b8
jge 0x29cc7
movslq -0x18(%rbp), %rcx
leaq 0x379a5(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x4, %eax
je 0x29c3d
movq -0x40(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x5, %eax
jne 0x29cb7
movq -0x38(%rbp), %rdi
callq 0x9110
movq -0x40(%rbp), %rdi
callq 0x9110
callq 0xc280
callq 0x91d0
movq %rax, -0x38(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x2e649(%rip), %eax     # 0x582b8
jge 0x29c9f
movslq -0x1c(%rbp), %rcx
leaq 0x37944(%rip), %rax     # 0x615c0
movq (%rax,%rcx,8), %rdx
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x37930(%rip), %rax     # 0x615c0
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x29c66
movl 0x2e613(%rip), %eax     # 0x582b8
addl $-0x1, %eax
movl %eax, 0x2e60a(%rip)     # 0x582b8
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x29cb9
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x29c01
movl 0x2e5eb(%rip), %eax     # 0x582b8
subl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x29ce7
movq -0x38(%rbp), %rdi
callq 0xd4c0
cmpl $0x0, %eax
jne 0x29cf9
movq -0x38(%rbp), %rdi
callq 0x9110
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x1, -0x20(%rbp)
jne 0x29d01
jmp 0x29d27
movl -0x20(%rbp), %edi
callq 0x26b20
movl -0x20(%rbp), %edi
callq 0x90d0
movq 0x37590(%rip), %rdi     # 0x612a8
callq 0x9110
callq 0xcb10
callq 0x9180
addq $0xa0, %rsp
popq %rbp
retq