// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/encdesc.c
// Function: gt_encdesc_encoder_encode
int gt_encdesc_encoder_encode(GtEncdescEncoder *ee,
                              GtCstrIterator *cstr_iterator,
                              const char *name, GtError *err)
{
  int had_err = 0;
  bool is_not_at_pageborder;
  FILE *fp = NULL;
  GtStr *name1;
  GtWord sampling_start_safe_pos = 0;
  const GtUword dummy = 0;
  GtUword pagesize;

  gt_assert(ee != NULL);
  gt_assert(cstr_iterator != NULL);
  gt_assert(name != NULL);
  gt_error_check(err);
  if (ee->timer != NULL) {
    gt_timer_show_progress(ee->timer, "analyze descriptions", stdout);
  }
  had_err = encdesc_analyze_descs(ee->encdesc, cstr_iterator, err);

  if (!had_err) {
    if (ee->timer != NULL) {
      gt_timer_show_progress(ee->timer, "write encoding header", stdout);
    }

    fp = gt_fa_fopen_with_suffix(name, GT_ENCDESC_FILESUFFIX, "wb", err);
    if (fp == NULL)
      had_err = -1;
  }

  /* also determines if fields will use hc */
  if (!had_err)
    had_err = encdesc_write_header(ee->encdesc, fp, err);
  if (!had_err) {
    if (ee->timer != NULL) {
      gt_timer_show_progress(ee->timer, "calculate huffmans", stdout);
    }
    encdesc_init_huffman(ee->encdesc);
    if (ee->timer != NULL) {
      gt_timer_show_progress(ee->timer, "write encoding", stdout);
    }
    gt_error_check(err);
    sampling_start_safe_pos = ftell(fp);
    gt_xfwrite_one(&dummy, fp);

    pagesize = ee->encdesc->pagesize;
    is_not_at_pageborder = (ftell(fp) % pagesize) != 0;
    if (is_not_at_pageborder)
      ee->encdesc->start_of_encoding = (ftell(fp) / pagesize + 1) * pagesize;
    else
      ee->encdesc->start_of_encoding = ftell(fp);

    gt_xfwrite_one(&ee->encdesc->start_of_encoding, fp);

    gt_xfseek(fp, ee->encdesc->start_of_encoding, SEEK_SET);

    if (ee->page_sampling)
      ee->encdesc->sampling =
        gt_sampling_new_page(ee->sampling_rate,
                             (off_t) ee->encdesc->start_of_encoding);
    else if (ee->regular_sampling)
      ee->encdesc->sampling =
        gt_sampling_new_regular(ee->sampling_rate,
                                (off_t) ee->encdesc->start_of_encoding);
    had_err = encdesc_write_encoding(ee->encdesc, cstr_iterator, fp, err);
  }
  if (!had_err) {
    if (ee->encdesc->sampling != NULL) {
      gt_xfseek(fp, sampling_start_safe_pos, SEEK_SET);
      gt_xfwrite_one(&ee->encdesc->start_of_samplingtab, fp);
    }
  }

  gt_fa_xfclose(fp);
  if (!had_err) {
    if (ee->timer != NULL) {
      gt_timer_show_progress(ee->timer,
                             "description encoding finished", stdout);
    }
    if (gt_log_enabled()) {
      GtUword rate;
      name1 = gt_str_new_cstr(name);
      gt_str_append_cstr(name1, GT_ENCDESC_FILESUFFIX);
      gt_log_log("description encoding overview:");
      gt_log_log("==>");
      if (ee->encdesc->sampling != NULL) {
        rate = gt_sampling_get_rate(ee->encdesc->sampling);
        if (gt_sampling_is_regular(ee->encdesc->sampling)) {
          gt_log_log("applied sampling technique:"
                     " sampling every "GT_WU"th description",
                     rate);
        }
        else {
          gt_log_log("applied sampling technique:"
                     " sampling every "GT_WU"th page",
                     rate);
        }
      }
      else {
        gt_log_log("applied sampling technique: none");
      }

      gt_log_log("total number of encoded descriptions: "GT_WU"",
                 ee->encdesc->num_of_descs);
      gt_log_log("total number of encoded characters: "GT_LLU"",
                 ee->encdesc->total_num_of_chars);
      gt_log_log("bits per character encoding: %f",
                 (gt_file_estimate_size(gt_str_get(name1)) * 8.0) /
                 ee->encdesc->total_num_of_chars);
      gt_log_log("<==");
      gt_str_delete(name1);
    }
  }
  return had_err;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x15f2eb
movq 0x4dcce6(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3b6d4f(%rip), %rsi    # 0x516013
leaq 0x410013(%rip), %rdx    # 0x56f2de
leaq 0x3ef0c1(%rip), %rcx    # 0x54e393
leaq 0x3eef8f(%rip), %r8     # 0x54e268
movl $0x3eb, %r9d            # imm = 0x3EB
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x15f2ed
jmp 0x15f2ef
cmpq $0x0, 0x58(%rsp)
jne 0x15f32f
movq 0x4dcca2(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3b6d0b(%rip), %rsi    # 0x516013
leaq 0x3ef09e(%rip), %rdx    # 0x54e3ad
leaq 0x3ef07d(%rip), %rcx    # 0x54e393
leaq 0x3eef4b(%rip), %r8     # 0x54e268
movl $0x3ec, %r9d            # imm = 0x3EC
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x15f331
jmp 0x15f333
cmpq $0x0, 0x50(%rsp)
jne 0x15f373
movq 0x4dcc5e(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3b6cc7(%rip), %rsi    # 0x516013
leaq 0x3b9805(%rip), %rdx    # 0x518b58
leaq 0x3ef039(%rip), %rcx    # 0x54e393
leaq 0x3eef07(%rip), %r8     # 0x54e268
movl $0x3ed, %r9d            # imm = 0x3ED
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x15f375
jmp 0x15f377
cmpq $0x0, 0x48(%rsp)
je 0x15f3c7
movq 0x48(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x15f38f
jmp 0x15f3c7
movq 0x4dcc0a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3b6c73(%rip), %rsi    # 0x516013
leaq 0x3b6e18(%rip), %rdx    # 0x5161bf
leaq 0x3eefe5(%rip), %rcx    # 0x54e393
leaq 0x3eeeb3(%rip), %r8     # 0x54e268
movl $0x3ee, %r9d            # imm = 0x3EE
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x15f3c9
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
je 0x15f3f2
movq 0x60(%rsp), %rax
movq (%rax), %rdi
movq 0x4dcb55(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x3eefd6(%rip), %rsi    # 0x54e3c3
callq 0x121930
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x15f8f0
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x44(%rsp)
jne 0x15f47f
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
je 0x15f43e
movq 0x60(%rsp), %rax
movq (%rax), %rdi
movq 0x4dcb09(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x3eef9f(%rip), %rsi    # 0x54e3d8
callq 0x121930
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %r9
leaq 0x3eef9f(%rip), %rsi    # 0x54e3ee
leaq 0x3c7747(%rip), %rdx    # 0x526b9d
leaq 0x3eee0b(%rip), %rcx    # 0x54e268
movl $0x3f9, %r8d            # imm = 0x3F9
callq 0xd92c0
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x15f47d
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x15f47f
cmpl $0x0, 0x44(%rsp)
jne 0x15f4a2
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x38(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x164600
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x44(%rsp)
jne 0x15f6d6
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
je 0x15f4d6
movq 0x60(%rsp), %rax
movq (%rax), %rdi
movq 0x4dca71(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x3eef22(%rip), %rsi    # 0x54e3f3
callq 0x121930
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x161110
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
je 0x15f50d
movq 0x60(%rsp), %rax
movq (%rax), %rdi
movq 0x4dca3a(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x3eeefe(%rip), %rsi    # 0x54e406
callq 0x121930
jmp 0x15f50f
cmpq $0x0, 0x48(%rsp)
je 0x15f55f
movq 0x48(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x15f527
jmp 0x15f55f
movq 0x4dca72(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3b6adb(%rip), %rsi    # 0x516013
leaq 0x3b6c80(%rip), %rdx    # 0x5161bf
leaq 0x3eee4d(%rip), %rcx    # 0x54e393
leaq 0x3eed1b(%rip), %r8     # 0x54e268
movl $0x409, %r9d            # imm = 0x409
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x15f561
movq 0x38(%rsp), %rdi
callq 0x19030
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rcx
leaq 0x20(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x126d30
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rdi
callq 0x19030
xorl %ecx, %ecx
movl %ecx, %edx
divq 0x18(%rsp)
cmpq $0x0, %rdx
setne %al
andb $0x1, %al
movb %al, 0x43(%rsp)
testb $0x1, 0x43(%rsp)
je 0x15f5f1
movq 0x38(%rsp), %rdi
callq 0x19030
xorl %ecx, %ecx
movl %ecx, %edx
divq 0x18(%rsp)
movq %rax, %rcx
addq $0x1, %rcx
imulq 0x18(%rsp), %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x60(%rax)
jmp 0x15f60b
movq 0x38(%rsp), %rdi
callq 0x19030
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x60(%rax)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
addq $0x60, %rdi
movq 0x38(%rsp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x126d30
movq 0x38(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x60(%rax), %rsi
xorl %edx, %edx
callq 0x126ca0
movq 0x60(%rsp), %rax
testb $0x1, 0x19(%rax)
je 0x15f67d
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x60(%rax), %rsi
callq 0x1cff10
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x28(%rax)
jmp 0x15f6b5
movq 0x60(%rsp), %rax
testb $0x1, 0x18(%rax)
je 0x15f6b3
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x60(%rax), %rsi
callq 0x1cfce0
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x28(%rax)
jmp 0x15f6b5
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x58(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x48(%rsp), %rcx
callq 0x161450
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x44(%rsp)
jne 0x15f721
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x15f71f
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x126ca0
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
addq $0x58, %rdi
movq 0x38(%rsp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x126d30
jmp 0x15f721
movq 0x38(%rsp), %rdi
callq 0xd9570
cmpl $0x0, 0x44(%rsp)
jne 0x15f8db
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
je 0x15f75f
movq 0x60(%rsp), %rax
movq (%rax), %rdi
movq 0x4dc7e8(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x3eecbb(%rip), %rsi    # 0x54e415
callq 0x121930
callq 0xe7720
testb $0x1, %al
jne 0x15f76d
jmp 0x15f8d9
movq 0x50(%rsp), %rdi
callq 0x11d510
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x3eec66(%rip), %rsi    # 0x54e3ee
callq 0x11d550
leaq 0x3eec9f(%rip), %rdi    # 0x54e433
movb $0x0, %al
callq 0xe7740
leaq 0x3eecb0(%rip), %rdi    # 0x54e452
movb $0x0, %al
callq 0xe7740
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x15f812
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rdi
callq 0x1d0b00
movq %rax, 0x10(%rsp)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rdi
callq 0x1d0aa0
testb $0x1, %al
jne 0x15f7e8
jmp 0x15f7fd
movq 0x10(%rsp), %rsi
leaq 0x3eec62(%rip), %rdi    # 0x54e456
movb $0x0, %al
callq 0xe7740
jmp 0x15f810
movq 0x10(%rsp), %rsi
leaq 0x3eec8a(%rip), %rdi    # 0x54e493
movb $0x0, %al
callq 0xe7740
jmp 0x15f820
leaq 0x3eecb0(%rip), %rdi    # 0x54e4c9
movb $0x0, %al
callq 0xe7740
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rax), %rsi
leaq 0x3eecb6(%rip), %rdi    # 0x54e4ea
xorl %eax, %eax
movb %al, 0xf(%rsp)
callq 0xe7740
movb 0xf(%rsp), %al
movq 0x60(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0x30(%rcx), %rsi
leaq 0x3eecbd(%rip), %rdi    # 0x54e514
callq 0xe7740
movq 0x30(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
callq 0xdf1d0
cvtsi2sd %rax, %xmm0
movsd 0x3ee9e5(%rip), %xmm1   # 0x54e260
mulsd %xmm1, %xmm0
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %xmm1
movaps 0x3b909c(%rip), %xmm2   # 0x518930
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x3b90a0(%rip), %xmm2   # 0x518940
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x3eec83(%rip), %rdi    # 0x54e53d
movb $0x1, %al
callq 0xe7740
leaq 0x3eec95(%rip), %rdi    # 0x54e55d
movb $0x0, %al
callq 0xe7740
movq 0x30(%rsp), %rdi
callq 0x11f560
jmp 0x15f8db
movl 0x44(%rsp), %eax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)