// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/shredder.c
// Function: generate_fragment
static char* generate_fragment(GtShredder *shredder,
                               GtUword *fragment_offset,
                               GtUword *fragment_length,
                               GtStr *desc)
{
  gt_assert(shredder && fragment_length);
  if (shredder->seqnum < gt_bioseq_number_of_sequences(shredder->bioseq)) {
    GtUword seqlen, fraglen;
    char *frag;
    seqlen = gt_bioseq_get_sequence_length(shredder->bioseq, shredder->seqnum);
    fraglen = (shredder->maxlength == shredder->minlength
               ? 0 : gt_rand_max(shredder->maxlength - shredder->minlength))
              + shredder->minlength;
    gt_assert(fraglen >= shredder->minlength);
    if (shredder->pos + fraglen > seqlen)
      fraglen = seqlen - shredder->pos;
    *fragment_offset = shredder->pos;
    *fragment_length = fraglen;
    gt_str_reset(desc);
    gt_str_append_cstr(desc, gt_bioseq_get_description(shredder->bioseq,
                                                       shredder->seqnum));
    gt_assert(shredder->pos + fraglen <= seqlen);
    frag = gt_bioseq_get_sequence_range(shredder->bioseq, shredder->seqnum,
                                        shredder->pos,
                                        shredder->pos + fraglen -1);
    if (shredder->pos + fraglen == seqlen) { /* last fragment */
      shredder->seqnum++;
      shredder->pos = 0;
    }
    else {
      if (fraglen > shredder->overlap)
        shredder->pos += fraglen - shredder->overlap;
      else
        shredder->pos++; /* go at least one base further each step */
    }
    return frag;
  }
  return NULL;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x1d7cc8
cmpq $0x0, 0x38(%rsp)
jne 0x1d7d00
movq 0x4642d1(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x33e33a(%rip), %rsi    # 0x516013
leaq 0x38ddbe(%rip), %rdx    # 0x565a9e
leaq 0x38dde5(%rip), %rcx    # 0x565acc
leaq 0x38dd1f(%rip), %r8     # 0x565a0d
movl $0x45, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1d7d02
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rdi
callq 0x85910
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x1d7f60
movq 0x48(%rsp), %rax
movq (%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x84e30
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x48(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1d7d66
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x1d7d82
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x48(%rsp), %rax
subq 0x8(%rax), %rdi
callq 0xec350
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq 0x48(%rsp), %rcx
addq 0x8(%rcx), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x1d7ddd
movq 0x4641f4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x33e25d(%rip), %rsi    # 0x516013
leaq 0x38dd21(%rip), %rdx    # 0x565ade
leaq 0x38dd08(%rip), %rcx    # 0x565acc
leaq 0x38dc42(%rip), %r8     # 0x565a0d
movl $0x4d, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1d7ddf
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rax
addq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
jbe 0x1d7e07
movq 0x28(%rsp), %rax
movq 0x48(%rsp), %rcx
subq 0x28(%rcx), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movq 0x30(%rsp), %rdi
callq 0x11e110
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x84ea0
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x11d550
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rax
addq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
jbe 0x1d7ea7
movq 0x46412a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x33e193(%rip), %rsi    # 0x516013
leaq 0x38dc76(%rip), %rdx    # 0x565afd
leaq 0x38dc3e(%rip), %rcx    # 0x565acc
leaq 0x38db78(%rip), %r8     # 0x565a0d
movl $0x55, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1d7ea9
movq 0x48(%rsp), %rax
movq (%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rdx
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rcx
addq 0x20(%rsp), %rcx
subq $0x1, %rcx
callq 0x851f0
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rax
addq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x1d7f14
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
movq 0x48(%rsp), %rax
movq $0x0, 0x28(%rax)
jmp 0x1d7f54
movq 0x20(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jbe 0x1d7f41
movq 0x20(%rsp), %rcx
movq 0x48(%rsp), %rax
subq 0x18(%rax), %rcx
movq 0x48(%rsp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
jmp 0x1d7f52
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x28(%rax)
jmp 0x1d7f54
movq 0x18(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x1d7f69
movq $0x0, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)