// File: /workspace/github_cpp_makefile_star2_O3/grame-cncm[P]digraph/./dglib/digraphop.hh
// Function: digraph<digraph<char, std::pair<std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, 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, int>>>, int>>, std::pair<std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, 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, int>>>, int>> partitionGraph<char, std::pair<std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, 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, int>>>, int>>(digraph<char, std::pair<std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, 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, int>>>, int>> const&, std::set<std::set<char, std::less<char>, std::allocator<char>>, std::less<std::set<char, std::less<char>, std::allocator<char>>>, std::allocator<std::set<char, std::less<char>, std::allocator<char>>>> const&)
inline digraph<digraph<N, A>, A> partitionGraph(const digraph<N, A>& g, const std::set<std::set<N>>& partition)
{
    std::map<N, digraph<N, A>> M;   // std::mapping between nodes and supernodes
    digraph<digraph<N, A>, A>  sg;  // the resulting supergraph

    // build the graph of supernodes

    // For each std::set s of the partition, create the corresponding graph sn
    // create also a std::mapping in order to retrieve the supernode a node
    /// belongs to.
    for (const auto& s : partition) {
        digraph<N, A> sn;                     // the supernode graph
        for (const N& n : s) {                // for each node of a cycle
            M.insert(std::make_pair(n, sn));  // remember its supernode
            sn.add(n);                        // and add it to the super node
        }
        sg.add(sn);  // and add the super node to the super graph
    }

    // compute the connections between the supernodes
    for (const auto& n1 : g.nodes()) {
        digraph<N, A> sn1(M[n1]);
        for (const auto& c : g.connections(n1)) {
            digraph<N, A> sn2(M[c.first]);
            if (sn1 == sn2) {
                // the connection is inside the same supernode
                sn1.add(n1, c.first, c.second);
            } else {
                // the connection is between supernodes
                sg.add(sn1, sn2, c.second);  // exploit the fact that add will keep the mini
            }
        }
    }

    return sg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %rbx
movq %rsi, 0x38(%rsp)
leaq 0x60(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq %rdi, 0x10(%rsp)
callq 0xd72e
movq 0x18(%rbx), %r12
addq $0x8, %rbx
cmpq %rbx, %r12
je 0xd54f
leaq 0x58(%rsp), %r13
leaq 0x18(%rsp), %rbp
movq %rbx, 0x30(%rsp)
movq %rsp, %rdi
callq 0x270c
movq 0x38(%r12), %rbx
leaq 0x28(%r12), %r15
cmpq %r15, %rbx
je 0xd4dc
movb 0x20(%rbx), %al
movb %al, 0x18(%rsp)
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0xd489
movq 0x1ab4d(%rip), %rcx     # 0x27fc8
cmpb $0x0, (%rcx)
je 0xd485
incl 0x8(%rax)
jmp 0xd489
lock
incl 0x8(%rax)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xda66
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xd4a3
callq 0x3504
movb 0x20(%rbx), %al
movq (%rsp), %r14
movb %al, 0x18(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3d48
addq $0x30, %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3acc
movq %rbx, %rdi
callq 0x21b0
movq %rax, %rbx
cmpq %r15, %rax
jne 0xd455
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x40(%rsp)
movq %rax, 0x48(%rsp)
testq %rax, %rax
movq 0x30(%rsp), %rbx
je 0xd50e
movq 0x1aac8(%rip), %rcx     # 0x27fc8
cmpb $0x0, (%rcx)
je 0xd50a
incl 0x8(%rax)
jmp 0xd50e
lock
incl 0x8(%rax)
movq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xd780
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0xd52c
callq 0x3504
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xd53b
callq 0x3504
movq %r12, %rdi
callq 0x21b0
movq %rax, %r12
cmpq %rbx, %rax
jne 0xd43a
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rbx
addq $0x8, %rax
movq %rax, 0x50(%rsp)
cmpq %rax, %rbx
je 0xd68b
leaq 0x58(%rsp), %r12
movq 0x1aa4f(%rip), %rbp     # 0x27fc8
leaq 0x20(%rbx), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0xd80a
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0xd5ad
cmpb $0x0, (%rbp)
je 0xd5a9
incl 0x8(%rax)
jmp 0xd5ad
lock
incl 0x8(%rax)
movq %rbx, 0x30(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
addq $0x30, %rdi
movq %r14, %rsi
callq 0x47dc
movq %rax, %rbx
movq 0x18(%rax), %r15
addq $0x8, %rbx
cmpq %rbx, %r15
je 0xd664
leaq 0x20(%r15), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xd80a
movq (%rax), %rdx
movq %rdx, (%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xd611
cmpb $0x0, (%rbp)
je 0xd609
incl 0x8(%rax)
jmp 0xd611
lock
incl 0x8(%rax)
movq (%rsp), %rdx
movq 0x18(%rsp), %rdi
leaq 0x28(%r15), %rcx
cmpq %rdx, %rdi
je 0xd636
movq 0x10(%rsp), %rax
movq (%rax), %rdi
leaq 0x18(%rsp), %rsi
movq %rsp, %rdx
callq 0xe18c
jmp 0xd641
movq %r14, %rsi
movq %r13, %rdx
callq 0x397e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xd650
callq 0x3504
movq %r15, %rdi
callq 0x21b0
movq %rax, %r15
cmpq %rbx, %rax
jne 0xd5da
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xd673
callq 0x3504
movq 0x30(%rsp), %rdi
callq 0x21b0
movq %rax, %rbx
cmpq 0x50(%rsp), %rax
jne 0xd579
leaq 0x58(%rsp), %rdi
callq 0xe62e
movq 0x10(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0xd71b
jmp 0xd6bf
jmp 0xd6d8
movq %rax, %r14
movq 0x48(%rsp), %rdi
jmp 0xd6ea
movq %rax, %r14
jmp 0xd708
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xd6db
callq 0x3504
jmp 0xd6db
movq %rax, %r14
movq 0x20(%rsp), %rdi
jmp 0xd6fe
movq %rax, %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xd6f9
callq 0x3504
jmp 0xd6f9
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xd708
callq 0x3504
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0xd71b
callq 0x3504
leaq 0x58(%rsp), %rdi
callq 0xe62e
movq %r14, %rdi
callq 0x2250
nop