// File: /workspace/github_cpp_makefile_star2_O3/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
movl %edx, 0x1c(%rsp)
testl %edx, %edx
jne 0x2d58b
movq 0x48(%rbx), %r12
jmp 0x2d58e
xorl %r12d, %r12d
movq 0x18(%rsi), %r13
movq %rsi, 0x10(%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x40(%rsp)
cmpq %rax, %r13
je 0x2d69b
leaq 0x8(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%r13), %rbp
addq %r12, %rbp
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x2d5ef
movq 0x20(%rsp), %rcx
xorl %edx, %edx
cmpq %rbp, 0x20(%rax)
setb %dl
cmovaeq %rax, %rcx
movq 0x10(%rax,%rdx,8), %rax
testq %rax, %rax
jne 0x2d5c7
cmpq 0x20(%rsp), %rcx
je 0x2d5ef
cmpq 0x20(%rcx), %rbp
jae 0x2d83d
movl $0x40, %edi
callq 0x9310
movq %rax, %r15
movq 0x28(%r13), %rax
testq %rax, %rax
je 0x2d7d1
movq 0x20(%r13), %r14
leaq 0x10(%r15), %rcx
movq %rcx, (%r15)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2ac50
addq %r12, %r14
movq %r14, 0x20(%r15)
movq %r15, %rax
addq $0x28, %rax
movq %rax, 0x30(%r15)
movq %rax, 0x28(%r15)
movq $0x0, 0x38(%r15)
movq %rsp, %rdi
movq %r15, %rsi
callq 0x2d97c
movq %rbp, 0x28(%rsp)
movaps (%rsp), %xmm0
movups %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
callq 0x2d9ca
leaq 0x38(%rsp), %rdi
callq 0x2db42
leaq 0x8(%rsp), %rdi
callq 0x2db42
movq %r13, %rdi
callq 0x93a0
movq %rax, %r13
cmpq 0x40(%rsp), %rax
jne 0x2d5b2
movq 0x10(%rsp), %rax
leaq 0x30(%rax), %r13
movq 0x30(%rax), %rbp
cmpq %r13, %rbp
je 0x2d776
leaq 0x8(%rbx), %r14
movq %rsp, %r15
movq 0x10(%rbp), %rsi
testq %rsi, %rsi
je 0x2d7e8
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x2d7ae
movq 0x20(%rsi), %rcx
movq 0x20(%rcx), %rcx
addq %r12, %rcx
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 0x2d6e3
cmpq %r14, %rdx
je 0x2d7ae
cmpq %rcx, 0x20(%rdx)
cmovaq %r14, %rdx
movq %rdx, 0x28(%rsp)
ja 0x2d7b3
movq 0x28(%rsi), %rcx
movq 0x20(%rcx), %rcx
addq %r12, %rcx
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 0x2d726
cmpq %r14, %rdx
je 0x2d807
cmpq %rcx, 0x20(%rdx)
cmovaq %r14, %rdx
movq %rdx, (%rsp)
ja 0x2d80b
movq %rbx, %rdi
leaq 0x28(%rsp), %rdx
movq %r15, %rcx
callq 0x2d384
movq (%rbp), %rbp
cmpq %r13, %rbp
jne 0x2d6b8
cmpb $0x0, 0x1c(%rsp)
je 0x2d78e
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
cmpq %rax, 0x48(%rbx)
jb 0x2d79b
jmp 0x2d79f
movq 0x48(%rbx), %rax
movq 0x10(%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
movq %r14, 0x28(%rsp)
movl $0x10, %edi
callq 0x9160
movq %rax, %r14
leaq 0x11e35(%rip), %rsi     # 0x3f5fc
movq %rax, %rdi
callq 0x9110
jmp 0x2d827
leaq 0x11be4(%rip), %rdi     # 0x3f3bc
leaq 0x11be5(%rip), %rsi     # 0x3f3c4
leaq 0x11cfd(%rip), %rcx     # 0x3f4e3
jmp 0x2d7fd
leaq 0x11bcd(%rip), %rdi     # 0x3f3bc
leaq 0x11bce(%rip), %rsi     # 0x3f3c4
leaq 0x11bf3(%rip), %rcx     # 0x3f3f0
movl $0x2d8, %edx            # imm = 0x2D8
callq 0x91f0
movq %r14, (%rsp)
movl $0x10, %edi
callq 0x9160
movq %rax, %r14
leaq 0x11e08(%rip), %rsi     # 0x3f627
movq %rax, %rdi
callq 0x9110
movq 0x287c2(%rip), %rsi     # 0x55ff0
movq 0x28773(%rip), %rdx     # 0x55fa8
movq %r14, %rdi
callq 0x9580
movl $0x10, %edi
callq 0x9160
movq %rax, %r14
leaq 0x11d85(%rip), %rsi     # 0x3f5d6
movq %rax, %rdi
callq 0x9110
jmp 0x2d827
jmp 0x2d88a
jmp 0x2d88a
movq %rax, %rbx
movl $0x40, %esi
movq %r15, %rdi
callq 0x9330
jmp 0x2d895
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x2db42
leaq 0x8(%rsp), %rdi
callq 0x2db42
jmp 0x2d895
movq %rax, %rbx
movq %r14, %rdi
callq 0x9270
movq %rbx, %rdi
callq 0x95c0
nop