// File: jeffreyan11[P]go-engine/board.cpp
// Function: Board::checkChains()
bool Board::checkChains() {
    bool result = false;
    int *temp = new int[arraySize*arraySize];
    int *tempPieces = new int[arraySize*arraySize];
    for (int i = 0; i < arraySize*arraySize; i++)
        temp[i] = chainID[i];
    for (int i = 0; i < arraySize*arraySize; i++)
        tempPieces[i] = pieces[i];

    for (unsigned int j = 0; j < chainList.size(); j++) {
        Chain *node = chainList.get(j);
        for (int i = 0; i < node->size; i++) {
            Move m = node->squares[i];

            if (temp[index(getX(m), getY(m))] == 0 || tempPieces[index(getX(m), getY(m))] == 0) {
                result = true;
                break;
            }

            temp[index(getX(m), getY(m))] = 0;
            tempPieces[index(getX(m), getY(m))] = 0;
        }
    }

    delete[] temp;
    delete[] tempPieces;
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movb $0x0, -0x9(%rbp)
movl 0xe673(%rip), %eax      # 0x141f4
imull 0xe66c(%rip), %eax      # 0x141f4
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, -0x18(%rbp)
movl 0xe63f(%rip), %eax      # 0x141f4
imull 0xe638(%rip), %eax      # 0x141f4
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl 0xe601(%rip), %ecx      # 0x141f4
imull 0xe5fa(%rip), %ecx      # 0x141f4
cmpl %ecx, %eax
jge 0x5c23
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5bea
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl 0xe5c1(%rip), %ecx      # 0x141f4
imull 0xe5ba(%rip), %ecx      # 0x141f4
cmpl %ecx, %eax
jge 0x5c62
movq -0x48(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x20(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x5c2a
movl $0x0, -0x2c(%rbp)
movq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
addq $0x28, %rdi
callq 0x8b00
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jae 0x5dd2
movq -0x48(%rbp), %rdi
addq $0x28, %rdi
movl -0x2c(%rbp), %esi
callq 0x8b20
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x5dc2
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movw 0x10(%rax,%rcx,2), %ax
movw %ax, -0x3e(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movzwl -0x3e(%rbp), %edi
callq 0x8b80
movl %eax, -0x5c(%rbp)
movzwl -0x3e(%rbp), %edi
callq 0x8ba0
movl -0x5c(%rbp), %edi
movl %eax, %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x58(%rbp), %rax
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x5d31
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movzwl -0x3e(%rbp), %edi
callq 0x8b80
movl %eax, -0x6c(%rbp)
movzwl -0x3e(%rbp), %edi
callq 0x8ba0
movl -0x6c(%rbp), %edi
movl %eax, %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x68(%rbp), %rax
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x5d3a
movb $0x1, -0x9(%rbp)
jmp 0x5dc2
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
movzwl -0x3e(%rbp), %edi
callq 0x8b80
movl %eax, -0x8c(%rbp)
movzwl -0x3e(%rbp), %edi
callq 0x8ba0
movl -0x8c(%rbp), %edi
movl %eax, %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x88(%rbp), %rax
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movzwl -0x3e(%rbp), %edi
callq 0x8b80
movl %eax, -0x7c(%rbp)
movzwl -0x3e(%rbp), %edi
callq 0x8ba0
movl -0x7c(%rbp), %edi
movl %eax, %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x78(%rbp), %rax
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5ca4
jmp 0x5dc4
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5c69
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
je 0x5def
movq -0x98(%rbp), %rdi
callq 0x22a0
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x5e0c
movq -0xa0(%rbp), %rdi
callq 0x22a0
movb -0x9(%rbp), %al
andb $0x1, %al
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)