// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x48(%rsp)
jne 0x161d1b
movq 0x4da2b6(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3b431f(%rip), %rsi    # 0x516013
leaq 0x3ec89d(%rip), %rdx    # 0x54e598
leaq 0x3ec8bd(%rip), %rcx    # 0x54e5bf
leaq 0x3ec55f(%rip), %r8     # 0x54e268
movl $0x599, %r9d            # imm = 0x599
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x161d1d
jmp 0x161d1f
cmpq $0x0, 0x38(%rsp)
jne 0x161d5f
movq 0x4da272(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3b42db(%rip), %rsi    # 0x516013
leaq 0x3e0896(%rip), %rdx    # 0x5425d5
leaq 0x3ec879(%rip), %rcx    # 0x54e5bf
leaq 0x3ec51b(%rip), %r8     # 0x54e268
movl $0x59a, %r9d            # imm = 0x59A
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x161d61
jmp 0x161d63
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpq 0x38(%rcx), %rax
jb 0x161dab
movq 0x4da226(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3b428f(%rip), %rsi    # 0x516013
leaq 0x3ec846(%rip), %rdx    # 0x54e5d1
leaq 0x3ec82d(%rip), %rcx    # 0x54e5bf
leaq 0x3ec4cf(%rip), %r8     # 0x54e268
movl $0x59b, %r9d            # imm = 0x59B
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x161dad
movq 0x48(%rsp), %rax
movq 0x48(%rax), %rax
cmpq 0x40(%rsp), %rax
jne 0x161dda
movq 0x48(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x161f50
movl %eax, 0x54(%rsp)
jmp 0x161f42
movq 0x48(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x161e6e
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rdi
movq 0x40(%rsp), %rsi
leaq 0x18(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x1d0450
movq 0x18(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpq 0x48(%rcx), %rax
ja 0x161e3c
movq 0x48(%rsp), %rax
movq 0x48(%rax), %rax
cmpq 0x40(%rsp), %rax
ja 0x161e3c
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
subq 0x48(%rcx), %rax
movq %rax, 0x20(%rsp)
jmp 0x161e6c
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x8(%rsp), %rsi
callq 0x489b50
movq 0x18(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x40(%rsp), %rax
subq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x161ec3
movq 0x48(%rsp), %rax
movq 0x48(%rax), %rax
cmpq 0x40(%rsp), %rax
ja 0x161e93
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
subq 0x48(%rcx), %rax
movq %rax, 0x20(%rsp)
jmp 0x161ec1
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x60(%rax), %rsi
callq 0x489b50
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rax
movq $0x0, 0x48(%rax)
jmp 0x161ec3
movq $0x0, 0x10(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x2c(%rsp)
movb %al, 0x7(%rsp)
jne 0x161eea
movq 0x10(%rsp), %rax
cmpq 0x20(%rsp), %rax
setb %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x161ef4
jmp 0x161f1b
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x161f50
movl %eax, 0x2c(%rsp)
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x161ecc
cmpl $0x0, 0x2c(%rsp)
jne 0x161f3a
movq 0x48(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x161f50
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax,%rax)