// File: Kingsford-Group[P]ghost2/src/alignmentExtender.hpp
// Function: extendAlignment(D_alpha, Graph&, Graph&, boost::bimaps::bimap<boost::bimaps::unordered_set_of<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, boost::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, boost::bimaps::unordered_set_of<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, boost::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, mpl_::na, mpl_::na, mpl_::na>*, std::vector<D_alpha, std::allocator<D_alpha>>&, boost::unordered::unordered_map<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, D_alpha, boost::hash<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::equal_to<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::allocator<std::pair<std::pair<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, D_alpha>>>&, int)
void extendAlignment(D_alpha seed, Graph& g1, Graph& g2, bmap *alignment, vector<D_alpha>& dalphas, distmap& d, int k)
{
  vector<D_alpha> maxP;
  maxP.push_back(seed);

  while(!maxP.empty()){
    D_alpha best = maxP.front();
    pop_heap(maxP.begin(), maxP.end(), CompareD_alphaL());
    maxP.pop_back();
    insertIfBetter(alignment, best, d);
    
    vlist *neighbors1 = g1.neighbors2(best.get_n1());
    vlist *neighbors2 = g2.neighbors2(best.get_n2());

    vector<D_alpha> matches = computePairwiseScores(neighbors1, neighbors2, *alignment, d, k);
    if(matches.size() == 0) continue;

    //Do the alignment problem
    matches = performMatching(matches);
    //Filter out matches that are already aligned or have D_seq>beta
    auto end = remove_if(matches.begin(), matches.end(), checkSeq);

    for(auto it = matches.begin(); it != end; ++it){
      alignment->insert(bmap::value_type(it->get_n1(), it->get_n2()));
      maxP.push_back(*it);
      push_heap(maxP.begin(), maxP.end(), CompareD_alphaL());
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x268(%rbp)
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x27ed0
movq -0x270(%rbp), %rdi
movq -0x268(%rbp), %rsi
callq 0x27f30
jmp 0x1e122
jmp 0x1e124
leaq -0x48(%rbp), %rdi
callq 0x295f0
xorb $-0x1, %al
testb $0x1, %al
jne 0x1e138
jmp 0x1e5d7
leaq -0x48(%rbp), %rdi
callq 0x290e0
movq %rax, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x28950
jmp 0x1e152
leaq -0x48(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x275a0
movq -0x278(%rbp), %rdi
movq %rax, -0xb0(%rbp)
callq 0x27610
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x29110
jmp 0x1e191
leaq -0x48(%rbp), %rdi
callq 0x29180
movq -0x20(%rbp), %rax
movq %rax, -0x280(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x28950
jmp 0x1e1ba
movq -0x280(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq -0x110(%rbp), %rsi
callq 0x1cbe0
jmp 0x1e1d3
leaq -0x110(%rbp), %rdi
callq 0x27fc0
movq -0x10(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0x138(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x27920
jmp 0x1e1ff
movq -0x288(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x24cb0
movq %rax, -0x290(%rbp)
jmp 0x1e21b
leaq -0x138(%rbp), %rdi
callq 0x10460
movq -0x290(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x27950
jmp 0x1e255
movq -0x298(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x24cb0
movq %rax, -0x2a0(%rbp)
jmp 0x1e271
leaq -0x160(%rbp), %rdi
callq 0x10460
movq -0x2a0(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x118(%rbp), %rsi
movq -0x140(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %r8
movl 0x10(%rbp), %r9d
leaq -0x178(%rbp), %rdi
callq 0x1d190
jmp 0x1e2b3
leaq -0x178(%rbp), %rdi
callq 0x27750
cmpq $0x0, %rax
jne 0x1e351
movl $0x2, -0x17c(%rbp)
jmp 0x1e58f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e5e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e5c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x27fc0
jmp 0x1e5c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x10460
jmp 0x1e5c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x10460
jmp 0x1e5c9
leaq -0x198(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x1d770
jmp 0x1e366
leaq -0x178(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
leaq -0x198(%rbp), %rsi
movq %rsi, -0x2b8(%rbp)
callq 0x29630
movq -0x2b8(%rbp), %rdi
callq 0x27ff0
movq -0x2b0(%rbp), %rdi
callq 0x275a0
movq -0x2b0(%rbp), %rdi
movq %rax, -0x1a8(%rbp)
callq 0x27610
movq %rax, -0x1b0(%rbp)
movq -0x1a8(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
leaq -0x32e(%rip), %rdx      # 0x1e0a0
callq 0x29660
movq %rax, -0x2a8(%rbp)
jmp 0x1e3dc
movq -0x2a8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x275a0
movq %rax, -0x1b8(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x275d0
testb $0x1, %al
jne 0x1e419
jmp 0x1e585
movq -0x20(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x27640
movq %rax, %rsi
leaq -0x218(%rbp), %rdi
callq 0x27920
jmp 0x1e441
leaq -0x1b8(%rbp), %rdi
callq 0x27640
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x27950
jmp 0x1e45e
leaq -0x1f8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
leaq -0x238(%rbp), %rdx
callq 0x28f40
jmp 0x1e47a
movq -0x2c0(%rbp), %rsi
leaq -0x248(%rbp), %rdi
leaq -0x1f8(%rbp), %rdx
callq 0x28e90
jmp 0x1e496
leaq -0x1f8(%rbp), %rdi
callq 0x28f70
leaq -0x238(%rbp), %rdi
callq 0x10460
leaq -0x218(%rbp), %rdi
callq 0x10460
leaq -0x1b8(%rbp), %rdi
callq 0x29570
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x27f30
jmp 0x1e4d4
leaq -0x48(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x275a0
movq -0x2c8(%rbp), %rdi
movq %rax, -0x250(%rbp)
callq 0x27610
movq %rax, -0x258(%rbp)
movq -0x250(%rbp), %rdi
movq -0x258(%rbp), %rsi
callq 0x28fd0
jmp 0x1e513
jmp 0x1e515
leaq -0x1b8(%rbp), %rdi
callq 0x296b0
jmp 0x1e3fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e5bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e577
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1e56b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x28f70
leaq -0x238(%rbp), %rdi
callq 0x10460
leaq -0x218(%rbp), %rdi
callq 0x10460
jmp 0x1e5bd
movl $0x0, -0x17c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x27ff0
leaq -0xa8(%rbp), %rdi
callq 0x27fc0
movl -0x17c(%rbp), %eax
testl %eax, %eax
je 0x1e5b8
jmp 0x1e5b3
jmp 0x1e124
jmp 0x1e124
leaq -0x178(%rbp), %rdi
callq 0x27ff0
leaq -0xa8(%rbp), %rdi
callq 0x27fc0
jmp 0x1e5e9
leaq -0x48(%rbp), %rdi
callq 0x27ff0
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x27ff0
movq -0x50(%rbp), %rdi
callq 0x10cc0
nopl (%rax,%rax)