// File: /workspace/github_cpp_makefile_star2_O1/jeffreyan11[P]go-engine/board.cpp
// Function: Board::getLocalMoves(unsigned short)
MoveList Board::getLocalMoves(Move m) {
    MoveList localMoves;

    if (m == MOVE_PASS)
        return localMoves;
    int x = getX(m);
    int y = getY(m);
    assert(pieces[index(x, y)] != EMPTY);

    Chain *node = nullptr;
    searchChainsByID(node, chainID[index(x, y)]);
    for (int i = 0; i < node->liberties; i++)
        localMoves.add(node->libertyList[i]);

    if (chainID[index(x+1, y)]
     && chainID[index(x+1, y)] != chainID[index(x, y)]) {
        node = nullptr;
        searchChainsByID(node, chainID[index(x+1, y)]);
        for (int i = 0; i < node->liberties; i++)
            localMoves.add(node->libertyList[i]);
    }

    if (chainID[index(x-1, y)]
     && chainID[index(x-1, y)] != chainID[index(x, y)]
     && chainID[index(x-1, y)] != chainID[index(x+1, y)]) {
        node = nullptr;
        searchChainsByID(node, chainID[index(x-1, y)]);
        for (int i = 0; i < node->liberties; i++)
            localMoves.add(node->libertyList[i]);
    }

    if (chainID[index(x, y+1)]
     && chainID[index(x, y+1)] != chainID[index(x, y)]
     && chainID[index(x, y+1)] != chainID[index(x+1, y)]
     && chainID[index(x, y+1)] != chainID[index(x-1, y)]) {
        node = nullptr;
        searchChainsByID(node, chainID[index(x, y+1)]);
        for (int i = 0; i < node->liberties; i++)
            localMoves.add(node->libertyList[i]);
    }

    if (chainID[index(x, y-1)]
     && chainID[index(x, y-1)] != chainID[index(x, y)]
     && chainID[index(x, y-1)] != chainID[index(x+1, y)]
     && chainID[index(x, y-1)] != chainID[index(x-1, y)]
     && chainID[index(x, y-1)] != chainID[index(x, y+1)]) {
        node = nullptr;
        searchChainsByID(node, chainID[index(x, y-1)]);
        for (int i = 0; i < node->liberties; i++)
            localMoves.add(node->libertyList[i]);
    }

    return localMoves;
}

// Assembly:
movq %rdi, %rax
movl $0x0, 0x400(%rdi)
cmpl $0x8000, %edx           # imm = 0x8000
je 0x5308
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movzwl %dx, %edi
shrl $0x8, %edi
movzbl %dl, %ecx
movq 0x20(%rsi), %r10
movl 0x70e5(%rip), %r9d      # 0xc18c
movl %r9d, %ebx
movq %rcx, -0x10(%rsp)
imull %ecx, %ebx
leal (%rbx,%rdi), %ecx
movslq %ecx, %rcx
movl (%r10,%rcx,4), %edx
movl 0x1028(%rsi), %ecx
testl %ecx, %ecx
je 0x50db
xorl %ebp, %ebp
movslq %ebp, %r11
movq 0x28(%rsi,%r11,8), %r11
cmpl %edx, (%r11)
je 0x50de
incl %ebp
cmpl %ebp, %ecx
jne 0x50c8
xorl %r11d, %r11d
movslq 0xc(%r11), %r15
movl 0x400(%rax), %r14d
testq %r15, %r15
jle 0x5111
xorl %r12d, %r12d
leal (%r14,%r12), %r13d
movzwl 0x410(%r11,%r12,2), %ebp
movw %bp, (%rax,%r13,2)
incq %r12
cmpq %r12, %r15
jne 0x50f1
addl %r14d, %r12d
movl %r12d, %r14d
movl %r14d, 0x400(%rax)
leal (%rbx,%rdi), %r11d
incl %r11d
movslq %r11d, %r11
movl (%r10,%r11,4), %r11d
testl %r11d, %r11d
je 0x5186
cmpl %edx, %r11d
je 0x5186
testl %ecx, %ecx
je 0x5149
xorl %ebp, %ebp
movslq %ebp, %r14
movq 0x28(%rsi,%r14,8), %r14
cmpl %r11d, (%r14)
je 0x514c
incl %ebp
cmpl %ebp, %ecx
jne 0x5136
xorl %r14d, %r14d
movslq 0xc(%r14), %r12
movl 0x400(%rax), %r15d
testq %r12, %r12
jle 0x517f
xorl %r13d, %r13d
leal (%r15,%r13), %ebp
movzwl 0x410(%r14,%r13,2), %r8d
movw %r8w, (%rax,%rbp,2)
incq %r13
cmpq %r13, %r12
jne 0x515f
addl %r15d, %r13d
movl %r13d, %r15d
movl %r15d, 0x400(%rax)
leal (%rbx,%rdi), %r8d
decl %r8d
movslq %r8d, %r8
movl (%r10,%r8,4), %ebx
cmpl %r11d, %ebx
je 0x51f7
testl %ebx, %ebx
je 0x51f7
cmpl %edx, %ebx
je 0x51f7
testl %ecx, %ecx
je 0x51ba
xorl %ebp, %ebp
movslq %ebp, %r8
movq 0x28(%rsi,%r8,8), %r14
cmpl %ebx, (%r14)
je 0x51bd
incl %ebp
cmpl %ebp, %ecx
jne 0x51a7
xorl %r14d, %r14d
movslq 0xc(%r14), %r12
movl 0x400(%rax), %r15d
testq %r12, %r12
jle 0x51f0
xorl %r13d, %r13d
leal (%r15,%r13), %r8d
movzwl 0x410(%r14,%r13,2), %ebp
movw %bp, (%rax,%r8,2)
incq %r13
cmpq %r13, %r12
jne 0x51d0
addl %r15d, %r13d
movl %r13d, %r15d
movl %r15d, 0x400(%rax)
movq -0x10(%rsp), %r8
incl %r8d
imull %r9d, %r8d
addl %edi, %r8d
movslq %r8d, %r8
movl (%r10,%r8,4), %ebp
cmpl %ebx, %ebp
je 0x5281
cmpl %r11d, %ebp
je 0x5281
testl %ebp, %ebp
je 0x5281
cmpl %edx, %ebp
je 0x5281
testl %ecx, %ecx
je 0x523a
xorl %r15d, %r15d
movslq %r15d, %r8
movq 0x28(%rsi,%r8,8), %r14
cmpl %ebp, (%r14)
je 0x523d
incl %r15d
cmpl %r15d, %ecx
jne 0x5225
xorl %r14d, %r14d
movslq 0xc(%r14), %r12
movl 0x400(%rax), %r15d
testq %r12, %r12
jle 0x527a
movq %r10, -0x8(%rsp)
xorl %r13d, %r13d
leal (%r15,%r13), %r8d
movzwl 0x410(%r14,%r13,2), %r10d
movw %r10w, (%rax,%r8,2)
incq %r13
cmpq %r13, %r12
jne 0x5255
addl %r15d, %r13d
movl %r13d, %r15d
movq -0x8(%rsp), %r10
movl %r15d, 0x400(%rax)
movq -0x10(%rsp), %r8
decl %r8d
imull %r8d, %r9d
addl %edi, %r9d
movslq %r9d, %rdi
movl (%r10,%rdi,4), %edi
cmpl %ebp, %edi
je 0x52fe
cmpl %ebx, %edi
je 0x52fe
cmpl %r11d, %edi
je 0x52fe
testl %edi, %edi
je 0x52fe
cmpl %edx, %edi
je 0x52fe
testl %ecx, %ecx
je 0x52c7
xorl %r8d, %r8d
movslq %r8d, %rdx
movq 0x28(%rsi,%rdx,8), %rdx
cmpl %edi, (%rdx)
je 0x52c9
incl %r8d
cmpl %r8d, %ecx
jne 0x52b3
xorl %edx, %edx
movslq 0xc(%rdx), %rsi
movl 0x400(%rax), %ecx
testq %rsi, %rsi
jle 0x52f8
xorl %edi, %edi
leal (%rcx,%rdi), %r8d
movzwl 0x410(%rdx,%rdi,2), %r9d
movw %r9w, (%rax,%r8,2)
incq %rdi
cmpq %rdi, %rsi
jne 0x52da
addl %ecx, %edi
movl %edi, %ecx
movl %ecx, 0x400(%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop