// File: /workspace/github_cpp_makefile_star2_O1/fpavetic[P]lcskpp/lcskpp.cpp
// Function: fill_lcskpp_reconstruction(std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>> const&, int, std::vector<int, std::allocator<int>> const&, int, int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>*)
static void fill_lcskpp_reconstruction(
    const vector<pair<int, int> >& matches,
    const int k,
    const vector<int>& prev_idx,
    const int last_idx,
    const int lcskpp_len,
    vector<pair<int, int> >* lcskpp_recon) {
  assert(lcskpp_recon != NULL);
  lcskpp_recon->clear();
  lcskpp_recon->reserve(lcskpp_len);

  for (int i = last_idx; i != -1; i = prev_idx[i]) {
    int r = matches[i].first+k-1;
    int c = matches[i].second+k-1;

    if (prev_idx[i] == -1 || 
        (matches[prev_idx[i]].first + k <= matches[i].first &&
         matches[prev_idx[i]].second + k <= matches[i].second)) {
      // Taking the entire match ...
      for (int j = 0; j < k; ++j, --r, --c) {
        lcskpp_recon->push_back(make_pair(r, c));
      }
    } else { 
      // ... otherwise it is a continuation. Only the
      // difference is taken.
      int curr = i;
      int prev = prev_idx[i];

      int curr_secondary_diag = 
        (matches[curr].first + matches[curr].second) / 2;
      int prev_secondary_diag = 
        (matches[prev].first + matches[prev].second) / 2;
      assert(prev_secondary_diag < curr_secondary_diag);

      for (int j = prev_secondary_diag; 
           j < curr_secondary_diag; ++j, --r, --c) {
        lcskpp_recon->push_back(make_pair(r, c));
      }
    }
  }

  reverse(lcskpp_recon->begin(), lcskpp_recon->end());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %rbx
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, (%rsp)
movq %rdi, 0x20(%rsp)
movq (%r9), %rax
cmpq %rax, 0x8(%r9)
je 0x3df4
movq %rax, 0x8(%rbx)
movslq %r8d, %rsi
movq %rbx, %rdi
callq 0x4b04
cmpl $-0x1, %ebp
je 0x3f26
movq (%rsp), %rax
decl %eax
movl %eax, 0xc(%rsp)
leaq 0x10(%rsp), %r13
movq %r14, 0x18(%rsp)
movslq %ebp, %rbp
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbp,8), %r12d
movl 0x4(%rax,%rbp,8), %r15d
movq (%r14), %rcx
movslq (%rcx,%rbp,4), %rcx
cmpq $-0x1, %rcx
je 0x3eca
movl (%rax,%rcx,8), %edx
movq (%rsp), %rsi
addl %edx, %esi
cmpl %r12d, %esi
jg 0x3e5b
movl 0x4(%rax,%rcx,8), %esi
addl (%rsp), %esi
cmpl %r15d, %esi
jle 0x3eca
leal (%r15,%r12), %esi
movl %esi, %r14d
shrl $0x1f, %r14d
addl %esi, %r14d
sarl %r14d
addl 0x4(%rax,%rcx,8), %edx
movl %edx, %eax
shrl $0x1f, %eax
addl %edx, %eax
sarl %eax
subl %eax, %r14d
jle 0x3f77
movl 0xc(%rsp), %eax
addl %eax, %r12d
addl %eax, %r15d
movq %r15, %rcx
shlq $0x20, %rcx
movl %r12d, %eax
orq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3eb2
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x3ebd
movq %rbx, %rdi
movq %r13, %rdx
callq 0x44ec
decl %r12d
decl %r15d
decl %r14d
jne 0x3e8c
jmp 0x3f12
cmpl $0x0, (%rsp)
jle 0x3f12
decl %r15d
decl %r12d
movq (%rsp), %r14
leal (%r15,%r14), %ecx
leal (%r12,%r14), %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3f02
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x3f0d
movq %rbx, %rdi
movq %r13, %rdx
callq 0x44ec
decl %r14d
jne 0x3eda
movq 0x18(%rsp), %r14
movq (%r14), %rax
movl (%rax,%rbp,4), %ebp
cmpl $-0x1, %ebp
jne 0x3e1c
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x8, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x3f68
movl (%rax), %edx
movl (%rcx), %esi
movl %esi, (%rax)
movl %edx, (%rcx)
movl 0x4(%rax), %edx
movl 0x4(%rcx), %esi
movl %esi, 0x4(%rax)
movl %edx, 0x4(%rcx)
addq $0x8, %rax
addq $-0x8, %rcx
cmpq %rcx, %rax
jb 0x3f47
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2582(%rip), %rdi      # 0x6500
leaq 0x2126(%rip), %rsi      # 0x60ab
leaq 0x24e4(%rip), %rcx      # 0x6470
movl $0x92, %edx
callq 0x20b0