// File: adamnovak[P]rlcsa/rlcsa.cpp
// Function: CSA::RLCSA::mergeEndPoints(CSA::RLCSA&, CSA::RLCSA&)
void
RLCSA::mergeEndPoints(RLCSA& index, RLCSA& increment)
{
  DeltaEncoder* endings = new DeltaEncoder(RLCSA::ENDPOINT_BLOCK_SIZE);

  DeltaVector::Iterator index_iter(*(index.end_points));
  DeltaVector::Iterator increment_iter(*(increment.end_points));

  endings->setBit(index_iter.select(0));
  for(usint i = 1; i < index.number_of_sequences; i++)
  {
    endings->setBit(index_iter.selectNext());
  }
  usint sum = index.end_points->getSize();
  delete index.end_points; index.end_points = 0;

  endings->setBit(sum + increment_iter.select(0));
  for(usint i = 1; i < increment.number_of_sequences; i++)
  {
    endings->setBit(sum + increment_iter.selectNext());
  }
  sum += increment.end_points->getSize();
  delete increment.end_points; increment.end_points = 0;

  this->end_points = new DeltaVector(*endings, sum);
  delete endings;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x140(%rbp)
movl $0x70, %edi
callq 0x32c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x138(%rbp)
movl $0x10, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x206f0
jmp 0x88ca
movq -0x138(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x828(%rax), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x200a0
movq -0x18(%rbp), %rax
movq 0x828(%rax), %rsi
leaq -0x120(%rbp), %rdi
callq 0x200a0
jmp 0x8905
movq -0x20(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
callq 0x20200
movl %eax, -0x144(%rbp)
jmp 0x8926
movl -0x144(%rbp), %esi
movq -0x150(%rbp), %rdi
callq 0x20740
jmp 0x893a
movl $0x1, -0x124(%rbp)
movl -0x124(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x820(%rcx), %eax
jae 0x89e4
movq -0x20(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x202a0
movl %eax, -0x154(%rbp)
jmp 0x8979
movl -0x154(%rbp), %esi
movq -0x160(%rbp), %rdi
callq 0x20740
jmp 0x898d
jmp 0x898f
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x8944
movq -0x138(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x70, %esi
callq 0x32d0
jmp 0x8c3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x8c31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x8c25
movq -0x10(%rbp), %rax
movq 0x828(%rax), %rdi
callq 0xe860
movl %eax, -0x164(%rbp)
jmp 0x89fc
movl -0x164(%rbp), %eax
movl %eax, -0x128(%rbp)
movq -0x10(%rbp), %rax
movq 0x828(%rax), %rax
movq %rax, -0x170(%rbp)
cmpq $0x0, %rax
je 0x8a3d
movq -0x170(%rbp), %rdi
callq 0x20050
movq -0x170(%rbp), %rdi
movl $0x48, %esi
callq 0x32d0
movq -0x10(%rbp), %rax
movq $0x0, 0x828(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x180(%rbp)
movl -0x128(%rbp), %eax
movl %eax, -0x178(%rbp)
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
callq 0x20200
movl %eax, -0x174(%rbp)
jmp 0x8a79
movq -0x180(%rbp), %rdi
movl -0x174(%rbp), %eax
movl -0x178(%rbp), %esi
addl %eax, %esi
callq 0x20740
jmp 0x8a95
movl $0x1, -0x12c(%rbp)
movl -0x12c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x820(%rcx), %eax
jae 0x8b0b
movq -0x20(%rbp), %rax
movq %rax, -0x190(%rbp)
movl -0x128(%rbp), %eax
movl %eax, -0x188(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x202a0
movl %eax, -0x184(%rbp)
jmp 0x8adc
movq -0x190(%rbp), %rdi
movl -0x184(%rbp), %eax
movl -0x188(%rbp), %esi
addl %eax, %esi
callq 0x20740
jmp 0x8af8
jmp 0x8afa
movl -0x12c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x12c(%rbp)
jmp 0x8a9f
movq -0x18(%rbp), %rax
movq 0x828(%rax), %rdi
callq 0xe860
movl %eax, -0x194(%rbp)
jmp 0x8b23
movl -0x194(%rbp), %eax
addl -0x128(%rbp), %eax
movl %eax, -0x128(%rbp)
movq -0x18(%rbp), %rax
movq 0x828(%rax), %rax
movq %rax, -0x1a0(%rbp)
cmpq $0x0, %rax
je 0x8b6a
movq -0x1a0(%rbp), %rdi
callq 0x20050
movq -0x1a0(%rbp), %rdi
movl $0x48, %esi
callq 0x32d0
movq -0x18(%rbp), %rax
movq $0x0, 0x828(%rax)
movl $0x48, %edi
callq 0x32c0
movq %rax, -0x1a8(%rbp)
jmp 0x8b8c
movq -0x1a8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x128(%rbp), %edx
callq 0x20020
jmp 0x8ba4
movq -0x140(%rbp), %rax
movq -0x1a8(%rbp), %rcx
movq %rcx, 0x828(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x1b0(%rbp)
cmpq $0x0, %rax
je 0x8be7
movq -0x1b0(%rbp), %rdi
callq 0x20720
movq -0x1b0(%rbp), %rdi
movl $0x70, %esi
callq 0x32d0
leaq -0x120(%rbp), %rdi
callq 0x200d0
leaq -0xa8(%rbp), %rdi
callq 0x200d0
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x48, %esi
callq 0x32d0
leaq -0x120(%rbp), %rdi
callq 0x200d0
leaq -0xa8(%rbp), %rdi
callq 0x200d0
movq -0x28(%rbp), %rdi
callq 0x3530
nopw %cs:(%rax,%rax)