// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/tools/gt_encseq_sample.c
// Function: gt_encseq_sample_choose_sequences
static int gt_encseq_sample_choose_sequences(GtEncseq *encseq,
                                             GtEncseqSampleArguments *args,
                                             GtError *err,
                                             GtEncseqSampleOutputInfo *output)
{
  GtUword i, sfrom, sto;
  GtUword num_sequences, count;
  GtUword sequence_length;
  GtUword total_num_seq;
  int had_err = 0;

  gt_assert(encseq);
  sequence_length = gt_encseq_min_seq_length(encseq);
  total_num_seq = gt_encseq_num_of_sequences(encseq);

  if (sequence_length != gt_encseq_max_seq_length(encseq)) {
    gt_error_set(err, "sequences do not have the same length");
    return -1;
  }
  if (args->seqrng.start != GT_UNDEF_UWORD &&
      args->seqrng.end != GT_UNDEF_UWORD) {
    /* specify a sequence range to extract */
    if (args->seqrng.start > args->seqrng.end) {
      gt_error_set(err, "range start ("GT_WU") must not be higher than "
      "range end ("GT_WU")",
      args->seqrng.start, args->seqrng.end);
      return -1;
    }
    if (args->seqrng.end >= total_num_seq) {
      gt_error_set(err, "range "GT_WU"-"GT_WU" includes a sequence number "
                   "exceeding the total number of sequences ("GT_WU")",
                   args->seqrng.start, args->seqrng.end,
                   gt_encseq_num_of_sequences(encseq));
      return -1;
    }
    sfrom = args->seqrng.start;
    sto = args->seqrng.end;
    total_num_seq = 1+sto-sfrom;
  } else {
    /* extract all sequences */
    sfrom = 0;
    sto = total_num_seq-1;
  }
  output->offset = sfrom;
  if (args->len > total_num_seq * sequence_length) {
    gt_error_set(err, "requested length "GT_WU" exceeds length of sequences"
    " ("GT_WU")", args->len, total_num_seq*sequence_length);
    return -1;
  }

  /* fill bit vector randomly */
  output->sample = gt_bittab_new(total_num_seq);
  num_sequences = ceil(args->len / (double)sequence_length);
  if (total_num_seq != 1) {
    count = 0;
    i = gt_rand_max(total_num_seq-1);
    while (count < num_sequences) {
      /* probability = num_sequences/total_num_seq */
      if (gt_rand_max(total_num_seq-1) < num_sequences &&
        !gt_bittab_bit_is_set(output->sample, i)) {
        gt_bittab_set_bit(output->sample, i);
      count ++;
        }
        i = (i+1) % total_num_seq;
    }
  } else {
    gt_bittab_set_bit(output->sample, 0);
  }
  return had_err;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
movl $0x0, 0x24(%rsp)
cmpq $0x0, 0x78(%rsp)
jne 0x339d3
movq 0x6085fe(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4e2667(%rip), %rsi    # 0x516013
leaq 0x525fc3(%rip), %rdx    # 0x559976
leaq 0x4e963b(%rip), %rcx    # 0x51cff5
leaq 0x4e9534(%rip), %r8     # 0x51cef5
movl $0xfb, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x339d5
movq 0x78(%rsp), %rdi
callq 0xb1050
movq %rax, 0x30(%rsp)
movq 0x78(%rsp), %rdi
callq 0xa9d50
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x78(%rsp), %rdi
callq 0xb10b0
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
je 0x33a37
movq 0x68(%rsp), %rdi
leaq 0x4e95f7(%rip), %rsi    # 0x51d017
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x33cfb
movq 0x70(%rsp), %rax
cmpq $-0x1, 0x18(%rax)
je 0x33b3f
movq 0x70(%rsp), %rax
cmpq $-0x1, 0x20(%rax)
je 0x33b3f
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x70(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jbe 0x33aa0
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rdx
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rcx
leaq 0x4e95b4(%rip), %rsi    # 0x51d03d
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x33cfb
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rax
cmpq 0x28(%rsp), %rax
jb 0x33b0e
movq 0x68(%rsp), %rax
movq %rax, (%rsp)
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x78(%rsp), %rdi
callq 0xa9d50
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq %rax, %r8
leaq 0x4e8b96(%rip), %rsi    # 0x51c68d
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x33cfb
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
addq $0x1, %rax
subq 0x50(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x33b56
movq $0x0, 0x50(%rsp)
movq 0x28(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
movq 0x70(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x28(%rsp), %rcx
imulq 0x30(%rsp), %rcx
cmpq %rcx, %rax
jbe 0x33bb3
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rax
movq 0x40(%rax), %rdx
movq 0x28(%rsp), %rcx
imulq 0x30(%rsp), %rcx
leaq 0x4e94db(%rip), %rsi    # 0x51d077
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x33cfb
movq 0x28(%rsp), %rdi
callq 0x89a20
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x70(%rsp), %rax
movq 0x40(%rax), %xmm0
movaps 0x4e4d56(%rip), %xmm3   # 0x518930
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x4e4d5a(%rip), %xmm2   # 0x518940
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x30(%rsp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x190e0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x4e5142(%rip), %xmm1   # 0x518d70
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x40(%rsp)
cmpq $0x1, 0x28(%rsp)
je 0x33cde
movq $0x0, 0x38(%rsp)
movq 0x28(%rsp), %rdi
subq $0x1, %rdi
callq 0xec350
movq %rax, 0x58(%rsp)
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
jae 0x33cdc
movq 0x28(%rsp), %rdi
subq $0x1, %rdi
callq 0xec350
cmpq 0x40(%rsp), %rax
jae 0x33cc3
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x58(%rsp), %rsi
callq 0x8a780
testb $0x1, %al
jne 0x33cc3
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x58(%rsp), %rsi
callq 0x89b00
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rax
addq $0x1, %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq 0x28(%rsp)
movq %rdx, 0x58(%rsp)
jmp 0x33c6a
jmp 0x33cf0
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x89b00
movl 0x24(%rsp), %eax
movl %eax, 0x84(%rsp)
movl 0x84(%rsp), %eax
addq $0x88, %rsp
retq
nopw (%rax,%rax)