// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]eigenmath/eigenmath.c
// Function: logfunc
void
logfunc(void)
{
	int h, i, n;
	double d;
	struct atom *p1, *p2;

	p1 = pop();

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

	if (hasdouble(p1)) {
		push(p1);
		floatfunc();
		p1 = pop();
	}

	if (iszero(p1)) {
		push_symbol(LOG);
		push_integer(0);
		list(2);
		return;
	}

	if (isdouble(p1)) {
		push(p1);
		d = pop_double();
		if (d > 0.0) {
			push_double(log(d));
			return;
		}
	}

	// log(z) -> log(mag(z)) + i arg(z)

	if (isdouble(p1) || isdoublez(p1)) {
		push(p1);
		magfunc();
		logfunc();
		push(p1);
		argfunc();
		push(imaginaryunit);
		multiply();
		add();
		return;
	}

	// log(1) -> 0

	if (isplusone(p1)) {
		push_integer(0);
		return;
	}

	// log(e) -> 1

	if (p1 == symbol(EXP1)) {
		push_integer(1);
		return;
	}

	if (isnegativenumber(p1)) {
		push(p1);
		negate();
		logfunc();
		push(imaginaryunit);
		push_symbol(PI);
		multiply();
		add();
		return;
	}

	// log(10) -> log(2) + log(5)

	if (isrational(p1)) {
		h = tos;
		push(p1);
		factor_factor();
		for (i = h; i < tos; i++) {
			p2 = stack[i];
			if (car(p2) == symbol(POWER)) {
				push(caddr(p2)); // exponent
				push_symbol(LOG);
				push(cadr(p2)); // base
				list(2);
				multiply();
			} else {
				push_symbol(LOG);
				push(p2);
				list(2);
			}
			stack[i] = pop();
		}
		add_terms(tos - h);
		return;
	}

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

	if (car(p1) == symbol(POWER)) {
		push(caddr(p1));
		push(cadr(p1));
		logfunc();
		multiply();
		return;
	}

	// log(a * b) -> log(a) + log(b)

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x8b78
movq %rax, %rbx
cmpb $0x7, 0x10(%rax)
jne 0xc623
movq %rbx, %rdi
callq 0x953d
movq %rax, %rbx
movq (%rax), %rax
movslq 0x64(%rax), %r14
testq %r14, %r14
jle 0xc60d
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x68(%rax,%r15,8), %rdi
callq 0x8b01
callq 0xc5b0
callq 0x8b78
movq (%rbx), %rcx
movq %rax, 0x68(%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0xc5e6
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8b01
movq %rbx, %rdi
callq 0xe24b
testl %eax, %eax
je 0xc644
movq %rbx, %rdi
callq 0x8b01
callq 0xa7fa
callq 0x8b78
movq %rax, %rbx
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
je 0xc680
movq 0x33d79(%rip), %rdi     # 0x403d0
callq 0x8b01
movq 0x31add(%rip), %rdi     # 0x3e140
callq 0x8b01
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8ad9
cmpb $0x5, 0x10(%rbx)
jne 0xc6c1
movq %rbx, %rdi
callq 0x8b01
callq 0x9086
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc6c1
callq 0x7150
movsd %xmm0, -0x30(%rbp)
callq 0x74ec
movb $0x5, 0x10(%rax)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %rax, %rdi
jmp 0xc610
movzbl 0x10(%rbx), %r14d
cmpl $0x5, %r14d
je 0xc6d8
movq %rbx, %rdi
callq 0xc3a9
testl %eax, %eax
je 0xc725
movq %rbx, %rdi
callq 0x8b01
callq 0xe8e3
callq 0xc5b0
movq %rbx, %rdi
callq 0x8b01
callq 0xddb0
movq 0xfa3e2(%rip), %rdi     # 0x106ae0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa975
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
je 0xc747
movq 0x319fe(%rip), %rdi     # 0x3e140
jmp 0xc610
cmpq 0x36b7a(%rip), %rbx     # 0x432c8
je 0xc776
movq %rbx, %rax
cmpl $0x1, %r14d
je 0xc903
cmpl $0x5, %r14d
je 0xc782
cmpl $0x4, %r14d
jne 0xc8fc
cmpb $0x1, 0x12(%rbx)
sete %al
jmp 0xc78d
movq 0xfa35b(%rip), %rdi     # 0x106ad8
jmp 0xc610
xorpd %xmm0, %xmm0
ucomisd (%rbx), %xmm0
seta %al
testb %al, %al
je 0xc7cc
movq %rbx, %rdi
callq 0x8b01
movq 0x104c50(%rip), %rdi    # 0x1113f0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
callq 0xc5b0
movq 0xfa325(%rip), %rdi     # 0x106ae0
callq 0x8b01
movq 0x34889(%rip), %rdi     # 0x41050
jmp 0xc6fe
movq %rbx, %rax
cmpl $0x1, %r14d
je 0xc903
cmpl $0x4, %r14d
jne 0xc8fc
movslq 0x2dace(%rip), %r13     # 0x3a2b8
movq %rbx, %rdi
callq 0x8b01
callq 0x1752f
movl 0x2dabb(%rip), %edi     # 0x3a2b8
cmpl %edi, %r13d
jge 0xc8f4
leaq 0x36db3(%rip), %rax     # 0x435c0
leaq (%rax,%r13,8), %r15
leaq 0x341e8(%rip), %r12     # 0x40a00
movq %r13, -0x30(%rbp)
movq (%r15), %rbx
movb 0x10(%rbx), %al
cmpb $0x1, %al
movq %r12, %rcx
cmoveq %rbx, %rcx
movq (%rcx), %rcx
cmpq 0x36a7b(%rip), %rcx     # 0x432b0
je 0xc857
movq 0x33b92(%rip), %rdi     # 0x403d0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0x8ad9
jmp 0xc8d1
leaq 0x8(%rbx), %r14
cmpb $0x1, %al
movq %r12, %rax
cmoveq %r14, %rax
movq (%rax), %rax
movb 0x10(%rax), %cl
addq $0x8, %rax
cmpb $0x1, %cl
movq %r12, %rdx
cmoveq %rax, %rdx
movq (%rdx), %rdx
cmpb $0x1, 0x10(%rdx)
movq %r12, %rdx
jne 0xc88e
cmpb $0x1, %cl
cmovneq %r12, %rax
movq (%rax), %rdx
movq (%rdx), %rdi
callq 0x8b01
movq 0x33b33(%rip), %rdi     # 0x403d0
callq 0x8b01
cmpb $0x1, 0x10(%rbx)
cmovneq %r12, %r14
movq (%r14), %rax
cmpb $0x1, 0x10(%rax)
cmovneq %r12, %rax
movq (%rax), %rdi
callq 0x8b01
movl $0x2, %edi
callq 0x8ad9
movl $0x2, %edi
callq 0xa8bb
callq 0x8b78
movq %rax, (%r15)
incq %r13
movslq 0x2d9d5(%rip), %rdi     # 0x3a2b8
addq $0x8, %r15
cmpq %rdi, %r13
jl 0xc81c
movq -0x30(%rbp), %r13
subl %r13d, %edi
jmp 0xc712
leaq 0x340fd(%rip), %rax     # 0x40a00
movq (%rax), %rax
cmpq 0x369a3(%rip), %rax     # 0x432b0
je 0xc945
cmpl $0x1, %r14d
leaq 0x340e6(%rip), %r15     # 0x40a00
movq %r15, %rax
cmoveq %rbx, %rax
movq (%rax), %rax
cmpq 0x3697d(%rip), %rax     # 0x432a8
je 0xc9cc
movq 0x33a98(%rip), %rdi     # 0x403d0
callq 0x8b01
movq %rbx, %rdi
jmp 0xc663
leaq 0x8(%rbx), %r15
cmpl $0x1, %r14d
leaq 0x340ac(%rip), %r14     # 0x40a00
movq %r14, %rax
cmoveq %r15, %rax
movq (%rax), %rax
movb 0x10(%rax), %cl
addq $0x8, %rax
cmpb $0x1, %cl
movq %r14, %rdx
cmoveq %rax, %rdx
movq (%rdx), %rdx
cmpb $0x1, 0x10(%rdx)
movq %r14, %rdx
jne 0xc98c
cmpb $0x1, %cl
leaq 0x3407b(%rip), %rcx     # 0x40a00
cmoveq %rax, %rcx
movq (%rcx), %rdx
movq (%rdx), %rdi
callq 0x8b01
cmpb $0x1, 0x10(%rbx)
cmovneq %r14, %r15
movq (%r15), %rax
cmpb $0x1, 0x10(%rax)
cmoveq %rax, %r14
movq (%r14), %rdi
callq 0x8b01
callq 0xc5b0
movl $0x2, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa8bb
addq $0x8, %rbx
cmpl $0x1, %r14d
cmovneq %r15, %rbx
movl 0x2d8d9(%rip), %r14d    # 0x3a2b8
movq (%rbx), %rbx
cmpb $0x1, 0x10(%rbx)
jne 0xca06
movq (%rbx), %rdi
callq 0x8b01
callq 0xc5b0
leaq 0x8(%rbx), %rax
cmpb $0x1, 0x10(%rbx)
cmovneq %r15, %rax
movq (%rax), %rbx
jmp 0xc9e2
movl 0x2d8ac(%rip), %edi     # 0x3a2b8
subl %r14d, %edi
jmp 0xc712