// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x68(%rbp)
movw %dx, %ax
movq %rdi, %rcx
movq %rcx, -0x60(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movb $0x0, -0x13(%rbp)
callq 0x8ed0
movzwl -0x12(%rbp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x7cb1
movb $0x1, -0x13(%rbp)
movl $0x1, -0x18(%rbp)
jmp 0x8595
movzwl -0x12(%rbp), %edi
callq 0x8b80
movl %eax, -0x6c(%rbp)
jmp 0x7cbf
movl -0x6c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movzwl -0x12(%rbp), %edi
callq 0x8ba0
movl %eax, -0x70(%rbp)
jmp 0x7cd3
movq -0x58(%rbp), %rax
movl -0x70(%rbp), %ecx
movl %ecx, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x80(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x74(%rbp)
jmp 0x7cfd
movq -0x58(%rbp), %rdi
movq -0x80(%rbp), %rax
movl -0x74(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq -0x38(%rbp), %rsi
callq 0x8c50
jmp 0x7d19
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x7d6e
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movzwl 0x410(%rax,%rcx,2), %esi
callq 0x8ef0
jmp 0x7d47
jmp 0x7d49
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x7d20
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x8f30
jmp 0x85b1
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x90(%rbp)
movl -0x1c(%rbp), %edi
incl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x84(%rbp)
jmp 0x7d92
movq -0x90(%rbp), %rax
movl -0x84(%rbp), %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x7eb5
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xa0(%rbp)
movl -0x1c(%rbp), %edi
incl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x94(%rbp)
jmp 0x7dd0
movq -0x58(%rbp), %rax
movq -0xa0(%rbp), %rcx
movl -0x94(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0xb4(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0xb0(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0xa4(%rbp)
jmp 0x7e0b
movl -0xb4(%rbp), %eax
movq -0xb0(%rbp), %rcx
movl -0xa4(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x7eb5
movq -0x58(%rbp), %rax
movq $0x0, -0x38(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0xc0(%rbp)
movl -0x1c(%rbp), %edi
incl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0xb8(%rbp)
jmp 0x7e56
movq -0x58(%rbp), %rdi
movq -0xc0(%rbp), %rax
movl -0xb8(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq -0x38(%rbp), %rsi
callq 0x8c50
jmp 0x7e78
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x7eb3
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movzwl 0x410(%rax,%rcx,2), %esi
callq 0x8ef0
jmp 0x7ea6
jmp 0x7ea8
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x7e7f
jmp 0x7eb5
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xd0(%rbp)
movl -0x1c(%rbp), %edi
decl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0xc4(%rbp)
jmp 0x7ed9
movq -0xd0(%rbp), %rax
movl -0xc4(%rbp), %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x807c
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xe0(%rbp)
movl -0x1c(%rbp), %edi
decl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0xd4(%rbp)
jmp 0x7f17
movq -0x58(%rbp), %rax
movq -0xe0(%rbp), %rcx
movl -0xd4(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0xf4(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0xf0(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0xe4(%rbp)
jmp 0x7f52
movl -0xf4(%rbp), %eax
movq -0xf0(%rbp), %rcx
movl -0xe4(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x807c
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x100(%rbp)
movl -0x1c(%rbp), %edi
decl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0xf8(%rbp)
jmp 0x7f95
movq -0x58(%rbp), %rax
movq -0x100(%rbp), %rcx
movl -0xf8(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x114(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x110(%rbp)
movl -0x1c(%rbp), %edi
incl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x104(%rbp)
jmp 0x7fd2
movl -0x114(%rbp), %eax
movq -0x110(%rbp), %rcx
movl -0x104(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x807c
movq -0x58(%rbp), %rax
movq $0x0, -0x38(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x120(%rbp)
movl -0x1c(%rbp), %edi
decl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x118(%rbp)
jmp 0x801d
movq -0x58(%rbp), %rdi
movq -0x120(%rbp), %rax
movl -0x118(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq -0x38(%rbp), %rsi
callq 0x8c50
jmp 0x803f
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x807a
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
movzwl 0x410(%rax,%rcx,2), %esi
callq 0x8ef0
jmp 0x806d
jmp 0x806f
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x8046
jmp 0x807c
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x130(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
incl %esi
callq 0x8bc0
movl %eax, -0x124(%rbp)
jmp 0x80a0
movq -0x130(%rbp), %rax
movl -0x124(%rbp), %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x82c3
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x140(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
incl %esi
callq 0x8bc0
movl %eax, -0x134(%rbp)
jmp 0x80de
movq -0x58(%rbp), %rax
movq -0x140(%rbp), %rcx
movl -0x134(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x154(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x150(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x144(%rbp)
jmp 0x8119
movl -0x154(%rbp), %eax
movq -0x150(%rbp), %rcx
movl -0x144(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x82c3
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x160(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
incl %esi
callq 0x8bc0
movl %eax, -0x158(%rbp)
jmp 0x815c
movq -0x58(%rbp), %rax
movq -0x160(%rbp), %rcx
movl -0x158(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x174(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x170(%rbp)
movl -0x1c(%rbp), %edi
incl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x164(%rbp)
jmp 0x8199
movl -0x174(%rbp), %eax
movq -0x170(%rbp), %rcx
movl -0x164(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x82c3
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x180(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
incl %esi
callq 0x8bc0
movl %eax, -0x178(%rbp)
jmp 0x81dc
movq -0x58(%rbp), %rax
movq -0x180(%rbp), %rcx
movl -0x178(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x194(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x190(%rbp)
movl -0x1c(%rbp), %edi
decl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x184(%rbp)
jmp 0x8219
movl -0x194(%rbp), %eax
movq -0x190(%rbp), %rcx
movl -0x184(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x82c3
movq -0x58(%rbp), %rax
movq $0x0, -0x38(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1a0(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
incl %esi
callq 0x8bc0
movl %eax, -0x198(%rbp)
jmp 0x8264
movq -0x58(%rbp), %rdi
movq -0x1a0(%rbp), %rax
movl -0x198(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq -0x38(%rbp), %rsi
callq 0x8c50
jmp 0x8286
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x82c1
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rax
movslq -0x48(%rbp), %rcx
movzwl 0x410(%rax,%rcx,2), %esi
callq 0x8ef0
jmp 0x82b4
jmp 0x82b6
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x828d
jmp 0x82c3
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x1b0(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
decl %esi
callq 0x8bc0
movl %eax, -0x1a4(%rbp)
jmp 0x82e7
movq -0x1b0(%rbp), %rax
movl -0x1a4(%rbp), %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x858a
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x1c0(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
decl %esi
callq 0x8bc0
movl %eax, -0x1b4(%rbp)
jmp 0x8325
movq -0x58(%rbp), %rax
movq -0x1c0(%rbp), %rcx
movl -0x1b4(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x1d4(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1d0(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x1c4(%rbp)
jmp 0x8360
movl -0x1d4(%rbp), %eax
movq -0x1d0(%rbp), %rcx
movl -0x1c4(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x858a
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x1e0(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
decl %esi
callq 0x8bc0
movl %eax, -0x1d8(%rbp)
jmp 0x83a3
movq -0x58(%rbp), %rax
movq -0x1e0(%rbp), %rcx
movl -0x1d8(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x1f4(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1f0(%rbp)
movl -0x1c(%rbp), %edi
incl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x1e4(%rbp)
jmp 0x83e0
movl -0x1f4(%rbp), %eax
movq -0x1f0(%rbp), %rcx
movl -0x1e4(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x858a
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x200(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
decl %esi
callq 0x8bc0
movl %eax, -0x1f8(%rbp)
jmp 0x8423
movq -0x58(%rbp), %rax
movq -0x200(%rbp), %rcx
movl -0x1f8(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x214(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x210(%rbp)
movl -0x1c(%rbp), %edi
decl %edi
movl -0x30(%rbp), %esi
callq 0x8bc0
movl %eax, -0x204(%rbp)
jmp 0x8460
movl -0x214(%rbp), %eax
movq -0x210(%rbp), %rcx
movl -0x204(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x858a
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x220(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
decl %esi
callq 0x8bc0
movl %eax, -0x218(%rbp)
jmp 0x84a3
movq -0x58(%rbp), %rax
movq -0x220(%rbp), %rcx
movl -0x218(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x234(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x230(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
incl %esi
callq 0x8bc0
movl %eax, -0x224(%rbp)
jmp 0x84e0
movl -0x234(%rbp), %eax
movq -0x230(%rbp), %rcx
movl -0x224(%rbp), %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x858a
movq -0x58(%rbp), %rax
movq $0x0, -0x38(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x240(%rbp)
movl -0x1c(%rbp), %edi
movl -0x30(%rbp), %esi
decl %esi
callq 0x8bc0
movl %eax, -0x238(%rbp)
jmp 0x852b
movq -0x58(%rbp), %rdi
movq -0x240(%rbp), %rax
movl -0x238(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq -0x38(%rbp), %rsi
callq 0x8c50
jmp 0x854d
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x8588
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movzwl 0x410(%rax,%rcx,2), %esi
callq 0x8ef0
jmp 0x857b
jmp 0x857d
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x8554
jmp 0x858a
movb $0x1, -0x13(%rbp)
movl $0x1, -0x18(%rbp)
testb $0x1, -0x13(%rbp)
jne 0x85a4
movq -0x68(%rbp), %rdi
callq 0x8f30
movq -0x60(%rbp), %rax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x2350
nopw (%rax,%rax)