// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::getArticulationPoints(std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&, bool&, bool&) const
bool Graph::getArticulationPoints(unordered_set<uint32_t> &vertexCut, vector<uint32_t> &component1, vector<uint32_t> &component2, bool &actualComponent1, bool &connected) const {
    struct Value {
        Value(const uint32_t &visit) : visit(visit), low(visit) {}
        uint32_t visit;
        uint32_t low;
    };

    struct Instance {
        Instance(const uint32_t &node, const uint32_t &parentNode, const Graph &graph) : graphTraversal(graph, node), parentNode(parentNode), dfsChildren(0) {}
        GraphTraversal graphTraversal;
        uint32_t parentNode;
        uint32_t dfsChildren;
    };

    vertexCut.clear();
    component1.clear();
    component2.clear();

    Graph::GraphTraversal graphTraversal(*this);
    if (graphTraversal.curNode == NONE) {
        return false;
    }
    unordered_set<uint32_t> articulationPoints;
    unordered_map<uint32_t, Value> exploredSet;
    stack<Instance> frontier;
    uint32_t visit = 0;
    uint32_t root = NONE;
    if (exploredSet.find(graphTraversal.curNode) == exploredSet.end()) {
        root = graphTraversal.curNode;
        frontier.push(Instance(graphTraversal.curNode, NONE, *this));
        while (!frontier.empty()) {
            uint32_t node = frontier.top().graphTraversal.curNode;
            exploredSet.insert({node, Value(visit)});
            visit++;
            bool newCall;
            do {
                node = frontier.top().graphTraversal.curNode;
                Graph::GraphTraversal &neighbors = frontier.top().graphTraversal;
                newCall = false;
                while (neighbors.curEdgeOffset != NONE) {
                    uint32_t neighbor = (*edgeBuffer)[neighbors.curEdgeOffset];
                    if (neighbor != node) {
                        auto it = exploredSet.find(neighbor);
                        if (it == exploredSet.end()) {
                            newCall = true;
                            frontier.top().dfsChildren++;
                            frontier.push(Instance(neighbor, node, *this));
                            break;
                        } else if (it->second.visit < exploredSet.find(node)->second.visit) {
                            auto it1 = exploredSet.find(node);
                            if (it->second.visit < it1->second.low) {
                                it1->second.low = it->second.visit;
                            }
                        }
                    }
                    getNextEdge(neighbors);
                }
                if (!newCall) {
                    uint32_t parentNode = frontier.top().parentNode;
                    if (frontier.size() > 1) {
                        auto it1 = exploredSet.find(parentNode);
                        auto it2 = exploredSet.find(node);
                        assert(it1 != exploredSet.end() && it2 != exploredSet.end());
                        if (it2->second.low < it1->second.low) {
                            it1->second.low = it2->second.low;
                        }
                        if (parentNode != root && it2->second.low >= it1->second.visit && articulationPoints.insert(parentNode).second) {
                            //cout << "Articulation point " << parentNode << "\n";
                            unordered_set<uint32_t> cut;
                            cut.insert(parentNode);
                            if (checkSeparation(cut, component1, component2, actualComponent1)) {
                                vertexCut = cut;
                                //cout << "Articulation point " << parentNode << "\n";
                                return true;
                            }
                        }
                        frontier.pop();
                        if (frontier.top().graphTraversal.curEdgeOffset != NONE) {
                            getNextEdge(frontier.top().graphTraversal);
                        }
                    } else if (frontier.size() == 1) {
                        if (frontier.top().dfsChildren > 1 && articulationPoints.insert(frontier.top().graphTraversal.curNode).second) {
                            //cout << "Root articulation point " << frontier.top().graphTraversal.curNode << "\n";
                            unordered_set<uint32_t> cut;
                            cut.insert(frontier.top().graphTraversal.curNode);
                            if (checkSeparation(cut, component1, component2, actualComponent1)) {
                                vertexCut = cut;
                                //cout << "Root articulation point " << frontier.top().graphTraversal.curNode << "\n";
                                return true;
                            }
                        }
                        frontier.pop();
                        break;
                    }
                }
            } while (!newCall);
        }
    }
    if (exploredSet.size() != getNodeCountWithEdges()) {
        connected = false;
    } else {
        connected = true;
    }
    return false;
}

// Assembly:
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rdi, 0x3d8(%rsp)
movq %rsi, 0x3d0(%rsp)
movq %rdx, 0x3c8(%rsp)
movq %rcx, 0x3c0(%rsp)
movq %r8, 0x3b8(%rsp)
movq %r9, 0x3b0(%rsp)
movq 0x3d8(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x3d0(%rsp), %rdi
callq 0x1aed0
movq 0x3c8(%rsp), %rdi
callq 0x191c0
movq 0x3c0(%rsp), %rdi
callq 0x191c0
movq 0x130(%rsp), %rsi
leaq 0x3a8(%rsp), %rdi
callq 0x2a40
cmpl $-0x1, 0x3a8(%rsp)
jne 0x9f9a
movb $0x0, 0x3e7(%rsp)
jmp 0xaad8
leaq 0x370(%rsp), %rdi
callq 0x1a020
leaq 0x338(%rsp), %rdi
callq 0xab00
leaq 0x2e8(%rsp), %rdi
callq 0xab10
jmp 0x9fc3
movl $0x0, 0x2d8(%rsp)
movl $0xffffffff, 0x2d4(%rsp) # imm = 0xFFFFFFFF
leaq 0x338(%rsp), %rdi
leaq 0x3a8(%rsp), %rsi
callq 0xab60
movq %rax, 0x128(%rsp)
jmp 0x9ff8
movq 0x128(%rsp), %rax
movq %rax, 0x2c8(%rsp)
leaq 0x338(%rsp), %rdi
callq 0xab90
movq %rax, 0x2c0(%rsp)
leaq 0x2c8(%rsp), %rdi
leaq 0x2c0(%rsp), %rsi
callq 0xab40
testb $0x1, %al
jne 0xa03b
jmp 0xaa28
movq 0x130(%rsp), %rcx
movl 0x3a8(%rsp), %eax
movl %eax, 0x2d4(%rsp)
movl $0xffffffff, 0x2ac(%rsp) # imm = 0xFFFFFFFF
leaq 0x2b0(%rsp), %rdi
leaq 0x3a8(%rsp), %rsi
leaq 0x2ac(%rsp), %rdx
callq 0xabf0
jmp 0xa07b
leaq 0x2e8(%rsp), %rdi
leaq 0x2b0(%rsp), %rsi
callq 0xabc0
jmp 0xa092
jmp 0xa094
leaq 0x2e8(%rsp), %rdi
callq 0xac40
movb %al, 0x127(%rsp)
jmp 0xa0aa
movb 0x127(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xa0bc
jmp 0xaa26
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0x118(%rsp)
jmp 0xa0d3
movq 0x118(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x2a8(%rsp)
leaq 0x294(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0xacc0
jmp 0xa0fb
leaq 0x29c(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
leaq 0x294(%rsp), %rdx
callq 0xacf0
jmp 0xa11a
leaq 0x338(%rsp), %rdi
leaq 0x29c(%rsp), %rsi
callq 0xac70
movb %dl, 0x10f(%rsp)
movq %rax, 0x110(%rsp)
jmp 0xa140
movb 0x10f(%rsp), %al
movq 0x110(%rsp), %rcx
movq %rcx, 0x280(%rsp)
movb %al, 0x288(%rsp)
movl 0x2d8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2d8(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0x100(%rsp)
jmp 0xa186
movq 0x100(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x2a8(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0xf8(%rsp)
jmp 0xa1ae
movq 0xf8(%rsp), %rax
movq %rax, 0x270(%rsp)
movb $0x0, 0x27f(%rsp)
movq 0x270(%rsp), %rax
cmpl $-0x1, 0x4(%rax)
je 0xa431
movq 0x130(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x270(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x18900
movl (%rax), %eax
movl %eax, 0x26c(%rsp)
movl 0x26c(%rsp), %eax
cmpl 0x2a8(%rsp), %eax
je 0xa415
leaq 0x338(%rsp), %rdi
leaq 0x26c(%rsp), %rsi
callq 0xab60
movq %rax, 0xf0(%rsp)
jmp 0xa232
movq 0xf0(%rsp), %rax
movq %rax, 0x260(%rsp)
leaq 0x338(%rsp), %rdi
callq 0xab90
movq %rax, 0x258(%rsp)
leaq 0x260(%rsp), %rdi
leaq 0x258(%rsp), %rsi
callq 0xab40
testb $0x1, %al
jne 0xa275
jmp 0xa319
movb $0x1, 0x27f(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0xe8(%rsp)
jmp 0xa294
movq 0x130(%rsp), %rcx
movq 0xe8(%rsp), %rax
movl 0xc(%rax), %edx
incl %edx
movl %edx, 0xc(%rax)
leaq 0x248(%rsp), %rdi
leaq 0x26c(%rsp), %rsi
leaq 0x2a8(%rsp), %rdx
callq 0xabf0
jmp 0xa2cb
leaq 0x2e8(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0xabc0
jmp 0xa2e2
jmp 0xa431
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e0(%rsp)
movl %eax, 0x2dc(%rsp)
jmp 0xaabc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e0(%rsp)
movl %eax, 0x2dc(%rsp)
jmp 0xaaaf
leaq 0x260(%rsp), %rdi
callq 0xad20
movl 0x4(%rax), %eax
movl %eax, 0xdc(%rsp)
leaq 0x338(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
callq 0xab60
movq %rax, 0xe0(%rsp)
jmp 0xa34f
movq 0xe0(%rsp), %rax
movq %rax, 0x240(%rsp)
leaq 0x240(%rsp), %rdi
callq 0xad20
movq %rax, %rcx
movl 0xdc(%rsp), %eax
cmpl 0x4(%rcx), %eax
jae 0xa411
leaq 0x338(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
callq 0xab60
movq %rax, 0xd0(%rsp)
jmp 0xa39e
movq 0xd0(%rsp), %rax
movq %rax, 0x238(%rsp)
leaq 0x260(%rsp), %rdi
callq 0xad20
movl 0x4(%rax), %eax
movl %eax, 0xcc(%rsp)
leaq 0x238(%rsp), %rdi
callq 0xad20
movq %rax, %rcx
movl 0xcc(%rsp), %eax
cmpl 0x8(%rcx), %eax
jae 0xa40f
leaq 0x260(%rsp), %rdi
callq 0xad20
movl 0x4(%rax), %eax
movl %eax, 0xc8(%rsp)
leaq 0x238(%rsp), %rdi
callq 0xad20
movl 0xc8(%rsp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xa411
jmp 0xa413
jmp 0xa415
movq 0x130(%rsp), %rdi
movq 0x270(%rsp), %rsi
callq 0x19560
jmp 0xa42c
jmp 0xa1c6
testb $0x1, 0x27f(%rsp)
jne 0xaa0e
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0xc0(%rsp)
jmp 0xa456
movq 0xc0(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x234(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0xad40
movq %rax, 0xb8(%rsp)
jmp 0xa47f
movq 0xb8(%rsp), %rax
cmpq $0x1, %rax
jbe 0xa822
leaq 0x338(%rsp), %rdi
leaq 0x234(%rsp), %rsi
callq 0xab60
movq %rax, 0xb0(%rsp)
jmp 0xa4b0
movq 0xb0(%rsp), %rax
movq %rax, 0x228(%rsp)
leaq 0x338(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
callq 0xab60
movq %rax, 0xa8(%rsp)
jmp 0xa4df
movq 0xa8(%rsp), %rax
movq %rax, 0x220(%rsp)
leaq 0x338(%rsp), %rdi
callq 0xab90
movq %rax, 0x218(%rsp)
leaq 0x228(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0xad50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xa7(%rsp)
jne 0xa52b
jmp 0xa55c
leaq 0x338(%rsp), %rdi
callq 0xab90
movq %rax, 0x210(%rsp)
leaq 0x220(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0xad50
movb %al, 0xa7(%rsp)
movb 0xa7(%rsp), %al
testb $0x1, %al
jne 0xa569
jmp 0xa56b
jmp 0xa58a
leaq 0x3bcee(%rip), %rdi     # 0x46260
leaq 0x3bac1(%rip), %rsi     # 0x4603a
movl $0x4dd, %edx            # imm = 0x4DD
leaq 0x3bd10(%rip), %rcx     # 0x46295
callq 0x2110
leaq 0x220(%rsp), %rdi
callq 0xad20
movl 0x8(%rax), %eax
movl %eax, 0xa0(%rsp)
leaq 0x228(%rsp), %rdi
callq 0xad20
movq %rax, %rcx
movl 0xa0(%rsp), %eax
cmpl 0x8(%rcx), %eax
jae 0xa5eb
leaq 0x220(%rsp), %rdi
callq 0xad20
movl 0x8(%rax), %eax
movl %eax, 0x9c(%rsp)
leaq 0x228(%rsp), %rdi
callq 0xad20
movl 0x9c(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl 0x234(%rsp), %ecx
xorl %eax, %eax
cmpl 0x2d4(%rsp), %ecx
movb %al, 0x9b(%rsp)
je 0xa6b4
leaq 0x220(%rsp), %rdi
callq 0xad20
movl 0x8(%rax), %eax
movl %eax, 0x94(%rsp)
leaq 0x228(%rsp), %rdi
callq 0xad20
movl 0x94(%rsp), %ecx
movq %rax, %rdx
xorl %eax, %eax
cmpl 0x4(%rdx), %ecx
movb %al, 0x9b(%rsp)
jb 0xa6b4
leaq 0x370(%rsp), %rdi
leaq 0x234(%rsp), %rsi
callq 0x18960
movb %dl, 0x87(%rsp)
movq %rax, 0x88(%rsp)
jmp 0xa66a
movb 0x87(%rsp), %al
movq 0x88(%rsp), %rcx
movq %rcx, 0x1f0(%rsp)
movb %al, 0x1f8(%rsp)
movq 0x1f0(%rsp), %rax
movq %rax, 0x200(%rsp)
movb 0x1f8(%rsp), %al
movb %al, 0x208(%rsp)
movb 0x208(%rsp), %al
movb %al, 0x9b(%rsp)
movb 0x9b(%rsp), %al
testb $0x1, %al
jne 0xa6c4
jmp 0xa7c5
leaq 0x1b8(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x1a020
movq 0x68(%rsp), %rdi
leaq 0x234(%rsp), %rsi
callq 0x18960
movb %dl, 0x77(%rsp)
movq %rax, 0x78(%rsp)
jmp 0xa6f3
movq 0x130(%rsp), %rdi
movb 0x77(%rsp), %al
movq 0x78(%rsp), %rcx
movq %rcx, 0x1a8(%rsp)
movb %al, 0x1b0(%rsp)
movq 0x3c8(%rsp), %rdx
movq 0x3c0(%rsp), %rcx
movq 0x3b8(%rsp), %r8
leaq 0x1b8(%rsp), %rsi
callq 0xad70
movb %al, 0x67(%rsp)
jmp 0xa73e
movb 0x67(%rsp), %al
testb $0x1, %al
jne 0xa748
jmp 0xa79a
movq 0x3d0(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x1aee0
jmp 0xa75f
movb $0x1, 0x3e7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0xa7a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e0(%rsp)
movl %eax, 0x2dc(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x1a030
jmp 0xaaaf
movl $0x0, 0x1a4(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x1a030
movl 0x1a4(%rsp), %eax
testl %eax, %eax
jne 0xaa86
jmp 0xa7c3
jmp 0xa7c5
leaq 0x2e8(%rsp), %rdi
callq 0xb230
jmp 0xa7d4
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0x58(%rsp)
jmp 0xa7e8
movq 0x58(%rsp), %rax
cmpl $-0x1, 0x4(%rax)
je 0xa81d
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0x50(%rsp)
jmp 0xa807
movq 0x50(%rsp), %rsi
movq 0x130(%rsp), %rdi
callq 0x19560
jmp 0xa81b
jmp 0xa81d
jmp 0xaa0c
leaq 0x2e8(%rsp), %rdi
callq 0xad40
movq %rax, 0x48(%rsp)
jmp 0xa836
movq 0x48(%rsp), %rax
cmpq $0x1, %rax
jne 0xaa0a
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0x40(%rsp)
jmp 0xa859
movq 0x40(%rsp), %rcx
xorl %eax, %eax
cmpl $0x1, 0xc(%rcx)
movb %al, 0x3f(%rsp)
jbe 0xa8dc
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0x30(%rsp)
jmp 0xa87e
movq 0x30(%rsp), %rsi
leaq 0x370(%rsp), %rdi
callq 0x18960
movb %dl, 0x27(%rsp)
movq %rax, 0x28(%rsp)
jmp 0xa89b
movb 0x27(%rsp), %al
movq 0x28(%rsp), %rcx
movq %rcx, 0x180(%rsp)
movb %al, 0x188(%rsp)
movq 0x180(%rsp), %rax
movq %rax, 0x190(%rsp)
movb 0x188(%rsp), %al
movb %al, 0x198(%rsp)
movb 0x198(%rsp), %al
movb %al, 0x3f(%rsp)
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0xa8e9
jmp 0xa9f9
leaq 0x148(%rsp), %rdi
callq 0x1a020
leaq 0x2e8(%rsp), %rdi
callq 0xac60
movq %rax, 0x18(%rsp)
jmp 0xa90a
movq 0x18(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x18960
movb %dl, 0xf(%rsp)
movq %rax, 0x10(%rsp)
jmp 0xa927
movq 0x130(%rsp), %rdi
movb 0xf(%rsp), %al
movq 0x10(%rsp), %rcx
movq %rcx, 0x138(%rsp)
movb %al, 0x140(%rsp)
movq 0x3c8(%rsp), %rdx
movq 0x3c0(%rsp), %rcx
movq 0x3b8(%rsp), %r8
leaq 0x148(%rsp), %rsi
callq 0xad70
movb %al, 0xe(%rsp)
jmp 0xa972
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xa97c
jmp 0xa9ce
movq 0x3d0(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x1aee0
jmp 0xa993
movb $0x1, 0x3e7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0xa9d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e0(%rsp)
movl %eax, 0x2dc(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x1a030
jmp 0xaaaf
movl $0x0, 0x1a4(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x1a030
movl 0x1a4(%rsp), %eax
testl %eax, %eax
jne 0xaa86
jmp 0xa9f7
jmp 0xa9f9
leaq 0x2e8(%rsp), %rdi
callq 0xb230
jmp 0xaa08
jmp 0xaa21
jmp 0xaa0c
jmp 0xaa0e
jmp 0xaa10
movb 0x27f(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xa16f
jmp 0xa094
jmp 0xaa28
leaq 0x338(%rsp), %rdi
callq 0xb240
movq 0x130(%rsp), %rdi
movq %rax, (%rsp)
callq 0xb250
movl %eax, 0x8(%rsp)
jmp 0xaa4c
movq (%rsp), %rax
movl 0x8(%rsp), %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0xaa68
movq 0x3b0(%rsp), %rax
movb $0x0, (%rax)
jmp 0xaa73
movq 0x3b0(%rsp), %rax
movb $0x1, (%rax)
movb $0x0, 0x3e7(%rsp)
movl $0x1, 0x1a4(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0xb2f0
leaq 0x338(%rsp), %rdi
callq 0xb300
leaq 0x370(%rsp), %rdi
callq 0x1a030
jmp 0xaad8
leaq 0x2e8(%rsp), %rdi
callq 0xb2f0
leaq 0x338(%rsp), %rdi
callq 0xb300
leaq 0x370(%rsp), %rdi
callq 0x1a030
jmp 0xaae9
movb 0x3e7(%rsp), %al
andb $0x1, %al
addq $0x3e8, %rsp            # imm = 0x3E8
retq
movq 0x2e0(%rsp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)