// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %r13
movq %rcx, %rbx
movl %edx, %ebp
movq %rdi, 0x30(%rsp)
testq %r9, %r9
movq %r8, 0x18(%rsp)
movq %rsi, 0x28(%rsp)
je 0x156ff2
movq %r13, %rdi
callq 0x101a9a
movq 0x18(%rsp), %r8
testb %al, %al
movq 0x28(%rsp), %rsi
jne 0x157501
cmpq $0x0, 0x30(%rsp)
je 0x1574fc
testq %rsi, %rsi
je 0x1574fc
movq %rbx, %r14
shrq $0x20, %r14
testq %r8, %r8
je 0x15702c
movq 0x36cece(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x234bd3(%rip), %rsi    # 0x38bbf7
movq %r8, %rdi
callq 0x1229c8
cmpl $-0x1, %ebx
setne %al
cmpl %r14d, %ebx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x157057
leaq 0x234bc7(%rip), %rsi    # 0x38bc0d
xorl %ebx, %ebx
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0x1574e7
leaq 0x2349b1(%rip), %rsi    # 0x38ba0f
movl $0x40, %edi
movl $0x46b, %edx            # imm = 0x46B
callq 0x1092b2
movq %rax, %r15
movq 0x30(%rsp), %rdi
movq %rdi, 0x10(%rax)
callq 0x121e78
movq %rax, 0x20(%r15)
xorl %eax, %eax
movq %rax, 0x18(%r15)
movw $0x0, 0x38(%r15)
movq %rax, 0x28(%r15)
callq 0xe837d
movq %rax, 0x30(%r15)
testb %bpl, %bpl
movq %rbx, 0x10(%rsp)
je 0x1570c5
callq 0x141770
movq %rax, (%r15)
cmpq $0x0, 0x18(%rsp)
je 0x1570cc
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x1417d7
jmp 0x1570cc
movq $0x0, (%r15)
leaq 0x23493c(%rip), %r12    # 0x38ba0f
movl $0x50, %edi
movq %r12, %rsi
movl $0x47b, %edx            # imm = 0x47B
callq 0x1092b2
movq %rax, 0x8(%r15)
movq 0x28(%rsp), %rbx
movq %rbx, 0x10(%rax)
movq $0x0, 0x20(%rax)
movq 0x20(%r15), %rdi
movl $0x10, %esi
movq %r12, %rdx
movl $0x47f, %ecx            # imm = 0x47F
callq 0x1093ef
movq %r15, 0x20(%rsp)
movq 0x8(%r15), %rcx
movq %rax, 0x8(%rcx)
movq 0x10(%rsp), %rax
movl %eax, (%rcx)
movl %r14d, 0x4(%rcx)
movl $0x1, %edi
movl $0x30, %esi
movq %r12, %rdx
movl $0xe5, %ecx
callq 0x1093ef
movq %rax, %rbp
movl $0x400, %edi            # imm = 0x400
movq %r12, %rsi
movl $0xe7, %edx
callq 0x1092b2
movq %rax, (%rbp)
movq %rbx, %rdi
callq 0xd3724
movl %eax, %edi
shlq $0x7, %rdi
movl $0x8, %esi
movq %r12, %rdx
movl $0xe7, %ecx
callq 0x1093ef
movq (%rbp), %rcx
movq %rax, (%rcx)
xorl %r15d, %r15d
movq (%rbp), %rax
movq (%rax,%r15,8), %r12
movq %rbx, %rdi
callq 0xd3724
movl %eax, %eax
leaq (%r12,%rax,8), %rax
movq (%rbp), %rcx
movq %rax, 0x8(%rcx,%r15,8)
incq %r15
cmpq $0x7f, %r15
jne 0x157182
movq %rbx, %rdi
callq 0xd3724
movl %eax, 0x10(%rbp)
movl $0x80, 0x14(%rbp)
movl $0x0, 0x28(%rbp)
movq %rbx, %rdi
callq 0xd3724
decl %eax
movl %eax, 0x20(%rbp)
movabsq $0x7f00000000, %rax     # imm = 0x7F00000000
movq %rax, 0x18(%rbp)
movq 0x10(%rsp), %rax
movl %eax, 0x24(%rbp)
movl %r14d, 0x2c(%rbp)
movq %rbx, 0x8(%rbp)
movq 0x20(%rsp), %rbx
cmpq $0x0, 0x20(%rbx)
je 0x15748c
xorl %r12d, %r12d
xorl %r15d, %r15d
movl $0x0, 0xc(%rsp)
movq %r13, 0x68(%rsp)
callq 0x121b54
movq %rax, %rbx
movq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x121d35
movq %rbx, %rdi
movq %rax, %rsi
callq 0x121cc0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x11a3d9
movq %rax, 0x10(%rsp)
testq %rax, %rax
movl 0xc(%rsp), %eax
jne 0x157260
movq %r13, %rdi
leaq 0x2349de(%rip), %rsi    # 0x38bc32
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
movq %rbx, 0x70(%rsp)
je 0x157276
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
jmp 0x15742d
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movq 0x28(%rsp), %rdi
callq 0xd3700
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x119998
movq %rbx, %rdi
leaq 0x80(%rsp), %rsi
callq 0x1199ce
movq %rbx, %rdi
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x78(%rsp), %rcx
movq %r13, %r8
callq 0x119a11
cmpl $-0x1, %eax
je 0x1573e0
movb $0x1, %bl
cmpl $0x1, %eax
jne 0x157401
xorl %ebx, %ebx
movl $0x1, %r12d
movq %r15, 0x48(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x60(%rsp), %rdx
leaq 0x78(%rsp), %rcx
movq %r13, %r8
callq 0x119a11
cmpl $-0x1, %eax
cmovel %eax, %ebx
cmpl $0x1, %eax
jne 0x1573d9
movq %r12, 0x50(%rsp)
movq 0x38(%rsp), %r12
cmpq %r12, 0x60(%rsp)
jne 0x1573e4
movl %ebx, 0x44(%rsp)
testq %r12, %r12
je 0x1573b1
movq 0x80(%rsp), %rbx
movq 0x58(%rsp), %r14
xorl %r13d, %r13d
movq 0x8(%rbp), %r15
movzbl (%r14,%r13), %esi
movq %r15, %rdi
callq 0xd3ae2
movsbl %al, %esi
movq %r15, %rdi
callq 0xd3d89
movzbl (%rbx,%r13), %ecx
movl 0x24(%rbp), %edx
cmpl %ecx, %edx
movl %ecx, %esi
cmoval %edx, %esi
cmpl $-0x1, %edx
cmovel %ecx, %esi
movl 0x2c(%rbp), %edx
cmpl %edx, %esi
movl %edx, %ecx
cmovbl %esi, %ecx
cmpl $-0x1, %edx
cmovel %esi, %ecx
cmpb $-0x2, %al
jne 0x15738a
movl 0x20(%rbp), %eax
jmp 0x15738d
movzbl %al, %eax
movq (%rbp), %rdx
movq (%rdx,%rcx,8), %rdx
incq (%rdx,%rax,8)
cmpl 0x18(%rbp), %ecx
jbe 0x1573a1
movl %ecx, 0x18(%rbp)
cmpl 0x1c(%rbp), %ecx
jae 0x1573a9
movl %ecx, 0x1c(%rbp)
incq %r13
cmpq %r13, %r12
jne 0x157340
movq 0x60(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x50(%rsp), %r12
incq %r12
movl 0x44(%rsp), %ebx
testl %ebx, %ebx
movq 0x68(%rsp), %r13
movq 0x48(%rsp), %r15
je 0x1572e3
testl %ebx, %ebx
sete %bl
jmp 0x157401
xorl %ebx, %ebx
jmp 0x157401
xorl %ebx, %ebx
movq %r13, %rdi
leaq 0x23486e(%rip), %rsi    # 0x38bc5e
xorl %eax, %eax
callq 0x1019cf
movq 0x48(%rsp), %r15
movq 0x50(%rsp), %r12
testb %bl, %bl
je 0x15742d
movq 0x20(%rsp), %rsi
movq 0x8(%rsi), %rax
movq 0x8(%rax), %rax
testq %r15, %r15
je 0x15745b
movq %r15, %rcx
shlq $0x4, %rcx
movq -0x8(%rax,%rcx), %rdx
addq %r12, %rdx
movq %rdx, 0x8(%rax,%rcx)
jmp 0x15745f
xorl %ebx, %ebx
movq 0x20(%rsp), %r14
addq %r12, 0x18(%r14)
movq 0x70(%rsp), %rdi
callq 0x121e8b
movq 0x10(%rsp), %rdi
callq 0x119a53
incq %r15
cmpq 0x20(%r14), %r15
jb 0x157211
jmp 0x157483
movq %r12, 0x8(%rax)
movq 0x38(%rsp), %rax
movq 0x8(%rsi), %rcx
movq 0x8(%rcx), %rcx
movq %r15, %rdx
shlq $0x4, %rdx
movq %rax, (%rcx,%rdx)
movl $0x0, 0xc(%rsp)
movb $0x1, %bl
jmp 0x15742f
testb %bl, %bl
movq 0x20(%rsp), %rbx
je 0x1574e5
movq %rbp, %rdi
callq 0x157506
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1574b4
movq 0x36ca43(%rip), %rax    # 0x4c3ee8
movq (%rax), %rdx
leaq 0x2347d0(%rip), %rsi    # 0x38bc7f
callq 0x1229c8
movl 0x10(%rbp), %eax
movl 0x14(%rbp), %edx
imulq %rax, %rdx
leaq 0x143(%rip), %rsi       # 0x157608
movq %rbp, %rdi
callq 0x15b8c0
movq 0x8(%rbx), %rcx
movq %rax, 0x18(%rcx)
movl 0x28(%rbp), %eax
movl %eax, 0x48(%rcx)
movq %rbp, %rdi
callq 0x15761f
jmp 0x1574e7
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x48505
callq 0x484cc