// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/encdesc.c
// Function: gt_encdesc_decode
int gt_encdesc_decode(GtEncdesc *encdesc,
                      GtUword num,
                      GtStr *desc,
                      GtError *err)
{
  int had_err = 0;
  GtUword descs2read = 0,
          nearestsample = 0,
          idx;
  size_t startofnearestsample = 0;

  gt_assert(encdesc);
  gt_assert(desc);
  gt_assert(num < encdesc->num_of_descs);

  if (encdesc->cur_desc == num) {
    return encdesc_next_desc(encdesc, desc, err);
  }

  if (encdesc->sampling != NULL) {
    (void) gt_sampling_get_page(encdesc->sampling,
                                num,
                                &nearestsample,
                                &startofnearestsample);
    /* nearestsample <= cur_read < readnum: current sample is the right one */
    if (nearestsample <= encdesc->cur_desc && encdesc->cur_desc <= num)
      descs2read = num - encdesc->cur_desc;
    else { /* reset decoder to new sample */
      gt_bitinstream_reinit(encdesc->bitinstream,
                            startofnearestsample);
      encdesc->cur_desc = nearestsample;
      descs2read = num - nearestsample;
    }
  }
  else {
    if (encdesc->cur_desc <= num)
      descs2read = num - encdesc->cur_desc;
    else {
      gt_bitinstream_reinit(encdesc->bitinstream,
                            (size_t) encdesc->start_of_encoding);
      descs2read = num;
      encdesc->cur_desc = 0;
    }
  }

  /* decode all description until the requested */
  for (idx = 0; !had_err && idx < descs2read; idx++) {
    had_err = encdesc_next_desc(encdesc, NULL, err);
  }

  /* decode the requested description */
  if (!had_err) {
    had_err = encdesc_next_desc(encdesc, desc, err);
  }
  return had_err;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
andq $0x0, 0x8(%rsp)
andq $0x0, (%rsp)
testq %rdi, %rdi
je 0xd2f56
movq %rdx, %r14
testq %rdx, %rdx
je 0xd2f84
movq %rsi, %r12
movq %rdi, %r15
cmpq %rsi, 0x38(%rdi)
jbe 0xd2fb2
movq %rcx, %rbx
movq 0x48(%r15), %rax
cmpq %rax, %r12
jne 0xd2eaa
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xd2fea
movq 0x28(%r15), %rdi
testq %rdi, %rdi
je 0xd2ef9
leaq 0x8(%rsp), %r13
movq %rsp, %rcx
movq %r12, %rsi
movq %r13, %rdx
callq 0x11436c
movq 0x48(%r15), %rax
cmpq %rax, (%r13)
seta %cl
movq %r12, %r13
subq %rax, %r13
setb %al
orb %cl, %al
je 0xd2f16
movq 0x20(%r15), %rdi
movq (%rsp), %rsi
callq 0x296f41
movq 0x8(%rsp), %rax
movq %rax, 0x48(%r15)
subq %rax, %r12
jmp 0xd2f13
movq %r12, %r13
subq %rax, %r13
jae 0xd2f16
movq 0x20(%r15), %rdi
movq 0x60(%r15), %rsi
callq 0x296f41
andq $0x0, 0x48(%r15)
movq %r12, %r13
xorl %eax, %eax
xorl %r12d, %r12d
testl %eax, %eax
jne 0xd2f36
cmpq %r13, %r12
jae 0xd2f36
movq %r15, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0xd2fea
incq %r12
jmp 0xd2f1b
testl %eax, %eax
jne 0xd2f48
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xd2fea
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x36500b(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2120ac(%rip), %rsi    # 0x2e5013
leaq 0x24948a(%rip), %rdx    # 0x31c3f8
leaq 0x2494aa(%rip), %rcx    # 0x31c41f
leaq 0x24914c(%rip), %r8     # 0x31c0c8
movl $0x599, %r9d            # imm = 0x599
jmp 0xd2fde
movq 0x364fdd(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x21207e(%rip), %rsi    # 0x2e5013
leaq 0x23d6e3(%rip), %rdx    # 0x31067f
leaq 0x24947c(%rip), %rcx    # 0x31c41f
leaq 0x24911e(%rip), %r8     # 0x31c0c8
movl $0x59a, %r9d            # imm = 0x59A
jmp 0xd2fde
movq 0x364faf(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x212050(%rip), %rsi    # 0x2e5013
leaq 0x249467(%rip), %rdx    # 0x31c431
leaq 0x24944e(%rip), %rcx    # 0x31c41f
leaq 0x2490f0(%rip), %r8     # 0x31c0c8
movl $0x59b, %r9d            # imm = 0x59B
xorl %eax, %eax
callq 0x17a50
callq 0x17390