// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movl %edx, 0x10(%rsp)
movq %rsi, 0x18(%rsp)
movl 0xc(%rdi), %eax
imull %esi, %eax
shrq $0x20, %rsi
addl %esi, %eax
cmpl $-0x1, 0x20(%rdi,%rax,4)
jne 0x100fe
movq %rdi, %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
callq 0x10164
movl %eax, %ebx
cltq
imulq $0x78, %rax, %rax
leaq (%rax,%r13), %r15
addq $0x5c8, %r15            # imm = 0x5C8
movq %r15, %rdi
movl 0x10(%rsp), %esi
callq 0x4b86
movq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x4b8a
movl %ebx, 0x38(%rsp)
movq 0x10(%r13), %rdi
leaq 0x18(%rsp), %rsi
callq 0x7244
leaq 0x5c8(%r13), %r12
movq (%rax), %r14
movq 0x8(%rax), %rbp
cmpq %rbp, %r14
movq %r12, 0x48(%rsp)
je 0xffe3
movq (%r14), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movl 0xc(%r13), %ecx
imull %esi, %ecx
addl %eax, %ecx
movslq 0x20(%r13,%rcx,4), %rax
movl %eax, 0xc(%rsp)
cmpq $-0x1, %rax
je 0xff37
imulq $0x78, %rax, %rsi
movl 0x10(%rsp), %eax
cmpl %eax, (%r12,%rsi)
jne 0xff44
addq %r12, %rsi
movq %r15, %rdi
callq 0x4bcc
jmp 0xffd6
movq %r15, %rdi
callq 0x4ba0
jmp 0xffd6
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x110a0
movq %r13, %rbx
movq %rbp, %r13
movq %r15, %rbp
movl 0xc(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0x44(%rsp), %rdx
callq 0x111bd
movq %rax, %r12
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %r15
testq %rdi, %rdi
je 0xff97
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
cmpq %r15, %r12
movq 0x48(%rsp), %r12
movq %rbp, %r15
movq %r13, %rbp
movq %rbx, %r13
jne 0xffd6
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0xffc7
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0xffd6
leaq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x11272
addq $0x8, %r14
cmpq %rbp, %r14
jne 0xfef7
movq %r13, %rdi
movl 0x38(%rsp), %esi
callq 0x1021a
movq (%r13), %rdi
leaq 0x18(%rsp), %rsi
callq 0xfc48
xorq %rax, 0x18(%r13)
movq (%r13), %rdi
leaq 0x18(%rsp), %rdx
movl 0x10(%rsp), %esi
callq 0xfc7e
movq %r13, 0x38(%rsp)
xorq %rax, 0x18(%r13)
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq %rax, %r15
je 0x100d8
movabsq $0x5555555555555555, %rbp # imm = 0x5555555555555555
movabsq $0x3333333333333333, %r13 # imm = 0x3333333333333333
movabsq $0xf0f0f0f0f0f0f0f, %rbx # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r12 # imm = 0x101010101010101
movslq (%r15), %rax
imulq $0x78, %rax, %r14
addq 0x48(%rsp), %r14
movq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x4bb6
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x40(%r14,%rcx,8), %rdx
movq %rdx, %rsi
shrq %rsi
andq %rbp, %rsi
subq %rsi, %rdx
movq %rdx, %rsi
andq %r13, %rsi
shrq $0x2, %rdx
andq %r13, %rdx
addq %rsi, %rdx
movq %rdx, %rsi
shrq $0x4, %rsi
addq %rdx, %rsi
andq %rbx, %rsi
imulq %r12, %rsi
shrq $0x38, %rsi
addq %rsi, %rax
incq %rcx
cmpq $0x6, %rcx
jne 0x10079
testq %rax, %rax
jne 0x100cd
movl (%r15), %esi
movq 0x38(%rsp), %rdi
callq 0x1030e
addq $0x4, %r15
cmpq 0x10(%rsp), %r15
jne 0x1005c
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x100ef
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4441(%rip), %rdi      # 0x14546
leaq 0x43fb(%rip), %rsi      # 0x14507
leaq 0x440b(%rip), %rcx      # 0x1451e
movl $0x2b, %edx
callq 0x3110
jmp 0x10141
jmp 0x10141
jmp 0x10141
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x10144
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
jmp 0x10144
jmp 0x10141
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1015b
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
movq %rbx, %rdi
callq 0x32b0
nop