// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, 0x8(%rsp)
movq %rsi, %r14
movq %rsi, 0x10(%rsp)
movq %rsi, %rax
shrq $0x20, %rax
movl 0xc(%rdi), %ecx
imull %r14d, %ecx
addl %eax, %ecx
cmpl $-0x1, 0x20(%rdi,%rcx,4)
jne 0xfc37
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
callq 0xfc80
movl %eax, %ebp
cltq
imulq $0x78, %rax, %rax
leaq (%rbx,%rax), %r15
addq $0x5c8, %r15            # imm = 0x5C8
movq %r15, %rdi
movl 0x8(%rsp), %esi
callq 0x4d06
movq %r15, %rdi
movq %r14, %rsi
callq 0x4d0a
movl %ebp, 0x1c(%rsp)
movq 0x10(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7352
leaq 0x5c8(%rbx), %r13
movq (%rax), %rbp
movq 0x8(%rax), %r12
leaq 0x40(%rsp), %r14
movq %rbx, 0x38(%rsp)
cmpq %r12, %rbp
je 0xfba4
movq (%rbp), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movl 0xc(%rbx), %ecx
imull %esi, %ecx
addl %eax, %ecx
movslq 0x20(%rbx,%rcx,4), %rax
movl %eax, 0xc(%rsp)
cmpq $-0x1, %rax
je 0xfb42
imulq $0x78, %rax, %rsi
movl 0x8(%rsp), %eax
cmpl %eax, (%r13,%rsi)
jne 0xfb4c
addq %r13, %rsi
movq %r15, %rdi
callq 0x4d4c
jmp 0xfb9b
movq %r15, %rdi
callq 0x4d20
jmp 0xfb9b
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1087e
movq %r13, %rbx
movq %r12, %r13
movq %r15, %r12
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0x10855
movl %eax, %r15d
movq %r14, %rdi
callq 0x109f0
testb %r15b, %r15b
movq %r12, %r15
movq %r13, %r12
movq %rbx, %r13
movq 0x38(%rsp), %rbx
jne 0xfb9b
leaq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x108cc
addq $0x8, %rbp
jmp 0xfafb
movq %rbx, %rdi
movl 0x1c(%rsp), %esi
callq 0xfd02
movq (%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0xf8d2
xorq %rax, 0x18(%rbx)
movq (%rbx), %rdi
leaq 0x10(%rsp), %rdx
movl 0x8(%rsp), %esi
callq 0xf8ea
xorq %rax, 0x18(%rbx)
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %r12
cmpq %r12, %r15
je 0xfc1e
movslq (%r15), %rax
imulq $0x78, %rax, %r14
addq %r13, %r14
movq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x4d36
addq $0x40, %r14
movq %r14, %rdi
callq 0x10968
testq %rax, %rax
jne 0xfc18
movl (%r15), %esi
movq %rbx, %rdi
callq 0xfde4
addq $0x4, %r15
jmp 0xfbe0
leaq 0x20(%rsp), %rdi
callq 0x109f0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4938(%rip), %rdi      # 0x14576
leaq 0x48f2(%rip), %rsi      # 0x14537
leaq 0x4902(%rip), %rcx      # 0x1454e
pushq $0x2b
popq %rdx
callq 0x3100
jmp 0xfc6b
jmp 0xfc6b
jmp 0xfc6b
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x109f0
jmp 0xfc6e
jmp 0xfc6b
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x109f0
movq %rbx, %rdi
callq 0x32b0