// File: tewalds[P]morat/hex/board.h
// Function: Morat::Hex::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
		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)){
				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
			}
		}

		// did I win?
		Cell * g = & cells_[find_group(pos.xy)];
		uint8_t winmask = (to_play_ == Side::P1 ? 3 : 0xC);
		if((g->edge & winmask) == winmask){
			outcome_ = +to_play_;
		}

		to_play_ = ~to_play_;

		return true;
	}

// Assembly:
subq $0x88, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
andb $0x1, %cl
movb %cl, 0x6f(%rsp)
andb $0x1, %al
movb %al, 0x6e(%rsp)
movq 0x78(%rsp), %rdi
movq %rdi, 0x18(%rsp)
addq $0x9, %rdi
callq 0x1cb10
xorb $-0x1, %al
testb $0x1, %al
jne 0x1f44d
jmp 0x1f44f
jmp 0x1f46e
leaq 0x2e3f2(%rip), %rdi     # 0x4d848
leaq 0x2d414(%rip), %rsi     # 0x4c871
movl $0xeb, %edx
leaq 0x2e3f2(%rip), %rcx     # 0x4d85b
callq 0x52a0
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x1f6d0
testb $0x1, %al
jne 0x1f48e
movb $0x0, 0x87(%rsp)
jmp 0x1f6bc
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rax
movw (%rax), %ax
movw %ax, 0x6(%rdi)
movw 0x4(%rdi), %ax
addw $0x1, %ax
movw %ax, 0x4(%rdi)
addq $0x10, %rdi
movq 0x70(%rsp), %rax
movswq 0x2(%rax), %rsi
callq 0x11590
movq 0x18(%rsp), %rdi
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movb 0x8(%rdi), %cl
movb %cl, (%rax)
movb 0x6e(%rsp), %cl
andb $0x1, %cl
movq 0x60(%rsp), %rax
movb %cl, 0x7(%rax)
movq 0x70(%rsp), %rsi
movb 0x8(%rdi), %al
movb %al, 0x5f(%rsp)
movzbl 0x5f(%rsp), %edx
callq 0x1f740
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rsi
movb 0x8(%rdi), %al
movb %al, 0x5e(%rsp)
movzbl 0x5e(%rsp), %edx
callq 0x1f7f0
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x1f8f0
movq %rax, 0x48(%rsp)
movq %rdx, 0x50(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x11710
movq %rax, 0x40(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x11720
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x1f5f1
movq 0x40(%rsp), %rdi
callq 0x11730
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x17(%rsp)
jne 0x1f572
jmp 0x1f5a8
movq 0x18(%rsp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rax
movswl 0x2(%rax), %esi
callq 0x1f970
movq 0x8(%rsp), %rdi
movb %al, 0x37(%rsp)
leaq 0x37(%rsp), %rsi
callq 0x1f930
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x1f5b2
jmp 0x1f5dc
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rax
movswl 0x2(%rax), %esi
movq 0x40(%rsp), %rax
movswl 0x2(%rax), %edx
callq 0x1f9a0
movq 0x40(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x40(%rsp)
jmp 0x1f5de
movq 0x40(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x40(%rsp)
jmp 0x1f549
movq 0x18(%rsp), %rdi
movq %rdi, %rax
addq $0x10, %rax
movq %rax, (%rsp)
movq 0x70(%rsp), %rax
movswl 0x2(%rax), %esi
callq 0x1faf0
movq (%rsp), %rdi
movslq %eax, %rsi
callq 0x11590
movq 0x18(%rsp), %rdi
movq %rax, 0x28(%rsp)
addq $0x8, %rdi
leaq 0x4de8c(%rip), %rsi     # 0x6d4bc
callq 0x1f930
movb %al, %dl
movl $0xc, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movb %al, 0x27(%rsp)
movq 0x28(%rsp), %rax
movzbl 0x6(%rax), %eax
movzbl 0x27(%rsp), %ecx
andl %ecx, %eax
movzbl 0x27(%rsp), %ecx
cmpl %ecx, %eax
jne 0x1f68c
movq 0x18(%rsp), %rax
movb 0x8(%rax), %al
movb %al, 0x25(%rsp)
movzbl 0x25(%rsp), %edi
callq 0x1fba0
movb %al, %cl
movq 0x18(%rsp), %rax
movb %cl, 0x26(%rsp)
movb 0x26(%rsp), %cl
movb %cl, 0x9(%rax)
movq 0x18(%rsp), %rax
movb 0x8(%rax), %al
movb %al, 0x23(%rsp)
movzbl 0x23(%rsp), %edi
callq 0x1c680
movb %al, %cl
movq 0x18(%rsp), %rax
movb %cl, 0x24(%rsp)
movb 0x24(%rsp), %cl
movb %cl, 0x8(%rax)
movb $0x1, 0x87(%rsp)
movb 0x87(%rsp), %al
andb $0x1, %al
addq $0x88, %rsp
retq
nopl (%rax)