// File: macfergus[P]baduk/cppsrc/baduk/board.cpp
// Function: baduk::Board::place(baduk::Point, baduk::Stone)
void Board::place(Point point, Stone player) {
    assert(isEmpty(point));
    std::vector<StringIdx> adjacent_other_color;

    const auto new_string_idx = getUnusedString();
    auto& new_string = strings_[new_string_idx];
    new_string.setColor(player);
    new_string.addPoint(point);
    for (Point neighbor : neighbors_->get(point)) {
        auto neighbor_string = grid_[index(neighbor)];
        if (neighbor_string == EMPTY) {
            new_string.addLiberty(neighbor);
        } else if (strings_[neighbor_string].color() == player) {
            new_string.merge(strings_[neighbor_string]);
        } else {
            if (!contains(adjacent_other_color, neighbor_string)) {
                adjacent_other_color.push_back(neighbor_string);
            }
        }
    }
    replace(new_string_idx);

    // Update hash code.
    hashcode_ ^= zobrist_.getEmpty(point);
    hashcode_ ^= zobrist_.getStone(player, point);

    for (auto const& other_color_string : adjacent_other_color) {
        auto& enemy_string = strings_[other_color_string];
        enemy_string.removeLiberty(point);
        if (enemy_string.numLiberties() == 0) {
            remove(other_color_string);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rsi, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1c(%rbp)
movq -0x1c(%rbp), %rsi
callq 0x3c650
testb $0x1, %al
jne 0x3c728
jmp 0x3c72a
jmp 0x3c749
leaq 0x6e82(%rip), %rdi      # 0x435b3
leaq 0x6e3c(%rip), %rsi      # 0x43574
movl $0x2b, %edx
leaq 0x6e47(%rip), %rcx      # 0x4358b
callq 0x3140
leaq -0x38(%rbp), %rdi
callq 0x3e290
movq -0xe8(%rbp), %rdi
callq 0x3cb40
movl %eax, -0xec(%rbp)
jmp 0x3c766
movq -0xe8(%rbp), %rdi
movl -0xec(%rbp), %eax
movl %eax, -0x3c(%rbp)
addq $0x5c8, %rdi            # imm = 0x5C8
movslq -0x3c(%rbp), %rsi
callq 0x3e2b0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x9530
jmp 0x3c798
movq -0x58(%rbp), %rdi
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rsi
callq 0x9550
jmp 0x3c7af
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x8(%rbp), %rsi
callq 0x12fb0
movq %rax, -0xf8(%rbp)
jmp 0x3c7cc
movq -0xf8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x101b0
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0x101e0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x10210
testb $0x1, %al
jne 0x3c807
jmp 0x3c9ac
leaq -0x70(%rbp), %rdi
callq 0x10250
movq -0xe8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x80(%rbp)
movq %rdi, %rax
addq $0x20, %rax
movq %rax, -0x108(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rsi
callq 0x3c6a0
movl %eax, -0xfc(%rbp)
jmp 0x3c84b
movq -0x108(%rbp), %rdi
movl -0xfc(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3e2e0
movl (%rax), %eax
movl %eax, -0x84(%rbp)
cmpl $-0x1, -0x84(%rbp)
jne 0x3c8a5
movq -0x58(%rbp), %rdi
movq -0x80(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rsi
callq 0x9580
jmp 0x3c88f
jmp 0x3c99c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3cb24
movq -0xe8(%rbp), %rdi
addq $0x5c8, %rdi            # imm = 0x5C8
movslq -0x84(%rbp), %rsi
callq 0x3e2b0
movq %rax, %rdi
callq 0x3e310
movl %eax, -0x10c(%rbp)
jmp 0x3c8cf
movl -0x10c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x3c915
movq -0xe8(%rbp), %rdi
movq -0x58(%rbp), %rax
movq %rax, -0x118(%rbp)
addq $0x5c8, %rdi            # imm = 0x5C8
movslq -0x84(%rbp), %rsi
callq 0x3e2b0
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0x95e0
jmp 0x3c910
jmp 0x3c99a
leaq -0xb0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3e380
jmp 0x3c927
movl -0x84(%rbp), %esi
leaq -0xb0(%rbp), %rdi
callq 0x3e320
movb %al, -0x119(%rbp)
jmp 0x3c941
movb -0x119(%rbp), %al
xorb $-0x1, %al
movb %al, -0x11a(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3e470
movb -0x11a(%rbp), %al
testb $0x1, %al
jne 0x3c967
jmp 0x3c998
leaq -0x38(%rbp), %rdi
leaq -0x84(%rbp), %rsi
callq 0x3e4d0
jmp 0x3c979
jmp 0x3c998
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3e470
jmp 0x3cb24
jmp 0x3c99a
jmp 0x3c99c
jmp 0x3c99e
leaq -0x70(%rbp), %rdi
callq 0x10270
jmp 0x3c7f1
movq -0xe8(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x3cc50
jmp 0x3c9bd
movq -0xe8(%rbp), %rax
movq (%rax), %rdi
leaq -0x8(%rbp), %rsi
callq 0x3c1e0
movq %rax, -0x128(%rbp)
jmp 0x3c9d9
movq -0xe8(%rbp), %rax
movq -0x128(%rbp), %rdx
movq 0x18(%rax), %rcx
xorq %rdx, %rcx
movq %rcx, 0x18(%rax)
movq (%rax), %rdi
movl -0x14(%rbp), %esi
leaq -0x8(%rbp), %rdx
callq 0x3c220
movq %rax, -0x130(%rbp)
jmp 0x3ca0a
movq -0xe8(%rbp), %rax
movq -0x130(%rbp), %rcx
xorq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
leaq -0x38(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x3e540
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x3e570
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3e5a0
testb $0x1, %al
jne 0x3ca6d
jmp 0x3cb12
leaq -0xc0(%rbp), %rdi
callq 0x3e5e0
movq -0xe8(%rbp), %rdi
movq %rax, -0xd0(%rbp)
addq $0x5c8, %rdi            # imm = 0x5C8
movq -0xd0(%rbp), %rax
movslq (%rax), %rsi
callq 0x3e2b0
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rsi
callq 0x95b0
jmp 0x3cac4
movq -0xd8(%rbp), %rdi
callq 0x3e600
movq %rax, -0x138(%rbp)
jmp 0x3cad9
movq -0x138(%rbp), %rax
cmpq $0x0, %rax
jne 0x3caff
movq -0xe8(%rbp), %rdi
movq -0xd0(%rbp), %rax
movl (%rax), %esi
callq 0x3ce10
jmp 0x3cafd
jmp 0x3caff
jmp 0x3cb01
leaq -0xc0(%rbp), %rdi
callq 0x3e620
jmp 0x3ca51
leaq -0x38(%rbp), %rdi
callq 0x3e470
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x3e470
movq -0x48(%rbp), %rdi
callq 0x3370
nopw %cs:(%rax,%rax)