// File: /workspace/github_cpp_makefile_star2_O2/iPapatsoris[P]Maximum-Independent-Set/src/Reductions.cpp
// Function: Reductions::findMis(std::vector<unsigned int, std::allocator<unsigned int>> const&)
void Reductions::findMis(const vector<uint32_t> &cc) {
    vector<uint32_t> independentSet;
    vector<uint32_t> maximumIndependentSet;
    vector<uint32_t> frontier; // cc array indexes
    vector<unordered_set<uint32_t> > removedNodes;
    frontier.push_back(0);
    removedNodes.push_back(unordered_set<uint32_t>());
    while (frontier.size()) {
        uint32_t node = cc[frontier.back()];
        Graph::GraphTraversal graphTraversal(graph, node);
        while (graphTraversal.curEdgeOffset != NONE) {
            removedNodes.back().insert((*graph.edgeBuffer)[graphTraversal.curEdgeOffset]);
            graph.getNextEdge(graphTraversal);
        }
        uint32_t newNode = NONE;
        uint32_t newIndex;
        bool found = false;
        for (newIndex = frontier.back()+1 ; newIndex < cc.size() ; newIndex++) {
            if (cc.size() - newIndex + frontier.size() <= maximumIndependentSet.size()) {
                break;
            }
            newNode = cc[newIndex];
            if (removedNodes.back().find(newNode) == removedNodes.back().end()) {
                found = true;
                break;
            }
        }
        if (found) {
            frontier.push_back(newIndex);
            removedNodes.push_back(removedNodes.back());
        } else {
            if (frontier.size() > maximumIndependentSet.size()) {
                maximumIndependentSet = frontier;
            }
            while (frontier.size()) {
                newIndex = frontier.back() + 1;
                frontier.pop_back();
                removedNodes.pop_back();
                found = false;
                for (; newIndex < cc.size() ; newIndex++) {
                    if (cc.size() - newIndex + frontier.size() <= maximumIndependentSet.size()) {
                        break;
                    }
                    newNode = cc[newIndex];
                    if (!removedNodes.size() || removedNodes.size() && removedNodes.back().find(newNode) == removedNodes.back().end()) {
                        found = true;
                        break;
                    }
                }
                if (found) {
                    frontier.push_back(newIndex);
                    removedNodes.push_back((removedNodes.size() ? removedNodes.back() : unordered_set<uint32_t>()));
                    break;
                }
            }
        }
    }
    vector<uint32_t> &mis = this->mis.getMis();
    for (auto &i: maximumIndependentSet) {
        mis.push_back(cc[i]);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
andq $0x0, 0xc0(%rsp)
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x78(%rsp), %rsi
andl $0x0, (%rsi)
callq 0xde6c
leaq 0xa8(%rsp), %rax
andq $0x0, -0x10(%rax)
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x10(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x10f10
leaq 0x78(%rsp), %rdi
callq 0xad26
leaq 0x70(%rsp), %r12
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0xc(%rsp), %rbp
leaq 0x8(%rsp), %r13
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0xfad3
movl -0x4(%rax), %eax
movq (%rbx), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x4c(%rsp)
movq (%r14), %rsi
movq %r12, %rdi
leaq 0x4c(%rsp), %rdx
callq 0x2720
movl 0x74(%rsp), %esi
cmpq %r15, %rsi
je 0xf8f7
movq 0x18(%rsp), %rdi
addq $-0x38, %rdi
movq (%r14), %rax
movq 0x18(%rax), %rax
shlq $0x2, %rsi
addq (%rax), %rsi
callq 0xbc1a
movq (%r14), %rdi
movq %r12, %rsi
callq 0xa1ca
jmp 0xf8c5
orl $-0x1, 0xc(%rsp)
movq 0x38(%rsp), %rcx
addq $-0x4, %rcx
movl (%rcx), %eax
incl %eax
movl %eax, 0x8(%rsp)
movq (%rbx), %rdx
movq 0x8(%rbx), %rdi
subq %rdx, %rdi
sarq $0x2, %rdi
movq 0x30(%rsp), %r9
movq 0x38(%rsp), %rcx
movq 0x50(%rsp), %r8
movq 0x58(%rsp), %rsi
subq %r9, %rcx
subq %rax, %rdi
jbe 0xf995
movq %rcx, %r9
sarq $0x2, %r9
addq %r9, %rdi
subq %r8, %rsi
movq %rsi, %r8
sarq $0x2, %r8
cmpq %r8, %rdi
jbe 0xf998
movl (%rdx,%rax,4), %eax
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rdi
addq $-0x38, %rdi
movq %rbp, %rsi
callq 0xc35a
movq %r13, %rcx
testq %rax, %rax
jne 0xf905
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0xa1ac
movq 0x18(%rsp), %rsi
addq $-0x38, %rsi
leaq 0x10(%rsp), %rdi
callq 0x105fe
jmp 0xf898
subq %r8, %rsi
cmpq %rsi, %rcx
jbe 0xf9ac
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x9be8
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0xf898
movl -0x4(%rax), %ecx
addq $-0x4, %rax
incl %ecx
movl %ecx, 0x8(%rsp)
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rdi
addq $-0x38, %rdi
movq %rdi, 0x18(%rsp)
callq 0xad26
movl 0x8(%rsp), %eax
movl %eax, %eax
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
subq %rax, %rdx
jbe 0xf9ac
movq 0x38(%rsp), %rsi
subq 0x30(%rsp), %rsi
sarq $0x2, %rsi
addq %rsi, %rdx
movq 0x58(%rsp), %rsi
subq 0x50(%rsp), %rsi
sarq $0x2, %rsi
cmpq %rsi, %rdx
jbe 0xf9ac
movl (%rcx,%rax,4), %eax
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rdi
cmpq 0x10(%rsp), %rdi
je 0xfa4e
addq $-0x38, %rdi
movq %rbp, %rsi
callq 0xc35a
testq %rax, %rax
je 0xfa4e
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
jmp 0xf9e5
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0xa1ac
movq 0x18(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0xfa7a
addq $-0x38, %rsi
leaq 0x78(%rsp), %r13
movq %r13, %rdi
callq 0x10a20
jmp 0xfab9
andq $0x0, 0x98(%rsp)
leaq 0xa8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq $0x1, 0x80(%rsp)
leaq 0x78(%rsp), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r13)
movl $0x3f800000, 0x98(%rsp) # imm = 0x3F800000
movups %xmm0, 0x28(%r13)
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x10f10
movq %r13, %rdi
callq 0xad26
jmp 0xf893
movq 0x8(%r14), %r14
movq 0x50(%rsp), %r15
movq 0x58(%rsp), %r12
cmpq %r12, %r15
je 0xfafe
movl (%r15), %esi
shlq $0x2, %rsi
addq (%rbx), %rsi
movq %r14, %rdi
callq 0xa1ac
addq $0x4, %r15
jmp 0xfae1
leaq 0x10(%rsp), %rdi
callq 0x1062a
leaq 0x30(%rsp), %rdi
callq 0xb872
leaq 0x50(%rsp), %rdi
callq 0xb872
leaq 0xb0(%rsp), %rdi
callq 0xb872
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xfb41
jmp 0xfb5a
jmp 0xfb5a
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0xad26
jmp 0xfb5d
jmp 0xfb5a
jmp 0xfb5a
jmp 0xfb5a
jmp 0xfb5a
jmp 0xfb5a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1062a
leaq 0x30(%rsp), %rdi
callq 0xb872
leaq 0x50(%rsp), %rdi
callq 0xb872
leaq 0xb0(%rsp), %rdi
callq 0xb872
movq %rbx, %rdi
callq 0x22c0