// File: /workspace/github_cpp_makefile_star2_O1/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, 0x40(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, %r11
movq %rsi, %rdi
shrq $0x20, %rdi
movb $0x1, %al
cmpl %edi, %r13d
ja 0x7d9b
movq %rdx, %r12
movb $0x1, %al
movl %eax, 0x18(%rsp)
leaq 0x50(%rsp), %r14
movl $0x0, 0x14(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x38(%rsp)
movl $0x0, 0x1c(%rsp)
movq %r11, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movq %rdx, 0x48(%rsp)
movl %r13d, %r15d
movq 0x30(%rsp), %rax
cmpb $0x1, (%rax,%r15)
jne 0x7b4f
subl $0x1, %ebp
movl $0x0, %eax
cmovbl %eax, %ebp
jmp 0x7d23
movl (%r12,%r15,4), %eax
movl %eax, %ebx
subl 0x820(%r11), %ebx
jae 0x7b89
movq 0x828(%r11), %rsi
movq %r14, %rdi
callq 0x12744
cmpb $0x0, 0x100(%rsp)
je 0x7c10
movq 0x8(%rsp), %rax
movl (%rax,%r15,4), %eax
jmp 0x7c27
movl 0x1c(%rsp), %ecx
cmpl %eax, %ecx
movl %ecx, %eax
jae 0x7be2
movq 0x810(%r11), %rax
movq 0x10(%rax), %rsi
movq %r14, %r12
movq %r14, %rdi
callq 0x12744
movq %r14, %rdi
movl %ebx, %esi
callq 0x12be4
movq %rax, %rbx
movq %r12, %rdi
callq 0x1274a
movq %rbx, %rax
shrq $0x20, %rax
movq %rax, 0x38(%rsp)
movq 0x28(%rsp), %r11
movl 0x820(%r11), %eax
addl %ebx, %eax
movq 0x48(%rsp), %r12
movq 0x20(%rsp), %rdi
movl (%r12,%r15,4), %esi
cmpl %eax, %esi
movl %eax, 0x1c(%rsp)
jae 0x7c57
testl %ebp, %ebp
je 0x7cac
movl 0x14(%rsp), %edx
movl %edx, %eax
movl %r13d, %ecx
subl %edx, %ecx
addl (%r12,%rax,4), %ecx
movl %ecx, (%r12,%r15,4)
decl %ebp
jmp 0x7d12
movl (%r12,%r15,4), %esi
movq %r14, %rdi
callq 0x128f8
movq 0x8(%rsp), %rcx
subl (%rcx,%r15,4), %eax
incl %eax
movl %eax, (%r12,%r15,4)
movq 0x30(%rsp), %rax
movb $0x1, (%rax,%r15)
subl $0x1, %ebp
movl $0x0, %eax
cmovbl %eax, %ebp
movq %r14, %rdi
callq 0x1274a
movq 0x28(%rsp), %r11
movq 0x20(%rsp), %rdi
jmp 0x7d23
cmpb $0x0, 0x100(%rsp)
je 0x7c6f
movq 0x8(%rsp), %rax
movl (%rax,%r15,4), %eax
jmp 0x7d84
movq 0x810(%r11), %rsi
movq 0x18(%rsi), %r8
movl 0xc(%r8), %r10d
movl %r10d, %edx
imull 0x38(%rsp), %edx
movl %edx, %r9d
shrl $0x5, %r9d
andl $0x1f, %edx
movl $0x20, %ecx
subl %edx, %ecx
xorl %edi, %edi
movl %r10d, %eax
subl %ecx, %eax
jae 0x7d31
movl %r10d, %eax
jmp 0x7d4c
subl 0x820(%r11), %esi
movq 0x808(%r11), %rcx
movl %esi, %eax
xorl %edx, %edx
divl 0x1008(%rcx)
movl 0xc08(%rcx,%rax,4), %eax
leaq (%rcx,%rax,4), %rdx
addq $0x804, %rdx            # imm = 0x804
movl (%rdx), %eax
addq $0x4, %rdx
cmpl %esi, 0x4(%rcx,%rax,8)
jb 0x7cd6
movl %edi, %edx
subl %r13d, %edx
movq 0x40(%rsp), %rdi
movq (%rdi,%rax,8), %rdi
subl (%rcx,%rax,8), %esi
callq 0x13f52
movq 0x20(%rsp), %rdi
movq %rax, %rbp
movl %ebp, (%r12,%r15,4)
shrq $0x20, %rbp
movl %r13d, 0x14(%rsp)
movq 0x28(%rsp), %r11
movq 0x8(%rsp), %rax
incl (%rax,%r15,4)
movl $0x0, 0x18(%rsp)
incl %r13d
cmpl %edi, %r13d
jbe 0x7b30
jmp 0x7d97
movq (%r8), %rcx
movl %r9d, %edi
movl (%rcx,%rdi,4), %edi
movl %edx, %ecx
shll %cl, %edi
shrl %cl, %edi
movl %eax, %ecx
shll %cl, %edi
incl %r9d
movl $0x20, %ecx
testl %eax, %eax
je 0x7d68
subl %eax, %ecx
movq (%r8), %rdx
movl %r9d, %r8d
movl (%rdx,%r8,4), %edx
shrl %cl, %edx
negb %al
movl %eax, %ecx
shll %cl, %edx
shrl %cl, %edx
orl %edx, %edi
imull 0x4(%rsi), %edi
movl 0x8(%rsi), %eax
decl %eax
cmpl %edi, %eax
cmovael %edi, %eax
movq 0x8(%rsp), %rcx
subl (%rcx,%r15,4), %eax
movq 0x20(%rsp), %rdi
movl %eax, (%r12,%r15,4)
movq 0x30(%rsp), %rax
movb $0x1, (%rax,%r15)
jmp 0x7b3f
movl 0x18(%rsp), %eax
andb $0x1, %al
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7db1
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x1274a
movq %rbx, %rdi
callq 0x3460