// File: /workspace/github_cpp_makefile_star2_O2/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, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0x60(%rsp), %rbx
andq $0x0, 0x10(%rbx)
movaps %xmm0, (%rax)
movaps %xmm0, (%rbx)
leaq 0x20(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq %rsi, 0x18(%rsp)
movq (%rsi), %rbp
movl $0x0, (%rsp)
leaq 0x98(%rsp), %r12
leaq 0xd8(%rsp), %r13
movq 0x18(%rsp), %rax
cmpq 0x8(%rax), %rbp
je 0x15a2e
movq %r12, %rdi
movq %rbp, %rsi
callq 0xe7a0
addq $0x20, %rbp
leaq 0x78(%rsp), %rdi
movq %rbp, %rsi
callq 0xe7a0
leaq 0xf8(%rsp), %rdi
movq %r12, %rsi
callq 0xe7a0
leaq 0x40(%rsp), %rdi
leaq 0xf8(%rsp), %r14
movq %r14, %rsi
callq 0x157f5
movl %eax, %r15d
movq %r14, %rdi
callq 0xe290
cmpl $-0x1, %r15d
jne 0x15947
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %r15
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x186ec
subq %r14, %r15
movq %r15, %rsi
shlq $0x1b, %rsi
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rsi
sarq $0x20, %rsi
leaq 0x20(%rsp), %rdi
callq 0x1a2ca
shrq $0x5, %r15
movq %r13, %r14
movq %rbx, %r13
movq %r14, %rdi
leaq 0x78(%rsp), %rsi
callq 0xe7a0
movq %r13, %rbx
movq %r13, %rdi
movq %r14, %rsi
callq 0x157f5
movl %eax, %r12d
movq %r14, %rdi
callq 0xe290
cmpl $-0x1, %r12d
jne 0x159a8
movq 0x60(%rsp), %r14
movq 0x68(%rsp), %r12
movq %rbx, %rdi
leaq 0x78(%rsp), %rsi
callq 0x186ec
subq %r14, %r12
shrq $0x5, %r12
leal 0x1(%r12), %eax
movl (%rsp), %ecx
cmpl %r12d, %ecx
cmovlel %eax, %ecx
movl %ecx, (%rsp)
movslq %r12d, %r14
movslq %r15d, %rax
movq 0x20(%rsp), %rdi
imulq $0x18, %rax, %r15
movq (%rdi,%r15), %rax
movq 0x8(%rdi,%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
ja 0x159fd
addq %r15, %rdi
incl %r12d
movslq %r12d, %rsi
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, 0xb8(%rsp)
leaq 0xb8(%rsp), %rdx
callq 0x1a300
movq 0x20(%rsp), %rax
movq (%rax,%r15), %rax
movsd 0x20(%rbp), %xmm0
movsd %xmm0, (%rax,%r14,8)
leaq 0x78(%rsp), %rdi
callq 0xe290
leaq 0x98(%rsp), %r12
movq %r12, %rdi
callq 0xe290
addq $0x30, %rbp
movq %r13, %rbx
jmp 0x1589e
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rax
subq %r14, %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %rbx
shrq $0x3d, %rax
leaq (,%rbx,8), %rcx
xorl %r13d, %r13d
negq %rax
movl $0x0, %edi
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0xe040
movq %rax, 0x10(%rsp)
movl (%rsp), %ecx
movl %ecx, %eax
cmpq %rax, %rbx
movl %ebx, %eax
cmovbel %ecx, %eax
movslq %eax, %r12
leaq (,%r12,4), %rax
testl %r12d, %r12d
pushq $-0x1
popq %r15
cmovnsq %rax, %r15
movl $0x0, %ebp
cmovgl %r12d, %ebp
cmpq %rbx, %r13
je 0x15aec
movq %r15, %rdi
callq 0xe040
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r13,8)
imulq $0x18, %r13, %rcx
addq %r14, %rcx
xorl %edx, %edx
cmpq %rdx, %rbp
je 0x15ae7
movq (%rcx), %rsi
movq 0x8(%rcx), %rdi
subq %rsi, %rdi
sarq $0x3, %rdi
movss 0x2a725(%rip), %xmm0    # 0x401f8
cmpq %rdx, %rdi
jbe 0x15add
cvtsd2ss (%rsi,%rdx,8), %xmm0
movss %xmm0, (%rax,%rdx,4)
incq %rdx
jmp 0x15ab8
incq %r13
jmp 0x15a99
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1459c
movq %rax, (%rsp)
xorps %xmm0, %xmm0
movq 0x8(%rsp), %rax
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorl %r14d, %r14d
leaq 0x98(%rsp), %r12
leaq 0xb8(%rsp), %rbp
leaq 0x118(%rsp), %rbx
movq 0x28(%rsp), %rax
subq 0x20(%rsp), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %r14, %rax
jbe 0x15c66
movq (%rsp), %rax
movq (%rax,%r14,8), %r15
movq (%r15), %rax
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rcx
subq %rsi, %rcx
sarq $0x5, %rcx
cmpq %rcx, %rax
jae 0x15c43
movq 0x68(%rsp), %rcx
subq 0x60(%rsp), %rcx
sarq $0x5, %rcx
cmpq %rcx, 0x8(%r15)
jae 0x15c43
shlq $0x5, %rax
addq %rax, %rsi
movq %r12, %rdi
callq 0xe7a0
movq 0x8(%r15), %rsi
shlq $0x5, %rsi
addq 0x60(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0xe7a0
movq 0x18(%rsp), %rax
movq (%rax), %r15
movq 0x18(%rsp), %rax
cmpq 0x8(%rax), %r15
je 0x15c24
movq %rbp, %rdi
movq %r15, %rsi
callq 0xe7a0
movq %rbp, %rdi
movq %r12, %rsi
callq 0x186a9
testb %al, %al
je 0x15c09
leaq 0x20(%r15), %rsi
movq %rbx, %rdi
callq 0xe7a0
movq %rbx, %rdi
leaq 0x78(%rsp), %rsi
callq 0x186a9
movl %eax, %r13d
movq %rbx, %rdi
callq 0xe290
movq %rbp, %rdi
callq 0xe290
testb %r13b, %r13b
je 0x15c11
jmp 0x15c17
movq %rbp, %rdi
callq 0xe290
addq $0x50, %r15
jmp 0x15bb1
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x19cbc
leaq 0x78(%rsp), %rdi
callq 0xe290
movq %r12, %rdi
callq 0xe290
movq (%rsp), %rax
movq (%rax,%r14,8), %r15
testq %r15, %r15
je 0x15c4b
movq %r15, %rdi
callq 0xe720
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x15c5e
callq 0xe720
incq %r14
jmp 0x15b2b
movq (%rsp), %rdi
callq 0xe720
movq 0x10(%rsp), %rdi
callq 0xe720
leaq 0x20(%rsp), %rdi
callq 0x1a334
leaq 0x60(%rsp), %rdi
callq 0x18718
leaq 0x40(%rsp), %rdi
callq 0x18718
movq 0x8(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15cc2
jmp 0x15cc2
jmp 0x15cfc
movq %rax, %rbx
jmp 0x15d16
movq %rax, %rbx
jmp 0x15d09
jmp 0x15cce
jmp 0x15cc2
movq %rax, %rbx
jmp 0x15d20
movq %rax, %rbx
jmp 0x15cdb
jmp 0x15cce
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0xe290
leaq 0x98(%rsp), %rdi
callq 0xe290
jmp 0x15d20
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xe290
jmp 0x15cff
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0xe290
leaq 0x98(%rsp), %rdi
callq 0xe290
movq 0x8(%rsp), %rdi
callq 0x19cfe
leaq 0x20(%rsp), %rdi
callq 0x1a334
leaq 0x60(%rsp), %rdi
callq 0x18718
leaq 0x40(%rsp), %rdi
callq 0x18718
movq %rbx, %rdi
callq 0xe9f0