// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/hcr.c
// Function: hcr_write_seqs
static int hcr_write_seqs(FILE *fp, GtHcrEncoder *hcr_enc, GtError *err)
{
  int had_err = 0, seqit_err;
  GtUword bits_to_write = 0,
                len,
                read_counter = 0,
                page_counter = 0,
                bits_left_in_page,
                cur_read = 0;
  GtWord filepos;
  GtSeqIterator *seqit;
  const GtUchar *seq,
                *qual;
  char *desc;
  GtBitOutStream *bitstream;

  gt_error_check(err);

  gt_safe_assign(bits_left_in_page, (hcr_enc->pagesize * 8));

  gt_xfseek(fp, hcr_enc->seq_encoder->start_of_encoding, SEEK_SET);
  bitstream = gt_bitoutstream_new(fp);

  seqit = gt_seq_iterator_fastq_new(hcr_enc->files, err);
  if (!seqit) {
    gt_assert(gt_error_is_set(err));
    had_err = -1;
  }

  if (!had_err) {
    gt_seq_iterator_set_quality_buffer(seqit, &qual);
    gt_seq_iterator_set_symbolmap(seqit,
                            gt_alphabet_symbolmap(hcr_enc->seq_encoder->alpha));
    hcr_enc->seq_encoder->total_num_of_symbols = 0;
    while (!had_err &&
           (seqit_err = gt_seq_iterator_next(seqit,
                                            &seq,
                                            &len,
                                            &desc, err)) == 1) {
      GtSampling *sampling = hcr_enc->seq_encoder->sampling;

      /* count the bits */
      bits_to_write = hcr_write_seq(hcr_enc->seq_encoder, seq, qual, len,
                                    bitstream, true);

      /* check if a new sample has to be added */
      if (sampling != NULL &&
          gt_sampling_is_next_element_sample(sampling,
                                             page_counter,
                                             read_counter,
                                             bits_to_write,
                                             bits_left_in_page)) {
        gt_log_log("sampling read " GT_WU, cur_read);
        gt_bitoutstream_flush_advance(bitstream);

        filepos = gt_bitoutstream_pos(bitstream);
        if (filepos < 0) {
          had_err = -1;
          gt_error_set(err, "error by ftell: %s", strerror(errno));
        }
        else {
        gt_sampling_add_sample(sampling,
                               (size_t) filepos,
                               cur_read);

        read_counter = 0;
        page_counter = 0;
        gt_safe_assign(bits_left_in_page, (hcr_enc->pagesize * 8));
        }
      }

      if (!had_err) {
      /* do the writing */
      bits_to_write = hcr_write_seq(hcr_enc->seq_encoder,
                                    seq, qual, len, bitstream, false);

      /* update counter for sampling */
      while (bits_left_in_page < bits_to_write) {
        page_counter++;
        bits_to_write -= bits_left_in_page;
        gt_safe_assign(bits_left_in_page, (hcr_enc->pagesize * 8));
      }
      bits_left_in_page -= bits_to_write;
      /* always set first page as written */
      if (page_counter == 0)
        page_counter++;
      read_counter++;
      hcr_enc->seq_encoder->total_num_of_symbols += len;
      cur_read++;
      }
    }
    gt_assert(hcr_enc->num_of_reads == cur_read);
    if (!had_err && seqit_err) {
      had_err = seqit_err;
      gt_assert(gt_error_is_set(err));
    }
  }

  if (!had_err) {
    gt_bitoutstream_flush(bitstream);
    filepos = gt_bitoutstream_pos(bitstream);
    if (filepos < 0) {
      had_err = -1;
      gt_error_set(err, "error by ftell: %s", strerror(errno));
    }
    else {
      hcr_enc->seq_encoder->startofsamplingtab = filepos;
      gt_log_log("start of samplingtab: " GT_WU,
                 hcr_enc->seq_encoder->startofsamplingtab);
      if (hcr_enc->seq_encoder->sampling != NULL) {
        gt_sampling_write(hcr_enc->seq_encoder->sampling, fp);
      }
    }
  }
  gt_bitoutstream_delete(bitstream);
  gt_seq_iterator_delete(seqit);
  return had_err;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
movq %rdx, 0xe0(%rsp)
movl $0x0, 0xdc(%rsp)
movq $0x0, 0xd0(%rsp)
movq $0x0, 0xc0(%rsp)
movq $0x0, 0xb8(%rsp)
movq $0x0, 0xa8(%rsp)
cmpq $0x0, 0xe0(%rsp)
je 0x189910
movq 0xe0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x1898d8
jmp 0x189910
movq 0x4b26c1(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38c72a(%rip), %rsi    # 0x516013
leaq 0x38c8cf(%rip), %rdx    # 0x5161bf
leaq 0x3cbab3(%rip), %rcx    # 0x5553aa
leaq 0x3cb3ed(%rip), %r8     # 0x554ceb
movl $0x16c, %r9d            # imm = 0x16C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x189912
jmp 0x189914
movq 0xe8(%rsp), %rax
movq 0x30(%rax), %rax
shlq $0x3, %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x68(%rsp), %rax
jne 0x189975
cmpq $0x1, 0x70(%rsp)
setb %al
andb $0x1, %al
movzbl %al, %eax
cmpq $0x1, 0x68(%rsp)
setb %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x189975
movq 0x68(%rsp), %rax
movq %rax, 0xb0(%rsp)
xorl %eax, %eax
movl %eax, 0x28(%rsp)
jmp 0x189980
movl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x189980
movl 0x28(%rsp), %eax
movl %eax, 0x64(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x1899bd
movq 0x4b260a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38e685(%rip), %rsi    # 0x518025
leaq 0x3cb344(%rip), %rdx    # 0x554ceb
movl $0x16e, %ecx            # imm = 0x16E
movb $0x0, %al
callq 0x199f0
movl $0x1, %edi
callq 0x19890
jmp 0x1899bf
movq 0xf0(%rsp), %rdi
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rax), %rsi
xorl %edx, %edx
callq 0x126ca0
movq 0xf0(%rsp), %rdi
callq 0x489ee0
movq %rax, 0x78(%rsp)
movq 0xe8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0xe0(%rsp), %rsi
callq 0x1126d0
movq %rax, 0x98(%rsp)
cmpq $0x0, 0x98(%rsp)
jne 0x189a74
jmp 0x189a1e
movq 0xe0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x189a67
movq 0x4b256a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38c5d3(%rip), %rsi    # 0x516013
leaq 0x3b0540(%rip), %rdx    # 0x539f87
leaq 0x3cb95c(%rip), %rcx    # 0x5553aa
leaq 0x3cb296(%rip), %r8     # 0x554ceb
movl $0x175, %r9d            # imm = 0x175
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x189a69
movl $0xffffffff, 0xdc(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0xdc(%rsp)
jne 0x189fa4
movq 0x98(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x111990
movq 0x98(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rdi
callq 0x7e870
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x1118a0
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x28(%rax)
xorl %eax, %eax
cmpl $0x0, 0xdc(%rsp)
movb %al, 0x1f(%rsp)
jne 0x189b28
movq 0x98(%rsp), %rdi
movq 0xe0(%rsp), %r8
leaq 0x90(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0x80(%rsp), %rcx
callq 0x111ab0
movl %eax, 0xd8(%rsp)
cmpl $0x1, %eax
sete %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x189b35
jmp 0x189ee1
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, 0x58(%rsp)
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0xc8(%rsp), %rcx
movq 0x78(%rsp), %r8
movl $0x1, %r9d
callq 0x18a3b0
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0x58(%rsp)
je 0x189d22
movq 0x58(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movq 0xb0(%rsp), %r8
callq 0x1d0da0
testb $0x1, %al
jne 0x189bc5
jmp 0x189d22
movq 0xa8(%rsp), %rsi
leaq 0x3cb7e5(%rip), %rdi    # 0x5553b9
movb $0x0, %al
callq 0xe7740
movq 0x78(%rsp), %rdi
callq 0x48a200
movq 0x78(%rsp), %rdi
callq 0x48a2d0
movq %rax, 0xa0(%rsp)
cmpq $0x0, 0xa0(%rsp)
jge 0x189c41
movl $0xffffffff, 0xdc(%rsp) # imm = 0xFFFFFFFF
movq 0xe0(%rsp), %rax
movq %rax, 0x10(%rsp)
callq 0x19060
movl (%rax), %edi
callq 0x19200
movq 0x10(%rsp), %rdi
movq %rax, %rdx
leaq 0x3cb796(%rip), %rsi    # 0x5553cb
movb $0x0, %al
callq 0xd88c0
jmp 0x189d20
movq 0x58(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0x1d0b50
movq $0x0, 0xc0(%rsp)
movq $0x0, 0xb8(%rsp)
movq 0xe8(%rsp), %rax
movq 0x30(%rax), %rax
shlq $0x3, %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rax
jne 0x189cd4
cmpq $0x1, 0x50(%rsp)
setb %al
andb $0x1, %al
movzbl %al, %eax
cmpq $0x1, 0x48(%rsp)
setb %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x189cd4
movq 0x48(%rsp), %rax
movq %rax, 0xb0(%rsp)
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x189cdf
movl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x189cdf
movl 0xc(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x189d1c
movq 0x4b22ab(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38e326(%rip), %rsi    # 0x518025
leaq 0x3cafe5(%rip), %rdx    # 0x554ceb
movl $0x19f, %ecx            # imm = 0x19F
movb $0x0, %al
callq 0x199f0
movl $0x1, %edi
callq 0x19890
jmp 0x189d1e
jmp 0x189d20
jmp 0x189d22
cmpl $0x0, 0xdc(%rsp)
jne 0x189edc
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0xc8(%rsp), %rcx
movq 0x78(%rsp), %r8
xorl %r9d, %r9d
callq 0x18a3b0
movq %rax, 0xd0(%rsp)
movq 0xb0(%rsp), %rax
cmpq 0xd0(%rsp), %rax
jae 0x189e5e
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
movq 0xb0(%rsp), %rcx
movq 0xd0(%rsp), %rax
subq %rcx, %rax
movq %rax, 0xd0(%rsp)
movq 0xe8(%rsp), %rax
movq 0x30(%rax), %rax
shlq $0x3, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x189e0f
cmpq $0x1, 0x38(%rsp)
setb %al
andb $0x1, %al
movzbl %al, %eax
cmpq $0x1, 0x30(%rsp)
setb %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x189e0f
movq 0x30(%rsp), %rax
movq %rax, 0xb0(%rsp)
xorl %eax, %eax
movl %eax, 0x8(%rsp)
jmp 0x189e1a
movl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x189e1a
movl 0x8(%rsp), %eax
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0x189e57
movq 0x4b2170(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38e1eb(%rip), %rsi    # 0x518025
leaq 0x3caeaa(%rip), %rdx    # 0x554ceb
movl $0x1ac, %ecx            # imm = 0x1AC
movb $0x0, %al
callq 0x199f0
movl $0x1, %edi
callq 0x19890
jmp 0x189e59
jmp 0x189d69
movq 0xd0(%rsp), %rcx
movq 0xb0(%rsp), %rax
subq %rcx, %rax
movq %rax, 0xb0(%rsp)
cmpq $0x0, 0xb8(%rsp)
jne 0x189e98
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
movq 0xc0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc0(%rsp)
movq 0xc8(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
jmp 0x189ada
jmp 0x189ee3
movq 0xe8(%rsp), %rax
movq 0x18(%rax), %rax
cmpq 0xa8(%rsp), %rax
je 0x189f31
movq 0x4b20a0(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38c109(%rip), %rsi    # 0x516013
leaq 0x3cb4cd(%rip), %rdx    # 0x5553de
leaq 0x3cb492(%rip), %rcx    # 0x5553aa
leaq 0x3cadcc(%rip), %r8     # 0x554ceb
movl $0x1b7, %r9d            # imm = 0x1B7
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x189f33
cmpl $0x0, 0xdc(%rsp)
jne 0x189fa2
cmpl $0x0, 0xd8(%rsp)
je 0x189fa2
movl 0xd8(%rsp), %eax
movl %eax, 0xdc(%rsp)
movq 0xe0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x189f9e
movq 0x4b2033(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x38c09c(%rip), %rsi    # 0x516013
leaq 0x3b0009(%rip), %rdx    # 0x539f87
leaq 0x3cb425(%rip), %rcx    # 0x5553aa
leaq 0x3cad5f(%rip), %r8     # 0x554ceb
movl $0x1ba, %r9d            # imm = 0x1BA
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x189fa0
jmp 0x189fa2
jmp 0x189fa4
cmpl $0x0, 0xdc(%rsp)
jne 0x18a07d
movq 0x78(%rsp), %rdi
callq 0x48a160
movq 0x78(%rsp), %rdi
callq 0x48a2d0
movq %rax, 0xa0(%rsp)
cmpq $0x0, 0xa0(%rsp)
jge 0x18a013
movl $0xffffffff, 0xdc(%rsp) # imm = 0xFFFFFFFF
movq 0xe0(%rsp), %rax
movq %rax, (%rsp)
callq 0x19060
movl (%rax), %edi
callq 0x19200
movq (%rsp), %rdi
movq %rax, %rdx
leaq 0x3cb3c1(%rip), %rsi    # 0x5553cb
movb $0x0, %al
callq 0xd88c0
jmp 0x18a07b
movq 0xa0(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x38(%rax)
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rax), %rsi
leaq 0x3cb3be(%rip), %rdi    # 0x555400
movb $0x0, %al
callq 0xe7740
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x20(%rax)
je 0x18a079
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rdi
movq 0xf0(%rsp), %rsi
callq 0x1cffc0
jmp 0x18a07b
jmp 0x18a07d
movq 0x78(%rsp), %rdi
callq 0x48a2f0
movq 0x98(%rsp), %rdi
callq 0x111c10
movl 0xdc(%rsp), %eax
addq $0xf8, %rsp
retq
nopw %cs:(%rax,%rax)