// File: /workspace/github_c_makefile_star2_O3/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
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movq %rax, (%rsp)
testq %rdi, %rdi
je 0x13c713
movq %rdx, %r14
testq %rdx, %rdx
je 0x13c718
movq %rsi, %r12
movq %rdi, %r15
cmpq %rsi, 0x38(%rdi)
jbe 0x13c71d
movq %rcx, %rbx
movq 0x48(%r15), %rax
cmpq %rax, %r12
jne 0x13c65b
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x13c722
movq 0x28(%r15), %rdi
testq %rdi, %rdi
je 0x13c6aa
leaq 0x8(%rsp), %r13
movq %rsp, %rcx
movq %r12, %rsi
movq %r13, %rdx
callq 0x17106b
movq 0x48(%r15), %rax
cmpq %rax, (%r13)
seta %cl
movq %r12, %r13
subq %rax, %r13
setb %al
orb %cl, %al
je 0x13c6ca
movq 0x20(%r15), %rdi
movq (%rsp), %rsi
callq 0x2fad73
movq 0x8(%rsp), %rax
movq %rax, 0x48(%r15)
subq %rax, %r12
jmp 0x13c6c7
movq %r12, %r13
subq %rax, %r13
jae 0x13c6ca
movq 0x20(%r15), %rdi
movq 0x60(%r15), %rsi
callq 0x2fad73
movq $0x0, 0x48(%r15)
movq %r12, %r13
testq %r13, %r13
je 0x13c6f7
movl $0x1, %r12d
movq %r15, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x13c722
testl %eax, %eax
jne 0x13c6f3
leaq 0x1(%r12), %rcx
cmpq %r13, %r12
movq %rcx, %r12
jb 0x13c6d5
testl %eax, %eax
jne 0x13c705
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x13c722
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x40963
callq 0x4092a
callq 0x408f1