// File: /workspace/github_cpp_makefile_star2_O2/minimind[P]simple-graph/unittest/../graph/graph.hpp
// Function: void add<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>(Graph<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>&, Graph<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>> const&, bool)
void add( Graph<N,E>& a, const Graph<N,E>& b, const bool keepSameKeys )
{
  const unsigned long keyAdd = keepSameKeys ? 0 : a.m_counter;

  // The problem here is that the keys might change. So we need to create new keys and hence new node iterators in the edges.
  // We do this by going through all the nodes and edges and adding a.m_counter to all the keys.
  for ( typename SimpleGraph::ConstNodeIterator<N,E> i = b.nodes.begin();
        i != b.nodes.end();
        ++i )
  {
    if ( a.nodes.m_nodes.find( i.key() + keyAdd ) != a.nodes.m_nodes.end() )
    {
      throw std::runtime_error( "Cannot add node as key already exists" );
    }

    a.nodes.m_nodes.insert( std::make_pair(
      i.key() + keyAdd,
      boost::shared_ptr< SimpleGraph::SimpleNode<N,E> >( new SimpleGraph::SimpleNode<N,E>( *i, i.key() + keyAdd ) ) ) );
  }

  // Now we copy the edges
  for ( typename SimpleGraph::ConstEdgeIterator<N,E> j = b.edges.begin();
        j != b.edges.end();
        ++j )
  {
    typename SimpleGraph::NodeIterator<N,E> left = a.nodes.find( j.left().key() + keyAdd );
    if ( left == a.nodes.end() )
    {
      throw std::runtime_error( "Cannot copy graph as cannot find left node" );
    }

    typename SimpleGraph::NodeIterator<N,E> right = a.nodes.find( j.right().key() + keyAdd );
    if ( right == a.nodes.end() )
    {
      throw std::runtime_error( "Cannot copy graph as cannot find right node" );
    }

    a.add_edge( *j, left, right );
  }

  if ( keepSameKeys )
  {
    if ( a.m_counter < b.m_counter )
    {
      a.m_counter = b.m_counter;
    }
  }
  else
  {
    a.m_counter += b.m_counter;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r12
movl %edx, 0xc(%rsp)
testl %edx, %edx
jne 0x23bf5
movq 0x48(%r12), %r15
jmp 0x23bf8
xorl %r15d, %r15d
movq 0x18(%rsi), %r13
movq %rsi, (%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x48(%rsp)
leaq 0x8(%r12), %rbp
leaq 0x20(%rsp), %r14
movq %rbp, 0x40(%rsp)
movq %r12, 0x38(%rsp)
cmpq 0x48(%rsp), %r13
je 0x23ce3
movq 0x20(%r13), %rax
addq %r15, %rax
movq %rax, 0x20(%rsp)
movq %r12, %rdi
movq %rbp, %r12
movq %r14, %rbp
movq %r14, %rsi
callq 0x2457e
cmpq %r12, %rax
jne 0x23db0
movq 0x20(%r13), %r14
pushq $0x40
popq %rdi
callq 0x93a0
movq %rax, %r12
leaq 0x28(%r13), %rdi
callq 0x24382
movq 0x20(%r13), %rdx
addq %r15, %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x23f48
movq %r15, %rbx
addq %r15, %r14
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x23f74
movq %r14, 0x20(%rsp)
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x28(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rdi
movq %rbp, %r14
movq %rbp, %rsi
callq 0x23fa8
leaq 0x30(%rsp), %rdi
callq 0x241a8
leaq 0x18(%rsp), %rdi
callq 0x241a8
movq %r13, %rdi
callq 0x9400
movq %rax, %r13
movq 0x40(%rsp), %rbp
movq 0x38(%rsp), %r12
movq %rbx, %r15
jmp 0x23c1d
movq (%rsp), %rax
leaq 0x30(%rax), %r13
leaq 0x20(%rsp), %r14
leaq 0x50(%rsp), %rbx
movq %r13, %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
cmpq %r13, %rax
je 0x23d77
movq %r14, %rdi
callq 0x24556
movq 0x20(%rax), %rsi
addq %r15, %rsi
movq %r12, %rdi
callq 0x24544
movq %rax, 0x10(%rsp)
cmpq %rbp, %rax
je 0x23dcc
movq %r14, %rdi
callq 0x2456a
movq 0x20(%rax), %rsi
addq %r15, %rsi
movq %r12, %rdi
callq 0x24544
movq %rax, 0x50(%rsp)
cmpq %rbp, %rax
je 0x23de8
movq 0x20(%rsp), %rdi
addq $0x10, %rdi
callq 0x24358
movq %r12, %rdi
movq %rax, %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rcx
callq 0x23a36
movq 0x20(%rsp), %rax
jmp 0x23cf8
cmpb $0x0, 0xc(%rsp)
je 0x23d8f
movq (%rsp), %rax
movq 0x48(%rax), %rax
cmpq %rax, 0x48(%r12)
jb 0x23d9c
jmp 0x23da1
movq 0x48(%r12), %rax
movq (%rsp), %rcx
addq 0x48(%rcx), %rax
movq %rax, 0x48(%r12)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x91c0
movq %rax, %r14
leaq 0xe819(%rip), %rsi      # 0x325db
movq %rax, %rdi
callq 0x9140
jmp 0x23e02
pushq $0x10
popq %rdi
callq 0x91c0
movq %rax, %r14
leaq 0xe823(%rip), %rsi      # 0x32601
movq %rax, %rdi
callq 0x9140
jmp 0x23e02
pushq $0x10
popq %rdi
callq 0x91c0
movq %rax, %r14
leaq 0xe832(%rip), %rsi      # 0x3262c
movq %rax, %rdi
callq 0x9140
movq 0x281e7(%rip), %rsi     # 0x4bff0
movq 0x281a0(%rip), %rdx     # 0x4bfb0
movq %r14, %rdi
callq 0x95e0
jmp 0x23e1c
jmp 0x23e1c
movq %rax, %rbx
movq %r14, %rdi
callq 0x92d0
jmp 0x23e50
movq %rax, %rbx
pushq $0x40
popq %rsi
movq %r12, %rdi
callq 0x93c0
jmp 0x23e50
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x241a8
leaq 0x18(%rsp), %rdi
callq 0x241a8
movq %rbx, %rdi
callq 0x9610