// File: /workspace/github_cpp_makefile_star2_O1/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 0xd82e
movq 0x18(%rbx), %r12
addq $0x8, %rbx
cmpq %rbx, %r12
je 0xd652
leaq 0x58(%rsp), %r13
leaq 0x18(%rsp), %rbp
movq %rbx, 0x30(%rsp)
movq %rsp, %rdi
callq 0x27e2
movq 0x38(%r12), %rbx
leaq 0x28(%r12), %r15
cmpq %r15, %rbx
je 0xd5df
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 0xd58c
movq 0x1aa4a(%rip), %rcx     # 0x27fc8
cmpb $0x0, (%rcx)
je 0xd588
incl 0x8(%rax)
jmp 0xd58c
lock
incl 0x8(%rax)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xdb54
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xd5a6
callq 0x35d6
movb 0x20(%rbx), %al
movq (%rsp), %r14
movb %al, 0x18(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3e28
addq $0x30, %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3baa
movq %rbx, %rdi
callq 0x21b0
movq %rax, %rbx
cmpq %r15, %rax
jne 0xd558
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x40(%rsp)
movq %rax, 0x48(%rsp)
testq %rax, %rax
movq 0x30(%rsp), %rbx
je 0xd611
movq 0x1a9c5(%rip), %rcx     # 0x27fc8
cmpb $0x0, (%rcx)
je 0xd60d
incl 0x8(%rax)
jmp 0xd611
lock
incl 0x8(%rax)
movq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xd880
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0xd62f
callq 0x35d6
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xd63e
callq 0x35d6
movq %r12, %rdi
callq 0x21b0
movq %rax, %r12
cmpq %rbx, %rax
jne 0xd53d
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rbx
addq $0x8, %rax
movq %rax, 0x50(%rsp)
cmpq %rax, %rbx
je 0xd78b
leaq 0x58(%rsp), %r12
movq 0x1a94c(%rip), %rbp     # 0x27fc8
leaq 0x20(%rbx), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0xd90a
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0xd6b0
cmpb $0x0, (%rbp)
je 0xd6ac
incl 0x8(%rax)
jmp 0xd6b0
lock
incl 0x8(%rax)
movq %rbx, 0x30(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
addq $0x30, %rdi
movq %r14, %rsi
callq 0x48d0
movq %rax, %rbx
movq 0x18(%rax), %r15
addq $0x8, %rbx
cmpq %rbx, %r15
je 0xd764
leaq 0x20(%r15), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xd90a
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xd710
cmpb $0x0, (%rbp)
je 0xd70c
incl 0x8(%rax)
jmp 0xd710
lock
incl 0x8(%rax)
movq 0x18(%rsp), %rdi
leaq 0x28(%r15), %rcx
cmpq (%rsp), %rdi
je 0xd736
movq 0x10(%rsp), %rax
movq (%rax), %rdi
leaq 0x18(%rsp), %rsi
movq %rsp, %rdx
callq 0xe286
jmp 0xd741
movq %r14, %rsi
movq %r13, %rdx
callq 0x3a46
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xd750
callq 0x35d6
movq %r15, %rdi
callq 0x21b0
movq %rax, %r15
cmpq %rbx, %rax
jne 0xd6dd
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xd773
callq 0x35d6
movq 0x30(%rsp), %rdi
callq 0x21b0
movq %rax, %rbx
cmpq 0x50(%rsp), %rax
jne 0xd67c
leaq 0x58(%rsp), %rdi
callq 0xe742
movq 0x10(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0xd81b
jmp 0xd7bf
jmp 0xd7d8
movq %rax, %r14
movq 0x48(%rsp), %rdi
jmp 0xd7ea
movq %rax, %r14
jmp 0xd808
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xd7db
callq 0x35d6
jmp 0xd7db
movq %rax, %r14
movq 0x20(%rsp), %rdi
jmp 0xd7fe
movq %rax, %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xd7f9
callq 0x35d6
jmp 0xd7f9
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xd808
callq 0x35d6
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0xd81b
callq 0x35d6
leaq 0x58(%rsp), %rdi
callq 0xe742
movq %r14, %rdi
callq 0x2250
nop