// File: /workspace/github_cpp_makefile_star2_O2/iPapatsoris[P]Maximum-Independent-Set/src/Reductions.cpp
// Function: Reductions::foldCompleteKIndependentSets2(unsigned int const&, bool const&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&, bool const&)
void Reductions::foldCompleteKIndependentSets2(const uint32_t &theta, const bool &checkAllNodes, unordered_set<uint32_t> &oldCandidateNodes, unordered_set<uint32_t> &newCandidateNodes, const bool &theta4) {
    newCandidateNodes.clear();
    Graph::GraphTraversal graphTraversal(graph);
    auto it = oldCandidateNodes.begin();
    uint32_t node = (checkAllNodes ? graphTraversal.curNode : (it == oldCandidateNodes.end() ? NONE : *it));
    while (node != NONE) {
        uint32_t k, end;
        if (theta >= 6) {
            k = 1;
            end = 2;
        }
        else if (theta == 5) {
            k = 2;
            end = 2;
        } else if ((theta == 4 || theta == 3) && !theta4) {
            k = 1;
            end = 1;
        } else if (theta == 4 && theta4) {
            k = 2;
            end = 3;
        } else if (theta == 3 && theta4) {
            k = 2;
            end = 2;
        }
        for (; k <= end ; k++) {
            if ((checkAllNodes || (!checkAllNodes && !graph.nodeIndex[graph.getPos(*it)].removed)) &&
            graph.getNodeDegree(node) == k+1 && k != 3 || k == 3 && (graph.getNodeDegree(node) == 3 || graph.getNodeDegree(node) == 4)) {
                vector<uint32_t> nodes;
                vector<uint32_t> neighbors;
                nodes.push_back(node);
                graph.gatherNeighbors(node, neighbors);
                uint32_t secondNode = NONE;
                if (k == 2 || k == 3) {
                    secondNode = graph.getNextNodeWithIdenticalNeighbors(node, neighbors);
                    if (secondNode != NONE) {
                        nodes.push_back(secondNode);
                    }
                    else {
                        continue;
                    }
                }
                if (k == 3) {
                    uint32_t thirdNode;
                    uint32_t degree = graph.getNodeDegree(node);
                    if (degree == 3) {
                        uint32_t uncommonNeighbor;
                        thirdNode = graph.getNodeWithOneUncommonNeighbor(neighbors, uncommonNeighbor);
                        neighbors.push_back(uncommonNeighbor);
                    } else if (degree == 4) {
                        thirdNode = graph.getNextNodeWithIdenticalNeighbors(secondNode, neighbors);
                    } else {
                        assert(false);
                    }
                    if (thirdNode != NONE) {
                        nodes.push_back(thirdNode);
                    } else {
                        continue;
                    }
                }
                vector<uint32_t> &mis = this->mis.getMis();
                if (graph.isIndependentSet(neighbors)) {
                    uint32_t newNode = graph.contractToSingleNode(nodes, neighbors, reduceInfo);
                    this->mis.markHypernode(newNode, nodes, neighbors);
                } else if (theta != 4) {
                    mis.insert(mis.end(), nodes.begin(), nodes.end());
                }
                neighbors.insert(neighbors.end(), nodes.begin(), nodes.end());
                graph.remove(neighbors, reduceInfo, false, &newCandidateNodes);
                break;
            }
        }
        if (checkAllNodes) {
            graph.getNextNode(graphTraversal);
            node = graphTraversal.curNode;
        } else {
            it++;
            node = (it == oldCandidateNodes.end() ? NONE : *it);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, 0x58(%rsp)
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x40(%rsp)
movq %rdi, %r13
movq %r8, 0x60(%rsp)
movq %r8, %rdi
callq 0xad42
movq (%r13), %rsi
leaq 0x30(%rsp), %rdi
callq 0x270e
movq 0x10(%rbx), %rcx
movq %r14, 0x48(%rsp)
cmpb $0x1, (%r14)
pushq $-0x1
popq %rax
jne 0xfbe7
movl 0x30(%rsp), %eax
jmp 0xfbef
testq %rcx, %rcx
je 0xfbef
movl 0x8(%rcx), %eax
leaq 0x10(%r13), %rdx
movq %rdx, 0x38(%rsp)
leaq 0x2c(%rsp), %rbx
leaq 0x10(%rsp), %r12
leaq 0x70(%rsp), %rbp
movq %rcx, %rdx
movq %rdx, 0x50(%rsp)
leaq 0x8(%rdx), %rcx
movq %rcx, 0x68(%rsp)
movl %r14d, %ecx
movl %eax, 0x2c(%rsp)
cmpl $-0x1, %eax
je 0xff42
movq 0x40(%rsp), %rax
movl (%rax), %eax
pushq $0x2
popq %r14
pushq $0x1
popq %rdx
cmpl $0x5, %eax
jbe 0xfddb
movl %edx, %r15d
cmpl %r14d, %r15d
ja 0xff00
movq 0x48(%rsp), %rax
cmpb $0x0, (%rax)
jne 0xfc7c
movq (%r13), %r12
movq %r12, %rdi
movq 0x68(%rsp), %rsi
callq 0x1064c
movl %eax, %eax
movq (%r12), %rcx
leaq 0x10(%rsp), %r12
imulq $0xc, %rax, %rax
cmpb $0x0, 0x8(%rcx,%rax)
jne 0xfc96
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xa5ce
cmpl $0x3, %r15d
je 0xfc96
leal 0x1(%r15), %ecx
cmpl %eax, %ecx
je 0xfcc6
cmpl $0x3, %r15d
jne 0xfdd3
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xa5ce
cmpl $0x3, %eax
je 0xfcc6
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xa5ce
cmpl $0x4, %eax
jne 0xfdd3
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0xa1ac
movq (%r13), %rdi
orl $-0x1, 0x8(%rsp)
movq %rbx, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
leaq 0x8(%rsp), %r8
callq 0xa3c8
orl $-0x1, 0x8(%rsp)
movl %r15d, %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0xfe3e
movq (%r13), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x35f8
movl %eax, 0x8(%rsp)
cmpl $-0x1, %eax
je 0xfdc3
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0xa1ac
cmpl $0x3, %r15d
jne 0xfe27
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xa5ce
cmpl $0x4, %eax
je 0xfda9
cmpl $0x3, %eax
jne 0xff54
movq %rbx, %r12
movl %r14d, %ebx
movq (%r13), %rdi
movq %rbp, %rsi
movq %rbp, %r14
leaq 0xc(%rsp), %rbp
movq %rbp, %rdx
callq 0x3742
movl %eax, 0x4(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0xa1ac
movl 0x4(%rsp), %eax
movq %r14, %rbp
movl %ebx, %r14d
movq %r12, %rbx
leaq 0x10(%rsp), %r12
jmp 0xfdbe
movq (%r13), %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x35f8
movl %eax, 0x4(%rsp)
cmpl $-0x1, %eax
jne 0xfe2b
movq %rbp, %rdi
callq 0xb872
movq %r12, %rdi
callq 0xb872
incl %r15d
jmp 0xfc42
leal -0x3(%rax), %edx
cmpl $0x2, %edx
jae 0xfe0d
movq 0x58(%rsp), %rcx
cmpb $0x1, (%rcx)
pushq $0x1
popq %rdx
movl %edx, %r14d
jne 0xfc3f
xorl %r14d, %r14d
cmpl $0x4, %eax
sete %r14b
orl $0x2, %r14d
pushq $0x2
popq %rdx
jmp 0xfc3f
pushq $0x2
popq %rdx
movl %edx, %r14d
cmpl $0x5, %eax
je 0xfc3f
movl %ecx, %r14d
movl %r15d, %edx
jmp 0xfc3f
pushq $0x2
jmp 0xfe3a
movq %r12, %rdi
leaq 0x4(%rsp), %rsi
callq 0xa1ac
pushq $0x3
popq %rax
movl %eax, %r15d
movq (%r13), %rdi
movq 0x8(%r13), %r12
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x10664
testb %al, %al
je 0xfe89
movq (%r13), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
movq %rbp, %rdx
movq 0x38(%rsp), %rcx
callq 0x32c0
movl %eax, 0x4(%rsp)
movq 0x8(%r13), %rdi
leaq 0x4(%rsp), %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x14a58
jmp 0xfeaa
movq 0x40(%rsp), %rax
cmpl $0x4, (%rax)
je 0xfeaa
movq 0x8(%r12), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %r12, %rdi
callq 0xa81c
movq 0x78(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %rbp, %rdi
callq 0xa81c
movq (%r13), %rdi
xorl %eax, %eax
movb %al, 0x4(%rsp)
movb %al, 0xc(%rsp)
movq %rbp, %rsi
movq 0x38(%rsp), %rdx
leaq 0x4(%rsp), %rcx
movq 0x60(%rsp), %r8
leaq 0xc(%rsp), %r9
callq 0x9e48
leaq 0x10(%rsp), %r12
movq %rbp, %rdi
callq 0xb872
movq %r12, %rdi
callq 0xb872
movq 0x48(%rsp), %rax
cmpb $0x1, (%rax)
jne 0xff21
movq (%r13), %rdi
leaq 0x30(%rsp), %rsi
callq 0x9cf8
movl 0x30(%rsp), %eax
jmp 0xfc18
movq 0x50(%rsp), %rax
movq (%rax), %rcx
pushq $-0x1
popq %rax
movl $0x0, %edx
testq %rcx, %rcx
je 0xfc0a
movl 0x8(%rcx), %eax
jmp 0xfc07
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x798d(%rip), %rdi      # 0x178e8
leaq 0x798c(%rip), %rsi      # 0x178ee
leaq 0x79bf(%rip), %rcx      # 0x17928
movl $0x20c, %edx            # imm = 0x20C
callq 0x2100
jmp 0xff87
jmp 0xff87
jmp 0xff87
jmp 0xff87
jmp 0xff87
jmp 0xff87
jmp 0xff87
jmp 0xff87
jmp 0xff87
jmp 0xff87
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xb872
leaq 0x10(%rsp), %rdi
callq 0xb872
movq %rbx, %rdi
callq 0x22c0