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

  if(value >= par.size) { return pair_type(par.size, par.items); }

  this->getSample(this->sampleForValue(value));
  if(this->val > value) { return pair_type(par.size, par.items); }
  this->run = 0;

  while(this->cur < this->block_items && this->val < value)
  {
    usint temp = this->buffer.readDeltaCode(value - this->val);
    if(temp == 0) { break; }
    this->val += temp;

    temp = this->buffer.readDeltaCode();
    this->cur += temp;
    this->val += temp - 1;
  }
  if(this->val > value)
  {
    this->run = this->val - value;
    this->val = value;
    this->cur -= this->run;
  }

  return pair_type(this->val, this->sample.first + this->cur);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r15
movl (%r15), %eax
cmpl %esi, %eax
jbe 0x13f26
movl %esi, %ebx
movq %rdi, %r14
callq 0x12586
movq %r14, %rdi
movl %eax, %esi
callq 0x135a4
movl 0x18(%r14), %ebp
cmpl %ebx, %ebp
jbe 0x13f2f
movl (%r15), %eax
movl 0x4(%r15), %esi
jmp 0x141af
movl $0x0, 0x1c(%r14)
movl 0x14(%r14), %esi
movl 0x20(%r14), %eax
movl %eax, 0x4(%rsp)
cmpl %eax, %esi
jae 0x14191
movq 0x28(%r14), %r8
movl 0x40(%r14), %r10d
movl 0x44(%r14), %r15d
movl %ebx, %r12d
subl %ebp, %r12d
jbe 0x14191
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r10d, %r9d
movl %r15d, %eax
movl %eax, %ecx
decl %ecx
movl %ecx, 0x44(%r14)
movl %r9d, %eax
movl (%r8,%rax,4), %edi
je 0x13f83
movl %ecx, %eax
jmp 0x13f97
incl %r9d
movl %r9d, 0x40(%r14)
movl $0x20, 0x44(%r14)
movl $0x20, %eax
incl %edx
btl %ecx, %edi
jae 0x13f6e
movl %r10d, (%rsp)
movl $0x1, %r11d
movl %edx, %ecx
shll %cl, %r11d
xorl %r13d, %r13d
cmpl %edx, %eax
ja 0x13fe0
subl %eax, %edx
movl %r9d, %ecx
movl (%r8,%rcx,4), %r13d
negb %al
movl %eax, %ecx
shll %cl, %r13d
shrl %cl, %r13d
movl %edx, %ecx
shll %cl, %r13d
incl %r9d
movl %r9d, 0x40(%r14)
movl $0x20, 0x44(%r14)
movl $0x20, %eax
movl %r9d, %edi
testl %edx, %edx
je 0x14003
subl %edx, %eax
movl %eax, 0x44(%r14)
movl (%r8,%rdi,4), %r10d
movl %eax, %ecx
shrl %cl, %r10d
negb %dl
movl %edx, %ecx
shll %cl, %r10d
shrl %cl, %r10d
orl %r10d, %r13d
orl %r11d, %r13d
decl %r13d
xorl %r11d, %r11d
movl %r13d, %edx
subl %eax, %edx
jae 0x14018
movl %r13d, %edx
jmp 0x14037
movl (%r8,%rdi,4), %r11d
negb %al
movl %eax, %ecx
shll %cl, %r11d
shrl %cl, %r11d
movl %edx, %ecx
shll %cl, %r11d
incl %r9d
movl %r9d, 0x40(%r14)
movl $0x20, %eax
testl %edx, %edx
je 0x1405a
subl %edx, %eax
movl %eax, 0x44(%r14)
movl %r9d, %ecx
movl (%r8,%rcx,4), %edi
movl %eax, %ecx
shrl %cl, %edi
negb %dl
movl %edx, %ecx
shll %cl, %edi
shrl %cl, %edi
orl %r11d, %edi
movl %edi, %r11d
btsl %r13d, %r11d
cmpl %r12d, %r11d
ja 0x14186
addl %ebp, %r11d
movl %r11d, 0x18(%r14)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %eax, %ecx
decl %ecx
movl %ecx, 0x44(%r14)
movl %r9d, %eax
movl (%r8,%rax,4), %edi
je 0x14088
movl %ecx, %eax
jmp 0x1409c
incl %r9d
movl %r9d, 0x40(%r14)
movl $0x20, 0x44(%r14)
movl $0x20, %eax
incl %edx
btl %ecx, %edi
jae 0x14073
movl $0x1, %r10d
movl %edx, %ecx
shll %cl, %r10d
xorl %ebp, %ebp
cmpl %edx, %eax
ja 0x140dd
subl %eax, %edx
movl %r9d, %ecx
movl (%r8,%rcx,4), %ebp
negb %al
movl %eax, %ecx
shll %cl, %ebp
shrl %cl, %ebp
movl %edx, %ecx
shll %cl, %ebp
incl %r9d
movl %r9d, 0x40(%r14)
movl $0x20, 0x44(%r14)
movl $0x20, %eax
movl %r9d, %edi
testl %edx, %edx
je 0x14100
subl %edx, %eax
movl %eax, 0x44(%r14)
movl (%r8,%rdi,4), %r15d
movl %eax, %ecx
shrl %cl, %r15d
negb %dl
movl %edx, %ecx
shll %cl, %r15d
shrl %cl, %r15d
orl %r15d, %ebp
orl %r10d, %ebp
decl %ebp
xorl %r15d, %r15d
movl %ebp, %edx
subl %eax, %edx
jae 0x14115
movl %r9d, %r10d
movl %ebp, %edx
jmp 0x1413f
movl (%r8,%rdi,4), %r15d
negb %al
movl %eax, %ecx
shll %cl, %r15d
shrl %cl, %r15d
movl %edx, %ecx
shll %cl, %r15d
incl %r9d
movl %r9d, 0x40(%r14)
movl $0x20, 0x44(%r14)
movl $0x20, %eax
movl %r9d, %r10d
testl %edx, %edx
je 0x14162
subl %edx, %eax
movl %eax, 0x44(%r14)
movl %r9d, %ecx
movl (%r8,%rcx,4), %edi
movl %eax, %ecx
shrl %cl, %edi
negb %dl
movl %edx, %ecx
shll %cl, %edi
shrl %cl, %edi
orl %r15d, %edi
movl %edi, %r15d
btsl %ebp, %r15d
addl %r15d, %esi
movl %esi, 0x14(%r14)
leal (%r11,%r15), %ebp
decl %ebp
movl %ebp, 0x18(%r14)
movl %eax, %r15d
cmpl 0x4(%rsp), %esi
jb 0x13f57
jmp 0x14191
movl (%rsp), %eax
movl %eax, 0x40(%r14)
movl %r15d, 0x44(%r14)
movl %ebp, %eax
subl %ebx, %eax
jbe 0x141a7
movl %eax, 0x1c(%r14)
movl %ebx, 0x18(%r14)
subl %eax, %esi
movl %esi, 0x14(%r14)
jmp 0x141a9
movl %ebp, %ebx
addl 0xc(%r14), %esi
movl %ebx, %eax
shlq $0x20, %rsi
movl %eax, %eax
orq %rsi, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop