// File: /workspace/github_cpp_makefile_star2_O3/tewalds[P]morat/havannah/board.h
// Function: Morat::Havannah::Board::move(Morat::MoveValid const&, bool, bool)
bool move(const MoveValid & pos, bool checkwin = true, bool permanent = true) {
		assert(!outcome_.solved());

		if(!valid_move(pos))
			return false;

		last_move_ = pos;
		num_moves_++;

		Cell& cell = cells_[pos.xy];
		cell.piece = to_play_;
		cell.perm = permanent;

		update_hash(pos, to_play_); //depends on num_moves_
		update_pattern(pos, to_play_);

		// join the groups for win detection
		bool alreadyjoined = false; //useful for finding rings
		auto it = neighbors_small(pos);
		for (const MoveValid *i = it.begin(), *e = it.end(); i < e; i++) {
			if(i->on_board() && to_play_ == get(i->xy)){
				alreadyjoined |= join_groups(pos.xy, i->xy);
				i++; //skip the next one. If it is the same group,
					 //it is already connected and forms a corner, which we can ignore
			}
		}

		if(checkwin){
			Cell * g = & cells_[find_group(pos.xy)];
			if(g->numedges() >= 3){
				outcome_ = +to_play_;
				win_type_ = 0;
			}else if(g->numcorners() >= 2){
				outcome_ = +to_play_;
				win_type_ = 1;
			}else if(check_rings && alreadyjoined && g->size >= 6 && checkring_df(pos, to_play_)){
				outcome_ = +to_play_;
				win_type_ = 2;
			}else if(num_moves_ == num_cells_){
				outcome_ = Outcome::DRAW;
			}
		}

		to_play_ = ~to_play_;

		return true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x256d3(%rip), %r8      # 0x39109
movb 0xb(%rdi), %al
movl %edx, %ebp
cmpb (%r8), %al
jge 0x13c21
movswq 0x2(%rsi), %rdx
movq %rsi, %r14
cmpq $-0x1, %rdx
je 0x13b9d
movq 0x10(%rdi), %rax
leaq 0x256a0(%rip), %rsi     # 0x39101
shlq $0x4, %rdx
movq %rdi, %rbx
movb (%rax,%rdx), %dl
cmpb (%rsi), %dl
jne 0x13b9d
movzwl (%r14), %edx
movq %rbx, %rdi
movw %dx, 0x8(%rbx)
incw 0x6(%rbx)
movswq 0x2(%r14), %rdx
movb 0xa(%rbx), %sil
shlq $0x4, %rdx
movb %sil, (%rax,%rdx)
movb %cl, 0x7(%rax,%rdx)
movq %r14, %rsi
movzbl 0xa(%rbx), %edx
callq 0x13c40
movswq 0x2(%r14), %rcx
movsbq 0xa(%rbx), %rax
xorl %edx, %edx
leaq (%rcx,%rcx,8), %r13
movq 0x10(%rbx), %rcx
shlq $0x3, %r13
addq 0x88(%rbx), %r13
movzwl 0x2(%r13,%rdx), %esi
cmpq $0xffff, %rsi           # imm = 0xFFFF
je 0x13ade
movswq %si, %rsi
shlq $0x4, %rsi
orq %rax, 0x8(%rcx,%rsi)
shlq $0x2, %rax
addq $0x4, %rdx
cmpq $0x48, %rdx
jne 0x13ac2
xorl %r12d, %r12d
xorl %r15d, %r15d
movswq 0x2(%r13,%r15), %rdx
cmpq $-0x1, %rdx
je 0x13b27
movq 0x10(%rbx), %rax
movq %rdx, %rcx
shlq $0x4, %rcx
movb 0xa(%rbx), %sil
cmpb (%rax,%rcx), %sil
jne 0x13b27
movswl 0x2(%r14), %esi
movq %rbx, %rdi
callq 0x13dd0
orb %al, %r12b
addq $0x4, %r15
leaq 0x4(%r15), %rax
cmpq $0x14, %r15
movq %rax, %r15
jl 0x13af2
testb %bpl, %bpl
je 0x13c08
movswl 0x2(%r14), %ecx
movq 0x10(%rbx), %rax
movq %rcx, %rsi
shlq $0x4, %rsi
movzwl 0x2(%rax,%rsi), %edx
cmpl %ecx, %edx
je 0x13b7b
leaq 0x2(%rax,%rsi), %rcx
movl %edx, %edx
shlq $0x4, %rdx
movzwl 0x2(%rax,%rdx), %esi
movzwl %si, %edx
movl %edx, %edi
shll $0x4, %edi
cmpw 0x2(%rax,%rdi), %si
jne 0x13b5b
movw %dx, (%rcx)
movq %rdx, %rcx
shlq $0x4, %rcx
leaq 0x208ea(%rip), %rdx     # 0x34470
movzbl 0x5(%rax,%rcx), %esi
cmpb $0x3, (%rsi,%rdx)
jb 0x13ba1
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x0, 0xc(%rbx)
jmp 0x13c08
xorl %eax, %eax
jmp 0x13c12
addq %rcx, %rax
movzbl 0x4(%rax), %ecx
cmpb $0x2, (%rcx,%rdx)
jb 0x13bba
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x1, 0xc(%rbx)
jmp 0x13c08
cmpb $0x1, 0x98(%rbx)
jne 0x13bf2
cmpb $0x6, 0x1(%rax)
setae %al
andb %al, %r12b
cmpb $0x1, %r12b
jne 0x13bf2
movzbl 0xa(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x215ec
testb %al, %al
je 0x13bf2
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x2, 0xc(%rbx)
jmp 0x13c08
movzwl 0x6(%rbx), %eax
cmpw 0x4(%rbx), %ax
jne 0x13c08
leaq 0x25506(%rip), %rax     # 0x39109
movb (%rax), %al
movb %al, 0xb(%rbx)
movb $0x3, %al
subb 0xa(%rbx), %al
movb %al, 0xa(%rbx)
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20fad(%rip), %rdi     # 0x34bd5
leaq 0x1fc60(%rip), %rsi     # 0x3388f
leaq 0x20fb2(%rip), %rcx     # 0x34be8
movl $0x131, %edx            # imm = 0x131
callq 0x51d0