// File: /workspace/github_cpp_makefile_star2_O1/macfergus[P]baduk/cppsrc/baduk/board.cpp
// Function: baduk::Board::hashAfter(baduk::Point, baduk::Stone) const
zobrist::hashcode Board::hashAfter(Point point, Stone stone) const {
    auto hashcode = hash();
    const auto opponent = other(stone);

    // Place the new stone.
    hashcode ^= zobrist_.getEmpty(point);
    hashcode ^= zobrist_.getStone(stone, point);

    for (Point neighbor : neighbors_->get(point)) {
        const auto neighbor_string_idx = grid_[index(neighbor)];
        if (neighbor_string_idx == EMPTY) {
            continue;
        }
        const GoString& neighbor_string = strings_[neighbor_string_idx];
        if (neighbor_string.color() == stone) {
            continue;
        }
        if (neighbor_string.numLiberties() == 1) {
            for (const auto& p : neighbor_string.stones()) {
                hashcode ^= zobrist_.getStone(opponent, p);
                hashcode ^= zobrist_.getEmpty(p);
            }
        }
    }

    return hashcode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %edx, %ebp
movq %rdi, %r13
leaq 0x58(%rsp), %rbx
movq %rsi, (%rbx)
movq 0x18(%rdi), %r12
movl %edx, %edi
callq 0x37dc
movl %eax, %r14d
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xfc48
movq %rax, %r15
xorq %r12, %r15
movq (%r13), %rdi
movl %ebp, 0x8(%rsp)
movl %ebp, %esi
movq %r13, %rbp
movq %rbx, %rdx
callq 0xfc7e
movq %rax, %r13
xorq %r15, %r13
movq 0x10(%rbp), %rdi
movq %rbx, %rsi
callq 0x7244
movq (%rax), %rdx
movq 0x8(%rax), %r9
cmpq %r9, %rdx
je 0x10dea
movl %r14d, 0xc(%rsp)
leaq 0x5c8(%rbp), %r10
movabsq $0x5555555555555555, %r11 # imm = 0x5555555555555555
movabsq $0xf0f0f0f0f0f0f0f, %rbx # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r15 # imm = 0x101010101010101
leaq 0x48(%rsp), %r14
leaq 0x30(%rsp), %r12
movl 0x8(%rsp), %r8d
movq %r9, 0x28(%rsp)
movq %r10, 0x20(%rsp)
movq %rbp, 0x10(%rsp)
movq (%rdx), %rax
movl 0xc(%rbp), %ecx
imull %eax, %ecx
shrq $0x20, %rax
addl %eax, %ecx
movslq 0x20(%rbp,%rcx,4), %rax
cmpq $-0x1, %rax
je 0x10ddd
imulq $0x78, %rax, %rax
cmpl %r8d, (%r10,%rax)
je 0x10ddd
movq %rdx, 0x18(%rsp)
addq %r10, %rax
xorl %edx, %edx
xorl %ecx, %ecx
movabsq $0x3333333333333333, %rbp # imm = 0x3333333333333333
movq 0x40(%rax,%rdx,8), %rsi
movq %rsi, %rdi
shrq %rdi
andq %r11, %rdi
subq %rdi, %rsi
movq %rsi, %rdi
andq %rbp, %rdi
shrq $0x2, %rsi
andq %rbp, %rsi
addq %rdi, %rsi
movq %rsi, %rdi
shrq $0x4, %rdi
addq %rsi, %rdi
andq %rbx, %rdi
imulq %r15, %rdi
shrq $0x38, %rdi
addq %rdi, %rcx
incq %rdx
cmpq $0x6, %rdx
jne 0x10ca1
cmpq $0x1, %rcx
jne 0x10dd3
movq 0x38(%rax), %rcx
movq %rcx, 0x90(%rsp)
movups 0x8(%rax), %xmm0
movups 0x18(%rax), %xmm1
movups 0x28(%rax), %xmm2
movaps %xmm2, 0x80(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
callq 0x4f10
movq %rax, 0x48(%rsp)
movl %edx, 0x50(%rsp)
movq %rbx, %rdi
callq 0x4f56
movq %rax, 0x38(%rsp)
movl %edx, 0x40(%rsp)
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0x4d56
testb %al, %al
movl 0xc(%rsp), %ebx
movq 0x10(%rsp), %rbp
je 0x10da4
movq %r14, %rdi
callq 0x4d2a
movq %rax, 0x30(%rsp)
movq (%rbp), %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0xfc7e
movq %rax, %r15
movq (%rbp), %rdi
movq %r12, %rsi
callq 0xfc48
xorq %r13, %r15
xorq %rax, %r15
movq %r14, %rdi
callq 0x4cda
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0x4d56
movq %r15, %r13
testb %al, %al
jne 0x10d58
movl 0x8(%rsp), %r8d
movq 0x28(%rsp), %r9
movq 0x20(%rsp), %r10
movabsq $0x5555555555555555, %r11 # imm = 0x5555555555555555
movabsq $0xf0f0f0f0f0f0f0f, %rbx # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r15 # imm = 0x101010101010101
jmp 0x10dd8
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rdx
addq $0x8, %rdx
cmpq %r9, %rdx
jne 0x10c5f
movq %r13, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq