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

	// R = EXPO mod 2

	push(EXPO);
	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) {

	case 0:
		if (iszero(R))
			push_integer(1);
		else {
			push_symbol(POWER);
			push_integer(-1);
			push(R);
			list(3);
		}
		break;

	case 1:
		if (iszero(R))
			push(imaginaryunit);
		else {
			push_symbol(MULTIPLY);
			push_integer(-1);
			push_symbol(POWER);
			push_integer(-1);
			push(R);
			push_rational(-1, 2);
			add();
			list(3);
			list(3);
		}
		break;

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

	case 3:
		if (iszero(R)) {
			push_symbol(MULTIPLY);
			push_integer(-1);
			push(imaginaryunit);
			list(3);
		} else {
			push_symbol(POWER);
			push_integer(-1);
			push(R);
			push_rational(-1, 2);
			add();
			list(3);
		}
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
callq 0x8ba5
movl $0x2, %edi
callq 0xb1be
callq 0x108ee
movl 0x22595(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x1cfc1
decl %eax
movl %eax, 0x2257d(%rip)     # 0x3f2b8
leaq 0x2b87e(%rip), %r15     # 0x485c0
movq (%r15,%rax,8), %rbx
cmpb $0x1, 0x12(%rbx)
jne 0x1cd8a
movq %rbx, %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xb1be
movl $0x2, %edi
callq 0xadb3
movl 0x2254a(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x1cfc1
decl %eax
movl %eax, 0x22532(%rip)     # 0x3f2b8
movq (%r15,%rax,8), %rbx
movq %rbx, %rdi
callq 0x8ba5
movl $0x2, %edi
callq 0xb1be
movl $0x2, %edi
callq 0xacef
callq 0x15584
callq 0xf8e6
movl %eax, %r14d
movq %rbx, %rdi
callq 0x8ba5
movl %r14d, %edi
callq 0xb1be
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa533
movl $0x2, %edi
callq 0xacef
movl $0x2, %edi
callq 0xadb3
movl 0x224cc(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x1cfc1
decl %eax
movl %eax, 0x224b4(%rip)     # 0x3f2b8
cmpl $0x3, %r14d
ja 0x1cead
movq (%r15,%rax,8), %rbx
movl %r14d, %eax
leaq 0xd238(%rip), %rcx      # 0x2a054
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0xb477
testl %eax, %eax
je 0x1cf30
movq 0xeec9c(%rip), %rdi     # 0x10bad8
jmp 0x1ce9e
movq %rbx, %rdi
callq 0xb477
testl %eax, %eax
je 0x1ceb8
movq 0xf959f(%rip), %rdi     # 0x1163f0
jmp 0x1ce9e
movq %rbx, %rdi
callq 0xb477
testl %eax, %eax
je 0x1cef5
movq 0x2b43e(%rip), %rdi     # 0x482a8
callq 0x8ba5
movq 0xf957a(%rip), %rdi     # 0x1163f0
callq 0x8ba5
movq 0xeec5e(%rip), %rdi     # 0x10bae0
jmp 0x1cf4b
movq %rbx, %rdi
callq 0xb477
testl %eax, %eax
je 0x1cf52
movq 0xeec42(%rip), %rdi     # 0x10bae0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b3e9(%rip), %rdi     # 0x482a8
callq 0x8ba5
movq 0xf9525(%rip), %rdi     # 0x1163f0
callq 0x8ba5
movq 0x2b3d9(%rip), %rdi     # 0x482b0
callq 0x8ba5
movq 0xf950d(%rip), %rdi     # 0x1163f0
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
jmp 0x1cfa3
movq 0x2b3b4(%rip), %rdi     # 0x482b0
callq 0x8ba5
movq 0xf94e8(%rip), %rdi     # 0x1163f0
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa533
movl $0x2, %edi
callq 0xadb3
jmp 0x1cfad
movq 0x2b379(%rip), %rdi     # 0x482b0
callq 0x8ba5
movq 0xf94ad(%rip), %rdi     # 0x1163f0
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
jmp 0x1cfad
movq 0x2b34f(%rip), %rdi     # 0x482a8
callq 0x8ba5
movq 0xf948b(%rip), %rdi     # 0x1163f0
callq 0x8ba5
movq 0x2b33f(%rip), %rdi     # 0x482b0
callq 0x8ba5
movq 0xf9473(%rip), %rdi     # 0x1163f0
callq 0x8ba5
movq %rbx, %rdi
callq 0x8ba5
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa533
movl $0x2, %edi
callq 0xadb3
movl $0x3, %edi
callq 0x8b7d
movl $0x3, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8b7d
leaq 0x11f79(%rip), %rdi     # 0x2ef41
callq 0x780b