// File: /workspace/github_c_makefile_star2_O1/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, %r14
movq %rsi, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x58(%rdi), %rcx
xorl %eax, %eax
cmpq 0x60(%rdi), %rcx
ja 0x156c3b
movq %rdx, %r15
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movq 0x38(%rbx), %rbp
testq %rdi, %rdi
je 0x156aa2
callq 0xd4ad3
jmp 0x156ab0
movl $0x8, %edi
callq 0xd46fc
movq %rax, 0x10(%rbx)
movq 0x58(%rbx), %rax
leaq 0x28(%rsp), %rsi
movq %rax, 0x8(%rsi)
movq 0x30(%rbx), %rdi
leaq 0x15b8(%rip), %rdx      # 0x158080
xorl %ecx, %ecx
callq 0x16eba7
testq %rax, %rax
je 0x156c4a
movq %rax, %r13
movl $0x1, %r12d
testq %rbp, %rbp
je 0x156b45
movq %rbp, %rdi
callq 0x1794f7
cmpq 0x58(%rbx), %rax
jne 0x156b45
leaq 0x2354cc(%rip), %rdi    # 0x38bfc7
xorl %eax, %eax
callq 0x108e02
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %rbp, %rdi
movq %r12, %rdx
callq 0x179557
movq 0x48(%rbx), %rdi
movq (%r12), %rsi
callq 0x156c4f
movq 0x28(%rbx), %rdi
movq %r14, %rsi
callq 0x15bf13
movq %r14, %rdi
callq 0x101a9a
movzbl %al, %r12d
negl %r12d
orl $0x1, %r12d
jmp 0x156b47
xorl %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
jne 0x156b85
movq 0x10(%rbx), %rsi
movq 0x28(%rbx), %rdi
movq (%r13), %rdx
movq %r14, %rcx
callq 0x15bf7a
cmpl $0x1, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmovel %r12d, %ebp
testl %eax, %eax
jne 0x156b85
leaq 0x23546f(%rip), %rsi    # 0x38bfea
movq %r14, %rdi
xorl %eax, %eax
callq 0x1019cf
movl %ebp, 0xc(%rsp)
movq 0x10(%rbx), %rdi
callq 0xd4a9a
testq %rax, %rax
je 0x156c12
xorl %r12d, %r12d
movl $0xff, %ebp
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0xd47ba
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 0x156bd9
movl %edx, %r13d
callq 0x170d0
movq (%rax), %r14
movq 0x8(%rbx), %rdi
andl %ebp, %r13d
movl %r13d, %esi
callq 0xd3da7
movsbq %al, %rax
movb (%r14,%rax,4), %al
movq 0x10(%rsp), %rcx
movb %al, (%rcx,%r12)
incq %r12
movq 0x10(%rbx), %rdi
callq 0xd4a9a
cmpq %rax, %r12
jb 0x156b9f
movq 0x10(%rbx), %rdi
callq 0xd4a9a
xorl %ebp, %ebp
movb %bpl, (%r15,%rax)
movq 0x10(%rbx), %rdi
callq 0xd4a9a
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
callq 0x48259