// File: 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
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x1f0(%rbp)
movq %rdi, %rax
movq %rax, -0x1e8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x235d0
leaq -0x40(%rbp), %rdi
callq 0x235d0
leaq -0x58(%rbp), %rdi
callq 0x293c0
movl $0x0, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x275a0
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x27610
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x275d0
testb $0x1, %al
jne 0x1d7e6
jmp 0x1da88
leaq -0x68(%rbp), %rdi
callq 0x27640
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x27920
jmp 0x1d800
leaq -0x68(%rbp), %rdi
callq 0x27640
movq %rax, %rsi
leaq -0xc0(%rbp), %rdi
callq 0x27950
jmp 0x1d81a
leaq -0xe8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x10300
jmp 0x1d82f
leaq -0x28(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x1d6f0
movl %eax, -0x1f4(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x10460
movl -0x1f4(%rbp), %eax
movl %eax, -0xc4(%rbp)
cmpl $-0x1, -0xc4(%rbp)
jne 0x1d8fe
leaq -0x28(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x24d70
movq -0x200(%rbp), %rdi
movl %eax, -0xc4(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x23620
jmp 0x1d895
movl -0xc4(%rbp), %eax
incl %eax
movslq %eax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x293e0
jmp 0x1d8ab
jmp 0x1d8fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x1e072
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x1da77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x10460
jmp 0x1da77
leaq -0x110(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x10300
jmp 0x1d913
leaq -0x40(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x1d6f0
movl %eax, -0x204(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x10460
movl -0x204(%rbp), %eax
movl %eax, -0xec(%rbp)
cmpl $-0x1, -0xec(%rbp)
jne 0x1d98e
leaq -0x40(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x24d70
movq -0x210(%rbp), %rdi
movl %eax, -0xec(%rbp)
leaq -0xc0(%rbp), %rsi
callq 0x23620
jmp 0x1d975
movl -0xec(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jl 0x1d98c
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1d98e
movslq -0xec(%rbp), %rax
movq %rax, -0x218(%rbp)
movslq -0xc4(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x29470
movq %rax, %rdi
callq 0x254e0
movq %rax, %rcx
movq -0x218(%rbp), %rax
cmpq %rcx, %rax
jb 0x1da02
movslq -0xc4(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x29470
movq %rax, %rdi
movl -0xec(%rbp), %eax
incl %eax
movslq %eax, %rsi
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, -0x118(%rbp)
leaq -0x118(%rbp), %rdx
callq 0x29490
jmp 0x1da00
jmp 0x1da02
leaq -0x68(%rbp), %rdi
callq 0x27640
movq %rax, %rdi
callq 0x27660
movsd %xmm0, -0x220(%rbp)
jmp 0x1da1d
movslq -0xc4(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x29470
movq %rax, %rdi
movslq -0xec(%rbp), %rsi
callq 0x25500
movsd -0x220(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0xc0(%rbp), %rdi
callq 0x10460
leaq -0x90(%rbp), %rdi
callq 0x10460
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
callq 0x27810
movq %rax, -0x120(%rbp)
jmp 0x1d7c3
leaq -0x90(%rbp), %rdi
callq 0x10460
jmp 0x1e072
movslq -0x5c(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x29540
movq %rax, %rcx
movq -0x228(%rbp), %rax
cmpq %rcx, %rax
jae 0x1dab7
leaq -0x58(%rbp), %rdi
callq 0x29540
movl %eax, -0x5c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x29540
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x10040
movq %rax, -0x230(%rbp)
jmp 0x1dae4
movq -0x230(%rbp), %rax
movq %rax, -0x128(%rbp)
movl $0x0, -0x12c(%rbp)
movslq -0x12c(%rbp), %rax
movq %rax, -0x238(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x29540
movq %rax, %rcx
movq -0x238(%rbp), %rax
cmpq %rcx, %rax
jae 0x1dc4e
movslq -0x5c(%rbp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x10040
movq %rax, -0x240(%rbp)
jmp 0x1db4e
movq -0x240(%rbp), %rdx
movq -0x128(%rbp), %rax
movslq -0x12c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x130(%rbp)
movl -0x130(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x1dc38
movslq -0x130(%rbp), %rax
movq %rax, -0x248(%rbp)
movslq -0x12c(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x29470
movq %rax, %rdi
callq 0x254e0
movq %rax, %rcx
movq -0x248(%rbp), %rax
cmpq %rcx, %rax
jb 0x1dbdd
movq -0x128(%rbp), %rax
movslq -0x12c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x130(%rbp), %rcx
movss 0x9e5be(%rip), %xmm0    # 0xbc194
movss %xmm0, (%rax,%rcx,4)
jmp 0x1dc22
movslq -0x12c(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x29470
movq %rax, %rdi
movslq -0x130(%rbp), %rsi
callq 0x25500
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x128(%rbp), %rax
movslq -0x12c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x130(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x1dc24
movl -0x130(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x130(%rbp)
jmp 0x1db71
jmp 0x1dc3a
movl -0x12c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x12c(%rbp)
jmp 0x1dafc
movq -0x128(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x29540
movq -0x258(%rbp), %rdi
movq %rax, %rsi
movslq -0x5c(%rbp), %rdx
callq 0x1af90
movq %rax, -0x250(%rbp)
jmp 0x1dc81
movq -0x1f0(%rbp), %rdi
movq -0x250(%rbp), %rax
movq %rax, -0x138(%rbp)
movb $0x0, -0x139(%rbp)
callq 0x27ed0
movl $0x0, -0x140(%rbp)
movslq -0x140(%rbp), %rax
movq %rax, -0x260(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x29540
movq %rax, %rcx
movq -0x260(%rbp), %rax
cmpq %rcx, %rax
jae 0x1dfdf
movq -0x138(%rbp), %rax
movslq -0x140(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, -0x268(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x24d70
movq %rax, %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
jae 0x1df73
movq -0x138(%rbp), %rax
movslq -0x140(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, -0x270(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x24d70
movq %rax, %rcx
movq -0x270(%rbp), %rax
cmpq %rcx, %rax
jae 0x1df73
movq -0x138(%rbp), %rax
movslq -0x140(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
leaq -0x28(%rbp), %rdi
callq 0x24d90
movq %rax, %rsi
leaq -0x160(%rbp), %rdi
callq 0x10300
jmp 0x1dd76
movq -0x138(%rbp), %rax
movslq -0x140(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
leaq -0x40(%rbp), %rdi
callq 0x24d90
movq %rax, %rsi
leaq -0x180(%rbp), %rdi
callq 0x10300
jmp 0x1dda6
movq -0x10(%rbp), %rdi
callq 0x275a0
movq %rax, -0x188(%rbp)
movq -0x10(%rbp), %rdi
callq 0x27610
movq %rax, -0x190(%rbp)
leaq -0x188(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x275d0
testb $0x1, %al
jne 0x1dde2
jmp 0x1df3c
leaq -0x188(%rbp), %rdi
callq 0x27640
movq %rax, %rsi
movb $0x0, -0x1d1(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x27920
jmp 0x1de06
leaq -0x1b0(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x234b0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x271(%rbp)
jne 0x1de2a
jmp 0x1de67
leaq -0x188(%rbp), %rdi
callq 0x27640
movq %rax, %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x27950
jmp 0x1de47
movb $0x1, -0x1d1(%rbp)
leaq -0x1d0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x234b0
movb %al, -0x271(%rbp)
movb -0x271(%rbp), %al
movb %al, -0x272(%rbp)
testb $0x1, -0x1d1(%rbp)
jne 0x1de7e
jmp 0x1de8a
leaq -0x1d0(%rbp), %rdi
callq 0x10460
leaq -0x1b0(%rbp), %rdi
callq 0x10460
movb -0x272(%rbp), %al
testb $0x1, %al
jne 0x1dea2
jmp 0x1df20
leaq -0x188(%rbp), %rdi
callq 0x29570
movq -0x1f0(%rbp), %rdi
movq %rax, %rsi
callq 0x27f30
jmp 0x1debf
jmp 0x1df3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x1e066
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x1df62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x1df56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x10460
jmp 0x1df56
jmp 0x1df22
leaq -0x188(%rbp), %rdi
xorl %esi, %esi
callq 0x27810
movq %rax, -0x1e0(%rbp)
jmp 0x1ddb6
leaq -0x180(%rbp), %rdi
callq 0x10460
leaq -0x160(%rbp), %rdi
callq 0x10460
jmp 0x1df73
leaq -0x180(%rbp), %rdi
callq 0x10460
leaq -0x160(%rbp), %rdi
callq 0x10460
jmp 0x1e066
movq -0x138(%rbp), %rax
movslq -0x140(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x280(%rbp)
cmpq $0x0, %rax
je 0x1df9e
movq -0x280(%rbp), %rdi
callq 0x10940
movq -0x128(%rbp), %rax
movslq -0x140(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x288(%rbp)
cmpq $0x0, %rax
je 0x1dfc9
movq -0x288(%rbp), %rdi
callq 0x10940
jmp 0x1dfcb
movl -0x140(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x140(%rbp)
jmp 0x1dcac
movq -0x138(%rbp), %rax
movq %rax, -0x290(%rbp)
cmpq $0x0, %rax
je 0x1dfff
movq -0x290(%rbp), %rdi
callq 0x10940
movq -0x128(%rbp), %rax
movq %rax, -0x298(%rbp)
cmpq $0x0, %rax
je 0x1e01f
movq -0x298(%rbp), %rdi
callq 0x10940
movb $0x1, -0x139(%rbp)
testb $0x1, -0x139(%rbp)
jne 0x1e03b
movq -0x1f0(%rbp), %rdi
callq 0x27ff0
leaq -0x58(%rbp), %rdi
callq 0x29590
leaq -0x40(%rbp), %rdi
callq 0x236d0
leaq -0x28(%rbp), %rdi
callq 0x236d0
movq -0x1e8(%rbp), %rax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x1f0(%rbp), %rdi
callq 0x27ff0
leaq -0x58(%rbp), %rdi
callq 0x29590
leaq -0x40(%rbp), %rdi
callq 0x236d0
leaq -0x28(%rbp), %rdi
callq 0x236d0
movq -0x98(%rbp), %rdi
callq 0x10cc0
nopl (%rax)