// File: /workspace/github_c_makefile_star2_O3/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 0x14f37c
movq %rdx, %r15
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movq 0x38(%rbx), %r13
testq %rdi, %rdi
je 0x14f1f5
callq 0xd2519
jmp 0x14f203
movl $0x8, %edi
callq 0xd214c
movq %rax, 0x10(%rbx)
movq 0x58(%rbx), %rax
leaq 0x28(%rsp), %rsi
movq %rax, 0x8(%rsi)
movq 0x30(%rbx), %rdi
leaq 0x152e(%rip), %rdx      # 0x150749
xorl %ecx, %ecx
callq 0x166c18
testq %rax, %rax
je 0x14f38b
movq %rax, %r12
testq %r13, %r13
je 0x14f28e
movq %r13, %rdi
callq 0x171147
cmpq 0x58(%rbx), %rax
jne 0x14f28e
leaq 0x2339bc(%rip), %rdi    # 0x382c04
xorl %eax, %eax
callq 0x103d72
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rdx
callq 0x1711a1
movq 0x48(%rbx), %rdi
movq (%rbp), %rsi
callq 0x14f390
movq 0x28(%rbx), %rdi
movq %r14, %rsi
callq 0x154654
movq %r14, %rdi
callq 0xfcc32
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
jne 0x14f2c6
movq 0x10(%rbx), %rsi
movq 0x28(%rbx), %rdi
movq (%r12), %rdx
movq %r14, %rcx
callq 0x1546bb
xorl %ecx, %ecx
cmpl $0x1, %eax
sete %cl
leal -0x1(,%rcx,2), %ebp
testl %eax, %eax
jne 0x14f2c6
leaq 0x23396b(%rip), %rsi    # 0x382c27
movq %r14, %rdi
xorl %eax, %eax
callq 0xfcb67
movl %ebp, 0xc(%rsp)
movq 0x10(%rbx), %rdi
callq 0xd24e0
testq %rax, %rax
je 0x14f353
xorl %r12d, %r12d
movl $0xff, %ebp
movq 0x10(%rbx), %rdi
movq %r12, %rsi
callq 0xd2207
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 0x14f31a
movl %edx, %r13d
callq 0x170d0
movq (%rax), %r14
movq 0x8(%rbx), %rdi
andl %ebp, %r13d
movl %r13d, %esi
callq 0xd187b
movsbq %al, %rax
movb (%r14,%rax,4), %al
movq 0x10(%rsp), %rcx
movb %al, (%rcx,%r12)
incq %r12
movq 0x10(%rbx), %rdi
callq 0xd24e0
cmpq %rax, %r12
jb 0x14f2e0
movq 0x10(%rbx), %rdi
callq 0xd24e0
xorl %ebp, %ebp
movb %bpl, (%r15,%rax)
movq 0x10(%rbx), %rdi
callq 0xd24e0
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 0x473e5