// File: jeffreyan11[P]go-engine/board.cpp
// Function: Board::updateLiberty(Chain*, int, int)
void Board::updateLiberty(Chain *node, int x, int y) {
    Stone east = pieces[index(x+1, y)];
    Stone west = pieces[index(x-1, y)];
    Stone north = pieces[index(x, y+1)];
    Stone south = pieces[index(x, y-1)];

    // If the square is empty and not already a liberty of the chain
    if (east == EMPTY && node->findLiberty(coordToMove(x+1, y)) == -1)
        node->addLiberty(coordToMove(x+1, y));
    if (west == EMPTY && node->findLiberty(coordToMove(x-1, y)) == -1)
        node->addLiberty(coordToMove(x-1, y));
    if (north == EMPTY && node->findLiberty(coordToMove(x, y+1)) == -1)
        node->addLiberty(coordToMove(x, y+1));
    if (south == EMPTY && node->findLiberty(coordToMove(x, y-1)) == -1)
        node->addLiberty(coordToMove(x, y-1));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movq -0x50(%rbp), %rcx
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x1c(%rbp)
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x14(%rbp), %edi
subl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movq -0x48(%rbp), %rcx
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x20(%rbp)
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl $0x1, %esi
callq 0x8bc0
movq -0x40(%rbp), %rcx
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x24(%rbp)
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
subl $0x1, %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x4bec
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8c30
movq -0x58(%rbp), %rdi
movzwl %ax, %esi
callq 0x9400
cmpl $-0x1, %eax
jne 0x4bec
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8c30
movq -0x60(%rbp), %rdi
movzwl %ax, %esi
callq 0x9470
cmpl $0x0, -0x20(%rbp)
jne 0x4c3b
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x14(%rbp), %edi
subl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8c30
movq -0x68(%rbp), %rdi
movzwl %ax, %esi
callq 0x9400
cmpl $-0x1, %eax
jne 0x4c3b
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x14(%rbp), %edi
subl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8c30
movq -0x70(%rbp), %rdi
movzwl %ax, %esi
callq 0x9470
cmpl $0x0, -0x24(%rbp)
jne 0x4c8a
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl $0x1, %esi
callq 0x8c30
movq -0x78(%rbp), %rdi
movzwl %ax, %esi
callq 0x9400
cmpl $-0x1, %eax
jne 0x4c8a
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl $0x1, %esi
callq 0x8c30
movq -0x80(%rbp), %rdi
movzwl %ax, %esi
callq 0x9470
cmpl $0x0, -0x28(%rbp)
jne 0x4ce5
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
subl $0x1, %esi
callq 0x8c30
movq -0x88(%rbp), %rdi
movzwl %ax, %esi
callq 0x9400
cmpl $-0x1, %eax
jne 0x4ce5
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
subl $0x1, %esi
callq 0x8c30
movq -0x90(%rbp), %rdi
movzwl %ax, %esi
callq 0x9470
addq $0x90, %rsp
popq %rbp
retq
nop