// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]eigenmath/eigenmath.c
// Function: normalize_clock_double
void
normalize_clock_double(struct atom *EXPO)
{
	double expo, n, r;

	expo = EXPO->u.d;

	// expo = expo mod 2

	expo = fmod(expo, 2.0);

	// convert negative rotation to positive

	if (expo < 0.0)
		expo += 2.0;

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

	r = expo - n / 2.0; // remainder

	switch ((int) n) {

	case 0:
		if (r == 0.0)
			push_integer(1);
		else {
			push_symbol(POWER);
			push_integer(-1);
			push_double(r);
			list(3);
		}
		break;

	case 1:
		if (r == 0.0)
			push(imaginaryunit);
		else {
			push_symbol(MULTIPLY);
			push_integer(-1);
			push_symbol(POWER);
			push_integer(-1);
			push_double(r - 0.5);
			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_integer(-1);
			push_double(r);
			list(3);
			list(3);
		}
		break;

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movsd (%rdi), %xmm0
movsd 0xac88(%rip), %xmm1     # 0x23178
callq 0x7160
movsd 0xac7b(%rip), %xmm3     # 0x23178
addsd %xmm0, %xmm3
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm0, %xmm2
orpd %xmm3, %xmm2
movapd %xmm2, -0x20(%rbp)
movapd %xmm2, %xmm0
addsd %xmm2, %xmm0
callq 0x72f0
cvttsd2si %xmm0, %eax
cmpl $0x3, %eax
ja 0x185eb
mulsd 0xac0f(%rip), %xmm0     # 0x23150
movapd -0x20(%rbp), %xmm1
addsd %xmm0, %xmm1
leaq 0xab13(%rip), %rcx      # 0x23064
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x18652
jp 0x18652
pushq $0x1
jmp 0x18580
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x185f2
jp 0x185f2
pushq $-0x1
popq %rdi
addq $0x18, %rsp
popq %rbx
popq %rbp
jmp 0xa426
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x1862a
jp 0x1862a
movq 0x28cf1(%rip), %rdi     # 0x41298
callq 0x861b
pushq $-0x1
popq %rdi
callq 0xa426
movq 0xec515(%rip), %rdi     # 0x104ad0
callq 0x861b
jmp 0x18675
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x1867a
jp 0x1867a
movq 0xec4f0(%rip), %rdi     # 0x104ad0
addq $0x18, %rsp
popq %rbx
popq %rbp
jmp 0x861b
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movq 0x28c9f(%rip), %rdi     # 0x41298
movapd %xmm1, -0x20(%rbp)
callq 0x861b
pushq $-0x1
popq %rbx
movl %ebx, %edi
callq 0xa426
movq 0x28c8c(%rip), %rdi     # 0x412a0
callq 0x861b
movl %ebx, %edi
callq 0xa426
movapd -0x20(%rbp), %xmm0
jmp 0x186b5
movq 0x28c6f(%rip), %rdi     # 0x412a0
movapd %xmm1, -0x20(%rbp)
callq 0x861b
pushq $-0x1
popq %rdi
callq 0xa426
movapd -0x20(%rbp), %xmm0
addsd 0xab00(%rip), %xmm0     # 0x23150
jmp 0x18670
movq 0x28c47(%rip), %rdi     # 0x412a0
movapd %xmm1, -0x20(%rbp)
callq 0x861b
pushq $-0x1
popq %rdi
callq 0xa426
movapd -0x20(%rbp), %xmm0
callq 0xaf59
pushq $0x3
popq %rdi
jmp 0x186c6
movq 0x28c17(%rip), %rdi     # 0x41298
movapd %xmm1, -0x20(%rbp)
callq 0x861b
pushq $-0x1
popq %rbx
movl %ebx, %edi
callq 0xa426
movq 0x28c04(%rip), %rdi     # 0x412a0
callq 0x861b
movl %ebx, %edi
callq 0xa426
movapd -0x20(%rbp), %xmm0
addsd 0xaa9b(%rip), %xmm0     # 0x23150
callq 0xaf59
pushq $0x3
popq %rbx
movl %ebx, %edi
callq 0x85eb
movl %ebx, %edi
addq $0x18, %rsp
popq %rbx
popq %rbp
jmp 0x85eb