// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]eigenmath/eigenmath.c
// Function: arctan
void
arctan(void)
{
	int i, n;
	struct atom *X, *Y, *Z;

	X = pop();
	Y = pop();

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

	if (isnum(X) && isnum(Y)) {
		arctan_numbers(X, Y);
		return;
	}

	// arctan(z) = -1/2 i log((i - z) / (i + z))

	if (!iszero(X) && (isdoublez(X) || isdoublez(Y))) {
		push(Y);
		push(X);
		divide();
		Z = pop();
		push_double(-0.5);
		push(imaginaryunit);
		multiply();
		push(imaginaryunit);
		push(Z);
		subtract();
		push(imaginaryunit);
		push(Z);
		add();
		divide();
		logfunc();
		multiply();
		return;
	}

	// arctan(-y,x) = -arctan(y,x)

	if (isnegativeterm(Y)) {
		push(Y);
		negate();
		push(X);
		arctan();
		negate();
		return;
	}

	if (car(Y) == symbol(TAN) && isplusone(X)) {
		push(cadr(Y)); // x of tan(x)
		return;
	}

	push_symbol(ARCTAN);
	push(Y);
	push(X);
	list(3);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
callq 0x8b78
movq %rax, %rbx
callq 0x8b78
movq %rax, %r14
movb 0x10(%rax), %r15b
cmpb $0x7, %r15b
jne 0xd3c8
movq %r14, %rdi
callq 0x953d
movq %rax, %r14
movq (%rax), %rax
movslq 0x64(%rax), %r15
testq %r15, %r15
jle 0xd3b8
xorl %r12d, %r12d
movq (%r14), %rax
movq 0x68(%rax,%r12,8), %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
callq 0xd34a
callq 0x8b78
movq (%r14), %rcx
movq %rax, 0x68(%rcx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xd389
movq %r14, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x8b01
movl %r15d, %eax
andb $-0x2, %al
cmpb $0x4, %al
jne 0xd3ed
movb 0x10(%rbx), %al
andb $-0x2, %al
cmpb $0x4, %al
jne 0xd3ed
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xd5ca
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
je 0xd445
movq %r14, %rdi
callq 0xa813
testl %eax, %eax
je 0xd548
movq %r14, %rdi
callq 0x8b01
movq 0x103fd8(%rip), %rdi    # 0x1113f0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq %rbx, %rdi
callq 0x8b01
callq 0xd34a
movq 0x103fb5(%rip), %rdi    # 0x1113f0
callq 0x8b01
jmp 0xd536
movq %rbx, %rdi
callq 0xc3a9
testl %eax, %eax
jne 0xd45d
movq %r14, %rdi
callq 0xc3a9
testl %eax, %eax
je 0xd3f9
movq %r14, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movq 0x103f7c(%rip), %rdi    # 0x1113f0
callq 0x8b01
callq 0xa234
movl $0x2, %edi
callq 0xa8bb
callq 0x8b78
movq %rax, %rbx
callq 0x74ec
movb $0x5, 0x10(%rax)
movabsq $-0x4020000000000000, %rcx # imm = 0xBFE0000000000000
movq %rcx, (%rax)
movq %rax, %rdi
callq 0x8b01
movq 0xf962b(%rip), %rdi     # 0x106ae0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movq 0xf9615(%rip), %rdi     # 0x106ae0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movq 0x103f11(%rip), %rdi    # 0x1113f0
callq 0x8b01
movl $0x2, %edi
callq 0xa8bb
movl $0x2, %edi
callq 0xa975
movq 0xf95e1(%rip), %rdi     # 0x106ae0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xa975
movq 0x103ed3(%rip), %rdi    # 0x1113f0
callq 0x8b01
callq 0xa234
movl $0x2, %edi
callq 0xa8bb
callq 0xc5b0
movl $0x2, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xa8bb
cmpb $0x1, %r15b
leaq 0x334ad(%rip), %r12     # 0x40a00
movq %r12, %rax
cmoveq %r14, %rax
movq (%rax), %rax
cmpq 0x3476c(%rip), %rax     # 0x41cd0
je 0xd594
movq 0x30c2b(%rip), %rdi     # 0x3e198
callq 0x8b01
movq %r14, %rdi
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0x3, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x8ad9
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xcb82
testl %eax, %eax
je 0xd566
addq $0x8, %r14
cmpb $0x1, %r15b
cmovneq %r12, %r14
movq (%r14), %rax
cmpb $0x1, 0x10(%rax)
cmoveq %rax, %r12
movq (%r12), %rdi
jmp 0xd3bb