// File: /workspace/github_c_makefile_star2_O3/georgeweigt[P]eigenmath/eigenmath.c
// Function: power
void
power(void)
{
	int h, i, n;
	struct atom *p1, *BASE, *EXPO;

	EXPO = pop();
	BASE = pop();

	if (istensor(BASE) && istensor(EXPO)) {
		push_symbol(POWER);
		push(BASE);
		push(EXPO);
		list(3);
		return;
	}

	if (istensor(EXPO)) {
		p1 = copy_tensor(EXPO);
		n = p1->u.tensor->nelem;
		for (i = 0; i < n; i++) {
			push(BASE);
			push(p1->u.tensor->elem[i]);
			power();
			p1->u.tensor->elem[i] = pop();
		}
		push(p1);
		return;
	}

	if (istensor(BASE)) {
		p1 = copy_tensor(BASE);
		n = p1->u.tensor->nelem;
		for (i = 0; i < n; i++) {
			push(p1->u.tensor->elem[i]);
			push(EXPO);
			power();
			p1->u.tensor->elem[i] = pop();
		}
		push(p1);
		return;
	}

	if (BASE == symbol(EXP1) && isdouble(EXPO)) {
		push_double(M_E);
		BASE = pop();
	}

	if (BASE == symbol(PI) && isdouble(EXPO)) {
		push_double(M_PI);
		BASE = pop();
	}

	if (isnum(BASE) && isnum(EXPO)) {
		power_numbers(BASE, EXPO);
		return;
	}

	// expr^0

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

	// 0^expr

	if (iszero(BASE)) {
		push_symbol(POWER);
		push(BASE);
		push(EXPO);
		list(3);
		return;
	}

	// 1^expr

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

	// expr^1

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

	// BASE is an integer?

	if (isinteger(BASE)) {
		// raise each factor in BASE to power EXPO
		// EXPO is not numerical, that case was handled by power_numbers() above
		h = tos;
		push(BASE);
		factor_factor();
		n = tos - h;
		for (i = 0; i < n; i++) {
			p1 = stack[h + i];
			if (car(p1) == symbol(POWER)) {
				push_symbol(POWER);
				push(cadr(p1)); // base
				push(caddr(p1)); // expo
				push(EXPO);
				multiply();
				list(3);
			} else {
				push_symbol(POWER);
				push(p1);
				push(EXPO);
				list(3);
			}
			stack[h + i] = pop();
		}
		if (n > 1) {
			sort_factors(n);
			list(n);
			push_symbol(MULTIPLY);
			swap();
			cons(); // prepend MULTIPLY to list
		}
		return;
	}

	// BASE is a numerical fraction?

	if (isfraction(BASE)) {
		// power numerator, power denominator
		// EXPO is not numerical, that case was handled by power_numbers() above
		push(BASE);
		numerator();
		push(EXPO);
		power();
		push(BASE);
		denominator();
		push(EXPO);
		negate();
		power();
		multiply();
		return;
	}

	// BASE = e ?

	if (BASE == symbol(EXP1)) {
		power_natural_number(EXPO);
		return;
	}

	// (a + b) ^ c

	if (car(BASE) == symbol(ADD)) {
		power_sum(BASE, EXPO);
		return;
	}

	// (a b) ^ c  -->  (a ^ c) (b ^ c)

	if (car(BASE) == symbol(MULTIPLY)) {
		h = tos;
		p1 = cdr(BASE);
		while (iscons(p1)) {
			push(car(p1));
			push(EXPO);
			power();
			p1 = cdr(p1);
		}
		multiply_factors(tos - h);
		return;
	}

	// (a ^ b) ^ c  -->  a ^ (b c)

	if (car(BASE) == symbol(POWER)) {
		push(cadr(BASE));
		push(caddr(BASE));
		push(EXPO);
		multiply_expand(); // always expand products of exponents
		power();
		return;
	}

	// none of the above

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0x34d2d(%rip), %r13d    # 0x3f2b8
leal -0x186a1(%r13), %eax
cmpl $0xfffe7960, %eax       # imm = 0xFFFE7960
jb 0xa7dd
leaq 0x3e01c(%rip), %r15     # 0x485c0
leaq 0x3b455(%rip), %r12     # 0x45a00
leal -0x1(%r13), %eax
movl %eax, 0x34d03(%rip)     # 0x3f2b8
cmpl $0x1, %r13d
jbe 0xa7dd
movq (%r15,%rax,8), %rbx
addl $-0x2, %r13d
movl %r13d, 0x34cea(%rip)    # 0x3f2b8
movq (%r15,%r13,8), %r14
cmpb $0x7, 0x10(%r14)
movb 0x10(%rbx), %al
je 0xa7f5
cmpb $0x7, %al
je 0xa831
cmpb $0x5, %al
jne 0xa639
cmpq 0x3dcd5(%rip), %r14     # 0x482c8
jne 0xa639
callq 0x74dc
movb $0x5, 0x10(%rax)
movabsq $0x4005bf0a8b145769, %rcx # imm = 0x4005BF0A8B145769
movq %rcx, (%rax)
movq %rax, %rdi
callq 0x8ba5
movl 0x34c9e(%rip), %r13d    # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rcx,%r13), %eax
cmpl %ecx, %eax
jbe 0xa7dd
decl %r13d
movl %r13d, 0x34c83(%rip)    # 0x3f2b8
movq (%r15,%r13,8), %r14
cmpq 0x3ba10(%rip), %r14     # 0x46050
jne 0xa68c
cmpb $0x5, 0x10(%rbx)
jne 0xa68c
callq 0x74dc
movb $0x5, 0x10(%rax)
movabsq $0x400921fb54442d18, %rcx # imm = 0x400921FB54442D18
movq %rcx, (%rax)
movq %rax, %rdi
callq 0x8ba5
movl 0x34c4b(%rip), %r13d    # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rcx,%r13), %eax
cmpl %ecx, %eax
jbe 0xa7dd
decl %r13d
movl %r13d, 0x34c30(%rip)    # 0x3f2b8
movq (%r15,%r13,8), %r14
movb 0x10(%r14), %r15b
movl %r15d, %eax
andb $-0x2, %al
cmpb $0x4, %al
jne 0xa6a6
movb 0x10(%rbx), %al
andb $-0x2, %al
cmpb $0x4, %al
je 0xabb9
movq %rbx, %rdi
callq 0xb477
testl %eax, %eax
jne 0xa7e9
movq %r14, %rdi
callq 0xb477
testl %eax, %eax
jne 0xa7fd
movq %r14, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
jne 0xa7e9
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd1c4
testl %eax, %eax
jne 0xaba3
cmpb $0x4, %r15b
je 0xa8a9
cmpq 0x3dbbd(%rip), %r14     # 0x482c8
je 0xaa2d
cmpb $0x1, %r15b
movq %r12, %rax
cmoveq %r14, %rax
movq (%rax), %rax
cmpq 0x3db7a(%rip), %rax     # 0x482a0
je 0xaa43
cmpq 0x3db75(%rip), %rax     # 0x482a8
je 0xaa5c
movq 0x3db70(%rip), %rdi     # 0x482b0
cmpq %rdi, %rax
jne 0xa804
leaq 0x8(%r14), %r13
cmpb $0x1, %r15b
movq %r12, %rax
cmoveq %r13, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmovneq %r12, %rax
movq (%rax), %rdi
callq 0x8ba5
cmpb $0x1, 0x10(%r14)
cmovneq %r12, %r13
movq (%r13), %rax
cmpb $0x1, 0x10(%rax)
jne 0xa784
movq 0x8(%rax), %rax
jmp 0xa78b
movq 0x3b275(%rip), %rax     # 0x45a00
cmpb $0x1, 0x10(%rax)
movq %r12, %rcx
leaq 0x3de27(%rip), %r15     # 0x485c0
jne 0xa79e
movq %rax, %rcx
movq (%rcx), %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
incl 0x10131c(%rip)          # 0x10bad0
movl $0x2, %edi
callq 0xacef
decl 0x10130c(%rip)          # 0x10bad0
movl 0x34aed(%rip), %r13d    # 0x3f2b8
leal -0x186a1(%r13), %eax
cmpl $0xfffe7960, %eax       # imm = 0xFFFE7960
jae 0xa5ab
leaq 0x2475d(%rip), %rdi     # 0x2ef41
callq 0x780b
movq 0x1012e8(%rip), %rdi    # 0x10bad8
jmp 0xaba6
cmpb $0x7, %al
jne 0xab33
movq 0x3daac(%rip), %rdi     # 0x482b0
callq 0x8ba5
movq %r14, %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movl $0x3, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8b7d
movq %rbx, %rdi
callq 0x9638
movq %rax, %rbx
movq (%rax), %rax
movslq 0x64(%rax), %r15
testq %r15, %r15
jle 0xa8a1
xorl %r12d, %r12d
movl $0xfffe795f, %r13d      # imm = 0xFFFE795F
movq %r14, %rdi
callq 0x8ba5
movq (%rbx), %rax
movq 0x68(%rax,%r12,8), %rdi
callq 0x8ba5
callq 0xa573
movl 0x34a47(%rip), %eax     # 0x3f2b8
leal (%rax,%r13), %ecx
cmpl %r13d, %ecx
jbe 0xa7dd
decl %eax
movl %eax, 0x34a32(%rip)     # 0x3f2b8
leaq 0x3dd33(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rax
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xa851
movq %rbx, %rdi
jmp 0xaba6
movq 0x8(%r14), %rax
cmpl $0x1, -0x4(%rax)
jne 0xaab3
cmpl $0x1, (%rax)
jne 0xaab3
movq %r14, %rdi
callq 0x8ba5
callq 0x190c2
movl 0x349e5(%rip), %eax     # 0x3f2b8
subl %r13d, %eax
leaq 0x3dce3(%rip), %r15     # 0x485c0
jle 0xaa1e
movl %r13d, %esi
movl %eax, -0x2c(%rbp)
movl %eax, %eax
movq %rax, -0x38(%rbp)
shlq $0x3, %rsi
xorl %r14d, %r14d
leaq 0x3b103(%rip), %r13     # 0x45a00
movq %rsi, -0x40(%rbp)
leaq (%rsi,%r14,8), %rax
movq (%r15,%rax), %r12
cmpb $0x1, 0x10(%r12)
movq %r13, %rax
cmoveq %r12, %rax
movq (%rax), %r15
movq 0x3d990(%rip), %r13     # 0x482b0
movq %r13, %rdi
callq 0x8ba5
cmpq %r13, %r15
je 0xa94d
movq %r12, %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
leaq 0x3dc7c(%rip), %r15     # 0x485c0
leaq 0x3b0b5(%rip), %r13     # 0x45a00
jmp 0xa9c6
cmpb $0x1, 0x10(%r12)
leaq 0x8(%r12), %r15
leaq 0x3b0a1(%rip), %r13     # 0x45a00
movq %r13, %rax
cmoveq %r15, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmovneq %r13, %rax
movq (%rax), %rdi
callq 0x8ba5
cmpb $0x1, 0x10(%r12)
cmovneq %r13, %r15
movq (%r15), %rax
cmpb $0x1, 0x10(%rax)
jne 0xa992
movq 0x8(%rax), %rax
jmp 0xa999
movq 0x3b067(%rip), %rax     # 0x45a00
cmpb $0x1, 0x10(%rax)
movq %r13, %rcx
leaq 0x3dc19(%rip), %r15     # 0x485c0
jne 0xa9ac
movq %rax, %rcx
movq (%rcx), %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xacef
movl $0x3, %edi
callq 0x8b7d
movl 0x348e2(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %edx       # imm = 0xFFFE795F
leal (%rax,%rdx), %ecx
cmpl %edx, %ecx
jbe 0xa7dd
leaq (,%r14,8), %rcx
decl %eax
movl %eax, 0x348c2(%rip)     # 0x3f2b8
movq (%r15,%rax,8), %rdx
movq -0x40(%rbp), %rsi
addq %rsi, %rcx
movq %rdx, (%r15,%rcx)
incq %r14
cmpq %r14, -0x38(%rbp)
jne 0xa901
movl -0x2c(%rbp), %ebx
cmpl $0x1, %ebx
jne 0xabd2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c4ac
movq %r14, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c6e9
addq $0x8, %r14
cmpb $0x1, %r15b
leaq 0x3af95(%rip), %r15     # 0x45a00
cmovneq %r15, %r14
movq (%r14), %r14
cmpb $0x1, 0x10(%r14)
movl %r13d, %edi
jne 0xaaae
movq (%r14), %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
callq 0xa573
leaq 0x8(%r14), %rax
cmpb $0x1, 0x10(%r14)
cmovneq %r15, %rax
movq (%rax), %r14
cmpb $0x1, 0x10(%r14)
je 0xaa7c
movl 0x3480a(%rip), %edi     # 0x3f2b8
subl %r13d, %edi
jmp 0xab20
movq %r14, %rdi
callq 0x8ba5
callq 0xe238
movq %rbx, %rdi
callq 0x8ba5
callq 0xa573
movq %r14, %rdi
callq 0x8ba5
callq 0xe915
movl 0x347d8(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0xa7dd
decl %eax
movl %eax, 0x347c0(%rip)     # 0x3f2b8
movq %rbx, %rdi
callq 0x8ba5
movq 0x10b8e9(%rip), %rdi    # 0x1163f0
callq 0x8ba5
movl $0x2, %edi
callq 0xacef
callq 0xa573
movl $0x2, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xacef
movq %r14, %rdi
callq 0x9638
movq %rax, %r14
movq (%rax), %rax
movslq 0x64(%rax), %r15
testq %r15, %r15
jle 0xaba3
xorl %r12d, %r12d
movl $0xfffe795f, %r13d      # imm = 0xFFFE795F
movq (%r14), %rax
movq 0x68(%rax,%r12,8), %rdi
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
callq 0xa573
movl 0x34745(%rip), %eax     # 0x3f2b8
leal (%rax,%r13), %ecx
cmpl %r13d, %ecx
jbe 0xa7dd
decl %eax
movl %eax, 0x34730(%rip)     # 0x3f2b8
leaq 0x3da31(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rax
movq (%r14), %rcx
movq %rax, 0x68(%rcx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xab53
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
movq %r14, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c062
leaq (%r15,%rax,8), %rdi
movq -0x38(%rbp), %rsi
leaq (,%rsi,8), %rax
subq %rax, %rdi
leaq 0xf9d9(%rip), %rcx      # 0x1a5c5
movl $0x8, %edx
callq 0x70a0
movl %ebx, %edi
callq 0x8b7d
movq 0x3d6a4(%rip), %rdi     # 0x482a8
callq 0x8ba5
callq 0xb238
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8be6