// File: /workspace/github_cpp_makefile_star2_O2/adamnovak[P]rlcsa/rlcsa.cpp
// Function: CSA::RLCSA::processRun(std::pair<unsigned int, unsigned int>, unsigned int*, unsigned int*, bool*, CSA::RLEVector::Iterator**, bool) const
bool
RLCSA::processRun(pair_type run, usint* data, usint* offsets, bool* finished, PsiVector::Iterator** iters, bool steps) const
{
  bool found = true;
  usint run_start = 0, run_left = 0;
  pair_type next_sample = pair_type(0, 0);

  for(usint i = run.first; i <= run.second; i++)
  {
    if(finished[i])
    {
      if(run_left > 0) { run_left--; }
      continue;
    }
    if(data[i] < this->number_of_sequences) // Implicit sample here.
    {
      DeltaVector::Iterator iter(*(this->end_points));
      data[i] = (steps ? offsets[i] : iter.select(data[i]) + 1 - offsets[i]);
      finished[i] = true;
      if(run_left > 0) { run_left--; }
      continue;
    }
    if(next_sample.first < data[i]) // Need another sample.
    {
      next_sample = this->sa_samples->getFirstSampleAfter(data[i] - this->number_of_sequences);
      next_sample.first += this->number_of_sequences;
    }
    if(data[i] < next_sample.first) // No sample found for current position.
    {
      if(run_left > 0)
      {
        data[i] = data[run_start] + i - run_start;
        run_left--;
      }
      else
      {
        pair_type value = this->psi(data[i] - this->number_of_sequences, run.second - i, iters);
        data[i] = value.first;
        run_left = value.second;
        run_start = i;
      }
      offsets[i]++;
      found = false;
    }
    else  // Sampled position found.
    {
      data[i] = (steps ? offsets[i] : this->sa_samples->getSample(next_sample.second) - offsets[i]);
      finished[i] = true;
      if(run_left > 0) { run_left--; }
    }
  }
  return found;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r9, 0x48(%rsp)
movq %r8, %r14
movq %rcx, 0x18(%rsp)
movq %rsi, %r13
movq %rsi, %r8
shrq $0x20, %r8
movl %r8d, %ebx
subl %r13d, %ebx
movb $0x1, %al
movl %eax, 0x24(%rsp)
leaq 0x50(%rsp), %r12
xorl %r9d, %r9d
movq $0x0, 0x38(%rsp)
xorl %ebp, %ebp
movl $0x0, 0x20(%rsp)
movq %rdi, 0x8(%rsp)
movq %r8, 0x28(%rsp)
movq %rdx, 0x10(%rsp)
movq %r14, 0x40(%rsp)
cmpl %r8d, %r13d
ja 0x6ac2
movl %r13d, %r15d
cmpb $0x1, (%r14,%r15)
jne 0x6908
subl $0x1, %ebp
movl $0x0, %eax
cmovbl %eax, %ebp
jmp 0x6ab8
movl (%rdx,%r15,4), %esi
movl 0x820(%rdi), %ecx
movl %esi, %eax
subl %ecx, %eax
jae 0x6944
movl %r9d, 0x34(%rsp)
movq 0x828(%rdi), %rsi
movq %r12, %rdi
callq 0xf8d8
cmpb $0x0, 0x100(%rsp)
je 0x69a9
movq 0x18(%rsp), %rax
movl (%rax,%r15,4), %eax
jmp 0x69c5
cmpl %esi, %r9d
jae 0x6987
movq 0x8(%rsp), %rcx
movq 0x810(%rcx), %rdi
movl %eax, %esi
callq 0x88b2
movq 0x10(%rsp), %rdx
leaq 0x50(%rsp), %r12
movq 0x28(%rsp), %r8
movq 0x8(%rsp), %rdi
movl 0x820(%rdi), %ecx
leal (%rcx,%rax), %r9d
shrq $0x20, %rax
movq %rax, 0x38(%rsp)
movl (%rdx,%r15,4), %esi
cmpl %r9d, %esi
jae 0x6a09
testl %ebp, %ebp
je 0x6a6a
movl 0x20(%rsp), %ecx
movl %ecx, %eax
movl (%rdx,%rax,4), %eax
subl %ecx, %eax
addl %r13d, %eax
decl %ebp
jmp 0x6aa3
movq 0x10(%rsp), %rax
movl (%rax,%r15,4), %esi
movq %r12, %rdi
callq 0xf976
movq 0x18(%rsp), %rcx
subl (%rcx,%r15,4), %eax
incl %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
movq 0x40(%rsp), %r14
movb $0x1, (%r14,%r15)
subl $0x1, %ebp
movl $0x0, %eax
cmovbl %eax, %ebp
leaq 0x50(%rsp), %r12
movq %r12, %rdi
callq 0xf8de
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rdi
movq 0x28(%rsp), %r8
movl 0x34(%rsp), %r9d
jmp 0x6ab8
cmpb $0x0, 0x100(%rsp)
je 0x6a1e
movq 0x18(%rsp), %rax
movl (%rax,%r15,4), %eax
jmp 0x6a5c
movq 0x8(%rsp), %rax
movq 0x810(%rax), %rdi
movq 0x38(%rsp), %rsi
movl %r9d, %r14d
callq 0x893a
movl %r14d, %r9d
movq 0x40(%rsp), %r14
movq 0x10(%rsp), %rdx
leaq 0x50(%rsp), %r12
movq 0x28(%rsp), %r8
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rcx
subl (%rcx,%r15,4), %eax
movl %eax, (%rdx,%r15,4)
movb $0x1, (%r14,%r15)
jmp 0x68f8
subl %ecx, %esi
movq 0x8(%rsp), %rdi
movl %ebx, %edx
movq 0x48(%rsp), %rcx
movl %r9d, %ebp
callq 0x88fe
movl %ebp, %r9d
movq 0x10(%rsp), %rdx
leaq 0x50(%rsp), %r12
movq 0x28(%rsp), %r8
movq 0x8(%rsp), %rdi
movq %rax, %rbp
shrq $0x20, %rbp
movl %r13d, 0x20(%rsp)
movl %eax, (%rdx,%r15,4)
movq 0x18(%rsp), %rax
incl (%rax,%r15,4)
movl $0x0, 0x24(%rsp)
incl %r13d
decl %ebx
jmp 0x68e5
movl 0x24(%rsp), %eax
andb $0x1, %al
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xf8de
movq %rbx, %rdi
callq 0x3410
nop