// File: kdungs[P]codecon/src/matching.cc
// Function: matchingPositions(std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>> const&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>> const&)
std::vector<std::size_t> matchingPositions(const Rows& original, const Rows& modified) {
  assert(original.size() == modified.size());
  auto positions = std::vector<std::size_t>{};
  positions.reserve(original.size());

  auto ps = std::vector<std::size_t>(original.size());
  std::iota(std::begin(ps), std::end(ps), 0u);

  for (const auto& orow : original) {
    std::sort(std::begin(ps), std::end(ps),
              [&orow, &modified](const std::size_t l, const std::size_t r) {
                return distance(orow, modified[l]) >
                       distance(orow, modified[r]);
              });
    positions.push_back(ps.back());
    ps.pop_back();
  }

  return positions;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xb8(%rbp)
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4590
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4590
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jne 0x2802
jmp 0x2821
leaq 0x684e(%rip), %rdi      # 0x9057
leaq 0x680d(%rip), %rsi      # 0x901d
movl $0x25, %edx
leaq 0x685e(%rip), %rcx      # 0x907a
callq 0x2110
movq -0xb8(%rbp), %rdi
movb $0x0, -0x19(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x45c0
movq -0x10(%rbp), %rdi
callq 0x4590
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x45e0
jmp 0x2859
movq -0x10(%rbp), %rdi
callq 0x4590
movq %rax, -0xc8(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x46e0
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x4700
jmp 0x2892
leaq -0x49(%rbp), %rdi
callq 0x4770
leaq -0x48(%rbp), %rdi
callq 0x47f0
movq %rax, -0xd0(%rbp)
jmp 0x28ad
movq -0xd0(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4820
movq %rax, -0xd8(%rbp)
jmp 0x28ca
movq -0xd8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x4790
jmp 0x28e6
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4850
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4880
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x48b0
testb $0x1, %al
jne 0x291e
jmp 0x2a11
leaq -0x70(%rbp), %rdi
callq 0x48f0
movq %rax, -0x80(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x47f0
movq %rax, -0xe0(%rbp)
jmp 0x293d
movq -0xe0(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4820
movq %rax, -0xe8(%rbp)
jmp 0x295d
movq -0xe8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq -0x98(%rbp), %rcx
callq 0x2a60
jmp 0x29a4
leaq -0x48(%rbp), %rdi
callq 0x4980
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x4910
jmp 0x29be
leaq -0x48(%rbp), %rdi
callq 0x49c0
leaq -0x70(%rbp), %rdi
callq 0x49f0
jmp 0x2908
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x4770
jmp 0x2a40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4a10
jmp 0x2a40
movb $0x1, -0x19(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4a10
testb $0x1, -0x19(%rbp)
jne 0x2a30
movq -0xb8(%rbp), %rdi
callq 0x4a10
movq -0xb0(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
movq -0xb8(%rbp), %rdi
callq 0x4a10
movq -0x28(%rbp), %rdi
callq 0x2230
nopw %cs:(%rax,%rax)