// File: /workspace/github_cpp_makefile_star2_O2/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), %edi
movsbl %dil, %eax
testw %ax, %ax
js 0x7c4a
movl %esi, %ebx
cmpl $0x8, %esi
ja 0x7e47
cmpw $0x9000, %di            # imm = 0x9000
jae 0x7e47
movzwl %di, %ecx
shrl $0xc, %ecx
cmpl %ebx, %ecx
jne 0x7c64
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 0x7c89
andl $0xf00, %edi            # imm = 0xF00
shll $0xc, %ebx
cwtl
xorl %ecx, %ecx
orl %edi, %ebx
orl %ebx, %eax
jmp 0x7c55
cmpw $0x8, %cx
setne %al
cmpl $0x8, %ebx
setne %cl
testb %al, %cl
jne 0x7cdc
movq %rsp, %r15
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x8178
movq (%r15), %rsi
leaq 0x14d5f(%rip), %rdi     # 0x1ca14
movl %ebx, %edx
xorl %eax, %eax
callq 0x4040
movq %r15, %rdi
callq 0x4130
cmpl $0x7, %ebx
ja 0x7e64
movzwl (%r14), %edi
testw %di, %di
js 0x7e64
movzwl %di, %esi
shrl $0xc, %esi
leal (%rbx,%rsi,8), %ecx
cmpb $0x3f, %cl
ja 0x7e7d
movzbl %cl, %eax
leaq 0x14348(%rip), %rdx     # 0x1c040
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movsbl %dil, %ecx
movb $-0x6, %dl
movb $0x6, %sil
addl $0x200, %edi            # imm = 0x200
movl %ecx, %eax
idivb %dl
movl %eax, %edx
movl %ecx, %eax
idivb %sil
movsbl %ah, %eax
imull $0x6, %eax, %eax
addb %dl, %al
addb $0x5, %al
movzbl %al, %eax
jmp 0x7d8e
movsbl %dil, %eax
movb $0x6, %cl
imull $0x6, %edi, %edx
idivb %cl
movl $0x700, %ecx            # imm = 0x700
andl %ecx, %edi
movzbl %al, %eax
imull $-0x23, %eax, %eax
addb %dl, %al
movl $0x100, %edx            # imm = 0x100
jmp 0x7e30
pushq $0x23
popq %rax
subl %edi, %eax
andl $0x700, %edi            # imm = 0x700
shll $0xc, %ebx
movzbl %al, %eax
orl %edi, %eax
orl %eax, %ebx
xorl $0x400, %ebx            # imm = 0x400
jmp 0x7e3e
movsbl %dil, %eax
movb $0x6, %cl
movb $0x5, %dl
addl $0x600, %edi            # imm = 0x600
idivb %cl
movsbl %ah, %ecx
subb %cl, %dl
movzbl %dl, %ecx
imull $0x6, %ecx, %ecx
addb %al, %cl
movzbl %cl, %eax
andl $0x700, %edi            # imm = 0x700
shll $0xc, %ebx
orl %eax, %edi
orl %edi, %ebx
jmp 0x7e3e
movsbl %dil, %ecx
movb $0x6, %dl
shll $0xc, %ebx
movl %ecx, %eax
idivb %dl
movl $0x700, %edx            # imm = 0x700
movsbl %ah, %eax
andl %edx, %edi
addb %al, %al
subb %al, %cl
addb $0x5, %cl
movzbl %cl, %eax
movl $0x300, %ecx            # imm = 0x300
subl %edi, %ecx
andl %edx, %ecx
orl %eax, %ecx
orl %ecx, %ebx
jmp 0x7e3e
movsbl %dil, %ecx
movb $0x6, %dl
shll $0xc, %ebx
movl %ecx, %eax
idivb %dl
movl $0x700, %edx            # imm = 0x700
movsbl %ah, %eax
andl %edx, %edi
movl %eax, %esi
subb %cl, %sil
addb %al, %sil
addb $0x1e, %sil
movzbl %sil, %eax
orl %edi, %eax
orl %eax, %ebx
xorl %edx, %ebx
jmp 0x7e3e
movsbl %dil, %ecx
movb $-0x6, %dl
movb $0x6, %sil
movl %ecx, %eax
idivb %dl
movl %eax, %edx
movl %ecx, %eax
movb $0x5, %cl
idivb %sil
movsbl %ah, %eax
subb %al, %cl
movzbl %cl, %eax
movl $0x700, %ecx            # imm = 0x700
imull $0x6, %eax, %eax
andl %ecx, %edi
addb %dl, %al
movl $0x500, %edx            # imm = 0x500
addb $0x5, %al
movzbl %al, %eax
subl %edi, %edx
shll $0xc, %ebx
andl %ecx, %edx
orl %eax, %edx
orl %edx, %ebx
xorl %ecx, %ecx
movl %ebx, %eax
jmp 0x7c55
leaq 0x14b82(%rip), %rdi     # 0x1c9d0
leaq 0x14b90(%rip), %rsi     # 0x1c9e5
leaq 0x14b92(%rip), %rcx     # 0x1c9ee
pushq $0x5d
popq %rdx
callq 0x41c0
leaq 0x14bba(%rip), %rdi     # 0x1ca25
leaq 0x14b73(%rip), %rsi     # 0x1c9e5
leaq 0x14b75(%rip), %rcx     # 0x1c9ee
pushq $0x67
jmp 0x7e5e
leaq 0x14bb6(%rip), %rdi     # 0x1ca3a
movl %ebx, %edx
xorl %eax, %eax
callq 0x4040
leaq 0x14bc0(%rip), %rdi     # 0x1ca54
leaq 0x14b4a(%rip), %rsi     # 0x1c9e5
leaq 0x14b4c(%rip), %rcx     # 0x1c9ee
pushq $0x7f
jmp 0x7e5e