// File: /workspace/github_cpp_makefile_star2_O1/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, 0x40(%rsp)
xorl %eax, %eax
movq %rax, 0xa0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq %rax, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
xorl %r12d, %r12d
movq %rax, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movq (%rsi), %rbx
movq %rsi, 0x68(%rsp)
cmpq 0x8(%rsi), %rbx
je 0x185ff
leaq 0x30(%rsp), %rbp
leaq 0x10(%rsp), %r14
leaq 0x128(%rsp), %r13
xorl %r12d, %r12d
movq %rbp, 0x20(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x28d6a
movq %r14, (%rsp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x28d6a
movq %r13, 0x118(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x118(%rsp), %rdi
callq 0x28d6a
leaq 0x90(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x18305
movl %eax, %r15d
movq 0x118(%rsp), %rdi
cmpq %r13, %rdi
je 0x1846b
movq 0x128(%rsp), %rsi
incq %rsi
callq 0xd550
cmpl $-0x1, %r15d
leaq 0x108(%rsp), %r14
leaq 0xf8(%rsp), %r13
jne 0x184dc
movq 0x90(%rsp), %r14
movq 0x98(%rsp), %r15
leaq 0x90(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1d38c
subq %r14, %r15
movq %r15, %rsi
shlq $0x1b, %rsi
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rsi
sarq $0x20, %rsi
leaq 0x50(%rsp), %rdi
callq 0x1f666
shrq $0x5, %r15
leaq 0x108(%rsp), %r14
leaq 0xf8(%rsp), %r13
movq %r14, 0xf8(%rsp)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x28d6a
leaq 0x70(%rsp), %rdi
movq %r13, %rsi
callq 0x18305
movl %eax, %r13d
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0x18525
movq 0x108(%rsp), %rsi
incq %rsi
callq 0xd550
cmpl $-0x1, %r13d
jne 0x18554
movq 0x70(%rsp), %r14
movq 0x78(%rsp), %r13
leaq 0x70(%rsp), %rdi
movq %rsp, %rsi
callq 0x1d38c
subq %r14, %r13
shrq $0x5, %r13
leal 0x1(%r13), %eax
cmpl %r13d, %r12d
cmovlel %eax, %r12d
movslq %r13d, %r14
movslq %r15d, %rcx
movq 0x50(%rsp), %rax
leaq (%rcx,%rcx,2), %r15
movq 0x8(%rax,%r15,8), %rcx
subq (%rax,%r15,8), %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
ja 0x1859e
leaq (%rax,%r15,8), %rdi
incl %r13d
movslq %r13d, %rsi
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, 0xb8(%rsp)
leaq 0xb8(%rsp), %rdx
callq 0x1f6a2
movsd 0x40(%rbx), %xmm0
movq 0x50(%rsp), %rax
movq (%rax,%r15,8), %rax
movsd %xmm0, (%rax,%r14,8)
movq (%rsp), %rdi
leaq 0x10(%rsp), %r14
cmpq %r14, %rdi
je 0x185cd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xd550
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
leaq 0x128(%rsp), %r13
je 0x185ec
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xd550
addq $0x50, %rbx
movq 0x68(%rsp), %rax
cmpq 0x8(%rax), %rbx
jne 0x183e4
movq %r12, %rdx
movl %edx, %eax
movq 0x50(%rsp), %rbp
movq 0x58(%rsp), %rbx
movq %rbx, %rsi
subq %rbp, %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rsi
cmpq %rax, %rsi
movl %esi, %r12d
cmovbel %edx, %r12d
movq %rsi, %rax
shrq $0x3d, %rax
movq %rsi, 0xb0(%rsp)
leaq (,%rsi,8), %rcx
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0xd040
movq %rax, 0x48(%rsp)
movslq %r12d, %rax
movq %rax, 0xa8(%rsp)
cmpq %rbp, %rbx
je 0x186f9
movq 0xa8(%rsp), %rcx
leaq (,%rcx,4), %rax
testl %ecx, %ecx
movq $-0x1, %r13
cmovnsq %rax, %r13
movq 0xb0(%rsp), %r15
cmpq $0x1, %r15
adcq $0x0, %r15
movl %ecx, %ebx
xorl %r14d, %r14d
movq %r13, %rdi
callq 0xd040
movq 0x48(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
testl %r12d, %r12d
jle 0x186f1
leaq (%r14,%r14,2), %rdx
movq (%rbp,%rdx,8), %rcx
movq 0x8(%rbp,%rdx,8), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
xorl %esi, %esi
movss 0x30b0d(%rip), %xmm0    # 0x491e4
cmpq %rsi, %rdx
jbe 0x186e4
xorps %xmm0, %xmm0
cvtsd2ss (%rcx,%rsi,8), %xmm0
movss %xmm0, (%rax,%rsi,4)
incq %rsi
cmpq %rsi, %rbx
jne 0x186cf
incq %r14
cmpq %r15, %r14
jne 0x186a2
movq 0x48(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0x169a3
movq %rax, %r12
xorps %xmm0, %xmm0
movq 0x40(%rsp), %rax
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
je 0x18985
leaq 0xc8(%rsp), %r13
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rcx
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rdx, (%rcx)
jae 0x1893c
movq 0x78(%rsp), %rdx
subq 0x70(%rsp), %rdx
sarq $0x5, %rdx
cmpq %rdx, 0x8(%rcx)
jae 0x1893c
movq (%rcx), %rcx
shlq $0x5, %rcx
leaq 0x30(%rsp), %rdx
movq %rdx, 0x20(%rsp)
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x28d6a
movq (%r12,%rbx,8), %rax
movq 0x8(%rax), %rax
movq 0x70(%rsp), %rcx
shlq $0x5, %rax
leaq 0x10(%rsp), %rdx
movq %rdx, (%rsp)
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x28d6a
movq 0x68(%rsp), %rax
movq (%rax), %rbp
cmpq 0x8(%rax), %rbp
je 0x18905
movq %r13, 0xb8(%rsp)
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x28d6a
movq 0xc0(%rsp), %rdx
cmpq 0x28(%rsp), %rdx
jne 0x18834
testq %rdx, %rdx
je 0x18839
movq 0x20(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0xd570
testl %eax, %eax
sete %r15b
jmp 0x1883c
xorl %r15d, %r15d
jmp 0x1883c
movb $0x1, %r15b
testb %r15b, %r15b
je 0x18896
leaq 0xe8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x20(%rbp), %rsi
movq 0x28(%rbp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x28d6a
movq 0xe0(%rsp), %rdx
cmpq 0x8(%rsp), %rdx
jne 0x18896
testq %rdx, %rdx
je 0x188f3
movq (%rsp), %rsi
movq 0xd8(%rsp), %rdi
callq 0xd570
testl %eax, %eax
sete %r14b
jmp 0x18899
xorl %r14d, %r14d
testb %r15b, %r15b
je 0x188c3
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x188c3
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0xd550
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x188e0
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0xd550
testb %r14b, %r14b
jne 0x188f8
addq $0x50, %rbp
movq 0x68(%rsp), %rax
jmp 0x187dc
movb $0x1, %r14b
jmp 0x18899
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x1eecc
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x18920
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xd550
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x1893c
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xd550
movq (%r12,%rbx,8), %rdi
testq %rdi, %rdi
je 0x1894a
callq 0xd710
movq 0x48(%rsp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x1895d
callq 0xd710
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
incq %rbx
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rbx, %rax
ja 0x18743
movq %r12, %rdi
callq 0xd710
movq 0x48(%rsp), %rdi
callq 0xd710
leaq 0x50(%rsp), %rdi
callq 0x1f6d6
leaq 0x70(%rsp), %rdi
callq 0x1d3ca
leaq 0x90(%rsp), %rdi
callq 0x1d3ca
movq 0x40(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x189ee
jmp 0x189ee
jmp 0x18a51
movq %rax, %r14
jmp 0x18a6f
movq %rax, %r14
jmp 0x18a8b
jmp 0x18a1a
jmp 0x189ee
movq %rax, %r14
jmp 0x18a38
movq %rax, %r14
jmp 0x18a95
movq %rax, %r14
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x18a54
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0xd550
jmp 0x18a54
jmp 0x18a1a
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x18a38
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xd550
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x18a95
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xd550
jmp 0x18a95
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x18a6f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xd550
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x18a8b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xd550
movq 0x40(%rsp), %rdi
callq 0x1ef2c
leaq 0x50(%rsp), %rdi
callq 0x1f6d6
leaq 0x70(%rsp), %rdi
callq 0x1d3ca
leaq 0x90(%rsp), %rdi
callq 0x1d3ca
movq %r14, %rdi
callq 0xd9c0