// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movl %esi, %r15d
movq %rdi, 0x20(%rsp)
movq (%r9), %rax
cmpq %rax, 0x8(%r9)
je 0x3de9
movq %rax, 0x8(%rbx)
movslq %r8d, %rsi
movq %rbx, %rdi
callq 0x4b0a
cmpl $-0x1, %ebp
je 0x3f20
leal -0x1(%r15), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
leaq 0x18(%rsp), %r13
movq %r15, 0x10(%rsp)
movslq %ebp, %rbp
movq 0x20(%rsp), %rcx
movq (%rcx), %rdx
movl (%rdx,%rbp,8), %r12d
movl 0x4(%rdx,%rbp,8), %r14d
movslq (%rax,%rbp,4), %rax
cmpq $-0x1, %rax
je 0x3e4e
movl (%rdx,%rax,8), %ecx
movl 0x4(%rdx,%rax,8), %eax
leal (%rcx,%r15), %edx
cmpl %r12d, %edx
jg 0x3e9c
leal (%rax,%r15), %edx
cmpl %r14d, %edx
jg 0x3e9c
testl %r15d, %r15d
jle 0x3f07
decl %r14d
decl %r12d
movq 0x10(%rsp), %r15
leal (%r14,%r15), %ecx
leal (%r12,%r15), %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3e8a
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x3e95
movq %rbx, %rdi
movq %r13, %rdx
callq 0x44f4
decl %r15d
jne 0x3e62
jmp 0x3f07
leal (%r14,%r12), %edx
movl %edx, %r15d
shrl $0x1f, %r15d
addl %edx, %r15d
sarl %r15d
addl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
subl %ecx, %r15d
jle 0x3f71
movl 0x4(%rsp), %eax
addl %eax, %r12d
addl %eax, %r14d
movq %r14, %rcx
shlq $0x20, %rcx
movl %r12d, %eax
orq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3ef1
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x3efc
movq %rbx, %rdi
movq %r13, %rdx
callq 0x44f4
decl %r12d
decl %r14d
decl %r15d
jne 0x3ecb
movq 0x8(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbp,4), %ebp
cmpl $-0x1, %ebp
movq 0x10(%rsp), %r15
jne 0x3e17
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 0x3f62
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 0x3f41
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2588(%rip), %rdi      # 0x6500
leaq 0x212c(%rip), %rsi      # 0x60ab
leaq 0x24ea(%rip), %rcx      # 0x6470
movl $0x92, %edx
callq 0x20b0