// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
callq 0x8b01
movl $0x2, %edi
callq 0xacbe
callq 0xf98a
callq 0x8b78
movq %rax, %rbx
cmpb $0x1, 0x12(%rax)
jne 0x1ad01
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xacbe
movl $0x2, %edi
callq 0xa975
callq 0x8b78
movq %rax, %rbx
movq %rbx, %rdi
callq 0x8b01
movl $0x2, %edi
callq 0xacbe
movl $0x2, %edi
callq 0xa8bb
callq 0x13eac
callq 0xeb5b
movl %eax, %r14d
movq %rbx, %rdi
callq 0x8b01
movl %r14d, %edi
callq 0xacbe
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa1f4
movl $0x2, %edi
callq 0xa8bb
movl $0x2, %edi
callq 0xa975
callq 0x8b78
cmpl $0x3, %r14d
ja 0x1ae04
movq %rax, %rbx
movl %r14d, %eax
leaq 0xb2bf(%rip), %rcx      # 0x26038
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
je 0x1ae81
movq 0xebd3f(%rip), %rdi     # 0x106ad8
jmp 0x1adfb
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
je 0x1ae09
movq 0xf6642(%rip), %rdi     # 0x1113f0
jmp 0x1adfb
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
je 0x1ae46
movq 0x284e1(%rip), %rdi     # 0x432a8
callq 0x8b01
movq 0xf661d(%rip), %rdi     # 0x1113f0
callq 0x8b01
movq 0xebd01(%rip), %rdi     # 0x106ae0
jmp 0x1ae9c
movq %rbx, %rdi
callq 0xaece
testl %eax, %eax
je 0x1aea3
movq 0xebce5(%rip), %rdi     # 0x106ae0
popq %rbx
popq %r14
popq %rbp
jmp 0x8b01
popq %rbx
popq %r14
popq %rbp
retq
movq 0x28498(%rip), %rdi     # 0x432a8
callq 0x8b01
movq 0xf65d4(%rip), %rdi     # 0x1113f0
callq 0x8b01
movq 0x28488(%rip), %rdi     # 0x432b0
callq 0x8b01
movq 0xf65bc(%rip), %rdi     # 0x1113f0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
jmp 0x1aef4
movq 0x28463(%rip), %rdi     # 0x432b0
callq 0x8b01
movq 0xf6597(%rip), %rdi     # 0x1113f0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa1f4
movl $0x2, %edi
callq 0xa975
jmp 0x1aefe
movq 0x28428(%rip), %rdi     # 0x432b0
callq 0x8b01
movq 0xf655c(%rip), %rdi     # 0x1113f0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
jmp 0x1aefe
movq 0x283fe(%rip), %rdi     # 0x432a8
callq 0x8b01
movq 0xf653a(%rip), %rdi     # 0x1113f0
callq 0x8b01
movq 0x283ee(%rip), %rdi     # 0x432b0
callq 0x8b01
movq 0xf6522(%rip), %rdi     # 0x1113f0
callq 0x8b01
movq %rbx, %rdi
callq 0x8b01
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xa1f4
movl $0x2, %edi
callq 0xa975
movl $0x3, %edi
callq 0x8ad9
movl $0x3, %edi
popq %rbx
popq %r14
popq %rbp
jmp 0x8ad9