// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, %rbx
testl %edx, %edx
movl %edx, 0xc(%rsp)
jne 0x2e81f
movq 0x48(%rbx), %r12
jmp 0x2e822
xorl %r12d, %r12d
movq 0x18(%rsi), %r13
movq %rsi, (%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x40(%rsp)
cmpq %rax, %r13
je 0x2e94f
leaq 0x8(%rbx), %rsi
movq %rsi, 0x38(%rsp)
movq 0x20(%r13), %rbp
addq %r12, %rbp
movq 0x10(%rbx), %rcx
movq %rsi, %rax
testq %rcx, %rcx
je 0x2e872
movq %rsi, %rax
xorl %edx, %edx
cmpq %rbp, 0x20(%rcx)
setb %dl
cmovaeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x2e85b
movq %rsi, %rcx
cmpq %rsi, %rax
je 0x2e885
cmpq 0x20(%rax), %rbp
cmovbq %rsi, %rax
movq %rax, %rcx
cmpq %rsi, %rcx
jne 0x2ea8a
movq %r12, %r14
movq %rbx, %r12
movl $0x40, %edi
callq 0xa310
movq %rax, %r15
movq 0x28(%r13), %rax
testq %rax, %rax
je 0x2ea73
movq 0x20(%r13), %rbx
leaq 0x10(%r15), %rcx
movq %rcx, (%r15)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2bee4
addq %r14, %rbx
movq %rbx, 0x20(%r15)
movq %r15, %rax
addq $0x28, %rax
movq %rax, 0x30(%r15)
movq %rax, 0x28(%r15)
movq $0x0, 0x38(%r15)
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x2ec3c
movq %rbp, 0x20(%rsp)
movups 0x10(%rsp), %xmm0
movups %xmm0, 0x28(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movq %r12, %rbx
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x2ec8a
leaq 0x30(%rsp), %rdi
callq 0x2ee0a
leaq 0x18(%rsp), %rdi
callq 0x2ee0a
movq %r13, %rdi
callq 0xa3a0
movq %rax, %r13
cmpq 0x40(%rsp), %rax
movq %r14, %r12
movq 0x38(%rsp), %rsi
jne 0x2e845
movq (%rsp), %rax
leaq 0x30(%rax), %r13
movq 0x30(%rax), %rbp
cmpq %r13, %rbp
je 0x2ea3d
leaq 0x8(%rbx), %r14
leaq 0x10(%rsp), %r15
movq 0x10(%rbp), %rsi
testq %rsi, %rsi
je 0x2eaa8
movq 0x20(%rsi), %rax
movq 0x20(%rax), %rcx
addq %r12, %rcx
movq 0x10(%rbx), %rax
movq %r14, %rdx
testq %rax, %rax
je 0x2e9b0
movq %rax, %rdi
movq %r14, %rdx
xorl %r8d, %r8d
cmpq %rcx, 0x20(%rdi)
setb %r8b
cmovaeq %rdi, %rdx
movq 0x10(%rdi,%r8,8), %rdi
testq %rdi, %rdi
jne 0x2e997
movq %r14, %rdi
cmpq %r14, %rdx
je 0x2e9c3
cmpq %rcx, 0x20(%rdx)
cmovaq %r14, %rdx
movq %rdx, %rdi
movq %rdi, 0x20(%rsp)
cmpq %r14, %rdi
je 0x2eac7
movq 0x28(%rsi), %rcx
movq 0x20(%rcx), %rcx
addq %r12, %rcx
movq %r14, %rdx
testq %rax, %rax
je 0x2e9ff
movq %r14, %rdx
xorl %edi, %edi
cmpq %rcx, 0x20(%rax)
setb %dil
cmovaeq %rax, %rdx
movq 0x10(%rax,%rdi,8), %rax
testq %rax, %rax
jne 0x2e9e7
movq %r14, %rax
cmpq %r14, %rdx
je 0x2ea12
cmpq %rcx, 0x20(%rdx)
cmovaq %r14, %rdx
movq %rdx, %rax
movq %rax, 0x10(%rsp)
cmpq %r14, %rax
je 0x2eae5
movq %rbx, %rdi
leaq 0x20(%rsp), %rdx
movq %r15, %rcx
callq 0x2e618
movq (%rbp), %rbp
cmpq %r13, %rbp
jne 0x2e96d
cmpb $0x0, 0xc(%rsp)
je 0x2ea54
movq (%rsp), %rax
movq 0x48(%rax), %rax
cmpq %rax, 0x48(%rbx)
jb 0x2ea60
jmp 0x2ea64
movq 0x48(%rbx), %rax
movq (%rsp), %rcx
addq 0x48(%rcx), %rax
movq %rax, 0x48(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11942(%rip), %rdi     # 0x403bc
leaq 0x11943(%rip), %rsi     # 0x403c4
leaq 0x11a5b(%rip), %rcx     # 0x404e3
jmp 0x2eabd
movl $0x10, %edi
callq 0xa160
movq %rax, %r14
leaq 0x11b38(%rip), %rsi     # 0x405d6
movq %rax, %rdi
callq 0xa110
jmp 0x2eb01
leaq 0x1190d(%rip), %rdi     # 0x403bc
leaq 0x1190e(%rip), %rsi     # 0x403c4
leaq 0x11933(%rip), %rcx     # 0x403f0
movl $0x2d8, %edx            # imm = 0x2D8
callq 0xa1f0
movl $0x10, %edi
callq 0xa160
movq %rax, %r14
leaq 0x11b21(%rip), %rsi     # 0x405fc
movq %rax, %rdi
callq 0xa110
jmp 0x2eb01
movl $0x10, %edi
callq 0xa160
movq %rax, %r14
leaq 0x11b2e(%rip), %rsi     # 0x40627
movq %rax, %rdi
callq 0xa110
movq 0x284e8(%rip), %rsi     # 0x56ff0
movq 0x28499(%rip), %rdx     # 0x56fa8
movq %r14, %rdi
callq 0xa580
jmp 0x2eb1b
jmp 0x2eb1b
movq %rax, %rbx
movq %r14, %rdi
callq 0xa270
jmp 0x2eb51
movq %rax, %rbx
movl $0x40, %esi
movq %r15, %rdi
callq 0xa330
jmp 0x2eb51
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2ee0a
leaq 0x18(%rsp), %rdi
callq 0x2ee0a
movq %rbx, %rdi
callq 0xa5c0
nop