// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/region_mapping.c
// Function: gt_region_mapping_get_sequence_length
int gt_region_mapping_get_sequence_length(GtRegionMapping *rm,
                                          GtUword *length, GtStr *seqid,
                                          GtError *err)
{
  GtUword filenum, seqnum;
  int had_err;
  gt_error_check(err);
  GT_UNUSED GtRange range = {0,0};
  gt_assert(rm && seqid);
  if (rm->userawseq) {
    return rm->rawlength;
  }
  had_err = update_seq_col_if_necessary(rm, seqid, err);
  if (!had_err) {
    if (gt_md5_seqid_has_prefix(gt_str_get(seqid))) {
      had_err = gt_seq_col_md5_to_sequence_length(rm->seq_col, length, seqid,
                                                  err);
    }
    else if (rm->usedesc) {
      gt_assert(rm->seqid2seqnum_mapping);
      had_err = gt_seqid2seqnum_mapping_map(rm->seqid2seqnum_mapping,
                                            gt_str_get(seqid), &range, &seqnum,
                                            &filenum, NULL, err);
      if (!had_err)
        *length = gt_seq_col_get_sequence_length(rm->seq_col, filenum, seqnum);
    }
    else if (rm->matchdesc) {
      had_err = gt_seq_col_grep_desc_sequence_length(rm->seq_col, length,
                                                     seqid, err);
    }
    else if (rm->useseqno) {
      GtUword seqno = GT_UNDEF_UWORD;
      gt_assert(rm->encseq);
      if (1 != sscanf(gt_str_get(seqid), "seq"GT_WU"", &seqno)) {
        gt_error_set(err, "seqid '%s' does not have the form 'seqX' "
                          "where X is a sequence number in the encoded "
                          "sequence", gt_str_get(seqid));
        had_err = -1;
      }
      gt_assert(had_err || seqno != GT_UNDEF_UWORD);
      if (!had_err && seqno >= gt_encseq_num_of_sequences(rm->encseq)) {
          gt_error_set(err, "trying to access sequence "GT_WU", but encoded "
                            "sequence contains only "GT_WU" sequences",
                            seqno, gt_encseq_num_of_sequences(rm->encseq));
          had_err = -1;
      }
      if (!had_err) {
        *length = gt_encseq_seqlength(rm->encseq, seqno);
      }
    } else if (rm->mapping) {
      *length = gt_seq_col_get_sequence_length(rm->seq_col, 0, 0);
    } else {
      gt_assert(!rm->usedesc && !rm->matchdesc);
      gt_error_set(err, "no mapping rule given and no MD5 tags "
                        "present in the query seqid \"%s\" -- no mapping can "
                        "be defined", gt_str_get(seqid));
      had_err = -1;
    }
  }
  return had_err;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r12
testq %rcx, %rcx
je 0xa870f
movq %r14, %rdi
callq 0x34fea
testb %al, %al
jne 0xa891b
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
testq %r12, %r12
je 0xa8916
testq %r13, %r13
je 0xa8916
cmpb $0x1, 0x1b(%r12)
jne 0xa8738
movl 0x50(%r12), %r15d
jmp 0xa8750
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0xa8547
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testl %eax, %eax
je 0xa8761
movl %r15d, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r13, %rdi
callq 0x3bb5d
movq %rax, %rdi
callq 0x7aa64
testb %al, %al
je 0xa8795
movq 0x38(%r12), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r14, %rcx
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xd82ad
cmpb $0x1, 0x19(%r12)
jne 0xa87fe
movq 0x40(%r12), %r15
testq %r15, %r15
je 0xa8920
movq %r13, %rdi
callq 0x3bb5d
movq %r14, (%rsp)
leaq 0x20(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq %r15, %rdi
movq %rax, %rsi
xorl %r9d, %r9d
callq 0xa944a
movl %eax, %r15d
testl %eax, %eax
jne 0xa8750
movq 0x38(%r12), %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0xd8361
movq %rax, (%rbx)
xorl %r15d, %r15d
jmp 0xa8750
cmpb $0x1, 0x18(%r12)
jne 0xa8826
movq 0x38(%r12), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r14, %rcx
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xd823b
cmpb $0x1, 0x1c(%r12)
jne 0xa8898
movq $-0x1, 0x10(%rsp)
cmpq $0x0, 0x30(%r12)
je 0xa8925
movq %r13, %rdi
callq 0x3bb5d
leaq 0x5329b(%rip), %rsi     # 0xfbaed
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0xb680
cmpl $0x1, %eax
jne 0xa88b9
movq 0x10(%rsp), %r13
cmpq $-0x1, %r13
je 0xa892a
movq 0x30(%r12), %rdi
callq 0xbff74
cmpq %rax, %r13
jae 0xa88eb
movq 0x30(%r12), %rdi
movq 0x10(%rsp), %rsi
callq 0xc3d9a
jmp 0xa87f3
cmpq $0x0, 0x20(%r12)
je 0xa88ca
movq 0x38(%r12), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
xorl %edx, %edx
callq 0xd8361
movq %rax, (%rbx)
jmp 0xa8750
movq %r13, %rdi
callq 0x3bb5d
leaq 0x5322c(%rip), %rsi     # 0xfbaf4
jmp 0xa88d9
movq %r13, %rdi
callq 0x3bb5d
leaq 0x533a8(%rip), %rsi     # 0xfbc81
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x34f1f
jmp 0xa8750
movq 0x10(%rsp), %rbx
movq 0x30(%r12), %rdi
callq 0xbff74
leaq 0x53274(%rip), %rsi     # 0xfbb75
movq %r14, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x34f1f
jmp 0xa8750
callq 0x23f65
callq 0x23f2c
callq 0x24010
callq 0x23fd7
callq 0x23f9e