// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
callq 0xca50
callq 0x14c60
callq 0x91d0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x1, %eax
jne 0x2adcb
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
callq 0xca50
callq 0xc660
callq 0x91d0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0x2, %edi
movl %edi, -0x24(%rbp)
callq 0xca50
callq 0xc280
callq 0x1d410
callq 0x13520
movl %eax, -0xc(%rbp)
movq -0x18(%rbp), %rdi
callq 0x9110
movl -0xc(%rbp), %edi
callq 0xca50
movl -0x24(%rbp), %esi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xb840
callq 0xc280
callq 0xc660
callq 0x91d0
movq %rax, -0x18(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x20(%rbp)
subq $0x3, %rax
ja 0x2afef
movq -0x20(%rbp), %rax
leaq 0x1a1dc(%rip), %rcx     # 0x4501c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2ae63
movl $0x1, %edi
callq 0xca50
jmp 0x2ae8c
movq 0x36446(%rip), %rdi     # 0x612b0
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0x3, %edi
callq 0x90d0
jmp 0x2afef
movq -0x18(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2aead
movq 0xf9c3a(%rip), %rdi     # 0x124ae0
callq 0x9110
jmp 0x2af0a
movq 0x363f4(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0x363e6(%rip), %rdi     # 0x612b0
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xb840
callq 0xc660
movl $0x3, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
jmp 0x2afef
movq -0x18(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2af29
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
jmp 0x2af72
movq 0x36378(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0x3636a(%rip), %rdi     # 0x612b0
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0x3, %edi
callq 0x90d0
movl $0x3, %edi
callq 0x90d0
jmp 0x2afef
movq -0x18(%rbp), %rdi
callq 0xcdc0
cmpl $0x0, %eax
je 0x2afb0
movq 0x3631f(%rip), %rdi     # 0x612a8
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq 0xf9b41(%rip), %rdi     # 0x124ae0
callq 0x9110
movl $0x3, %edi
callq 0x90d0
jmp 0x2afed
movq 0x362f9(%rip), %rdi     # 0x612b0
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xca50
movq -0x18(%rbp), %rdi
callq 0x9110
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x2, %esi
callq 0xb840
callq 0xc660
movl $0x3, %edi
callq 0x90d0
jmp 0x2afef
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)