// File: /workspace/github_c_makefile_star2_O1/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), %rbp
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 0x10ae3c
movq %rax, (%r14)
movb $0x1, %r12b
movq %rbx, (%rsp)
cmpq $0x2, %rbx
jb 0x1ca548
movq %rbp, 0x8(%rsp)
movl %r15d, %eax
movq %rax, 0x10(%rsp)
movb $0x1, %r12b
movl $0x1, %ebp
xorl %ebx, %ebx
movq -0x8(%r14,%rbp,8), %rax
movq %rax, (%r14,%rbp,8)
movq 0x18(%rsp), %rdi
callq 0x10ae3c
movq (%r14,%rbp,8), %rcx
leaq (%rax,%rcx), %rsi
incq %rsi
cmpq 0x20(%rsp), %rsi
cmovaeq %rbx, %rsi
movzbl %r12b, %r12d
cmovael %ebx, %r12d
movq %rsi, (%r14,%rbp,8)
movq %r13, %rdi
xorl %edx, %edx
callq 0xec754
testb %al, %al
jne 0x1ca4c3
movq (%r14,%rbp,8), %rsi
movq %r13, %rdi
callq 0xefc48
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0xefce0
movq %rax, %rbx
movq %r13, %rdi
movq %r15, %rsi
callq 0xeffd3
movq (%r14,%rbp,8), %rcx
subq %rbx, %rcx
xorl %ebx, %ebx
subq 0x10(%rsp), %rax
cmpq %rax, %rcx
jae 0x1ca4c3
incq %rbp
cmpq (%rsp), %rbp
jne 0x1ca4ba
movq 0x8(%rsp), %rbp
testb $0x1, %r12b
jne 0x1ca57e
testq %rbp, %rbp
je 0x1ca56c
movq 0x2f998e(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x1eb4de(%rip), %rsi    # 0x3b5a42
movq %rbp, %rdi
callq 0x1229c8
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x114e0b
testb $0x1, %r12b
je 0x1ca5a6
movq (%r14), %rsi
movq (%rsp), %rax
movq -0x8(%r14,%rax,8), %rdx
leaq 0x1eb4cc(%rip), %rdi    # 0x3b5a5d
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x108e02
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq