// File: /workspace/github_cpp_makefile_star2_O1/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, 0x28(%rsp)
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x60(%rsp)
movq %rdi, %r13
movq %r8, 0x80(%rsp)
movq %r8, %rdi
callq 0xd016
movq (%r13), %rsi
leaq 0x38(%rsp), %rdi
callq 0x29d8
movq 0x10(%rbx), %rax
movq %r14, 0x78(%rsp)
cmpb $0x1, (%r14)
movq %rax, 0x30(%rsp)
jne 0x1209c
movl 0x38(%rsp), %eax
jmp 0x120ab
testq %rax, %rax
je 0x120a6
movl 0x8(%rax), %eax
jmp 0x120ab
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x8(%rsp)
cmpl $-0x1, %eax
je 0x1248f
leaq 0x10(%r13), %rax
movq %rax, 0x68(%rsp)
leaq 0x8(%rsp), %rbx
leaq 0x40(%rsp), %r14
movl %r12d, %eax
movq 0x60(%rsp), %rcx
movl (%rcx), %ecx
movl $0x1, %edx
movl $0x2, %r12d
cmpl $0x5, %ecx
ja 0x1214c
leal -0x3(%rcx), %edx
cmpl $0x2, %edx
jae 0x1213c
movl $0x1, %r12d
movq 0x28(%rsp), %rdx
cmpb $0x1, (%rdx)
movl $0x1, %edx
jne 0x1214c
cmpl $0x3, %ecx
je 0x12126
cmpl $0x4, %ecx
jne 0x12146
movl $0x3, %r12d
movq 0x28(%rsp), %rdx
cmpb $0x0, (%rdx)
movl $0x2, %edx
jne 0x1214c
cmpl $0x3, %ecx
jne 0x12146
movq 0x28(%rsp), %rcx
cmpb $0x0, (%rcx)
movl $0x2, %ecx
cmovnel %ecx, %eax
cmovnel %ecx, %r15d
jmp 0x12146
movl $0x2, %edx
cmpl $0x5, %ecx
je 0x1214c
movl %eax, %r12d
movl %r15d, %edx
cmpl %r12d, %edx
jbe 0x12159
movl %edx, %r15d
jmp 0x12448
movq 0x30(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x70(%rsp)
movl %edx, %r15d
movq 0x78(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x121a6
movq (%r13), %rbx
cmpb $0x1, 0x3c(%rbx)
movq 0x70(%rsp), %rax
jne 0x12191
movq 0x40(%rbx), %rdi
movq 0x70(%rsp), %rsi
callq 0xda16
movl (%rax), %eax
movq (%rbx), %rcx
leaq (%rax,%rax,2), %rax
cmpb $0x0, 0x8(%rcx,%rax,4)
leaq 0x8(%rsp), %rbx
jne 0x121c0
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xc98e
cmpl $0x3, %r15d
je 0x121c0
leal 0x1(%r15), %ecx
cmpl %eax, %ecx
je 0x121f0
cmpl $0x3, %r15d
jne 0x1243c
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xc98e
cmpl $0x3, %eax
je 0x121f0
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xc98e
cmpl $0x4, %eax
jne 0x1243c
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rsp)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x12224
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x12231
leaq 0x10(%rsp), %rdi
movq %rbx, %rdx
callq 0xdeac
movq (%r13), %rdi
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
leaq 0x4(%rsp), %r8
callq 0xc714
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl %r15d, %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x122ac
movq (%r13), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3c24
movl %eax, 0x4(%rsp)
cmpl $-0x1, %eax
je 0x12293
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x1229d
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x122ac
movl $0x6, %ebp
jmp 0x12419
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0xdeac
cmpl $0x3, %r15d
jne 0x1236b
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xc98e
cmpl $0x4, %eax
je 0x12301
cmpl $0x3, %eax
jne 0x124a1
movq (%r13), %rdi
movq %r14, %rsi
leaq 0xc(%rsp), %rdx
callq 0x3df8
movl %eax, (%rsp)
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x12317
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x12324
movq (%r13), %rdi
leaq 0x4(%rsp), %rsi
movq %r14, %rdx
callq 0x3c24
movl %eax, (%rsp)
jmp 0x12324
movq %r14, %rdi
leaq 0xc(%rsp), %rdx
callq 0xdeac
movl (%rsp), %ebx
cmpl $-0x1, %ebx
je 0x12347
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x1234e
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
xorl %ebp, %ebp
jmp 0x1235d
movl $0x6, %ebp
jmp 0x1235d
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
movq %rsp, %rdx
callq 0xdeac
cmpl $-0x1, %ebx
leaq 0x8(%rsp), %rbx
je 0x12419
movq (%r13), %rdi
movq 0x8(%r13), %rbp
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x12d96
testb %al, %al
je 0x123b3
movq (%r13), %rdi
leaq 0x10(%rsp), %rbp
movq %rbp, %rsi
movq %r14, %rdx
movq 0x68(%rsp), %rcx
callq 0x383a
movl %eax, (%rsp)
movq 0x8(%r13), %rdi
movq %rsp, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x176c4
jmp 0x123d3
movq 0x60(%rsp), %rax
cmpl $0x4, (%rax)
je 0x123d3
movq 0x8(%rbp), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %rbp, %rdi
callq 0xeb0c
movq 0x48(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %r14, %rdi
callq 0xeb0c
movq (%r13), %rdi
xorl %eax, %eax
movb %al, (%rsp)
movb %al, 0xc(%rsp)
movq %r14, %rsi
movq 0x68(%rsp), %rdx
movq %rsp, %rcx
movq 0x80(%rsp), %r8
leaq 0xc(%rsp), %r9
callq 0xc16e
movl $0x4, %ebp
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x12428
callq 0x21a0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x12437
callq 0x21a0
cmpl $0x6, %ebp
jne 0x12448
incl %r15d
cmpl %r12d, %r15d
jbe 0x1216a
movq 0x78(%rsp), %rax
cmpb $0x1, (%rax)
jne 0x12466
movq (%r13), %rdi
leaq 0x38(%rsp), %rsi
callq 0xc034
movl 0x38(%rsp), %eax
jmp 0x12482
movq 0x30(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
movq %rax, 0x30(%rsp)
je 0x1247d
movl 0x8(%rax), %eax
jmp 0x12482
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x8(%rsp)
cmpl $-0x1, %eax
jne 0x120cb
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8423(%rip), %rdi      # 0x1a8cb
leaq 0x8422(%rip), %rsi      # 0x1a8d1
leaq 0x8455(%rip), %rcx      # 0x1a90b
movl $0x20c, %edx            # imm = 0x20C
callq 0x2110
jmp 0x124d2
jmp 0x124d2
jmp 0x124d2
jmp 0x124d2
jmp 0x124d2
jmp 0x124d2
jmp 0x124d2
jmp 0x124d2
jmp 0x124d2
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x124e4
callq 0x21a0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x124f3
callq 0x21a0
movq %rbx, %rdi
callq 0x2320
nop