// File: /workspace/github_cpp_makefile_star2_O3/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 0x5280
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movzwl %dx, %r11d
shrl $0x8, %r11d
movzbl %dl, %r12d
movq 0x20(%rsi), %r13
movl 0x716e(%rip), %r10d     # 0xc18c
movl %r10d, %r14d
imull %r12d, %r14d
addl %r11d, %r14d
movslq %r14d, %rcx
movl (%r13,%rcx,4), %edi
movl 0x1028(%rsi), %edx
testl %edx, %edx
je 0x504e
xorl %ecx, %ecx
movslq %ecx, %r8
movq 0x28(%rsi,%r8,8), %rbx
cmpl %edi, (%rbx)
je 0x5050
incl %ecx
cmpl %ecx, %edx
jne 0x503c
xorl %ebx, %ebx
movslq 0xc(%rbx), %r8
xorl %ecx, %ecx
testq %r8, %r8
jle 0x506f
movzwl 0x410(%rbx,%rcx,2), %ebp
movw %bp, (%rax,%rcx,2)
incq %rcx
cmpq %rcx, %r8
jne 0x505b
movl %ecx, 0x400(%rax)
leal 0x1(%r14), %r8d
movslq %r8d, %r8
movl (%r13,%r8,4), %ebx
testl %ebx, %ebx
sete %r8b
cmpl %edi, %ebx
sete %bpl
orb %r8b, %bpl
movq %r12, -0x10(%rsp)
jne 0x50f4
testl %edx, %edx
je 0x50b3
xorl %r8d, %r8d
movslq %r8d, %r15
movq 0x28(%rsi,%r15,8), %r15
cmpl %ebx, (%r15)
je 0x50b6
incl %r8d
cmpl %r8d, %edx
jne 0x509e
xorl %r15d, %r15d
movslq 0xc(%r15), %r8
testq %r8, %r8
jle 0x50ee
movq %r13, %r9
movl %ecx, %r12d
leaq (%rax,%r12,2), %r13
xorl %r12d, %r12d
movzwl 0x410(%r15,%r12,2), %ebp
movw %bp, (%r13,%r12,2)
incq %r12
cmpq %r12, %r8
jne 0x50cc
addl %r12d, %ecx
movq %r9, %r13
movq -0x10(%rsp), %r12
movl %ecx, 0x400(%rax)
decl %r14d
movslq %r14d, %r8
movl (%r13,%r8,4), %ebp
cmpl %ebx, %ebp
je 0x516b
testl %ebp, %ebp
je 0x516b
cmpl %edi, %ebp
je 0x516b
testl %edx, %edx
je 0x5127
xorl %r8d, %r8d
movslq %r8d, %r14
movq 0x28(%rsi,%r14,8), %r14
cmpl %ebp, (%r14)
je 0x512a
incl %r8d
cmpl %r8d, %edx
jne 0x5112
xorl %r14d, %r14d
movslq 0xc(%r14), %r15
testq %r15, %r15
jle 0x5165
movq %r13, -0x18(%rsp)
movl %ecx, %r13d
xorl %r12d, %r12d
leal (%r12,%r13), %r8d
movzwl 0x410(%r14,%r12,2), %r9d
movw %r9w, (%rax,%r8,2)
incq %r12
cmpq %r12, %r15
jne 0x513e
addl %r12d, %ecx
movq -0x18(%rsp), %r13
movq -0x10(%rsp), %r12
movl %ecx, 0x400(%rax)
leal 0x1(%r12), %r8d
imull %r10d, %r8d
addl %r11d, %r8d
movslq %r8d, %r8
movl (%r13,%r8,4), %r14d
cmpl %ebp, %r14d
je 0x51fd
cmpl %ebx, %r14d
je 0x51fd
testl %r14d, %r14d
je 0x51fd
cmpl %edi, %r14d
je 0x51fd
testl %edx, %edx
je 0x51af
xorl %r8d, %r8d
movslq %r8d, %r9
movq 0x28(%rsi,%r9,8), %r15
cmpl %r14d, (%r15)
je 0x51b2
incl %r8d
cmpl %r8d, %edx
jne 0x519a
xorl %r15d, %r15d
movslq 0xc(%r15), %r12
testq %r12, %r12
jle 0x51f2
movq %r13, -0x18(%rsp)
movl %r11d, -0x4(%rsp)
movl %ecx, %r8d
xorl %r13d, %r13d
leal (%r8,%r13), %r9d
movzwl 0x410(%r15,%r13,2), %r11d
movw %r11w, (%rax,%r9,2)
incq %r13
cmpq %r13, %r12
jne 0x51cb
addl %r13d, %ecx
movl -0x4(%rsp), %r11d
movq -0x18(%rsp), %r13
movl %ecx, 0x400(%rax)
movq -0x10(%rsp), %r12
decl %r12d
imull %r12d, %r10d
addl %r11d, %r10d
movslq %r10d, %r8
movl (%r13,%r8,4), %r8d
cmpl %r14d, %r8d
je 0x5276
cmpl %ebp, %r8d
je 0x5276
cmpl %ebx, %r8d
je 0x5276
testl %r8d, %r8d
je 0x5276
cmpl %edi, %r8d
je 0x5276
testl %edx, %edx
je 0x5244
xorl %r9d, %r9d
movslq %r9d, %rdi
movq 0x28(%rsi,%rdi,8), %rdi
cmpl %r8d, (%rdi)
je 0x5246
incl %r9d
cmpl %r9d, %edx
jne 0x522f
xorl %edi, %edi
movslq 0xc(%rdi), %rdx
testq %rdx, %rdx
jle 0x5270
movl %ecx, %r8d
xorl %esi, %esi
leal (%r8,%rsi), %r9d
movzwl 0x410(%rdi,%rsi,2), %r10d
movw %r10w, (%rax,%r9,2)
incq %rsi
cmpq %rsi, %rdx
jne 0x5254
addl %esi, %ecx
movl %ecx, 0x400(%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop