// File: grame-cncm[P]digraph/./dglib/digraphop.hh
// Function: digraph<digraph<char, int>, int> mapnodes<digraph<char, int>, digraph<char, int>, int>(digraph<digraph<char, int>, int> const&, std::function<digraph<char, int> (digraph<char, int> const&)>)
inline digraph<M, A> mapnodes(const digraph<N, A>& g, std::function<M(const N&)> foo)
{
    digraph<M, A>  r;
    std::map<N, M> cache;
    // create a new graph with the transformed nodes
    for (const auto& n1 : g.nodes()) {
        M n2 = foo(n1);
        r.add(n2);
        cache.insert(std::make_pair(n1, n2));
    }

    // copy the connections
    for (const auto& n : g.nodes()) {
        for (const auto& cnx : g.connections(n)) {
            r.add(cache[n], cache[cnx.first], cnx.second);
        }
    }
    return r;
}

// Assembly:
subq $0x168, %rsp            # imm = 0x168
movq %rdx, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
movq %rdi, %rax
movq %rax, 0x48(%rsp)
movq %rdi, 0x160(%rsp)
movq %rsi, 0x158(%rsp)
movq %rdx, 0x150(%rsp)
movb $0x0, 0x14f(%rsp)
callq 0x2d3e0
leaq 0x118(%rsp), %rdi
callq 0x33360
movq 0x158(%rsp), %rdi
callq 0x32690
movq %rax, 0x50(%rsp)
jmp 0x24cbf
movq 0x50(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rdi
callq 0x326b0
movq %rax, 0xf8(%rsp)
movq 0x110(%rsp), %rdi
callq 0x326e0
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x32710
testb $0x1, %al
jne 0x24d14
jmp 0x24e85
leaq 0xf8(%rsp), %rdi
callq 0x32730
movq 0x38(%rsp), %rsi
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rdx
leaq 0xd8(%rsp), %rdi
callq 0x33370
jmp 0x24d45
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
leaq 0xd8(%rsp), %rsi
callq 0x2d5a0
movq 0x40(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x2d510
jmp 0x24d70
leaq 0xc8(%rsp), %rdi
callq 0x24610
movq 0xe8(%rsp), %rsi
leaq 0xa8(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x33420
jmp 0x24d9c
leaq 0x118(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x333d0
movb %dl, 0x27(%rsp)
movq %rax, 0x28(%rsp)
jmp 0x24dbc
movb 0x27(%rsp), %al
movq 0x28(%rsp), %rcx
movq %rcx, 0x98(%rsp)
movb %al, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x33460
leaq 0xd8(%rsp), %rdi
callq 0x24610
leaq 0xf8(%rsp), %rdi
callq 0x32850
jmp 0x24cf6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x24ffa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x24610
jmp 0x24e73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x24e73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x33460
leaq 0xd8(%rsp), %rdi
callq 0x24610
jmp 0x24ffa
movq 0x158(%rsp), %rdi
callq 0x32690
movq %rax, 0x18(%rsp)
jmp 0x24e99
movq 0x18(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rdi
callq 0x326b0
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rdi
callq 0x326e0
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x32710
testb $0x1, %al
jne 0x24eee
jmp 0x24fd9
leaq 0x88(%rsp), %rdi
callq 0x32730
movq %rax, 0x78(%rsp)
movq 0x158(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x32750
movq %rax, 0x10(%rsp)
jmp 0x24f19
movq 0x10(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rdi
callq 0x32780
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rdi
callq 0x327b0
movq %rax, 0x60(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x327e0
testb $0x1, %al
jne 0x24f56
jmp 0x24fc5
leaq 0x68(%rsp), %rdi
callq 0x32800
movq %rax, 0x58(%rsp)
movq 0x78(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x33490
movq %rax, 0x8(%rsp)
jmp 0x24f7e
movq 0x58(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x33490
movq %rax, (%rsp)
jmp 0x24f96
movq (%rsp), %rdx
movq 0x8(%rsp), %rsi
movq 0x40(%rsp), %rdi
movq 0x58(%rsp), %rcx
addq $0x10, %rcx
callq 0x2d6f0
jmp 0x24fb4
jmp 0x24fb6
leaq 0x68(%rsp), %rdi
callq 0x32820
jmp 0x24f41
jmp 0x24fc7
leaq 0x88(%rsp), %rdi
callq 0x32850
jmp 0x24ed0
movb $0x1, 0x14f(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x33580
testb $0x1, 0x14f(%rsp)
jne 0x2501d
jmp 0x25013
leaq 0x118(%rsp), %rdi
callq 0x33580
movq 0x40(%rsp), %rdi
callq 0x24bb0
jmp 0x2502a
movq 0x40(%rsp), %rdi
callq 0x24bb0
movq 0x48(%rsp), %rax
addq $0x168, %rsp            # imm = 0x168
retq
movq 0x108(%rsp), %rdi
callq 0x2290
nopw (%rax,%rax)