// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/hcr.c
// Function: gt_hcr_encoder_new
GtHcrEncoder *gt_hcr_encoder_new(GtStrArray *files, GtAlphabet *alpha,
                                 bool descs, GtQualRange qrange, GtTimer *timer,
                                 GtError *err)
{
  GtBaseQualDistr *bqd;
  GtHcrEncoder *hcr_enc;
  GtSeqIterator *seqit;
  GtStrArray *file;
  int had_err = 0,
      status;
  GtUword len1,
                len2,
                i,
                num_of_reads = 0;
  const GtUchar *seq,
                *qual;
  char *desc;

  gt_error_check(err);
  gt_assert(alpha && files);

  if (timer != NULL)
    gt_timer_show_progress(timer, "get <base,qual> distr", stdout);

  if (qrange.start != GT_UNDEF_UINT)
    if (qrange.start == qrange.end) {
      gt_error_set(err, "qrange.start must unequal qrange.end");
      return NULL;
    }

  hcr_enc = gt_malloc(sizeof (GtHcrEncoder));
  hcr_enc->files = files;
  hcr_enc->num_of_files = gt_str_array_size(files);
  hcr_enc->num_of_reads = 0;
  hcr_enc->page_sampling = false;
  hcr_enc->regular_sampling = false;
  hcr_enc->sampling_rate = 0;
  hcr_enc->pagesize = gt_pagesize();
  if (descs) {
    hcr_enc->encdesc_encoder = gt_encdesc_encoder_new();
    if (timer != NULL)
      gt_encdesc_encoder_set_timer(hcr_enc->encdesc_encoder, timer);
  }
  else
    hcr_enc->encdesc_encoder = NULL;

  hcr_enc->seq_encoder = gt_malloc(sizeof (GtHcrSeqEncoder));
  hcr_enc->seq_encoder->alpha = alpha;
  hcr_enc->seq_encoder->sampling = NULL;
  hcr_enc->seq_encoder->fileinfos = gt_calloc((size_t) hcr_enc->num_of_files,
                                   sizeof (*(hcr_enc->seq_encoder->fileinfos)));
  hcr_enc->seq_encoder->qrange = qrange;
  bqd = hcr_base_qual_distr_new(alpha, qrange);

  /* check if reads in the same file are of same length and get
     <base, quality> pair distribution */
  for (i = 0; i < hcr_enc->num_of_files; i++) {
    file = gt_str_array_new();
    gt_str_array_add(file, gt_str_array_get_str(files, i));
    seqit = gt_seq_iterator_fastq_new(file, err);
    if (!seqit) {
      gt_error_set(err, "cannot initialize GtSeqIteratorFastQ object");
      had_err = -1;
    }
    if (!had_err) {
      gt_seq_iterator_set_symbolmap(seqit, gt_alphabet_symbolmap(alpha));
      gt_seq_iterator_set_quality_buffer(seqit, &qual);
      status = gt_seq_iterator_next(seqit, &seq, &len1, &desc, err);

      if (status == 1) {
        num_of_reads = 1UL;
        while (!had_err) {
          status = gt_seq_iterator_next(seqit, &seq, &len2, &desc, err);
          if (status == -1)
            had_err = -1;
          if (status != 1)
            break;
          if (len2 != len1) {
            gt_error_set(err, "reads have to be of equal length");
            had_err = -1;
            break;
          }
          if (hcr_base_qual_distr_add(bqd, qual, seq, len1) != 0)
            had_err = -1;
          len1 = len2;
          num_of_reads++;
        }
      }
      else if (status == -1)
        had_err = -1;

      if (!had_err) {
        if (i == 0)
          hcr_enc->seq_encoder->fileinfos[i].readnum = num_of_reads;
        else
          hcr_enc->seq_encoder->fileinfos[i].readnum =
            hcr_enc->seq_encoder->fileinfos[i - 1].readnum + num_of_reads;
        hcr_enc->seq_encoder->fileinfos[i].readlength = len1;
      }
    }
    hcr_enc->num_of_reads += num_of_reads;
    gt_str_array_delete(file);
    gt_seq_iterator_delete(seqit);
  }
  if (!had_err)
    hcr_base_qual_distr_trim(bqd);

  if (!had_err) {
    if (timer != NULL)
      gt_timer_show_progress(timer, "build huffman tree for sequences and"
                             " qualities", stdout);
    hcr_enc->seq_encoder->huffman =
      gt_huffman_new(bqd,
                     hcr_base_qual_distr_func,
                     (GtUword) bqd->ncols * bqd->nrows);
  }
  if (!had_err) {
    hcr_enc->seq_encoder->qual_offset = bqd->qual_offset;
    hcr_base_qual_distr_delete(bqd);
    return hcr_enc;
  }
  return NULL;
}

// Assembly:
subq $0xa8, %rsp
movb %dl, %al
movq %rcx, 0x98(%rsp)
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
andb $0x1, %al
movb %al, 0x87(%rsp)
movq %r8, 0x78(%rsp)
movq %r9, 0x70(%rsp)
movl $0x0, 0x4c(%rsp)
movq $0x0, 0x28(%rsp)
cmpq $0x0, 0x70(%rsp)
je 0x187355
movq 0x70(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x18731d
jmp 0x187355
movq 0x4b4c7c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38ece5(%rip), %rsi    # 0x516013
leaq 0x38ee8a(%rip), %rdx    # 0x5161bf
leaq 0x3cdb75(%rip), %rcx    # 0x554eb1
leaq 0x3cd9a8(%rip), %r8     # 0x554ceb
movl $0x45f, %r9d            # imm = 0x45F
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x187357
jmp 0x187359
cmpq $0x0, 0x88(%rsp)
je 0x18736f
cmpq $0x0, 0x90(%rsp)
jne 0x1873a7
movq 0x4b4c2a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38ec93(%rip), %rsi    # 0x516013
leaq 0x3cdb3d(%rip), %rdx    # 0x554ec4
leaq 0x3cdb23(%rip), %rcx    # 0x554eb1
leaq 0x3cd956(%rip), %r8     # 0x554ceb
movl $0x460, %r9d            # imm = 0x460
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1873a9
cmpq $0x0, 0x78(%rsp)
je 0x1873cc
movq 0x78(%rsp), %rdi
movq 0x4b4b7b(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x3cdb0c(%rip), %rsi    # 0x554ed3
callq 0x121930
cmpl $-0x1, 0x98(%rsp)
je 0x18740c
movl 0x98(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jne 0x18740a
movq 0x70(%rsp), %rdi
leaq 0x3cdaf7(%rip), %rsi    # 0x554ee9
movb $0x0, %al
callq 0xd88c0
movq $0x0, 0xa0(%rsp)
jmp 0x1878c2
jmp 0x18740c
movl $0x40, %edi
leaq 0x3cd8d3(%rip), %rsi    # 0x554ceb
movl $0x46b, %edx            # imm = 0x46B
callq 0xe80f0
movq %rax, 0x60(%rsp)
movq 0x90(%rsp), %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x90(%rsp), %rdi
callq 0x11fcc0
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x60(%rsp), %rax
movq $0x0, 0x18(%rax)
movq 0x60(%rsp), %rax
movb $0x0, 0x38(%rax)
movq 0x60(%rsp), %rax
movb $0x0, 0x39(%rax)
movq 0x60(%rsp), %rax
movq $0x0, 0x28(%rax)
callq 0xa2640
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x30(%rax)
testb $0x1, 0x87(%rsp)
je 0x1874c4
callq 0x15eec0
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
cmpq $0x0, 0x78(%rsp)
je 0x1874c2
movq 0x60(%rsp), %rax
movq (%rax), %rdi
movq 0x78(%rsp), %rsi
callq 0x15ef60
jmp 0x1874d0
movq 0x60(%rsp), %rax
movq $0x0, (%rax)
movl $0x50, %edi
leaq 0x3cd80f(%rip), %rsi    # 0x554ceb
movl $0x47b, %edx            # imm = 0x47B
callq 0xe80f0
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x88(%rsp), %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x10(%rax)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x20(%rax)
movq 0x60(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x10, %esi
leaq 0x3cd7be(%rip), %rdx    # 0x554ceb
movl $0x47f, %ecx            # imm = 0x47F
callq 0xe83c0
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x98(%rsp), %rcx
movq %rcx, (%rax)
movq 0x88(%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0x1878e0
movq %rax, 0x68(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x60(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x187810
callq 0x11f5c0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x11f960
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x11f840
movq 0x50(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x1126d0
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x1875fc
movq 0x70(%rsp), %rdi
leaq 0x3cd921(%rip), %rsi    # 0x554f0e
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x4c(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x4c(%rsp)
jne 0x1877d7
movq 0x58(%rsp), %rax
movq %rax, (%rsp)
movq 0x88(%rsp), %rdi
callq 0x7e870
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x1118a0
movq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x111990
movq 0x58(%rsp), %rdi
movq 0x70(%rsp), %r8
leaq 0x20(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x111ab0
movl %eax, 0x48(%rsp)
cmpl $0x1, 0x48(%rsp)
jne 0x187729
movq $0x1, 0x28(%rsp)
cmpl $0x0, 0x4c(%rsp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x187681
jmp 0x187727
movq 0x58(%rsp), %rdi
movq 0x70(%rsp), %r8
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x111ab0
movl %eax, 0x48(%rsp)
cmpl $-0x1, 0x48(%rsp)
jne 0x1876b2
movl $0xffffffff, 0x4c(%rsp) # imm = 0xFFFFFFFF
cmpl $0x1, 0x48(%rsp)
je 0x1876bb
jmp 0x187727
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x1876e4
movq 0x70(%rsp), %rdi
leaq 0x3cd867(%rip), %rsi    # 0x554f3a
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x4c(%rsp) # imm = 0xFFFFFFFF
jmp 0x187727
movq 0x68(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x40(%rsp), %rcx
callq 0x187b70
cmpl $0x0, %eax
je 0x18770a
movl $0xffffffff, 0x4c(%rsp) # imm = 0xFFFFFFFF
movq 0x38(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x18766e
jmp 0x18773a
cmpl $-0x1, 0x48(%rsp)
jne 0x187738
movl $0xffffffff, 0x4c(%rsp) # imm = 0xFFFFFFFF
jmp 0x18773a
cmpl $0x0, 0x4c(%rsp)
jne 0x1877d5
cmpq $0x0, 0x30(%rsp)
jne 0x187771
movq 0x28(%rsp), %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x30(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x1877b4
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x30(%rsp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
addq 0x28(%rsp), %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x30(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq 0x30(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
jmp 0x1877d7
movq 0x28(%rsp), %rcx
movq 0x60(%rsp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
movq 0x50(%rsp), %rdi
callq 0x11fd20
movq 0x58(%rsp), %rdi
callq 0x111c10
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x18757e
cmpl $0x0, 0x4c(%rsp)
jne 0x187821
movq 0x68(%rsp), %rdi
callq 0x187ce0
cmpl $0x0, 0x4c(%rsp)
jne 0x187882
cmpq $0x0, 0x78(%rsp)
je 0x18784b
movq 0x78(%rsp), %rdi
movq 0x4b46fc(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x3cd715(%rip), %rsi    # 0x554f5b
callq 0x121930
movq 0x68(%rsp), %rdi
movq 0x68(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, %edx
movq 0x68(%rsp), %rax
movl 0x14(%rax), %eax
imulq %rax, %rdx
leaq 0x623(%rip), %rsi       # 0x187e90
callq 0x191820
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x18(%rax)
cmpl $0x0, 0x4c(%rsp)
jne 0x1878b6
movq 0x68(%rsp), %rax
movl 0x28(%rax), %ecx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movl %ecx, 0x48(%rax)
movq 0x68(%rsp), %rdi
callq 0x187f00
movq 0x60(%rsp), %rax
movq %rax, 0xa0(%rsp)
jmp 0x1878c2
movq $0x0, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)