// File: /workspace/github_cpp_makefile_star2_O3/Kingsford-Group[P]ghost2/src/alignmentExtender.hpp
// Function: performMatching(std::vector<D_alpha, std::allocator<D_alpha>>&)
vector<D_alpha> performMatching(vector<D_alpha>& matches){
  vector<string> nodes1;
  vector<string> nodes2;

  vector<vector<double>> matrix;
  int maxwidth = 0;
  for(auto it = matches.begin(); it != matches.end(); it++){
    string s1 = it->get_n1(), s2 = it->get_n2();
    int i = find(nodes1, s1);
    if(i == -1){
      i = nodes1.size();
      nodes1.push_back(s1);
      matrix.resize(i+1);
    }
    int j = find(nodes2, s2);
    if(j == -1){
      j = nodes2.size();
      nodes2.push_back(s2);
      if(j >= maxwidth) maxwidth = j+1;
    }
    if(j >= matrix[i].size()) matrix[i].resize(j+1, 100);
    matrix[i][j] = it->get_da();
  }
  if(maxwidth < matrix.size()) maxwidth = matrix.size();

  float** mat = new float*[matrix.size()];
  for(int i = 0; i < matrix.size(); i++){
    mat[i] = new float[maxwidth];
    for(int j = 0; j < maxwidth; j++){
      if(j >= matrix[i].size()) mat[i][j] = 100;
      else mat[i][j] = matrix[i][j];
    }
  }
  ssize_t** res = kuhn_match(mat, matrix.size(), maxwidth);
  vector<D_alpha> ans;
  for(int i = 0; i < matrix.size(); i++){
    if(res[i][0] < nodes1.size() && res[i][1] < nodes2.size()){
      string a = nodes1[res[i][0]], b = nodes2[res[i][1]];
      for(auto it = matches.begin(); it != matches.end(); it++){
        if(it->get_n1() == a && it->get_n2() == b){
          ans.push_back(*it);
          break;
        }
      }
    }
    delete[] res[i];
    delete[] mat[i];
  }
  delete[] res;
  delete[] mat;
  return ans;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x48(%rsp)
xorl %r15d, %r15d
movq %r15, 0xb0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movq %r15, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movq %r15, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq (%rsi), %rbx
movl $0x0, %r14d
movl $0x0, %edx
movq %rsi, 0x78(%rsp)
cmpq 0x8(%rsi), %rbx
je 0x17358
leaq 0x38(%rsp), %rbp
leaq 0x18(%rsp), %r14
leaq 0x128(%rsp), %r12
movl $0x0, (%rsp)
leaq 0x118(%rsp), %r15
leaq 0xf8(%rsp), %r13
movq %rbp, 0x28(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x27846
movq %r14, 0x8(%rsp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x27846
movq %r12, 0x118(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x27846
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
callq 0x17026
movl %eax, %r15d
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x171a7
movq 0x128(%rsp), %rsi
incq %rsi
callq 0xc550
cmpl $-0x1, %r15d
leaq 0x108(%rsp), %r14
jne 0x17208
movq 0xa0(%rsp), %r14
movq 0xa8(%rsp), %r15
leaq 0xa0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1c08e
subq %r14, %r15
movq %r15, %rsi
shlq $0x1b, %rsi
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rsi
sarq $0x20, %rsi
leaq 0x60(%rsp), %rdi
callq 0x1e30e
shrq $0x5, %r15
leaq 0x108(%rsp), %r14
movq %r14, 0xf8(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x27846
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x17026
movl %eax, %r13d
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0x17255
movq 0x108(%rsp), %rsi
incq %rsi
callq 0xc550
cmpl $-0x1, %r13d
jne 0x17294
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %r13
leaq 0x80(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1c08e
subq %r14, %r13
shrq $0x5, %r13
leal 0x1(%r13), %eax
movl (%rsp), %ecx
cmpl %r13d, %ecx
cmovlel %eax, %ecx
movl %ecx, (%rsp)
movslq %r13d, %r14
movslq %r15d, %rax
movq 0x60(%rsp), %rcx
leaq (%rax,%rax,2), %r15
movq (%rcx,%r15,8), %rax
movq 0x8(%rcx,%r15,8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
ja 0x172ea
leaq (%rcx,%r15,8), %rdi
incl %r13d
movslq %r13d, %rsi
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, 0xb8(%rsp)
leaq 0xb8(%rsp), %rdx
callq 0x1e34a
movq 0x60(%rsp), %rax
movq (%rax,%r15,8), %rax
movsd 0x40(%rbx), %xmm0
movsd %xmm0, (%rax,%r14,8)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %r14
cmpq %r14, %rdi
je 0x17311
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x17328
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xc550
addq $0x50, %rbx
movq 0x78(%rsp), %rax
cmpq 0x8(%rax), %rbx
leaq 0x118(%rsp), %r15
leaq 0xf8(%rsp), %r13
jne 0x17127
movq 0x60(%rsp), %r15
movq 0x68(%rsp), %r14
movl (%rsp), %edx
movl %edx, %eax
movq %r14, %rsi
subq %r15, %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rsi
cmpq %rax, %rsi
movl %esi, %ebp
cmovbel %edx, %ebp
movq %rsi, %rax
shrq $0x3d, %rax
movq %rsi, 0x58(%rsp)
leaq (,%rsi,8), %rcx
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0xc040
movq %rax, (%rsp)
movslq %ebp, %rax
movq %rax, 0x50(%rsp)
cmpq %r15, %r14
je 0x17434
movq 0x50(%rsp), %rcx
leaq (,%rcx,4), %rax
testl %ecx, %ecx
movq $-0x1, %r13
cmovnsq %rax, %r13
movq 0x58(%rsp), %rbx
cmpq $0x1, %rbx
adcq $0x0, %rbx
movl %ecx, %r12d
xorl %r14d, %r14d
movq %r13, %rdi
callq 0xc040
movq (%rsp), %rcx
movq %rax, (%rcx,%r14,8)
testl %ebp, %ebp
jle 0x1742c
leaq (%r14,%r14,2), %rdx
movq (%r15,%rdx,8), %rcx
movq 0x8(%r15,%rdx,8), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
xorl %esi, %esi
movss 0x30e02(%rip), %xmm0    # 0x48214
cmpq %rsi, %rdx
jbe 0x1741f
xorps %xmm0, %xmm0
cvtsd2ss (%rcx,%rsi,8), %xmm0
movss %xmm0, (%rax,%rsi,4)
incq %rsi
cmpq %rsi, %r12
jne 0x1740a
incq %r14
cmpq %rbx, %r14
jne 0x173e0
movq (%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x15701
movq %rax, %r14
xorps %xmm0, %xmm0
movq 0x48(%rsp), %rax
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0x176cd
leaq 0xc8(%rsp), %rbx
xorl %r15d, %r15d
leaq 0xb8(%rsp), %rbp
movq %r14, 0x50(%rsp)
movq (%r14,%r15,8), %r13
movq (%r13), %rax
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rdx
subq %rcx, %rdx
sarq $0x5, %rdx
cmpq %rdx, %rax
jae 0x1768b
movq 0x88(%rsp), %rdx
subq 0x80(%rsp), %rdx
sarq $0x5, %rdx
cmpq %rdx, 0x8(%r13)
jae 0x1768b
shlq $0x5, %rax
leaq 0x38(%rsp), %rdx
movq %rdx, 0x28(%rsp)
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x27846
movq %r13, 0x58(%rsp)
movq 0x8(%r13), %rax
movq 0x80(%rsp), %rcx
shlq $0x5, %rax
leaq 0x18(%rsp), %rdx
movq %rdx, 0x8(%rsp)
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x27846
movq 0x78(%rsp), %rax
movq (%rax), %r13
cmpq 0x8(%rax), %r13
je 0x17649
movq %rbx, 0xb8(%rsp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x27846
movq 0xc0(%rsp), %rdx
cmpq 0x30(%rsp), %rdx
jne 0x1757b
testq %rdx, %rdx
je 0x17583
movq 0x28(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0xc570
testl %eax, %eax
je 0x17583
xorl %r14d, %r14d
jmp 0x1760c
leaq 0xe8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x20(%r13), %rsi
movq 0x28(%r13), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x27846
movq 0xe0(%rsp), %rdx
cmpq 0x10(%rsp), %rdx
jne 0x175dc
movq 0xd8(%rsp), %r12
testq %rdx, %rdx
je 0x175e9
movq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0xc570
testl %eax, %eax
sete %r14b
jmp 0x175ec
movq 0xd8(%rsp), %r12
xorl %r14d, %r14d
jmp 0x175ec
movb $0x1, %r14b
leaq 0xe8(%rsp), %rax
cmpq %rax, %r12
je 0x1760c
movq 0xe8(%rsp), %rsi
incq %rsi
movq %r12, %rdi
callq 0xc550
movq 0xb8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x17629
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0xc550
testb %r14b, %r14b
jne 0x1763c
addq $0x50, %r13
movq 0x78(%rsp), %rax
jmp 0x1752c
movq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x1dbaa
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
movq 0x50(%rsp), %r14
je 0x1766a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
movq 0x58(%rsp), %r13
je 0x1768b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xc550
movq %r13, %rdi
callq 0xc710
movq (%rsp), %rax
movq (%rax,%r15,8), %rdi
testq %rdi, %rdi
je 0x176a5
callq 0xc710
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
incq %r15
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %r15, %rax
ja 0x17485
movq %r14, %rdi
callq 0xc710
movq (%rsp), %rdi
callq 0xc710
leaq 0x60(%rsp), %rdi
callq 0x1e37e
leaq 0x80(%rsp), %rdi
callq 0x1c0cc
leaq 0xa0(%rsp), %rdi
callq 0x1c0cc
movq 0x48(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1775a
jmp 0x1775a
jmp 0x17799
movq %rax, %r14
jmp 0x177b8
movq %rax, %r14
jmp 0x177d4
jmp 0x17761
movq %rax, %r14
movq 0xb8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1779c
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0xc550
jmp 0x1779c
jmp 0x1775a
movq %rax, %r14
jmp 0x17780
movq %rax, %r14
jmp 0x177de
jmp 0x17761
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x17780
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x177de
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xc550
jmp 0x177de
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x177b8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x177d4
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x48(%rsp), %rdi
callq 0x1dc0a
leaq 0x60(%rsp), %rdi
callq 0x1e37e
leaq 0x80(%rsp), %rdi
callq 0x1c0cc
leaq 0xa0(%rsp), %rdi
callq 0x1c0cc
movq %r14, %rdi
callq 0xc9c0