// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x68, %rsp
movq 0x78(%rsp), %rax
movb 0x70(%rsp), %al
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movl %r8d, 0x44(%rsp)
movl %r9d, 0x40(%rsp)
andb $0x1, %al
movb %al, 0x3f(%rsp)
movb $0x1, 0x27(%rsp)
movl 0x44(%rsp), %eax
shll %eax
movl 0x44(%rsp), %ecx
shrl $0x4, %ecx
subl %ecx, %eax
movl %eax, %eax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
cmpq 0x48(%rsp), %rax
jb 0x2705e2
movq 0x48(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0xec350
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
movq $0x1, 0x30(%rsp)
movq 0x30(%rsp), %rax
cmpq 0x58(%rsp), %rax
jae 0x27072c
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rdx
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rsp), %rdi
callq 0xec350
movq %rax, %rdx
addq $0x1, %rdx
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpq 0x48(%rsp), %rax
jb 0x27067f
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
movb $0x0, 0x27(%rsp)
movq 0x50(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
xorl %edx, %edx
callq 0xaaca0
testb $0x1, %al
jne 0x270712
movq 0x50(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0xb03a0
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0xb0530
movq %rax, 0x10(%rsp)
movq 0x50(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x8(%rsp)
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
subq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movl 0x40(%rsp), %edx
subq %rdx, %rcx
cmpq %rcx, %rax
jae 0x270710
jmp 0x270717
jmp 0x270712
jmp 0x270630
jmp 0x270719
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x270600
testb $0x1, 0x3f(%rsp)
je 0x27076c
testb $0x1, 0x27(%rsp)
jne 0x27076c
cmpq $0x0, 0x78(%rsp)
je 0x27075d
movq 0x78(%rsp), %rdi
movq 0x3cb7ea(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x30e773(%rip), %rsi    # 0x57eecb
callq 0x121930
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x100d90
testb $0x1, 0x27(%rsp)
je 0x27079b
movq 0x60(%rsp), %rax
movq (%rax), %rsi
movq 0x60(%rsp), %rax
movq 0x58(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x30e752(%rip), %rdi    # 0x57eee6
movb $0x0, %al
callq 0xe7740
addq $0x68, %rsp
retq