// File: /workspace/github_cpp_makefile_star2_O1/tewalds[P]pentagod/./move.h
// Function: Move::rotate(unsigned int) const
Move rotate(unsigned int other) const {
		if(l < 0) //special
			return *this;

		assert(o <= 8 && other <= 8);

		if(other == o) //already the correct orientation
			return *this;

		if(o == 8 && other < 8) //unoriented move, default to board
			return Move(l, r, other);

		if(o == 8 || other == 8){ // oriented moves are incompatible with unoriented boards
			printf("rotate %s to %i\n", to_s(true).c_str(), other);
			assert(o <= 7 && other <= 7);
		}

/*
flip move:  Move(y, x, (9-r)&7). Works because (9-1)&7=8&7=0, (9-1)&7=8&7=0
rotate cw:  Move(5-y,   x, (r+2)&7)
rotate 180: Move(5-x, 5-y, (r+4)&7)
rotate ccw: Move(  y, 5-x, (r+6)&7)
*/

		unsigned int c = o*8 + other;
		switch(c){
		case  0: case 011: case 022: case 033: case 044: case 055: case 066: case 077: return *this;
		                                                                                    //Move(  x(),   y(),       r, other);
		case 01: case 012: case 023: case 030: case 047: case 054: case 065: case 076: return Move(5-y(),   x(), (r+2)&7, other);
		case 02: case 013: case 020: case 031: case 046: case 057: case 064: case 075: return Move(5-x(), 5-y(), (r+4)&7, other);
		case 03: case 010: case 021: case 032: case 045: case 056: case 067: case 074: return Move(  y(), 5-x(), (r+6)&7, other);

		case 04: case 015: case 026: case 037: case 040: case 051: case 062: case 073: return Move(  y(),   x(), ( 9-r)&7, other);
		case 07: case 014: case 025: case 036: case 041: case 052: case 063: case 070: return Move(5-x(),   y(), (11-r)&7, other);
		case 06: case 017: case 024: case 035: case 042: case 053: case 060: case 071: return Move(5-y(), 5-x(), (13-r)&7, other);
		case 05: case 016: case 027: case 034: case 043: case 050: case 061: case 072: return Move(  x(), 5-y(), (15-r)&7, other);
		default:
			printf("o: %i, other: %i, c: %#4x", o, other, c);
			assert(false && "Bad orientation?!?");
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
movzwl (%rdi), %eax
testb %al, %al
js 0x93a1
movl %esi, %ebx
cmpl $0x8, %esi
ja 0x96cc
cmpw $0x9000, %ax            # imm = 0x9000
jae 0x96cc
movl %eax, %ecx
shrl $0xc, %ecx
cmpl %ebx, %ecx
jne 0x93bb
movl (%r14), %eax
movl %eax, %ecx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
movzwl %ax, %eax
orl %ecx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
cmpw $0x8, %cx
setne %dl
cmpl $0x8, %ebx
setae %sil
orb %dl, %sil
jne 0x93dc
shll $0xc, %ebx
andl $0xf7f, %eax            # imm = 0xF7F
orl %ebx, %eax
xorl %ecx, %ecx
jmp 0x93ac
cmpw $0x8, %cx
setne %al
cmpl $0x8, %ebx
setne %cl
testb %al, %cl
jne 0x9439
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x99d8
movq (%r15), %rsi
leaq 0x20634(%rip), %rdi     # 0x29a3e
movl %ebx, %edx
xorl %eax, %eax
callq 0x4040
movq (%r15), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x9425
callq 0x42b0
cmpl $0x7, %ebx
ja 0x96eb
cmpw $0x0, (%r14)
js 0x96eb
movzwl (%r14), %eax
movzwl %ax, %eax
movl %eax, %esi
shrl $0xc, %esi
leal (%rbx,%rsi,8), %ecx
cmpb $0x3f, %cl
ja 0x970a
movzbl %cl, %ecx
leaq 0x1fbe5(%rip), %rdx     # 0x29040
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movsbl %al, %edx
imull $0xffffd555, %edx, %ecx # imm = 0xFFFFD555
movl %ecx, %esi
shrl $0x1f, %esi
shrl $0x10, %ecx
addl %esi, %ecx
movsbq %al, %rsi
imulq $0x2aaaaaab, %rsi, %rsi # imm = 0x2AAAAAAB
movq %rsi, %rdi
shrq $0x3f, %rdi
shrq $0x20, %rsi
addl %edi, %esi
addl %esi, %esi
leal (%rsi,%rsi,2), %esi
subl %esi, %edx
addl %edx, %edx
leal (%rdx,%rdx,2), %edx
leal 0x5(%rcx,%rdx), %ecx
movzbl %cl, %ecx
addl $0x200, %eax            # imm = 0x200
jmp 0x959d
movsbl %al, %ecx
imull $0x2aab, %ecx, %ecx     # imm = 0x2AAB
movsbq %al, %rdx
imulq $0x2aaaaaab, %rdx, %rdx # imm = 0x2AAAAAAB
movq %rdx, %rsi
shrq $0x3f, %rsi
shrq $0x20, %rdx
addl %esi, %edx
movl %ecx, %esi
shrl $0x1f, %esi
shrl $0x10, %ecx
addl %edx, %edx
leal (%rdx,%rdx,2), %edx
addl %esi, %ecx
movl %eax, %esi
subl %edx, %esi
movl $0x700, %edx            # imm = 0x700
andl %edx, %eax
addl %esi, %esi
leal (%rsi,%rsi,2), %esi
addl %ecx, %esi
movzbl %sil, %ecx
movl $0x100, %esi            # imm = 0x100
subl %eax, %esi
andl %edx, %esi
orl %ecx, %esi
shll $0xc, %ebx
orl %esi, %ebx
jmp 0x96c3
movsbl %al, %ecx
movsbq %al, %rdx
imulq $0x2aaaaaab, %rdx, %rdx # imm = 0x2AAAAAAB
movq %rdx, %rsi
shrq $0x3f, %rsi
shrq $0x20, %rdx
addl %esi, %edx
addl %edx, %edx
leal (%rdx,%rdx,2), %edx
imull $0xffffd555, %ecx, %ecx # imm = 0xFFFFD555
movl %ecx, %esi
shrl $0x1f, %esi
shrl $0x10, %ecx
addl %esi, %ecx
leal 0xf(%rcx,%rcx,2), %ecx
subl %eax, %edx
andl $0x700, %eax            # imm = 0x700
leal 0x5(%rdx,%rcx,2), %ecx
movzbl %cl, %ecx
orl %eax, %ecx
shll $0xc, %ebx
orl %ecx, %ebx
xorl $0x400, %ebx            # imm = 0x400
jmp 0x96c3
movsbl %al, %ecx
imull $0x2aab, %ecx, %edx     # imm = 0x2AAB
movl %edx, %esi
shrl $0x1f, %esi
shrl $0x10, %edx
addl %esi, %edx
movsbq %al, %rsi
imulq $0x2aaaaaab, %rsi, %rsi # imm = 0x2AAAAAAB
movq %rsi, %rdi
shrq $0x3f, %rdi
shrq $0x20, %rsi
addl %edi, %esi
addl %esi, %esi
leal (%rsi,%rsi,2), %esi
subl %ecx, %esi
addl %esi, %esi
leal 0x1e(%rsi,%rsi,2), %ecx
addl %edx, %ecx
movzbl %cl, %ecx
addl $0x600, %eax            # imm = 0x600
andl $0x700, %eax            # imm = 0x700
orl %ecx, %eax
shll $0xc, %ebx
orl %eax, %ebx
jmp 0x96c3
movsbl %al, %ecx
movsbq %al, %rdx
imulq $0x2aaaaaab, %rdx, %rdx # imm = 0x2AAAAAAB
movq %rdx, %rsi
shrq $0x3f, %rsi
shrq $0x20, %rdx
addl %esi, %edx
addl %edx, %edx
leal (%rdx,%rdx,2), %esi
movl $0x700, %edx            # imm = 0x700
movl %eax, %edi
andl %edx, %edi
imull $0x2aab, %ecx, %r8d     # imm = 0x2AAB
subl %esi, %ecx
movl %r8d, %esi
shrl $0x1f, %esi
shrl $0x10, %r8d
addl %esi, %r8d
addl %r8d, %r8d
leal (%r8,%r8,2), %esi
movl %eax, %r8d
subl %esi, %r8d
addl %ecx, %r8d
negl %r8d
leal 0x5(%rax,%r8), %eax
movzbl %al, %eax
movl $0x300, %ecx            # imm = 0x300
subl %edi, %ecx
andl %edx, %ecx
orl %eax, %ecx
shll $0xc, %ebx
orl %ecx, %ebx
jmp 0x96c3
movsbl %al, %ecx
movsbq %al, %rdx
imulq $0x2aaaaaab, %rdx, %rdx # imm = 0x2AAAAAAB
movq %rdx, %rsi
shrq $0x3f, %rsi
shrq $0x20, %rdx
addl %esi, %edx
addl %edx, %edx
leal (%rdx,%rdx,2), %edx
movl %eax, %esi
subl %edx, %esi
imull $0xffffd555, %ecx, %ecx # imm = 0xFFFFD555
movl %ecx, %edx
shrl $0x1f, %edx
shrl $0x10, %ecx
addl %edx, %ecx
movl $0x700, %edx            # imm = 0x700
andl %edx, %eax
leal 0xf(%rcx,%rcx,2), %ecx
leal (%rsi,%rcx,2), %ecx
movzbl %cl, %ecx
orl %eax, %ecx
shll $0xc, %ebx
orl %ecx, %ebx
xorl %edx, %ebx
jmp 0x96c3
movsbl %al, %edx
imull $0xffffd555, %edx, %ecx # imm = 0xFFFFD555
movsbq %al, %rsi
imulq $0x2aaaaaab, %rsi, %rsi # imm = 0x2AAAAAAB
movq %rsi, %rdi
shrq $0x3f, %rdi
shrq $0x20, %rsi
addl %edi, %esi
movl %ecx, %edi
shrl $0x1f, %edi
shrl $0x10, %ecx
addl %esi, %esi
leal (%rsi,%rsi,2), %esi
addl %edi, %ecx
movl $0x700, %edi            # imm = 0x700
subl %edx, %esi
addl %esi, %esi
leal 0x1e(%rsi,%rsi,2), %edx
andl %edi, %eax
leal 0x5(%rcx,%rdx), %ecx
movzbl %cl, %ecx
movl $0x500, %edx            # imm = 0x500
subl %eax, %edx
andl %edi, %edx
orl %ecx, %edx
shll $0xc, %ebx
orl %edx, %ebx
xorl %ecx, %ecx
movl %ebx, %eax
jmp 0x93ac
leaq 0x20327(%rip), %rdi     # 0x299fa
leaq 0x20335(%rip), %rsi     # 0x29a0f
leaq 0x20337(%rip), %rcx     # 0x29a18
movl $0x5d, %edx
callq 0x41b0
leaq 0x2035d(%rip), %rdi     # 0x29a4f
leaq 0x20316(%rip), %rsi     # 0x29a0f
leaq 0x20318(%rip), %rcx     # 0x29a18
movl $0x67, %edx
callq 0x41b0
leaq 0x20353(%rip), %rdi     # 0x29a64
movl %ebx, %edx
xorl %eax, %eax
callq 0x4040
leaq 0x2035d(%rip), %rdi     # 0x29a7e
leaq 0x202e7(%rip), %rsi     # 0x29a0f
leaq 0x202e9(%rip), %rcx     # 0x29a18
movl $0x7f, %edx
callq 0x41b0
nop