// File: /workspace/github_c_makefile_star2_O3/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 $0x78, %rsp
movq %r9, %r15
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r13
testq %r9, %r9
movq %r8, 0x18(%rsp)
je 0x14f716
movq %r15, %rdi
callq 0xfcc32
movq 0x18(%rsp), %r8
testb %al, %al
jne 0x14fc4c
testq %r13, %r13
je 0x14fc47
testq %r12, %r12
je 0x14fc47
movq %rbx, %r14
shrq $0x20, %r14
testq %r8, %r8
je 0x14f74d
movq 0x36979d(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x2330ef(%rip), %rsi    # 0x382834
movq %r8, %rdi
callq 0x11cc90
cmpl $-0x1, %ebx
setne %al
cmpl %r14d, %ebx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x14f779
leaq 0x2330e3(%rip), %rsi    # 0x38284a
xorl %r12d, %r12d
movq %r15, %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0x14fc35
movq %r12, 0x38(%rsp)
leaq 0x232ec7(%rip), %rsi    # 0x38264c
movl $0x40, %edi
movl $0x46b, %edx            # imm = 0x46B
callq 0x104226
movq %rax, %r12
movq %r13, 0x10(%rax)
movq %r13, %rdi
callq 0x11c131
movq %rax, 0x20(%r12)
xorl %eax, %eax
movq %rax, 0x18(%r12)
movw $0x0, 0x38(%r12)
movq %rax, 0x28(%r12)
callq 0xe3e95
movq %rax, 0x30(%r12)
testb %bpl, %bpl
movq %r15, 0x40(%rsp)
movq %r13, 0x68(%rsp)
je 0x14f7f8
callq 0x13ad24
movq %rax, (%r12)
cmpq $0x0, 0x18(%rsp)
movq %r12, %r15
je 0x14f803
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x13ad8b
jmp 0x14f803
movq $0x0, (%r12)
movq %r12, %r15
leaq 0x232e42(%rip), %r12    # 0x38264c
movl $0x50, %edi
movq %r12, %rsi
movl $0x47b, %edx            # imm = 0x47B
callq 0x104226
movq %rax, 0x8(%r15)
movq 0x38(%rsp), %r13
movq %r13, 0x10(%rax)
movq $0x0, 0x20(%rax)
movq 0x20(%r15), %rdi
movl $0x10, %esi
movq %r12, %rdx
movl $0x47f, %ecx            # imm = 0x47F
callq 0x10436a
movq %r15, 0x48(%rsp)
movq 0x8(%r15), %rcx
movq %rax, 0x8(%rcx)
movl %ebx, (%rcx)
movl %r14d, 0x4(%rcx)
movl $0x1, %edi
movl $0x30, %esi
movq %r12, %rdx
movl $0xe5, %ecx
callq 0x10436a
movq %rax, %rbp
movl $0x400, %edi            # imm = 0x400
movq %r12, %rsi
movl $0xe7, %edx
callq 0x104226
movq %rax, (%rbp)
movq %r13, %rdi
callq 0xd11cf
movl %eax, %edi
shlq $0x7, %rdi
movl $0x8, %esi
movq %r12, %rdx
movl $0xe7, %ecx
callq 0x10436a
movq (%rbp), %rcx
movq %rax, (%rcx)
xorl %r15d, %r15d
movq (%rbp), %rax
movq (%rax,%r15,8), %r12
movq %r13, %rdi
callq 0xd11cf
movl %eax, %eax
leaq (%r12,%rax,8), %rax
movq (%rbp), %rcx
movq %rax, 0x8(%rcx,%r15,8)
incq %r15
cmpq $0x7f, %r15
jne 0x14f8b4
movq %r13, %rdi
callq 0xd11cf
movl %eax, 0x10(%rbp)
movl $0x80, 0x14(%rbp)
movl $0x0, 0x28(%rbp)
movq %r13, %rdi
callq 0xd11cf
decl %eax
movl %eax, 0x20(%rbp)
movabsq $0x7f00000000, %rax     # imm = 0x7F00000000
movq %rax, 0x18(%rbp)
movl %ebx, 0x24(%rbp)
movl %r14d, 0x2c(%rbp)
movq %r13, 0x8(%rbp)
movq 0x48(%rsp), %r12
cmpq $0x0, 0x20(%r12)
je 0x14fbd8
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
xorl %ebx, %ebx
movq 0x40(%rsp), %r15
movq %rax, %r14
callq 0x11be10
movq %rax, %r13
movq 0x68(%rsp), %rdi
movq %r14, 0x58(%rsp)
movq %r14, %rsi
callq 0x11bfee
movq %r13, %rdi
movq %rax, %rsi
callq 0x11bf79
movq %r13, 0x10(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x114cc9
movq %rax, %r13
testq %rax, %rax
je 0x14f994
testl %ebx, %ebx
je 0x14f9b2
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x14fb82
xorl %r14d, %r14d
movq %r15, %rdi
leaq 0x232ece(%rip), %rsi    # 0x38286f
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x14fb7d
movq 0x38(%rsp), %rdi
callq 0xd11ab
movq %r13, %rdi
movq %rax, %rsi
callq 0x1142c4
movq %r13, %rdi
leaq 0x70(%rsp), %rsi
callq 0x1142fa
movq %r13, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x60(%rsp), %rcx
movq %r15, %r8
callq 0x11433d
cmpl $-0x1, %eax
je 0x14fb19
cmpl $0x1, %eax
jne 0x14fb34
movq %r13, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x60(%rsp), %rcx
movq %r15, %r8
callq 0x11433d
cmpl $0x1, %eax
jne 0x14fb20
movl $0x1, %eax
movq %rax, 0x8(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %r13, 0x50(%rsp)
movq 0x28(%rsp), %r13
cmpq 0x30(%rsp), %r13
jne 0x14fbb3
testq %r13, %r13
je 0x14fae3
movq 0x70(%rsp), %r15
movq 0x20(%rsp), %r12
xorl %ebx, %ebx
movq 0x8(%rbp), %r14
movzbl (%r12,%rbx), %esi
movq %r14, %rdi
callq 0xd15a9
movsbl %al, %esi
movq %r14, %rdi
callq 0xd185d
movzbl (%r15,%rbx), %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 0x14faa6
movl 0x20(%rbp), %eax
jmp 0x14faa9
movzbl %al, %eax
movq (%rbp), %rdx
movq (%rdx,%rcx,8), %rdx
incq (%rdx,%rax,8)
cmpl 0x18(%rbp), %ecx
jbe 0x14fabd
movl %ecx, 0x18(%rbp)
cmpl 0x1c(%rbp), %ecx
jae 0x14fac5
movl %ecx, 0x1c(%rbp)
incq %rbx
cmpq %rbx, %r13
jne 0x14fa5c
movq 0x28(%rsp), %rax
movq 0x40(%rsp), %r15
movq 0x48(%rsp), %r12
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x14fae5
xorl %eax, %eax
movq %rax, 0x30(%rsp)
incq 0x8(%rsp)
movq 0x50(%rsp), %r13
movq %r13, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x60(%rsp), %rcx
movq %r15, %r8
callq 0x11433d
cmpl $0x1, %eax
je 0x14fa37
jmp 0x14fb2f
xorl %r14d, %r14d
movl %eax, %ebx
jmp 0x14fb7d
movl $0x1, %ecx
movq %rcx, 0x8(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x14fbae
movq 0x8(%r12), %rax
movq 0x8(%rax), %rax
movq 0x58(%rsp), %rsi
testq %rsi, %rsi
je 0x14fb5f
movq %rsi, %rcx
shlq $0x4, %rcx
movq -0x8(%rax,%rcx), %rdx
addq 0x8(%rsp), %rdx
movq %rdx, 0x8(%rax,%rcx)
jmp 0x14fb68
movq 0x8(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq 0x30(%rsp), %rcx
movq %rsi, %rdx
shlq $0x4, %rdx
movq %rcx, (%rax,%rdx)
xorl %ebx, %ebx
movb $0x1, %r14b
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
addq %rax, 0x18(%r12)
callq 0x11c144
movq %r13, %rdi
callq 0x11437f
movq 0x58(%rsp), %rax
incq %rax
cmpq 0x20(%r12), %rax
jb 0x14f93e
jmp 0x14fbd3
xorl %r14d, %r14d
jmp 0x14fb7d
xorl %r14d, %r14d
movq %r15, %rdi
leaq 0x232cdb(%rip), %rsi    # 0x38289b
xorl %eax, %eax
callq 0xfcb67
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %r13
jmp 0x14fb82
testb %r14b, %r14b
je 0x14fc32
movq %rbp, %rdi
callq 0x14fc51
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x14fc00
movq 0x3692e7(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x232cc1(%rip), %rsi    # 0x3828bc
callq 0x11cc90
movl 0x10(%rbp), %eax
movl 0x14(%rbp), %edx
imulq %rax, %rdx
leaq 0x13e(%rip), %rsi       # 0x14fd4f
movq %rbp, %rdi
callq 0x153ff8
movq 0x8(%r12), %rcx
movq %rax, 0x18(%rcx)
movl 0x28(%rbp), %eax
movl %eax, 0x48(%rcx)
movq %rbp, %rdi
callq 0x14fd66
jmp 0x14fc35
xorl %r12d, %r12d
movq %r12, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x47691
callq 0x47658