// File: /workspace/github_cpp_makefile_star2_O2/jeffreyan11[P]go-engine/board.cpp
// Function: Board::captureChain(Chain*, int)
void Board::captureChain(Chain *node, int nodeIndex) {
    Player victim = node->color;
    if (victim == BLACK)
        whiteCaptures += node->size;
    else
        blackCaptures += node->size;

    for (int i = 0; i < node->size; i++) {
        int rx = getX(node->squares[i]);
        int ry = getY(node->squares[i]);
        pieces[index(rx, ry)] = EMPTY;
        chainID[index(rx, ry)] = 0;
        zobristKey ^= zobristTable[zobristIndex(node->color, rx, ry)];

        // Add this square to adjacent chains' liberties
        int addID = chainID[index(rx+1, ry)];
        if (addID
         && addID != node->id) {
            Chain *temp = nullptr;
            searchChainsByID(temp, addID);

            if (temp->findLiberty(coordToMove(rx, ry)) == -1)
                temp->addLiberty(coordToMove(rx, ry));
        }

        addID = chainID[index(rx-1, ry)];
        if (addID
         && addID != node->id
         && addID != chainID[index(rx+1, ry)]) {
            Chain *temp = nullptr;
            searchChainsByID(temp, addID);

            if (temp->findLiberty(coordToMove(rx, ry)) == -1)
                temp->addLiberty(coordToMove(rx, ry));
        }

        addID = chainID[index(rx, ry+1)];
        if (addID
         && addID != node->id
         && addID != chainID[index(rx+1, ry)]
         && addID != chainID[index(rx-1, ry)]) {
            Chain *temp = nullptr;
            searchChainsByID(temp, addID);

            if (temp->findLiberty(coordToMove(rx, ry)) == -1)
                temp->addLiberty(coordToMove(rx, ry));
        }

        addID = chainID[index(rx, ry-1)];
        if (addID
         && addID != node->id
         && addID != chainID[index(rx+1, ry)]
         && addID != chainID[index(rx-1, ry)]
         && addID != chainID[index(rx, ry+1)]) {
            Chain *temp = nullptr;
            searchChainsByID(temp, addID);

            if (temp->findLiberty(coordToMove(rx, ry)) == -1)
                temp->addLiberty(coordToMove(rx, ry));
        }
    }

    // Remove this chain since it has been captured
    delete node;
    chainList.removeFast(nodeIndex);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, 0x18(%rsp)
movq %rsi, %r14
movq %rdi, %r8
movl 0x8(%rsi), %eax
cmpl $0x1, 0x4(%rsi)
jne 0x36ff
addl %eax, 0xc(%r8)
jmp 0x3703
addl %eax, 0x8(%r8)
xorl %r13d, %r13d
movq %r8, 0x20(%rsp)
cltq
cmpq %rax, %r13
jge 0x3964
movzwl 0x10(%r14,%r13,2), %ecx
movzbl %cl, %ebp
movl %ecx, %r15d
shrl $0x8, %r15d
movq (%r8), %rax
movl 0x7a45(%rip), %edx      # 0xb174
imull %ebp, %edx
addl %r15d, %edx
movslq %edx, %rdx
andl $0x0, (%rax,%rdx,4)
movq 0x20(%r8), %rax
movl 0x7a2e(%rip), %edx      # 0xb174
imull %ebp, %edx
addl %r15d, %edx
movslq %edx, %rdx
andl $0x0, (%rax,%rdx,4)
leal (%r15,%r15), %edx
leal -0x2(,%rbp,2), %esi
imull 0x7a0b(%rip), %esi      # 0xb170
addl 0x4(%r14), %edx
addl %esi, %edx
addl $-0x3, %edx
movslq %edx, %rdx
leaq 0x7a38(%rip), %rsi      # 0xb1b0
movq (%rsi,%rdx,8), %rdx
xorq %rdx, 0x10(%r8)
movzwl %cx, %r12d
movl 0x79ea(%rip), %ecx      # 0xb174
movl %ecx, %esi
imull %ebp, %esi
leal (%rsi,%r15), %edx
incl %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %edx
testl %edx, %edx
je 0x37eb
cmpl (%r14), %edx
je 0x37eb
andq $0x0, 0x8(%rsp)
movq %r8, %rdi
leaq 0x8(%rsp), %rsi
movq %r8, %rbx
callq 0x5100
movq 0x8(%rsp), %rdi
movl %r12d, %esi
callq 0x5378
cmpl $-0x1, %eax
jne 0x37d9
movq 0x8(%rsp), %rdi
movl %r12d, %esi
callq 0x539c
movq 0x20(%rbx), %rax
movl 0x7991(%rip), %ecx      # 0xb174
movl %ecx, %esi
imull %ebp, %esi
movq %rbx, %r8
movl %r12d, 0x14(%rsp)
leal 0x1(%r15), %r12d
leal (%rsi,%r15), %edx
decl %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %edx
testl %edx, %edx
je 0x3858
cmpl (%r14), %edx
je 0x3858
addl %r12d, %esi
movslq %esi, %rsi
cmpl (%rax,%rsi,4), %edx
je 0x3858
andq $0x0, 0x8(%rsp)
movq %r8, %rdi
leaq 0x8(%rsp), %rsi
movq %r8, %rbx
callq 0x5100
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x5378
cmpl $-0x1, %eax
jne 0x384b
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x539c
movq 0x20(%rbx), %rax
movl 0x791f(%rip), %ecx      # 0xb174
movq %rbx, %r8
leal -0x1(%r15), %r9d
leal 0x1(%rbp), %ebx
movl %ecx, %edx
imull %ebx, %edx
addl %r15d, %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %edx
testl %edx, %edx
je 0x38df
cmpl (%r14), %edx
je 0x38df
movl %ecx, %esi
imull %ebp, %esi
leal (%rsi,%r12), %edi
movslq %edi, %rdi
cmpl (%rax,%rdi,4), %edx
je 0x38df
addl %r9d, %esi
movslq %esi, %rsi
cmpl (%rax,%rsi,4), %edx
je 0x38df
movl %r9d, 0x1c(%rsp)
andq $0x0, 0x8(%rsp)
movq %r8, %rdi
leaq 0x8(%rsp), %rsi
callq 0x5100
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x5378
cmpl $-0x1, %eax
jne 0x38cb
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x539c
movq 0x20(%rsp), %r8
movq 0x20(%r8), %rax
movl 0x789a(%rip), %ecx      # 0xb174
movl 0x1c(%rsp), %r9d
leal -0x1(%rbp), %edx
imull %ecx, %edx
addl %r15d, %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %edx
testl %edx, %edx
je 0x3958
cmpl (%r14), %edx
je 0x3958
imull %ecx, %ebp
addl %ebp, %r12d
movslq %r12d, %rsi
cmpl (%rax,%rsi,4), %edx
je 0x3958
addl %r9d, %ebp
movslq %ebp, %rsi
cmpl (%rax,%rsi,4), %edx
je 0x3958
imull %ebx, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
cmpl (%rax,%rcx,4), %edx
je 0x3958
andq $0x0, 0x8(%rsp)
movq %r8, %rbx
movq %r8, %rdi
leaq 0x8(%rsp), %rsi
callq 0x5100
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %ebp
movl %ebp, %esi
callq 0x5378
cmpl $-0x1, %eax
jne 0x3955
movq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0x539c
movq %rbx, %r8
incq %r13
movl 0x8(%r14), %eax
jmp 0x370b
movq %r14, %rdi
movq %r8, %rbx
callq 0x5366
movl $0x610, %esi            # imm = 0x610
movq %r14, %rdi
callq 0x21b0
movl 0x1028(%rbx), %eax
decl %eax
movq 0x28(%rbx,%rax,8), %rcx
movslq 0x18(%rsp), %rdx
movq %rcx, 0x28(%rbx,%rdx,8)
movl %eax, 0x1028(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq