// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/hcr.c
// Function: hcr_next_seq_qual
static int hcr_next_seq_qual(GtHcrSeqDecoder *seq_dec, char *seq, char *qual,
                             GtError *err)
{
  enum state {
    HCR_ERROR = -1,
    END,
    SUCCESS
  };
  unsigned char base;
  GtUword i,
                nearestsample,
                *symbol;
  size_t startofnearestsample = 0;
  enum state status = END;
  FastqFileInfo cur_read;
  FastqFileInfo *fileinfo = NULL;

  if (seq_dec->cur_read <= seq_dec->num_of_reads) {
    GtSampling *sampling = seq_dec->sampling;
    status = SUCCESS;
    if (seq_dec->symbols == NULL)
      seq_dec->symbols = gt_array_new(sizeof (GtUword));
    else
      gt_array_reset(seq_dec->symbols);

    cur_read.readnum = seq_dec->cur_read;
    fileinfo = (FastqFileInfo *)gt_rbtree_next_key(seq_dec->file_info_rbt,
                                                   &cur_read,
                                                   hcr_cmp_FastqFileInfo,
                                                   NULL);
    gt_assert(fileinfo);

    /* reset huffman_decoder if next read is sampled */
    if (sampling != NULL &&
        gt_sampling_get_next_elementnum(sampling) == seq_dec->cur_read) {
      gt_log_log("reset because sampled read is next");
      (void) gt_sampling_get_next_sample(sampling,
                                         &nearestsample,
                                         &startofnearestsample);
      reset_data_iterator_to_pos(seq_dec->data_iter, startofnearestsample);
      (void) gt_huffman_decoder_get_new_mem_chunk(seq_dec->huff_dec, err);
      if (gt_error_is_set(err))
        status = HCR_ERROR;
    }
    if (status != HCR_ERROR) {
      int ret;
      ret =  gt_huffman_decoder_next(seq_dec->huff_dec, seq_dec->symbols,
                                     fileinfo->readlength, err);
      if (ret != 1)
        status = HCR_ERROR;
      if (ret == 0)
        gt_error_set(err, "reached end of file");
    }
    if (qual || seq) {
      for (i = 0; i < gt_array_size(seq_dec->symbols); i++) {
        symbol = (GtUword*) gt_array_get(seq_dec->symbols, i);
        if (qual != NULL)
          qual[i] = get_qual_from_symbol(seq_dec, *symbol);
        if (seq != NULL) {
          base = get_base_from_symbol(seq_dec, *symbol);
          seq[i] = (char)toupper(gt_alphabet_decode(seq_dec->alpha,
                                                    (GtUchar) base));
        }
      }
      if (qual != NULL)
        qual[gt_array_size(seq_dec->symbols)] = '\0';
      if (seq != NULL)
        seq[gt_array_size(seq_dec->symbols)] = '\0';
    }
    seq_dec->cur_read++;
  }
  return (int) status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r12
movq %rsi, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movq 0x58(%rdi), %rcx
xorl %eax, %eax
cmpq 0x60(%rdi), %rcx
ja 0xea6e4
movq %rdx, %r15
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movq 0x38(%rbx), %r13
testq %rdi, %rdi
je 0xea56c
callq 0x5876c
jmp 0xea578
pushq $0x8
popq %rdi
callq 0x5809c
movq %rax, 0x10(%rbx)
movq 0x58(%rbx), %rax
leaq 0x28(%rsp), %rsi
movq %rax, 0x8(%rsi)
movq 0x30(%rbx), %rdi
leaq 0x19a9(%rip), %rdx      # 0xebf39
xorl %ecx, %ecx
callq 0x10784c
testq %rax, %rax
je 0xea6f3
movq %rax, %rbp
testq %r13, %r13
je 0xea606
movq %r13, %rdi
callq 0x11452e
cmpq 0x58(%rbx), %rax
jne 0xea606
leaq 0x238a53(%rip), %rdi    # 0x323010
xorl %eax, %eax
callq 0x92a82
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %r14
movq %r13, %rdi
movq %r14, %rdx
callq 0x11460f
movq 0x48(%rbx), %rdi
movq (%r14), %rsi
callq 0xea72b
movq 0x28(%rbx), %rdi
movq %r12, %rsi
callq 0xf0e27
movq %r12, %rdi
callq 0x89eb7
testb %al, %al
je 0xea606
pushq $-0x1
popq %rax
movl %eax, 0xc(%rsp)
jmp 0xea642
movq 0x10(%rbx), %rsi
movq 0x28(%rbx), %rdi
movq (%rbp), %rdx
movq %r12, %rcx
callq 0xf0ee7
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leal -0x1(,%rcx,2), %ecx
movl %ecx, 0xc(%rsp)
testl %eax, %eax
jne 0xea642
leaq 0x2389fb(%rip), %rsi    # 0x323033
movq %r12, %rdi
xorl %eax, %eax
callq 0x89dbb
xorl %r12d, %r12d
movl $0xff, %ebp
movq 0x10(%rbx), %rdi
callq 0x586a4
movq 0x10(%rbx), %rdi
cmpq %rax, %r12
jae 0xea6bf
movq %r12, %rsi
callq 0x581aa
movq %rax, %rcx
movq (%rax), %rax
movl 0x78(%rbx), %esi
xorl %edx, %edx
divq %rsi
addl 0x7c(%rbx), %eax
movb %al, (%r15,%r12)
movzbl (%rcx), %eax
movl 0x78(%rbx), %ecx
xorl %edx, %edx
divl %ecx
andl %ebp, %ecx
movl $0xfe, %r13d
cmpl %ecx, %edx
je 0xea692
movl %edx, %r13d
callq 0x170c0
movq (%rax), %r14
movq 0x8(%rbx), %rdi
andl %ebp, %r13d
movl %r13d, %esi
callq 0x575cc
movsbq %al, %rax
movb (%r14,%rax,4), %al
movq 0x10(%rsp), %rcx
movb %al, (%rcx,%r12)
incq %r12
jmp 0xea64a
callq 0x586a4
xorl %ebp, %ebp
movb %bpl, (%r15,%rax)
movq 0x10(%rbx), %rdi
callq 0x586a4
movq 0x10(%rsp), %rcx
movb %bpl, (%rcx,%rax)
incq 0x58(%rbx)
movl 0xc(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x34d86e(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1fa90f(%rip), %rsi    # 0x2e5013
leaq 0x26ec93(%rip), %rdx    # 0x35939e
leaq 0x2388ec(%rip), %rcx    # 0x322ffe
leaq 0x23833f(%rip), %r8     # 0x322a58
movl $0x38d, %r9d            # imm = 0x38D
xorl %eax, %eax
callq 0x17a50
callq 0x17390