// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rsi, %r14
movb 0xb(%rdi), %al
leaq 0x25607(%rip), %rsi     # 0x39109
cmpb (%rsi), %al
jge 0x13ce9
movq %rdi, %rbx
movswq 0x2(%r14), %rax
cmpq $-0x1, %rax
je 0x13b32
movq 0x10(%rbx), %rsi
shlq $0x4, %rax
movb (%rsi,%rax), %al
leaq 0x255d7(%rip), %rsi     # 0x39101
cmpb (%rsi), %al
sete %bpl
jmp 0x13b34
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x13cd8
movl %edx, 0x4(%rsp)
movzwl (%r14), %eax
movw %ax, 0x8(%rbx)
incw 0x6(%rbx)
movswq 0x2(%r14), %rax
movq 0x10(%rbx), %rdx
shlq $0x4, %rax
movb 0xa(%rbx), %sil
movb %sil, (%rdx,%rax)
movb %cl, 0x7(%rdx,%rax)
movzbl 0xa(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13d08
movsbq 0xa(%rbx), %rax
movswq 0x2(%r14), %rcx
leaq (%rcx,%rcx,8), %r12
shlq $0x3, %r12
addq 0x88(%rbx), %r12
movq 0x10(%rbx), %rcx
xorl %edx, %edx
movzwl 0x2(%r12,%rdx), %esi
cmpq $0xffff, %rsi           # imm = 0xFFFF
je 0x13bb0
movswq %si, %rsi
shlq $0x4, %rsi
orq %rax, 0x8(%rcx,%rsi)
shlq $0x2, %rax
addq $0x4, %rdx
cmpq $0x48, %rdx
jne 0x13b94
xorl %r13d, %r13d
xorl %r15d, %r15d
movswq 0x2(%r12,%r15), %rdx
cmpq $-0x1, %rdx
je 0x13bf9
movq 0x10(%rbx), %rax
movq %rdx, %rcx
shlq $0x4, %rcx
movb 0xa(%rbx), %sil
cmpb (%rax,%rcx), %sil
jne 0x13bf9
movswl 0x2(%r14), %esi
movq %rbx, %rdi
callq 0x13e94
orb %al, %r13b
addq $0x4, %r15
leaq 0x4(%r15), %rax
cmpq $0x14, %r15
movq %rax, %r15
jl 0x13bc4
cmpb $0x0, 0x4(%rsp)
je 0x13cd0
movswl 0x2(%r14), %esi
movq 0x10(%rbx), %rax
movq %rsi, %rdx
shlq $0x4, %rdx
movzwl 0x2(%rax,%rdx), %ecx
cmpl %esi, %ecx
je 0x13c4c
leaq 0x2(%rax,%rdx), %rdx
movl %ecx, %ecx
shlq $0x4, %rcx
movzwl 0x2(%rax,%rcx), %esi
movzwl %si, %ecx
movl %ecx, %edi
shll $0x4, %edi
cmpw 0x2(%rax,%rdi), %si
jne 0x13c2f
movw %si, (%rdx)
shll $0x4, %ecx
movzbl 0x5(%rax,%rcx), %esi
leaq 0x20815(%rip), %rdx     # 0x34470
cmpb $0x3, (%rsi,%rdx)
jb 0x13c6d
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x0, 0xc(%rbx)
jmp 0x13cd0
addq %rcx, %rax
movzbl 0x4(%rax), %ecx
cmpb $0x2, (%rcx,%rdx)
jb 0x13c86
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x1, 0xc(%rbx)
jmp 0x13cd0
cmpb $0x1, 0x98(%rbx)
jne 0x13cba
testb $0x1, %r13b
je 0x13cba
cmpb $0x6, 0x1(%rax)
jb 0x13cba
movzbl 0xa(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2186a
testb %al, %al
je 0x13cba
movb 0xa(%rbx), %al
movb %al, 0xb(%rbx)
movb $0x2, 0xc(%rbx)
jmp 0x13cd0
movzwl 0x6(%rbx), %eax
cmpw 0x4(%rbx), %ax
jne 0x13cd0
leaq 0x2543e(%rip), %rax     # 0x39109
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 0x20ee5(%rip), %rdi     # 0x34bd5
leaq 0x1fb98(%rip), %rsi     # 0x3388f
leaq 0x20eea(%rip), %rcx     # 0x34be8
movl $0x131, %edx            # imm = 0x131
callq 0x51d0