// File: /workspace/github_c_makefile_star2_O3/georgeweigt[P]eigenmath/eigenmath.c
// Function: eval_rotate
void
eval_rotate(struct atom *p1)
{
	int m, n;
	uint32_t c;
	struct atom *PSI, *OPCODE, *PHASE;

	push(cadr(p1));
	evalf();
	PSI = pop();

	if (!istensor(PSI) || PSI->u.tensor->ndim > 1 || PSI->u.tensor->nelem > 32768 || !POWEROF2(PSI->u.tensor->nelem))
		stopf("rotate error 1 first argument is not a vector or dimension error");

	c = 0;

	p1 = cddr(p1);

	while (iscons(p1)) {

		if (!iscons(cdr(p1)))
			stopf("rotate error 2 unexpected end of argument list");

		OPCODE = car(p1);
		push(cadr(p1));
		evalf();
		n = pop_integer();

		if (n > 14 || (1 << n) >= PSI->u.tensor->nelem)
			stopf("rotate error 3 qubit number format or range");

		p1 = cddr(p1);

		if (OPCODE == symbol(C_UPPER)) {
			c |= 1 << n;
			continue;
		}

		if (OPCODE == symbol(H_UPPER)) {
			rotate_h(PSI, c, n);
			c = 0;
			continue;
		}

		if (OPCODE == symbol(P_UPPER)) {
			if (!iscons(p1))
				stopf("rotate error 2 unexpected end of argument list");
			push(car(p1));
			p1 = cdr(p1);
			evalf();
			push(imaginaryunit);
			multiply();
			expfunc();
			PHASE = pop();
			rotate_p(PSI, PHASE, c, n);
			c = 0;
			continue;
		}

		if (OPCODE == symbol(Q_UPPER)) {
			rotate_q(PSI, n);
			c = 0;
			continue;
		}

		if (OPCODE == symbol(V_UPPER)) {
			rotate_v(PSI, n);
			c = 0;
			continue;
		}

		if (OPCODE == symbol(W_UPPER)) {
			m = n;
			if (!iscons(p1))
				stopf("rotate error 2 unexpected end of argument list");
			push(car(p1));
			p1 = cdr(p1);
			evalf();
			n = pop_integer();
			if (n > 14 || (1 << n) >= PSI->u.tensor->nelem)
				stopf("rotate error 3 qubit number format or range");
			rotate_w(PSI, c, m, n);
			c = 0;
			continue;
		}

		if (OPCODE == symbol(X_UPPER)) {
			rotate_x(PSI, c, n);
			c = 0;
			continue;
		}

		if (OPCODE == symbol(Y_UPPER)) {
			rotate_y(PSI, c, n);
			c = 0;
			continue;
		}

		if (OPCODE == symbol(Z_UPPER)) {
			rotate_z(PSI, c, n);
			c = 0;
			continue;
		}

		stopf("rotate error 4 unknown rotation code");
	}

	push(PSI);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x8(%rdi), %r15
cmpb $0x1, 0x10(%rdi)
leaq 0x25f34(%rip), %rcx     # 0x45a00
movq %rcx, %rax
cmoveq %r15, %rax
movq (%rax), %rax
cmpb $0x1, 0x10(%rax)
cmovneq %rcx, %rax
movq (%rax), %rdi
callq 0x8ba5
callq 0x96e2
movl 0x1f7c7(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x1fe12
decl %eax
movl %eax, 0x1f7af(%rip)     # 0x3f2b8
leaq 0x28ab0(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rsi
cmpb $0x7, 0x10(%rsi)
jne 0x1fe1e
movq (%rsi), %rax
cmpl $0x1, (%rax)
jg 0x1fe1e
movl 0x64(%rax), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jg 0x1fe1e
movl %eax, %ecx
shrl %ecx
andl $0x55555555, %ecx       # imm = 0x55555555
subl %ecx, %eax
movl $0x33333333, %ecx       # imm = 0x33333333
movl %eax, %edx
andl %ecx, %edx
shrl $0x2, %eax
andl %ecx, %eax
addl %edx, %eax
movl %eax, %ecx
shrl $0x4, %ecx
addl %eax, %ecx
andl $0xf0f0f0f, %ecx        # imm = 0xF0F0F0F
imull $0x1010101, %ecx, %eax  # imm = 0x1010101
shrl $0x18, %eax
cmpl $0x2, %eax
jae 0x1fe1e
movq %rsi, -0x30(%rbp)
cmpb $0x1, 0x10(%r14)
leaq 0x25e7d(%rip), %rdx     # 0x45a00
cmovneq %rdx, %r15
movq (%r15), %rax
leaq 0x8(%rax), %rcx
cmpb $0x1, 0x10(%rax)
cmovneq %rdx, %rcx
movq (%rcx), %r13
cmpb $0x1, 0x10(%r13)
jne 0x1fde3
leaq 0x10(%r13), %rbx
xorl %r14d, %r14d
movq 0x8(%r13), %rax
cmpb $0x1, 0x10(%rax)
jne 0x1fe06
movq (%r13), %r12
movq (%rax), %rdi
callq 0x8ba5
callq 0x96e2
callq 0xf8e6
cmpl $0xe, %eax
movq -0x30(%rbp), %rdi
jg 0x1fdfa
movl %eax, %r15d
movl $0x1, %eax
movl %r15d, %ecx
shll %cl, %eax
movq (%rdi), %rcx
cmpl 0x64(%rcx), %eax
jge 0x1fdfa
addq $0x8, %r13
cmpb $0x1, (%rbx)
leaq 0x25dfd(%rip), %rsi     # 0x45a00
cmovneq %rsi, %r13
movq (%r13), %rcx
leaq 0x8(%rcx), %rdx
cmpb $0x1, 0x10(%rcx)
cmovneq %rsi, %rdx
movq (%rdx), %r13
cmpq 0x23b7f(%rip), %r12     # 0x437a0
je 0x1fc93
cmpq 0x24b16(%rip), %r12     # 0x44740
je 0x1fc9b
cmpq 0x2640d(%rip), %r12     # 0x46040
je 0x1fcab
cmpq 0x26724(%rip), %r12     # 0x46360
je 0x1fd44
cmpq 0x276b7(%rip), %r12     # 0x47300
je 0x1fd51
cmpq 0x279ca(%rip), %r12     # 0x47620
je 0x1fd5b
cmpq 0x27cdd(%rip), %r12     # 0x47940
je 0x1fdb9
cmpq 0x27ff0(%rip), %r12     # 0x47c60
je 0x1fdc6
cmpq 0x28303(%rip), %r12     # 0x47f80
jne 0x1fe2a
movl %r14d, %esi
movl %r15d, %edx
callq 0x2061c
jmp 0x1fdd1
orl %eax, %r14d
jmp 0x1fdd4
movl %r14d, %esi
movl %r15d, %edx
callq 0x1fe36
jmp 0x1fdd1
cmpb $0x1, 0x10(%r13)
jne 0x1fe06
movq (%r13), %rdi
callq 0x8ba5
cmpb $0x1, 0x10(%r13)
leaq 0x8(%r13), %rax
leaq 0x25d31(%rip), %rcx     # 0x45a00
cmovneq %rcx, %rax
movq (%rax), %r13
callq 0x96e2
movq 0xebdfe(%rip), %rdi     # 0x10bae0
callq 0x8ba5
movl $0x2, %edi
callq 0xacef
movq 0x285d0(%rip), %rdi     # 0x482c8
callq 0x8ba5
callq 0xb238
callq 0xa573
movl 0x1f5ab(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %edx       # imm = 0xFFFE795F
leal (%rax,%rdx), %ecx
cmpl %edx, %ecx
jbe 0x1fe12
decl %eax
movl %eax, 0x1f593(%rip)     # 0x3f2b8
leaq 0x28894(%rip), %rcx     # 0x485c0
movq (%rcx,%rax,8), %rsi
movq -0x30(%rbp), %rdi
movl %r14d, %edx
movl %r15d, %ecx
callq 0x1ff9f
jmp 0x1fdd1
movl %r15d, %esi
callq 0x20053
jmp 0x1fdd1
movl %r15d, %esi
callq 0x2018a
jmp 0x1fdd1
cmpb $0x1, 0x10(%r13)
jne 0x1fe06
movq (%r13), %rdi
callq 0x8ba5
cmpb $0x1, 0x10(%r13)
leaq 0x8(%r13), %rax
leaq 0x25c81(%rip), %rcx     # 0x45a00
cmovneq %rcx, %rax
movq (%rax), %r13
callq 0x96e2
callq 0xf8e6
cmpl $0xe, %eax
movq -0x30(%rbp), %rdi
jg 0x1fdfa
movl $0x1, %edx
movl %eax, %ecx
shll %cl, %edx
movq (%rdi), %rcx
cmpl 0x64(%rcx), %edx
jge 0x1fdfa
movl %r14d, %esi
movl %r15d, %edx
movl %eax, %ecx
callq 0x20301
jmp 0x1fdd1
movl %r14d, %esi
movl %r15d, %edx
callq 0x2040f
jmp 0x1fdd1
movl %r14d, %esi
movl %r15d, %edx
callq 0x204f1
xorl %r14d, %r14d
leaq 0x10(%r13), %rbx
cmpb $0x1, 0x10(%r13)
je 0x1fbab
movq -0x30(%rbp), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
leaq 0xebd3(%rip), %rdi      # 0x2e9d4
callq 0x780b
leaq 0xeb98(%rip), %rdi      # 0x2e9a5
callq 0x780b
leaq 0xf128(%rip), %rdi      # 0x2ef41
callq 0x780b
leaq 0xeb3f(%rip), %rdi      # 0x2e964
callq 0x780b
leaq 0xebcf(%rip), %rdi      # 0x2ea00
callq 0x780b