// File: /workspace/github_c_makefile_star2_O0/georgeweigt[P]eigenmath/eigenmath.c
// Function: normalize_polar_term_rational
void
normalize_polar_term_rational(struct atom *R)
{
	int n;

	// R = R mod 2

	push(R);
	push_integer(2);
	modfunc();
	R = pop();

	// convert negative rotation to positive

	if (R->sign == MMINUS) {
		push(R);
		push_integer(2);
		add();
		R = pop();
	}

	push(R);
	push_integer(2);
	multiply();
	floorfunc();
	n = pop_integer(); // number of 90 degree turns

	push(R);
	push_integer(n);
	push_rational(-1, 2);
	multiply();
	add();
	R = pop(); // remainder

	switch (n % 4) {

	case 0:
		if (iszero(R))
			push_integer(1);
		else {
			push_symbol(POWER);
			push_symbol(EXP1);
			push_symbol(MULTIPLY);
			push(R);
			push(imaginaryunit);
			push_symbol(PI);
			list(4);
			list(3);
		}
		break;

	case 1:
		if (iszero(R))
			push(imaginaryunit);
		else {
			push_symbol(MULTIPLY);
			push(imaginaryunit);
			push_symbol(POWER);
			push_symbol(EXP1);
			push_symbol(MULTIPLY);
			push(R);
			push(imaginaryunit);
			push_symbol(PI);
			list(4);
			list(3);
			list(3);
		}
		break;

	case 2:
		if (iszero(R))
			push_integer(-1);
		else {
			push_symbol(MULTIPLY);
			push_integer(-1);
			push_symbol(POWER);
			push_symbol(EXP1);
			push_symbol(MULTIPLY);
			push(R);
			push(imaginaryunit);
			push_symbol(PI);
			list(4);
			list(3);
			list(3);
		}
		break;

	case 3:
		if (iszero(R)) {
			push_symbol(MULTIPLY);
			push_integer(-1);
			push(imaginaryunit);
			list(3);
		} else {
			push_symbol(MULTIPLY);
			push_integer(-1);
			push(imaginaryunit);
			push_symbol(POWER);
			push_symbol(EXP1);
			push_symbol(MULTIPLY);
			push(R);
			push(imaginaryunit);
			push_symbol(PI);
			list(4);
			list(3);
			list(4);
		}
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
callq 0xca50
callq 0x14c60
callq 0x91d0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x1, %eax
jne 0x2be5b
movq -0x8(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
callq 0xca50
callq 0xc660
callq 0x91d0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
movl %edi, -0x1c(%rbp)
callq 0xca50
callq 0xc280
callq 0x1d410
callq 0x13520
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9110
movl -0xc(%rbp), %edi
callq 0xca50
movl -0x1c(%rbp), %esi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xb840
callq 0xc280
callq 0xc660
callq 0x91d0
movq %rax, -0x8(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %edx
addl $0x3, %edx
testl %eax, %eax
movl %eax, %ecx
cmovsl %edx, %ecx
andl $-0x4, %ecx
subl %ecx, %eax
movl %eax, %ecx
movq %rcx, -0x18(%rbp)
subl $0x3, %eax
ja 0x2c15d
movq -0x18(%rbp), %rax
leaq 0x1915a(%rip), %rcx     # 0x4503c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2bf05
movl $0x1, %edi
callq 0xca50
jmp 0x2bf5e
movq 0x353a4(%rip), %rdi     # 0x612b0
callq 0x9110
movq 0x353b0(%rip), %rdi     # 0x612c8
callq 0x9110
movq 0x35384(%rip), %rdi     # 0x612a8
callq 0x9110
movq -0x8(%rbp), %rdi
callq 0x9110
movq 0xf8ba7(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x3310b(%rip), %rdi     # 0x5f050
callq 0x9110
movl $0x4, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
jmp 0x2c15d
movq -0x8(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2bf7f
movq 0xf8b68(%rip), %rdi     # 0x124ae0
callq 0x9110
jmp 0x2bffa
movq 0x35322(%rip), %rdi     # 0x612a8
callq 0x9110
movq 0xf8b4e(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x35312(%rip), %rdi     # 0x612b0
callq 0x9110
movq 0x3531e(%rip), %rdi     # 0x612c8
callq 0x9110
movq 0x352f2(%rip), %rdi     # 0x612a8
callq 0x9110
movq -0x8(%rbp), %rdi
callq 0x9110
movq 0xf8b15(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x33079(%rip), %rdi     # 0x5f050
callq 0x9110
movl $0x4, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
jmp 0x2c15d
movq -0x8(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2c019
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
jmp 0x2c092
movq 0x35288(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0x3527a(%rip), %rdi     # 0x612b0
callq 0x9110
movq 0x35286(%rip), %rdi     # 0x612c8
callq 0x9110
movq 0x3525a(%rip), %rdi     # 0x612a8
callq 0x9110
movq -0x8(%rbp), %rdi
callq 0x9110
movq 0xf8a7d(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x32fe1(%rip), %rdi     # 0x5f050
callq 0x9110
movl $0x4, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
jmp 0x2c15d
movq -0x8(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2c0d6
movq 0x351fc(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0xf8a1e(%rip), %rdi     # 0x124ae0
callq 0x9110
movl $0x3, %edi
callq 0x90d0
jmp 0x2c15b
movq 0x351cb(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0xf89ed(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x351b1(%rip), %rdi     # 0x612b0
callq 0x9110
movq 0x351bd(%rip), %rdi     # 0x612c8
callq 0x9110
movq 0x35191(%rip), %rdi     # 0x612a8
callq 0x9110
movq -0x8(%rbp), %rdi
callq 0x9110
movq 0xf89b4(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x32f18(%rip), %rdi     # 0x5f050
callq 0x9110
movl $0x4, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
movl $0x4, %edi
callq 0x90d0
jmp 0x2c15d
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)