// File: GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Support.cpp
// Function: GPX2Support::DFS_outside(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<int, Partition*, std::less<int>, std::allocator<std::pair<int const, Partition*>>>&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Node*, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, Node*>>>&)
pair<GPX2Structs::SearchResult, vector<string>> GPX2Support::DFS_outside(string id, GPX2Structs::PartitionMap &partitions, GPX2Structs::NodeMap &unitedGraph)
{
    string now;
    int idPartition = whichPartition(id, partitions);
    vector<string> partition = partitions[idPartition]->getNodes();
    vector<string> alreadyVisited;
    deque<string> nextToVisit;
    int partitionConnected{ -1 };
    bool notAlreadyVisited{ false };
    bool notToVisit{ false };
    bool cutEdge{ false };

    nextToVisit.push_back(id);
    
    while (!nextToVisit.empty()) {
        now = nextToVisit.back();
        nextToVisit.pop_back();

        alreadyVisited.push_back(now);

        bool endNode{false};

        vector<Node::node> edges = unitedGraph[now]->getEdges();
        for (Node::node cn : edges) {
            notAlreadyVisited = (find(alreadyVisited.begin(), alreadyVisited.end(), cn.first) == alreadyVisited.end());
            notToVisit = (find(nextToVisit.begin(), nextToVisit.end(), cn.first) == nextToVisit.end());
            cutEdge = (cn.second == 0);
            if (notAlreadyVisited && notToVisit && cutEdge) {
                nextToVisit.push_back(cn.first);
            }
            //if the node has a edge that was not cut, it must be a endNode
            if(!cutEdge){
                endNode = true;
            }
        }

        if(endNode){
            partitionConnected = whichPartition(now, partitions);
            if(idPartition != partitionConnected){
                return make_pair(GPX2Structs::SearchResult::CONNECTED_TO_PARTITION, alreadyVisited);
            }
        }
    }
    
    unitedGraph[id]->setAccess(false);
    unitedGraph[alreadyVisited.back()]->setAccess(false);
    return make_pair(GPX2Structs::SearchResult::CONNECTED_TO_SELF, alreadyVisited);
}

// Assembly:
subq $0x318, %rsp            # imm = 0x318
movq %rsi, 0x88(%rsp)
movq %rdi, 0x78(%rsp)
movq %rdi, %rax
movq %rax, 0x80(%rsp)
movq %rdi, 0x310(%rsp)
movq %rsi, 0x308(%rsp)
movq %rdx, 0x300(%rsp)
movq %rcx, 0x2f8(%rsp)
leaq 0x2d8(%rsp), %rdi
callq 0x6690
movq 0x88(%rsp), %rsi
leaq 0x2b0(%rsp), %rdi
callq 0x6200
jmp 0x6bec3
movq 0x300(%rsp), %rsi
leaq 0x270(%rsp), %rdi
callq 0x55c60
jmp 0x6beda
leaq 0x2b0(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0x6c7f0
movl %eax, 0x74(%rsp)
jmp 0x6bef5
leaq 0x270(%rsp), %rdi
callq 0x55c90
leaq 0x2b0(%rsp), %rdi
callq 0x6988
movl 0x74(%rsp), %eax
movl %eax, 0x2d4(%rsp)
movq 0x300(%rsp), %rdi
leaq 0x2d4(%rsp), %rsi
callq 0x55370
movq %rax, 0x68(%rsp)
jmp 0x6bf36
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x67e70
movq %rax, 0x60(%rsp)
jmp 0x6bf4a
movq 0x60(%rsp), %rsi
leaq 0x258(%rsp), %rdi
callq 0x305f0
jmp 0x6bf5e
leaq 0x240(%rsp), %rdi
callq 0x1e3e0
leaq 0x1f0(%rsp), %rdi
callq 0x70690
jmp 0x6bf7a
movq 0x88(%rsp), %rsi
movl $0xffffffff, 0x1ec(%rsp) # imm = 0xFFFFFFFF
movb $0x0, 0x1eb(%rsp)
movb $0x0, 0x1ea(%rsp)
movb $0x0, 0x1e9(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0x706a0
jmp 0x6bfb4
jmp 0x6bfb6
leaq 0x1f0(%rsp), %rdi
callq 0x70700
xorb $-0x1, %al
testb $0x1, %al
jne 0x6bfce
jmp 0x6c49f
leaq 0x1f0(%rsp), %rdi
callq 0x70720
movq %rax, %rsi
leaq 0x2d8(%rsp), %rdi
callq 0x6070
jmp 0x6bfed
leaq 0x1f0(%rsp), %rdi
callq 0x70750
leaq 0x240(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0x37210
jmp 0x6c011
movb $0x0, 0x1e8(%rsp)
movq 0x2f8(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0x60c60
movq %rax, 0x58(%rsp)
jmp 0x6c035
movq 0x58(%rsp), %rax
movq (%rax), %rdi
callq 0x661c0
movq %rax, 0x50(%rsp)
jmp 0x6c049
movq 0x50(%rsp), %rsi
leaq 0x1d0(%rsp), %rdi
callq 0x615a0
jmp 0x6c05d
leaq 0x1d0(%rsp), %rax
movq %rax, 0x1c8(%rsp)
movq 0x1c8(%rsp), %rdi
callq 0x60f80
movq %rax, 0x1c0(%rsp)
movq 0x1c8(%rsp), %rdi
callq 0x60fb0
movq %rax, 0x1b8(%rsp)
leaq 0x1c0(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x60fe0
testb $0x1, %al
jne 0x6c0b5
jmp 0x6c357
leaq 0x1c0(%rsp), %rdi
callq 0x61020
movq %rax, %rsi
leaq 0x190(%rsp), %rdi
callq 0x61030
jmp 0x6c0d4
leaq 0x240(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x1e310
movq 0x40(%rsp), %rdi
movq %rax, 0x180(%rsp)
callq 0x1e340
movq %rax, 0x178(%rsp)
movq 0x180(%rsp), %rdi
movq 0x178(%rsp), %rsi
leaq 0x190(%rsp), %rdx
callq 0x49c90
movq %rax, 0x48(%rsp)
jmp 0x6c124
movq 0x48(%rsp), %rax
movq %rax, 0x188(%rsp)
leaq 0x240(%rsp), %rdi
callq 0x1e340
movq %rax, 0x170(%rsp)
leaq 0x188(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x55c20
movb %al, 0x1eb(%rsp)
leaq 0x130(%rsp), %rdi
movq %rdi, 0x30(%rsp)
leaq 0x1f0(%rsp), %rsi
movq %rsi, 0x28(%rsp)
callq 0x70860
movq 0x28(%rsp), %rsi
leaq 0x110(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x70890
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq 0x150(%rsp), %rdi
leaq 0x190(%rsp), %rcx
callq 0x707e0
jmp 0x6c1b9
leaq 0xf0(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
callq 0x70890
leaq 0x150(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x707c0
andb $0x1, %al
movb %al, 0x1ea(%rsp)
movsd 0x1b0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
andb $0x1, %al
movb %al, 0x1e9(%rsp)
testb $0x1, 0x1eb(%rsp)
je 0x6c326
testb $0x1, 0x1ea(%rsp)
je 0x6c326
testb $0x1, 0x1e9(%rsp)
je 0x6c326
leaq 0x1f0(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x706a0
jmp 0x6c24e
jmp 0x6c326
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
jmp 0x6c5a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
jmp 0x6c2a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x55c90
leaq 0x2b0(%rsp), %rdi
callq 0x6988
jmp 0x6c5a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
jmp 0x6c58e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
jmp 0x6c581
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
jmp 0x6c48d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x610b0
jmp 0x6c48d
testb $0x1, 0x1e9(%rsp)
jne 0x6c338
movb $0x1, 0x1e8(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x610b0
leaq 0x1c0(%rsp), %rdi
callq 0x610c0
jmp 0x6c097
testb $0x1, 0x1e8(%rsp)
je 0x6c45f
leaq 0xd0(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0x6200
jmp 0x6c37c
movq 0x300(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x55c60
jmp 0x6c393
leaq 0xd0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x6c7f0
movl %eax, 0x24(%rsp)
jmp 0x6c3ae
movl 0x24(%rsp), %eax
movl %eax, 0x1ec(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x55c90
leaq 0xd0(%rsp), %rdi
callq 0x6988
movl 0x2d4(%rsp), %eax
cmpl 0x1ec(%rsp), %eax
je 0x6c45d
movq 0x78(%rsp), %rdi
movl $0x0, 0x9c(%rsp)
leaq 0x9c(%rsp), %rsi
leaq 0x240(%rsp), %rdx
callq 0x708c0
jmp 0x6c40a
movl $0x1, 0x98(%rsp)
jmp 0x6c46a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
jmp 0x6c44e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a8(%rsp)
movl %eax, 0x2a4(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x55c90
leaq 0xd0(%rsp), %rdi
callq 0x6988
jmp 0x6c48d
jmp 0x6c45f
movl $0x0, 0x98(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x616a0
movl 0x98(%rsp), %eax
testl %eax, %eax
jne 0x6c53d
jmp 0x6c488
jmp 0x6bfb6
leaq 0x1d0(%rsp), %rdi
callq 0x616a0
jmp 0x6c581
movq 0x88(%rsp), %rsi
movq 0x2f8(%rsp), %rdi
callq 0x60c60
movq %rax, 0x18(%rsp)
jmp 0x6c4bb
movq 0x18(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x66230
jmp 0x6c4cc
movq 0x2f8(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x240(%rsp), %rdi
callq 0x47710
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x60c60
movq %rax, 0x10(%rsp)
jmp 0x6c4fa
movq 0x10(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x66230
jmp 0x6c50b
movq 0x78(%rsp), %rdi
movl $0x1, 0x94(%rsp)
leaq 0x94(%rsp), %rsi
leaq 0x240(%rsp), %rdx
callq 0x708c0
jmp 0x6c532
movl $0x1, 0x98(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0x70900
leaq 0x240(%rsp), %rdi
callq 0xa2c0
leaq 0x258(%rsp), %rdi
callq 0xa2c0
leaq 0x2d8(%rsp), %rdi
callq 0x6988
movq 0x80(%rsp), %rax
addq $0x318, %rsp            # imm = 0x318
retq
leaq 0x1f0(%rsp), %rdi
callq 0x70900
leaq 0x240(%rsp), %rdi
callq 0xa2c0
leaq 0x258(%rsp), %rdi
callq 0xa2c0
leaq 0x2d8(%rsp), %rdi
callq 0x6988
movq 0x2a8(%rsp), %rdi
callq 0x6850
nopw %cs:(%rax,%rax)