// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]eigenmath/eigenmath.c
// Function: absfunc
void
absfunc(void)
{
	int h;
	struct atom *p1, *p2, *p3;

	p1 = pop();

	if (isnum(p1)) {
		push(p1);
		if (isnegativenumber(p1))
			negate();
		return;
	}

	if (istensor(p1)) {
		if (p1->u.tensor->ndim > 1) {
			push_symbol(ABS);
			push(p1);
			list(2);
			return;
		}
		push(p1);
		push(p1);
		conjfunc();
		inner();
		push_rational(1, 2);
		power();
		return;
	}

	push(p1);
	push(p1);
	conjfunc();
	multiply();
	push_rational(1, 2);
	power();

	p2 = pop();
	push(p2);
	floatfunc();
	p3 = pop();
	if (isdouble(p3)) {
		push(p2);
		if (isnegativenumber(p3))
			negate();
		return;
	}

	// abs(1/a) evaluates to 1/abs(a)

	if (car(p1) == symbol(POWER) && isnegativeterm(caddr(p1))) {
		push(p1);
		reciprocate();
		absfunc();
		reciprocate();
		return;
	}

	// abs(a*b) evaluates to abs(a)*abs(b)

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

	if (isnegativeterm(p1) || (car(p1) == symbol(ADD) && isnegativeterm(cadr(p1)))) {
		push(p1);
		negate();
		p1 = pop();
	}

	push_symbol(ABS);
	push(p1);
	list(2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x868d
movq %rax, %rbx
movzbl 0x10(%rax), %eax
leal -0x4(%rax), %ecx
cmpl $0x2, %ecx
jae 0x9544
movq %rbx, %rdi
callq 0x861b
movq %rbx, %rdi
callq 0x8c2a
addq $0x8, %rsp
testl %eax, %eax
je 0x95ea
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x975f
cmpl $0x7, %eax
jne 0x958d
movq (%rbx), %rax
cmpl $0x2, (%rax)
jge 0x9709
movq %rbx, %rdi
callq 0x861b
movq %rbx, %rdi
callq 0x861b
callq 0x9771
callq 0x9780
pushq $0x1
popq %rdi
pushq $0x2
popq %rsi
callq 0x9a47
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9a87
movq %rbx, %rdi
callq 0x861b
movq %rbx, %rdi
callq 0x861b
callq 0x9771
callq 0x9fae
pushq $0x1
popq %rdi
pushq $0x2
popq %rsi
callq 0x9a47
callq 0x9a87
callq 0x868d
movq %rax, %r14
movq %rax, %rdi
callq 0x861b
callq 0x9fbd
callq 0x868d
cmpb $0x5, 0x10(%rax)
jne 0x95f5
movq %rax, %r15
movq %r14, %rdi
callq 0x861b
movq %r15, %rdi
jmp 0x9524
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb 0x10(%rbx), %r15b
cmpb $0x1, %r15b
leaq 0x353ec(%rip), %r14     # 0x3e9f0
movq %r14, %rax
cmoveq %rbx, %rax
sete %r12b
movq (%rax), %r13
cmpq 0x37c87(%rip), %r13     # 0x412a0
je 0x964e
cmpq 0x37c76(%rip), %r13     # 0x41298
je 0x9669
movq %rbx, %rdi
callq 0x9fd6
testl %eax, %eax
je 0x9700
movq %rbx, %rdi
callq 0x861b
callq 0x975f
callq 0x868d
movq %rax, %rbx
jmp 0x9709
leaq 0x8(%rbx), %rax
cmpb $0x1, %r15b
cmovneq %r14, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
jne 0x96b8
movq 0x8(%rax), %rax
jmp 0x96bf
movl 0x2ec38(%rip), %r15d    # 0x382a8
addq $0x8, %rbx
testb $0x1, %r12b
cmoveq %r14, %rbx
movq (%rbx), %rbx
cmpb $0x1, 0x10(%rbx)
jne 0x969c
movq (%rbx), %rdi
callq 0x861b
callq 0x94f7
cmpb $0x1, 0x10(%rbx)
sete %r12b
jmp 0x9670
movl 0x2ec06(%rip), %edi     # 0x382a8
subl %r15d, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa04c
movq 0x35331(%rip), %rax     # 0x3e9f0
cmpb $0x1, 0x10(%rax)
movq %r14, %rcx
jne 0x96cb
movq %rax, %rcx
movq (%rcx), %rdi
callq 0x9fd6
testl %eax, %eax
je 0x961b
movq %rbx, %rdi
callq 0x861b
callq 0xa03a
callq 0x94f7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa03a
cmpq 0x37b89(%rip), %r13     # 0x41290
je 0x9733
movq 0x32a40(%rip), %rdi     # 0x3c150
callq 0x861b
movq %rbx, %rdi
callq 0x861b
pushq $0x2
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x85eb
movq %rbx, %rax
addq $0x8, %rax
cmpb $0x1, %r15b
cmovneq %r14, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmoveq %rax, %r14
movq (%r14), %rdi
callq 0x9fd6
testl %eax, %eax
jne 0x9634
jmp 0x9709