// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movl %r9d, %r15d
movq %rdx, %r13
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
movq 0x70(%rsp), %rax
movq %rax, 0x18(%rsp)
leal (%r8,%r8), %edi
shrl $0x4, %r8d
subl %r8d, %edi
cmpq %rcx, %rdi
movq %rcx, %rbx
cmovaeq %rcx, %rdi
movq %rdi, %r12
callq 0x955fa
movq %rax, (%r14)
movl %r15d, %eax
movq %rax, 0x28(%rsp)
movq %r14, %r15
pushq $0x1
popq %rbp
movb $0x1, %r14b
movq %r12, 0x30(%rsp)
movq %rbx, 0x20(%rsp)
cmpq 0x10(%rsp), %rbp
jae 0x1715c1
movq -0x8(%r15,%rbp,8), %rax
movq %rax, (%r15,%rbp,8)
movq %r12, %rdi
callq 0x955fa
movq (%r15,%rbp,8), %rcx
leaq (%rax,%rcx), %rsi
incq %rsi
cmpq %rbx, %rsi
setb %al
movl $0x0, %ecx
cmovaeq %rcx, %rsi
andb %al, %r14b
movq %rsi, (%r15,%rbp,8)
movq %r13, %rdi
xorl %edx, %edx
callq 0x70e8f
testb %al, %al
jne 0x17152b
movq (%r15,%rbp,8), %rsi
movq %r13, %rdi
callq 0x74c9d
movb %r14b, 0xf(%rsp)
movq %r15, %r14
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0x74d9c
movq %rax, %rbx
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %r15
movb 0xf(%rsp), %r14b
callq 0x75173
movq (%r15,%rbp,8), %rcx
subq %rbx, %rcx
movq 0x20(%rsp), %rbx
movq 0x30(%rsp), %r12
subq 0x28(%rsp), %rax
cmpq %rax, %rcx
jae 0x17152b
incq %rbp
jmp 0x171517
testb $0x1, %r14b
je 0x1715f0
movq (%r15), %rsi
movq 0x10(%rsp), %rax
movq -0x8(%r15,%rax,8), %rdx
leaq 0x1db1d2(%rip), %rdi    # 0x34c7ad
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x92a82
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x171610
movq 0x2c68af(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x1db187(%rip), %rsi    # 0x34c792
callq 0xaf86f
movq %r15, %rdi
movq 0x10(%rsp), %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa07dd