// File: /workspace/github_cpp_makefile_star2_O3/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, 0x38(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, %r11
movq %rsi, %rdi
shrq $0x20, %rdi
movb $0x1, %al
movl %eax, 0x14(%rsp)
cmpl %edi, %r13d
jbe 0x7bc3
movl 0x14(%rsp), %eax
andb $0x1, %al
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
movl %eax, 0x14(%rsp)
leaq 0x50(%rsp), %rbx
movl $0x0, 0x24(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x40(%rsp)
xorl %r14d, %r14d
movq %r11, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
movl %r13d, %r15d
movq 0x38(%rsp), %rax
cmpb $0x1, (%rax,%r15)
jne 0x7c0d
subl $0x1, %ebp
movl $0x0, %eax
cmovbl %eax, %ebp
jmp 0x7dfc
movq %rbx, %r12
movq 0x8(%rsp), %rax
movl (%rax,%r15,4), %esi
movl 0x820(%r11), %eax
movl %esi, %ebx
subl %eax, %ebx
jae 0x7c54
movq 0x828(%r11), %rsi
movq %r12, %rbx
movq %r12, %rdi
callq 0x12ac0
cmpb $0x0, 0x100(%rsp)
je 0x7cdc
movq 0x18(%rsp), %rax
movl (%rax,%r15,4), %eax
jmp 0x7cf8
cmpl %esi, %r14d
jae 0x7cae
movq 0x810(%r11), %rax
movq 0x10(%rax), %rsi
movq %r12, %r14
movq %r12, %rdi
callq 0x12ac0
movq %r12, %rdi
movl %ebx, %esi
callq 0x130a2
movq %rax, %rbx
movq %r14, %rdi
callq 0x12ac6
movq %rbx, %rax
shrq $0x20, %rax
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %r11
movl 0x820(%r11), %eax
leal (%rax,%rbx), %r14d
movq 0x8(%rsp), %rcx
movl (%rcx,%r15,4), %esi
movq 0x28(%rsp), %rdi
cmpl %r14d, %esi
jae 0x7d2d
testl %ebp, %ebp
movq %r12, %rbx
je 0x7d85
movl 0x24(%rsp), %edx
movl %edx, %eax
movl %r13d, %ecx
subl %edx, %ecx
movq 0x8(%rsp), %rdx
addl (%rdx,%rax,4), %ecx
movl %ecx, (%rdx,%r15,4)
decl %ebp
jmp 0x7deb
movq 0x8(%rsp), %rax
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
callq 0x12c6e
movq 0x18(%rsp), %rcx
subl (%rcx,%r15,4), %eax
incl %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
movq 0x38(%rsp), %rax
movb $0x1, (%rax,%r15)
subl $0x1, %ebp
movl $0x0, %eax
cmovbl %eax, %ebp
movq %rbx, %rdi
callq 0x12ac6
movq 0x30(%rsp), %r11
movq 0x28(%rsp), %rdi
jmp 0x7dfc
cmpb $0x0, 0x100(%rsp)
movq %r12, %rbx
je 0x7d48
movq 0x18(%rsp), %rax
movl (%rax,%r15,4), %eax
jmp 0x7e60
movq 0x810(%r11), %rsi
movq 0x18(%rsi), %r8
movl 0xc(%r8), %r10d
movl %r10d, %edx
imull 0x40(%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 0x7e0d
movl %r10d, %eax
jmp 0x7e28
subl %eax, %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 0x7daa
movl %edi, %edx
subl %r13d, %edx
movq 0x48(%rsp), %rdi
movq (%rdi,%rax,8), %rdi
subl (%rcx,%rax,8), %esi
callq 0x14468
movq 0x28(%rsp), %rdi
movq %rax, %rbp
movq 0x8(%rsp), %rcx
movl %ebp, (%rcx,%r15,4)
shrq $0x20, %rbp
movl %r13d, 0x24(%rsp)
movq 0x30(%rsp), %r11
movq 0x18(%rsp), %rax
incl (%rax,%r15,4)
movl $0x0, 0x14(%rsp)
incl %r13d
cmpl %edi, %r13d
jbe 0x7bee
jmp 0x7bab
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 0x7e44
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 0x18(%rsp), %rcx
subl (%rcx,%r15,4), %eax
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
movq 0x38(%rsp), %rax
movb $0x1, (%rax,%r15)
jmp 0x7bfd
jmp 0x7e7a
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x12ac6
movq %rbx, %rdi
callq 0x3460
nop