// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rsi, 0x8(%rsp)
movl 0xc(%rdi), %eax
imull %esi, %eax
shrq $0x20, %rsi
addl %esi, %eax
cmpl $-0x1, 0x20(%rdi,%rax,4)
jne 0xfadc
movl %edx, %r15d
movq %rdi, %rbx
pxor %xmm0, %xmm0
movdqa %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
callq 0xfb42
movl %eax, %ebp
cltq
imulq $0x78, %rax, %rax
leaq (%rbx,%rax), %r12
addq $0x5c8, %r12            # imm = 0x5C8
movq %r12, %rdi
movl %r15d, %esi
callq 0x4b36
movq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x4b3a
movl %ebp, 0x28(%rsp)
movq 0x10(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7274
leaq 0x5c8(%rbx), %r13
movq (%rax), %r14
movq 0x8(%rax), %rbp
cmpq %rbp, %r14
je 0xf9bb
movq %rbp, 0x48(%rsp)
movq (%r14), %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, 0x4(%rsp)
cmpq $-0x1, %rax
je 0xf90b
imulq $0x78, %rax, %rsi
cmpl %r15d, (%r13,%rsi)
jne 0xf918
addq %r13, %rsi
movq %r12, %rdi
callq 0x4b7c
jmp 0xf9ae
movq %r12, %rdi
callq 0x4b50
jmp 0xf9ae
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x10958
movq %rbx, %rbp
movq %r12, %rbx
movl 0x4(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
leaq 0x2c(%rsp), %rdx
callq 0x10a75
movq %rax, %r12
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rax
testq %rdi, %rdi
je 0xf972
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
movq %rax, 0x50(%rsp)
callq 0x3180
movq 0x50(%rsp), %rax
cmpq %rax, %r12
movq %rbx, %r12
movq %rbp, %rbx
movq 0x48(%rsp), %rbp
jne 0xf9ae
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xf99f
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xf9ae
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x10b36
addq $0x8, %r14
cmpq %rbp, %r14
jne 0xf8cf
movq %rbx, %rdi
movl 0x28(%rsp), %esi
callq 0xfbbe
movq (%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0xf620
xorq %rax, 0x18(%rbx)
movq (%rbx), %rdi
leaq 0x8(%rsp), %rdx
movl %r15d, %esi
callq 0xf656
xorq %rax, 0x18(%rbx)
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r12
cmpq %r12, %r14
je 0xfab8
movslq (%r14), %rax
imulq $0x78, %rax, %r15
addq %r13, %r15
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x4b66
pxor %xmm6, %xmm6
movdqa 0x4ade(%rip), %xmm5     # 0x14500
movdqa 0x4ac6(%rip), %xmm4     # 0x144f0
movdqa 0x4aae(%rip), %xmm3     # 0x144e0
pxor %xmm0, %xmm0
xorl %eax, %eax
movdqu 0x40(%r15,%rax,8), %xmm1
movdqa %xmm1, %xmm2
psrlw $0x1, %xmm2
pand %xmm3, %xmm2
psubb %xmm2, %xmm1
movdqa %xmm1, %xmm2
pand %xmm4, %xmm2
psrlw $0x2, %xmm1
pand %xmm4, %xmm1
paddb %xmm2, %xmm1
movdqa %xmm1, %xmm2
psrlw $0x4, %xmm2
paddb %xmm1, %xmm2
pand %xmm5, %xmm2
psadbw %xmm6, %xmm2
paddq %xmm2, %xmm0
addq $0x2, %rax
cmpq $0x6, %rax
jne 0xfa38
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
paddq %xmm0, %xmm1
movq %xmm1, %rax
testq %rax, %rax
jne 0xfaa6
movl (%r14), %esi
movq %rbx, %rdi
callq 0xfcb2
addq $0x4, %r14
cmpq %r12, %r14
jne 0xf9ff
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0xfacd
movq 0x20(%rsp), %rsi
subq %r14, %rsi
movq %r14, %rdi
callq 0x3180
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a6c(%rip), %rdi      # 0x1454f
leaq 0x4a26(%rip), %rsi      # 0x14510
leaq 0x4a36(%rip), %rcx      # 0x14527
movl $0x2b, %edx
callq 0x3110
jmp 0xfb1f
jmp 0xfb1f
jmp 0xfb1f
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xfb22
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
jmp 0xfb22
jmp 0xfb1f
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xfb39
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
movq %rbx, %rdi
callq 0x32b0
nop