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

	coeff = R->u.d;

	// coeff = coeff mod 2

	coeff = fmod(coeff, 2.0);

	// convert negative rotation to positive

	if (coeff < 0.0)
		coeff += 2.0;

	n = (int) floor(2.0 * coeff); // number of 90 degree turns

	r = coeff - n / 2.0; // remainder

	switch (n % 4) {

	case 0:
		if (r == 0.0)
			push_integer(1);
		else {
			push_symbol(POWER);
			push_symbol(EXP1);
			push_symbol(MULTIPLY);
			push_double(r);
			push(imaginaryunit);
			push_symbol(PI);
			list(4);
			list(3);
		}
		break;

	case 1:
		if (r == 0.0)
			push(imaginaryunit);
		else {
			push_symbol(MULTIPLY);
			push(imaginaryunit);
			push_symbol(POWER);
			push_symbol(EXP1);
			push_symbol(MULTIPLY);
			push_double(r);
			push(imaginaryunit);
			push_symbol(PI);
			list(4);
			list(3);
			list(3);
		}
		break;

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

	case 3:
		if (r == 0.0) {
			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_double(r);
			push(imaginaryunit);
			push_symbol(PI);
			list(4);
			list(3);
			list(4);
		}
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0x18f6a(%rip), %xmm1    # 0x45100
callq 0x7160
movsd %xmm0, -0x18(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x18(%rbp), %xmm0
jbe 0x2c1bc
movsd 0x18f4e(%rip), %xmm0    # 0x45100
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
addsd %xmm0, %xmm0
callq 0x72f0
cvttsd2si %xmm0, %eax
movl %eax, -0xc(%rbp)
movsd -0x18(%rbp), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
movsd 0x18ed5(%rip), %xmm2    # 0x450b8
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%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, -0x28(%rbp)
subl $0x3, %eax
ja 0x2c4a5
movq -0x28(%rbp), %rax
leaq 0x18e2e(%rip), %rcx     # 0x4504c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2c243
jp 0x2c243
movl $0x1, %edi
callq 0xca50
jmp 0x2c29d
movq 0x35066(%rip), %rdi     # 0x612b0
callq 0x9110
movq 0x35072(%rip), %rdi     # 0x612c8
callq 0x9110
movq 0x35046(%rip), %rdi     # 0x612a8
callq 0x9110
movsd -0x20(%rbp), %xmm0
callq 0xe5e0
movq 0xf8868(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x32dcc(%rip), %rdi     # 0x5f050
callq 0x9110
movl $0x4, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
jmp 0x2c4a5
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2c2c0
jp 0x2c2c0
movq 0xf8827(%rip), %rdi     # 0x124ae0
callq 0x9110
jmp 0x2c33c
movq 0x34fe1(%rip), %rdi     # 0x612a8
callq 0x9110
movq 0xf880d(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x34fd1(%rip), %rdi     # 0x612b0
callq 0x9110
movq 0x34fdd(%rip), %rdi     # 0x612c8
callq 0x9110
movq 0x34fb1(%rip), %rdi     # 0x612a8
callq 0x9110
movsd -0x20(%rbp), %xmm0
callq 0xe5e0
movq 0xf87d3(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x32d37(%rip), %rdi     # 0x5f050
callq 0x9110
movl $0x4, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
jmp 0x2c4a5
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2c35d
jp 0x2c35d
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
jmp 0x2c3d7
movq 0x34f44(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0x34f36(%rip), %rdi     # 0x612b0
callq 0x9110
movq 0x34f42(%rip), %rdi     # 0x612c8
callq 0x9110
movq 0x34f16(%rip), %rdi     # 0x612a8
callq 0x9110
movsd -0x20(%rbp), %xmm0
callq 0xe5e0
movq 0xf8738(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x32c9c(%rip), %rdi     # 0x5f050
callq 0x9110
movl $0x4, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
jmp 0x2c4a5
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2c41d
jp 0x2c41d
movq 0x34eb5(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0xf86d7(%rip), %rdi     # 0x124ae0
callq 0x9110
movl $0x3, %edi
callq 0x90d0
jmp 0x2c4a3
movq 0x34e84(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0xf86a6(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x34e6a(%rip), %rdi     # 0x612b0
callq 0x9110
movq 0x34e76(%rip), %rdi     # 0x612c8
callq 0x9110
movq 0x34e4a(%rip), %rdi     # 0x612a8
callq 0x9110
movsd -0x20(%rbp), %xmm0
callq 0xe5e0
movq 0xf866c(%rip), %rdi     # 0x124ae0
callq 0x9110
movq 0x32bd0(%rip), %rdi     # 0x5f050
callq 0x9110
movl $0x4, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
movl $0x4, %edi
callq 0x90d0
jmp 0x2c4a5
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)