// File: /workspace/github_cpp_makefile_star2_O2/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 0x1a879(%rip), %r8      # 0x29a09
movb 0xb(%rdi), %al
movl %ecx, %r12d
cmpb (%r8), %al
jge 0xf31b
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
callq 0xf33a
movl %eax, %ebp
testb %al, %al
je 0xf30a
movzwl (%r14), %eax
movl %r15d, 0x4(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movw %ax, 0x8(%rbx)
incw 0x6(%rbx)
movswq 0x2(%r14), %rax
movq 0x10(%rbx), %rcx
movb 0xa(%rbx), %dl
shlq $0x4, %rax
movb %dl, (%rcx,%rax)
movb %r12b, 0x7(%rcx,%rax)
movzbl 0xa(%rbx), %edx
callq 0xf36e
movzbl 0xa(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf4fe
movswq 0x2(%r14), %rax
movq 0x88(%rbx), %rcx
xorl %r15d, %r15d
xorl %r12d, %r12d
imulq $0x48, %rax, %rax
leaq 0x2(%rcx,%rax), %r13
cmpq $0x18, %r15
jge 0xf25a
movswq (%r13,%r15), %rdx
cmpq $-0x1, %rdx
je 0xf254
movq 0x10(%rbx), %rax
movq %rdx, %rcx
shlq $0x4, %rcx
movb 0xa(%rbx), %sil
cmpb (%rax,%rcx), %sil
jne 0xf254
movswl 0x2(%r14), %esi
movq %rbx, %rdi
callq 0xf544
orb %al, %r12b
addq $0x4, %r15
addq $0x4, %r15
jmp 0xf219
cmpb $0x0, 0x4(%rsp)
je 0xf302
movswl 0x2(%r14), %esi
movq %rbx, %rdi
callq 0xf5c2
movslq %eax, %rcx
movq 0x10(%rbx), %rax
leaq 0x160a0(%rip), %rdx     # 0x25320
shlq $0x4, %rcx
movzbl 0x5(%rax,%rcx), %esi
cmpb $0x3, (%rsi,%rdx)
jb 0xf29b
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x0, 0xc(%rbx)
jmp 0xf302
addq %rcx, %rax
movzbl 0x4(%rax), %ecx
cmpb $0x2, (%rcx,%rdx)
jb 0xf2b4
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x1, 0xc(%rbx)
jmp 0xf302
cmpb $0x1, 0x98(%rbx)
jne 0xf2ec
cmpb $0x6, 0x1(%rax)
setae %al
andb %al, %r12b
cmpb $0x1, %r12b
jne 0xf2ec
movzbl 0xa(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x193f4
testb %al, %al
je 0xf2ec
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x2, 0xc(%rbx)
jmp 0xf302
movzwl 0x6(%rbx), %eax
cmpw 0x4(%rbx), %ax
jne 0xf302
leaq 0x1a70c(%rip), %rax     # 0x29a09
movb (%rax), %al
movb %al, 0xb(%rbx)
movb $0x3, %al
subb 0xa(%rbx), %al
movb %al, 0xa(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x166f8(%rip), %rdi     # 0x25a1a
leaq 0x15554(%rip), %rsi     # 0x2487d
leaq 0x166fd(%rip), %rcx     # 0x25a2d
movl $0x131, %edx            # imm = 0x131
callq 0x51f0