// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/randomcodes.c
// Function: gt_randomcodes_generate_sampling_positions
static void gt_randomcodes_generate_sampling_positions(GtUword *buffer,
    GtUword numofsamples, const GtEncseq *encseq,
    GtUword totallength, unsigned int sampling_factor,
    unsigned int bucketkeysize, bool sort, GtTimer *timer)
{
  GtUword i, randmax;
  bool sorted = true;
  randmax = (GtUword)(GT_MULT2(sampling_factor) -
      GT_DIV16(sampling_factor));
  if (randmax >= totallength)
    randmax = totallength;
  buffer[0] = gt_rand_max(randmax);
  for (i = 1UL; i < numofsamples; i++)
  {
    GtUword sn, sp, sl, rp;
    buffer[i] = buffer[i-1];
    while (true)
    {
      buffer[i] += (gt_rand_max(randmax) + 1UL);
      if (buffer[i] >= totallength)
      {
        buffer[i] = 0;
        sorted = false;
      }
      if (!gt_encseq_position_is_separator(encseq, buffer[i],
            GT_READMODE_FORWARD))
      {
        sn = gt_encseq_seqnum(encseq, buffer[i]);
        sp = gt_encseq_seqstartpos(encseq, sn);
        sl = gt_encseq_seqlength(encseq, sn);
        rp = buffer[i] - sp;
        if (rp < sl - bucketkeysize)
          break;
      }
    }
  }
  if (sort && !sorted)
  {
    if (timer != NULL)
      gt_timer_show_progress(timer, "to sort sampling positions", stdout);
    gt_radixsort_inplace_ulong(buffer, numofsamples);
  }
  if (sorted)
  {
    gt_log_log("range of sampling positions = [" GT_WU ", " GT_WU "]",
        buffer[0], buffer[numofsamples - 1]);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %r15d
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
movq 0x60(%rsp), %r12
leal (%r8,%r8), %edi
shrl $0x4, %r8d
subl %r8d, %edi
cmpq %rcx, %rdi
movq %rcx, 0x20(%rsp)
cmovaeq %rcx, %rdi
movq %rdi, 0x18(%rsp)
callq 0x105d85
movq %rax, (%r14)
cmpq $0x2, %rbx
jb 0x1c1743
movq %r12, (%rsp)
movl %r15d, %eax
movq %rax, 0x10(%rsp)
movb $0x1, %r12b
movl $0x1, %ebp
xorl %r15d, %r15d
movq %rbx, 0x8(%rsp)
movq -0x8(%r14,%rbp,8), %rax
movq %rax, (%r14,%rbp,8)
movq 0x18(%rsp), %rdi
callq 0x105d85
movq (%r14,%rbp,8), %rcx
leaq (%rax,%rcx), %rsi
incq %rsi
cmpq 0x20(%rsp), %rsi
setb %al
cmovaeq %r15, %rsi
andb %al, %r12b
movq %rsi, (%r14,%rbp,8)
movq %r13, %rdi
xorl %edx, %edx
callq 0xe811c
testb %al, %al
jne 0x1c16b8
movq (%r14,%rbp,8), %rsi
movq %r13, %rdi
callq 0xeb655
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0xeb6ee
movq %rax, %rbx
movq %r13, %rdi
movq %r15, %rsi
xorl %r15d, %r15d
callq 0xeb9d2
movq (%r14,%rbp,8), %rcx
subq %rbx, %rcx
subq 0x10(%rsp), %rax
cmpq %rax, %rcx
jae 0x1c16b8
incq %rbp
movq 0x8(%rsp), %rbx
cmpq %rbx, %rbp
jne 0x1c16af
testb %r12b, %r12b
je 0x1c1767
movq (%r14), %rax
movq -0x8(%r14,%rbx,8), %rdx
leaq 0x1eacfe(%rip), %rdi    # 0x3ac44d
movq %rax, %rsi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x103d72
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1c1786
movq 0x2f7761(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x1eacb1(%rip), %rsi    # 0x3ac432
callq 0x11cc90
movq %r14, %rdi
movq %rbx, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f85a