// File: /workspace/github_cpp_makefile_star2_O1/adamnovak[P]rlcsa/bits/rlevector.cpp
// Function: CSA::RLEVector::Iterator::select(unsigned int)
usint
RLEVector::Iterator::select(usint index)
{
  const RLEVector& par = (const RLEVector&)(this->parent);

  if(index >= par.items) { return par.size; }
  this->getSample(this->sampleForIndex(index));
  this->run = 0;

  usint lim = index - this->sample.first;
  while(this->cur < lim)
  {
    this->val += this->buffer.readDeltaCode();
    usint temp = this->buffer.readDeltaCode();
    this->val += temp - 1;
    this->cur += temp;
  }
  if(this->cur > lim)
  {
    this->run = this->cur - lim;
    this->cur -= this->run;
    this->val -= this->run;
  }

  return this->val;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq (%rdi), %rax
cmpl %esi, 0x4(%rax)
jbe 0x138f3
movl %esi, %ebp
movq %rdi, %rbx
callq 0x120a8
movq %rbx, %rdi
movl %eax, %esi
callq 0x130d8
movl $0x0, 0x1c(%rbx)
subl 0xc(%rbx), %ebp
movl 0x14(%rbx), %esi
cmpl %ebp, %esi
jae 0x138df
movq 0x28(%rbx), %rdi
movl 0x44(%rbx), %eax
movl 0x40(%rbx), %r8d
movl 0x18(%rbx), %r9d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %eax, %ecx
decl %ecx
movl %ecx, 0x44(%rbx)
movl %r8d, %eax
movl (%rdi,%rax,4), %r10d
je 0x136ee
movl %ecx, %eax
jmp 0x13701
incl %r8d
movl %r8d, 0x40(%rbx)
movl $0x20, 0x44(%rbx)
movl $0x20, %eax
incl %edx
btl %ecx, %r10d
jae 0x136da
movl $0x1, %r11d
movl %edx, %ecx
shll %cl, %r11d
xorl %r10d, %r10d
cmpl %edx, %eax
ja 0x13746
subl %eax, %edx
movl %r8d, %ecx
movl (%rdi,%rcx,4), %r10d
negb %al
movl %eax, %ecx
shll %cl, %r10d
shrl %cl, %r10d
movl %edx, %ecx
shll %cl, %r10d
incl %r8d
movl %r8d, 0x40(%rbx)
movl $0x20, 0x44(%rbx)
movl $0x20, %eax
movl %r8d, %r14d
testl %edx, %edx
je 0x13768
subl %edx, %eax
movl %eax, 0x44(%rbx)
movl (%rdi,%r14,4), %r15d
movl %eax, %ecx
shrl %cl, %r15d
negb %dl
movl %edx, %ecx
shll %cl, %r15d
shrl %cl, %r15d
orl %r15d, %r10d
orl %r11d, %r10d
decl %r10d
xorl %r11d, %r11d
movl %r10d, %edx
subl %eax, %edx
jae 0x1377d
movl %r10d, %edx
jmp 0x137a3
movl (%rdi,%r14,4), %r11d
negb %al
movl %eax, %ecx
shll %cl, %r11d
shrl %cl, %r11d
movl %edx, %ecx
shll %cl, %r11d
incl %r8d
movl %r8d, 0x40(%rbx)
movl $0x20, 0x44(%rbx)
movl $0x20, %eax
testl %edx, %edx
je 0x137c5
subl %edx, %eax
movl %eax, 0x44(%rbx)
movl %r8d, %ecx
movl (%rdi,%rcx,4), %r14d
movl %eax, %ecx
shrl %cl, %r14d
negb %dl
movl %edx, %ecx
shll %cl, %r14d
shrl %cl, %r14d
orl %r14d, %r11d
btsl %r10d, %r11d
addl %r11d, %r9d
movl %r9d, 0x18(%rbx)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %eax, %ecx
decl %ecx
movl %ecx, 0x44(%rbx)
movl %r8d, %eax
movl (%rdi,%rax,4), %r10d
je 0x137e9
movl %ecx, %eax
jmp 0x137fc
incl %r8d
movl %r8d, 0x40(%rbx)
movl $0x20, 0x44(%rbx)
movl $0x20, %eax
incl %edx
btl %ecx, %r10d
jae 0x137d5
movl $0x1, %r11d
movl %edx, %ecx
shll %cl, %r11d
xorl %r10d, %r10d
cmpl %edx, %eax
ja 0x13841
subl %eax, %edx
movl %r8d, %ecx
movl (%rdi,%rcx,4), %r10d
negb %al
movl %eax, %ecx
shll %cl, %r10d
shrl %cl, %r10d
movl %edx, %ecx
shll %cl, %r10d
incl %r8d
movl %r8d, 0x40(%rbx)
movl $0x20, 0x44(%rbx)
movl $0x20, %eax
movl %r8d, %r14d
testl %edx, %edx
je 0x13863
subl %edx, %eax
movl %eax, 0x44(%rbx)
movl (%rdi,%r14,4), %r15d
movl %eax, %ecx
shrl %cl, %r15d
negb %dl
movl %edx, %ecx
shll %cl, %r15d
shrl %cl, %r15d
orl %r15d, %r10d
orl %r11d, %r10d
decl %r10d
xorl %r11d, %r11d
movl %r10d, %edx
subl %eax, %edx
jae 0x13878
movl %r10d, %edx
jmp 0x1389e
movl (%rdi,%r14,4), %r11d
negb %al
movl %eax, %ecx
shll %cl, %r11d
shrl %cl, %r11d
movl %edx, %ecx
shll %cl, %r11d
incl %r8d
movl %r8d, 0x40(%rbx)
movl $0x20, 0x44(%rbx)
movl $0x20, %eax
testl %edx, %edx
je 0x138c3
subl %edx, %eax
movl %eax, 0x44(%rbx)
movl %r8d, %ecx
movl (%rdi,%rcx,4), %r14d
movl %eax, %ecx
shrl %cl, %r14d
negb %dl
movl %edx, %ecx
shll %cl, %r14d
shrl %cl, %r14d
orl %r11d, %r14d
movl %r14d, %r11d
btsl %r10d, %r11d
addl %r11d, %r9d
decl %r9d
movl %r9d, 0x18(%rbx)
addl %r11d, %esi
movl %esi, 0x14(%rbx)
cmpl %ebp, %esi
jb 0x136d5
subl %ebp, %esi
jbe 0x138ec
movl %esi, 0x1c(%rbx)
movl %ebp, 0x14(%rbx)
subl %esi, 0x18(%rbx)
addq $0x18, %rbx
movq %rbx, %rax
movl (%rax), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq