// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/hcr.c
// Function: hcr_seq_decoder_new
static GtHcrSeqDecoder *hcr_seq_decoder_new(GtAlphabet *alpha, const char *name,
                                            GtError *err)
{
  int had_err = 0;
  GtHcrSeqDecoder *seq_dec = gt_malloc(sizeof (GtHcrSeqDecoder));
  GtBaseQualDistr *bqd = NULL;
  GtWord end_enc_start_sampling = 0;
  FILE *fp = NULL;
  GT_UNUSED size_t read;
  GT_UNUSED const size_t one = (size_t) 1;

  seq_dec->alpha = alpha;
  seq_dec->alphabet_size = gt_alphabet_size(alpha);
  seq_dec->cur_read = 0;
  seq_dec->data_iter = NULL;
  seq_dec->file_info_rbt = NULL;
  seq_dec->fileinfos = NULL;
  seq_dec->filename = gt_str_new_cstr(name);
  seq_dec->huff_dec = NULL;
  seq_dec->huffman = NULL;
  seq_dec->sampling = NULL;
  seq_dec->symbols = NULL;
  gt_str_append_cstr(seq_dec->filename, HCRFILESUFFIX);

  fp = gt_fa_fopen_with_suffix(name, HCRFILESUFFIX, "rb", err);
  if (fp == NULL) {
    had_err = -1;
    hcr_seq_decoder_delete(seq_dec);
    seq_dec = NULL;
  }

  if (!had_err) {
    hcr_read_file_info(seq_dec, fp);

    bqd = hcr_base_qual_distr_new_from_file(fp, seq_dec->alpha);
    seq_dec->qual_offset = bqd->qual_offset;

    read = gt_xfread_one(&end_enc_start_sampling, fp);
    gt_assert(read == one);

    seq_dec->start_of_encoding = decoder_calc_start_of_encoded_data(fp);

    had_err = seq_decoder_init_huffman(seq_dec,
                                       end_enc_start_sampling, bqd, err);
    if (had_err) {
      hcr_seq_decoder_delete(seq_dec);
      seq_dec = NULL;
    }
  }

  if (!had_err) {
    size_t pos;
    gt_xfseek(fp, 0, SEEK_END);
    pos = ftell(fp);

    gt_xfseek(fp, end_enc_start_sampling, SEEK_SET);
    if (end_enc_start_sampling < pos)
      seq_dec->sampling = gt_sampling_read(fp);
    else
      seq_dec->sampling = NULL;

    seq_dec->file_info_rbt = seq_decoder_init_file_info(seq_dec->fileinfos,
                                                        seq_dec->num_of_files);
  }

  hcr_base_qual_distr_delete(bqd);
  gt_fa_fclose(fp);
  return seq_dec;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x80, %edi
leaq 0x3ceda4(%rip), %rsi    # 0x554ceb
movl $0x2f6, %edx            # imm = 0x2F6
callq 0xe80f0
movq %rax, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x1, 0x8(%rsp)
movq 0x50(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x50(%rsp), %rdi
callq 0x7e920
movl %eax, %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x78(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x58(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x48(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x30(%rax)
movq 0x30(%rsp), %rax
movq $0x0, (%rax)
movq 0x48(%rsp), %rdi
callq 0x11d510
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x28(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x20(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x38(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x10(%rax)
movq 0x30(%rsp), %rax
movq 0x40(%rax), %rdi
leaq 0x3cf048(%rip), %rsi    # 0x555071
callq 0x11d550
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %r9
leaq 0x3cf032(%rip), %rsi    # 0x555071
leaq 0x3f1e9f(%rip), %rdx    # 0x577ee5
leaq 0x3cec9e(%rip), %rcx    # 0x554ceb
movl $0x30a, %r8d            # imm = 0x30A
callq 0xd92c0
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0x186080
movl $0xffffffff, 0x3c(%rsp) # imm = 0xFFFFFFFF
movq 0x30(%rsp), %rdi
callq 0x1887d0
movq $0x0, 0x30(%rsp)
cmpl $0x0, 0x3c(%rsp)
jne 0x186171
movq 0x30(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x188870
movq 0x18(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x188a60
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movl 0x28(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x7c(%rax)
movq 0x18(%rsp), %rcx
leaq 0x20(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x126c30
movq %rax, 0x10(%rsp)
cmpq $0x1, 0x10(%rsp)
je 0x186120
movq 0x4b5eb1(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38ff1a(%rip), %rsi    # 0x516013
leaq 0x3cf06c(%rip), %rdx    # 0x55516c
leaq 0x3cf071(%rip), %rcx    # 0x555178
leaq 0x3cebdd(%rip), %r8     # 0x554ceb
movl $0x318, %r9d            # imm = 0x318
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x186122
movq 0x18(%rsp), %rdi
callq 0x188e80
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x40(%rsp), %rcx
callq 0x188f00
movl %eax, 0x3c(%rsp)
cmpl $0x0, 0x3c(%rsp)
je 0x18616f
movq 0x30(%rsp), %rdi
callq 0x1887d0
movq $0x0, 0x30(%rsp)
jmp 0x186171
cmpl $0x0, 0x3c(%rsp)
jne 0x186200
movq 0x18(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x126ca0
movq 0x18(%rsp), %rdi
callq 0x19030
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x126ca0
movq 0x20(%rsp), %rax
cmpq (%rsp), %rax
jae 0x1861d1
movq 0x18(%rsp), %rdi
callq 0x1d0250
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x38(%rax)
jmp 0x1861de
movq 0x30(%rsp), %rax
movq $0x0, 0x38(%rax)
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x68(%rax), %rsi
callq 0x189020
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x28(%rsp), %rdi
callq 0x187f00
movq 0x18(%rsp), %rdi
callq 0xd9390
movq 0x30(%rsp), %rax
addq $0x58, %rsp
retq
nop