// File: /workspace/github_cpp_makefile_star2_O3/adamnovak[P]rlcsa/rlcsa.cpp
// Function: CSA::RLCSA::locateUnsafe(std::pair<unsigned int, unsigned int>, unsigned int*, bool) const
void
RLCSA::locateUnsafe(pair_type range, usint* data, bool steps) const
{
  this->convertToBWTRange(range);
  usint items = length(range);
  usint* offsets = new usint[items];
  bool* finished = new bool[items];  // FIXME This could be more space efficient...

  PsiVector::Iterator** iters = this->getIterators();

  for(usint i = 0, j = range.first; i < items; i++, j++)
  {
    data[i] = j;
    offsets[i] = 0;
    finished[i] = false;
  }

  bool found = false;
  while(!found)
  {
    found = true;
    pair_type run = EMPTY_PAIR;
    for(usint i = 0; i < items; i++)
    {
      if(finished[i])
      {
        continue; // The run might continue after this.
      }
      else if(isEmpty(run))
      {
        run = pair_type(i, i);
      }
      else if(data[i] - data[run.first] == i - run.first)
      {
        run.second = i;
      }
      else
      {
        found &= this->processRun(run, data, offsets, finished, iters, steps);
        run = pair_type(i, i);
      }
    }
    if(!isEmpty(run)) { found &= this->processRun(run, data, offsets, finished, iters, steps); }
  }

  this->deleteIterators(iters);
  delete[] offsets;
  delete[] finished;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, 0xc(%rsp)
movq %rdx, %rbx
movq %rdi, %r15
movq %rsi, 0x18(%rsp)
movq %rsi, %r12
shrq $0x20, %r12
movl 0x820(%rdi), %ebp
incl %r12d
movl %r12d, %r14d
subl %esi, %r14d
leaq (,%r14,4), %rdi
callq 0x3030
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x3030
movq %rax, %r13
movq %r15, 0x28(%rsp)
movq %r15, %rdi
callq 0x732a
movq 0x18(%rsp), %r8
movq %rax, 0x20(%rsp)
movq %r12, 0x30(%rsp)
cmpl %r8d, %r12d
jne 0x7551
cmpl $0x2, %r14d
movl $0x1, %eax
cmovael %r14d, %eax
jmp 0x7696
cmpq $0x1, %r14
movq %r14, %r12
adcq $0x0, %r12
leaq (,%r12,4), %rdx
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x3150
movq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x3150
movq 0x18(%rsp), %r8
cmpl $0x2, %r14d
movl $0x1, %eax
cmovael %r14d, %eax
leaq 0x3(%rax), %rcx
andq $-0x4, %rcx
leaq -0x1(%rax), %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
addl %r8d, %ebp
movdqa 0x10d7d(%rip), %xmm1    # 0x18330
movdqa 0x10d85(%rip), %xmm2    # 0x18340
movdqa 0x10d8d(%rip), %xmm3    # 0x18350
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x10d8d(%rip), %xmm5    # 0x18360
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x760f
leaq (%r15,%rbp), %rdx
movl %edx, (%rbx,%r15,4)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x7628
leal (%r15,%rbp), %edx
incl %edx
movl %edx, 0x4(%rbx,%r15,4)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x766b
leal (%r15,%rbp), %edx
addl $0x2, %edx
movl %edx, 0x8(%rbx,%r15,4)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x7681
leal (%r15,%rbp), %edx
addl $0x3, %edx
movl %edx, 0xc(%rbx,%r15,4)
addq $0x4, %r15
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
cmpq %r15, %rcx
jne 0x75d3
cmpl %r8d, 0x30(%rsp)
je 0x777c
movl %eax, %r15d
movl $0x1, %eax
xorl %r14d, %r14d
movb $0x1, %bpl
movzbl 0xc(%rsp), %ecx
movl %ecx, 0xc(%rsp)
xorl %r12d, %r12d
xorl %esi, %esi
cmpb $0x0, (%r13,%r14)
jne 0x7711
cmpl %esi, %eax
ja 0x770b
movl %eax, %ecx
movl (%rbx,%r14,4), %edx
subl (%rbx,%rcx,4), %edx
movl %r12d, %edi
subl %eax, %edi
cmpl %edi, %edx
je 0x770e
shlq $0x20, %rsi
orq %rcx, %rsi
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
movq 0x28(%rsp), %rdi
movq %rbx, %rdx
movq 0x10(%rsp), %rcx
movq %r13, %r8
movq 0x20(%rsp), %r9
callq 0x7b6e
movq 0x18(%rsp), %r8
andb %al, %bpl
movl %r14d, %eax
movl %r14d, %esi
incq %r14
incl %r12d
cmpq %r15, %r14
jne 0x76bd
cmpl %esi, %eax
ja 0x7755
shlq $0x20, %rsi
movl %eax, %eax
orq %rsi, %rax
movl 0xc(%rsp), %ecx
movl %ecx, (%rsp)
movq 0x28(%rsp), %rdi
movq %rax, %rsi
movq %rbx, %rdx
movq 0x10(%rsp), %rcx
movq %r13, %r8
movq 0x20(%rsp), %r9
callq 0x7b6e
movq 0x18(%rsp), %r8
andb %al, %bpl
cmpl %r8d, 0x30(%rsp)
je 0x777c
xorl %r14d, %r14d
movl $0x0, %r12d
movl $0x0, %esi
movl $0x1, %eax
testb $0x1, %bpl
movb $0x1, %bpl
je 0x76bd
movq 0x20(%rsp), %rsi
callq 0x73a2
movq 0x10(%rsp), %rdi
callq 0x3300
movq %r13, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3300