// File: /workspace/github_cpp_makefile_star2_O3/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 $0xa8, %rsp
movq %r9, 0x80(%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, 0x68(%rsp)
movq %rdi, %rbx
movq %r8, 0x90(%rsp)
movq %r8, %rdi
callq 0xc96e
movq %rbx, 0x8(%rsp)
movq (%rbx), %rsi
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
callq 0x29d8
movq 0x10(%r14), %rsi
cmpb $0x0, (%r15)
jne 0x11772
testq %rsi, %rsi
je 0x11bcd
leaq 0x8(%rsi), %rbx
movl (%rbx), %eax
movl %eax, 0x14(%rsp)
cmpl $-0x1, %eax
je 0x11bcd
movq 0x8(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x78(%rsp)
leaq 0x14(%rsp), %r14
leaq 0x40(%rsp), %r13
movq %r15, 0x70(%rsp)
movq 0x68(%rsp), %rax
movl (%rax), %ecx
cmpl $0x5, %ecx
jbe 0x11b4e
movl $0x2, %r12d
movl $0x1, %eax
movq %rsi, 0x60(%rsp)
leaq 0x8(%rsi), %rcx
movq %rcx, 0x98(%rsp)
movl %eax, %ebx
movl %r12d, 0x5c(%rsp)
cmpb $0x0, (%r15)
jne 0x11804
movq 0x8(%rsp), %rax
movq (%rax), %r14
movq %r14, %rdi
movq 0x98(%rsp), %rsi
callq 0x124d0
movl %eax, %eax
movq (%r14), %rcx
leaq 0x14(%rsp), %r14
leaq (%rax,%rax,2), %rax
cmpb $0x0, 0x8(%rcx,%rax,4)
jne 0x11820
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq 0xc2d2
cmpl $0x3, %ebx
je 0x11820
leal 0x1(%rbx), %ecx
cmpl %ecx, %eax
je 0x11857
cmpl $0x3, %ebx
jne 0x11b07
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq 0xc2d2
cmpl $0x3, %eax
je 0x11857
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq 0xc2d2
cmpl $0x4, %eax
jne 0x11b07
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
xorl %eax, %eax
movq %rax, 0x50(%rsp)
movq %rax, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0xd7b4
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
xorl %ecx, %ecx
leaq 0x18(%rsp), %r8
callq 0xc092
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movl %ebx, %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x119c0
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x3c7e
movl %eax, 0x18(%rsp)
movb $0x1, %bpl
cmpl $-0x1, %eax
je 0x11ae4
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x118f5
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x11902
movq %r13, %rdi
leaq 0x18(%rsp), %rdx
callq 0xd7b4
cmpl $0x3, %ebx
jne 0x119c0
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq 0xc2d2
cmpl $0x4, %eax
je 0x11961
cmpl $0x3, %eax
leaq 0x20(%rsp), %rsi
jne 0x11bdf
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x1c(%rsp), %rdx
callq 0x3e66
movl %eax, 0x10(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x1197e
movl 0x1c(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x1198d
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x3c7e
movl %eax, 0x10(%rsp)
jmp 0x11991
leaq 0x20(%rsp), %rdi
leaq 0x1c(%rsp), %rdx
callq 0xd7b4
movl 0x10(%rsp), %eax
cmpl $-0x1, %eax
je 0x11ae4
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x119b3
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x119c0
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
callq 0xd7b4
movq 0x8(%rsp), %rax
movq (%rax), %rbp
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %r15
cmpq %r15, %r12
je 0x11a22
movq 0x8(%rax), %rax
movq %rax, 0x88(%rsp)
movq %r12, %r14
addq $0x4, %r12
cmpq %r15, %r12
je 0x11a10
movq %r12, %r15
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xbf3a
cmpl $-0x1, %eax
jne 0x11a5e
addq $0x4, %r15
cmpq 0x28(%rsp), %r15
jne 0x119f2
cmpq %r15, %r12
jne 0x119e3
movq 0x8(%rsp), %rax
movq (%rax), %rbp
leaq 0x14(%rsp), %r14
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %r15
movq %r15, %rdx
movq 0x78(%rsp), %rcx
callq 0x38a8
movq 0x70(%rsp), %r12
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x16d10
jmp 0x11a8d
movq 0x68(%rsp), %rax
cmpl $0x4, (%rax)
movq 0x70(%rsp), %r12
leaq 0x14(%rsp), %r14
je 0x11a8d
movq 0x88(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
callq 0xe46c
movq 0x28(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0xe46c
movq 0x8(%rsp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movb %al, 0x10(%rsp)
movb %al, 0x1c(%rsp)
movq %r15, %rsi
movq 0x78(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq 0x90(%rsp), %r8
leaq 0x1c(%rsp), %r9
callq 0xbaa6
xorl %ebp, %ebp
movq %r12, %r15
movl 0x5c(%rsp), %r12d
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x11af3
callq 0x21a0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x11b02
callq 0x21a0
testb %bpl, %bpl
je 0x11b12
incl %ebx
cmpl %r12d, %ebx
jbe 0x117d1
movl %r12d, %ebp
movq 0x60(%rsp), %rsi
cmpb $0x1, (%r15)
jne 0x11b8a
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rsi, %r14
movq %r15, %r12
leaq 0xa0(%rsp), %r15
movq %r15, %rsi
callq 0xb94a
movq %r14, %rsi
leaq 0x14(%rsp), %r14
movq %r15, %rax
movq %r12, %r15
jmp 0x11b96
leal -0x3(%rcx), %eax
cmpl $0x2, %eax
jae 0x11ba7
movl $0x1, %eax
movq 0x80(%rsp), %rdx
cmpb $0x1, (%rdx)
movl $0x1, %r12d
jne 0x117b9
xorl %r12d, %r12d
cmpl $0x4, %ecx
sete %r12b
orl $0x2, %r12d
movl $0x2, %eax
jmp 0x117b9
movq (%rsi), %rsi
testq %rsi, %rsi
je 0x11bcd
leaq 0x8(%rsi), %rax
movl (%rax), %eax
movl %eax, 0x14(%rsp)
cmpl $-0x1, %eax
jne 0x1179e
jmp 0x11bcd
movl $0x2, %eax
movl $0x2, %r12d
cmpl $0x5, %ecx
je 0x117b9
movl %ebx, %eax
movl %ebp, %r12d
cmpl %ebp, %ebx
jbe 0x117b9
jmp 0x11b1a
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7ce5(%rip), %rdi      # 0x198cb
leaq 0x7ce4(%rip), %rsi      # 0x198d1
leaq 0x7d17(%rip), %rcx      # 0x1990b
movl $0x20c, %edx            # imm = 0x20C
callq 0x2110
jmp 0x11c10
jmp 0x11c10
jmp 0x11c10
jmp 0x11c10
jmp 0x11c10
jmp 0x11c10
jmp 0x11c10
jmp 0x11c10
jmp 0x11c10
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x11c22
callq 0x21a0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x11c31
callq 0x21a0
movq %rbx, %rdi
callq 0x2320
nop