// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/samfile_encseq_mapping.c
// Function: gt_samfile_encseq_mapping_new
GtSamfileEncseqMapping *gt_samfile_encseq_mapping_new(
    /*const*/ GtSamfileIterator *samfile_iterator, const GtEncseq *encseq,
    GtError *err)
{
  GtSamfileEncseqMapping *samfile_encseq_mapping;
  bool haserr = false;
  gt_assert(samfile_iterator != NULL);
  gt_assert(encseq != NULL);
  gt_error_check(err);
  samfile_encseq_mapping = gt_malloc(sizeof (GtSamfileEncseqMapping));
  samfile_encseq_mapping->nof_sequences = gt_encseq_num_of_sequences(encseq);
  samfile_encseq_mapping->samfile2encseq = NULL;
  samfile_encseq_mapping->encseq = encseq;
  if ((GtUword)gt_samfile_iterator_number_of_references(samfile_iterator)
      != samfile_encseq_mapping->nof_sequences)
  {
    gt_error_set(err, "The number of sequences in the encoded sequence "
        "is not the same as the number of references in the SAM file.");
    haserr = true;
  }
  else
  {
    GtHashmap *seqid2seqnum;
    GtUword i, cnum, dlen, *stored, *seqnum;
    int32_t refnum;
    const char *d;
    char *seqid = NULL;
    seqid2seqnum = gt_hashmap_new(GT_HASH_STRING, gt_free_func, gt_free_func);
    for (i = 0; i < samfile_encseq_mapping->nof_sequences; i++)
    {

      d = gt_encseq_description(encseq, &dlen, i);
      seqid = gt_cstr_dup_nt(d, dlen);
      for (cnum = 0; cnum < dlen; cnum++)
      {
        if (seqid[cnum] == ' ')
        {
          seqid[cnum] = '\0';
          break;
        }
      }
      if ((stored = gt_hashmap_get(seqid2seqnum, seqid)) != NULL)
      {
        gt_error_set(err, "The encseq identifier '%s' is not unique!", seqid);
        haserr = true;
        break;
      }
      else
      {
        seqnum = gt_malloc(sizeof (GtUword));
        *seqnum = i;
        gt_hashmap_add(seqid2seqnum, seqid, seqnum);
      }
    }
    if (!haserr)
    {
      samfile_encseq_mapping->samfile2encseq = gt_malloc(
          sizeof (*samfile_encseq_mapping->samfile2encseq) *
          samfile_encseq_mapping->nof_sequences);
      for (refnum = 0; refnum < (int32_t)samfile_encseq_mapping->nof_sequences;
          refnum++)
      {
        d = gt_samfile_iterator_reference_name(samfile_iterator, refnum);
        if ((seqnum = gt_hashmap_get(seqid2seqnum, d)) == NULL)
        {
          gt_error_set(err,
              "The SAM identifier '%s' was not found in the encseq!", d);
          haserr = true;
          break;
        }
        samfile_encseq_mapping->samfile2encseq[refnum] = *seqnum;
      }
    }
    gt_hashmap_delete(seqid2seqnum);
  }
  if (haserr)
  {
    gt_samfile_encseq_mapping_delete(samfile_encseq_mapping);
    return NULL;
  }
  else
    return samfile_encseq_mapping;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x1139cf
movq %rsi, %r13
testq %rsi, %rsi
je 0x1139f9
movq %rdx, %r14
movq %rdi, %r15
testq %rdx, %rdx
je 0x113826
movq %r14, %rdi
callq 0x89eb7
testb %al, %al
jne 0x113a23
leaq 0x21e509(%rip), %rsi    # 0x331d36
pushq $0x18
popq %rdi
pushq $0x28
popq %rdx
callq 0x93160
movq %rax, %rbx
movq %r13, %rdi
callq 0x705a1
movq %rax, 0x10(%rbx)
andq $0x0, 0x8(%rbx)
movq %r13, (%rbx)
movq %r15, %rdi
callq 0x113db9
cltq
cmpq %rax, 0x10(%rbx)
jne 0x113910
movq %r15, 0x10(%rsp)
movq %r14, (%rsp)
leaq -0x80034(%rip), %rdx    # 0x9383f
pushq $0x1
popq %rdi
movq %rdx, %rsi
callq 0x8f330
movq %rax, %r12
xorl %ebp, %ebp
pushq $0x50
popq %r15
movq 0x10(%rbx), %rdi
cmpq %rdi, %rbp
jae 0x113926
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x75b24
movq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x6c330
movq %rax, %r14
movq 0x8(%rsp), %rcx
xorl %eax, %eax
cmpq %rax, %rcx
je 0x1138d1
cmpb $0x20, (%r14,%rax)
je 0x1138cc
incq %rax
jmp 0x1138bb
movb $0x0, (%r14,%rax)
movq %r12, %rdi
movq %r14, %rsi
callq 0x8f482
testq %rax, %rax
jne 0x11397c
pushq $0x8
popq %rdi
leaq 0x21e447(%rip), %rsi    # 0x331d36
movl %r15d, %edx
callq 0x93160
movq %rbp, (%rax)
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8f4bd
incq %rbp
jmp 0x113887
leaq 0x21e445(%rip), %rsi    # 0x331d5c
movq %r14, %rdi
xorl %eax, %eax
callq 0x89dbb
jmp 0x1139b3
shlq $0x3, %rdi
leaq 0x21e405(%rip), %rsi    # 0x331d36
pushq $0x59
popq %rdx
callq 0x93160
movq %rax, 0x8(%rbx)
xorl %r14d, %r14d
movq 0x10(%rsp), %r13
movslq 0x10(%rbx), %rax
cmpq %rax, %r14
jge 0x11398c
movq %r13, %rdi
movl %r14d, %esi
callq 0x113d36
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x8f482
testq %rax, %rax
je 0x113996
movq (%rax), %rax
movq 0x8(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
jmp 0x113945
leaq 0x21e446(%rip), %rsi    # 0x331dc9
movq (%rsp), %rdi
movq %r14, %rdx
jmp 0x1139a4
movq %r12, %rdi
callq 0x8f933
jmp 0x1139bd
leaq 0x21e456(%rip), %rsi    # 0x331df3
movq (%rsp), %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x89dbb
movq %r12, %rdi
callq 0x8f933
movq %rbx, %rdi
callq 0x113a59
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x324592(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d1633(%rip), %rsi    # 0x2e5013
leaq 0x21e318(%rip), %rdx    # 0x331cff
leaq 0x21e32a(%rip), %rcx    # 0x331d18
leaq 0x21e341(%rip), %r8     # 0x331d36
pushq $0x25
jmp 0x113a4b
movq 0x324568(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d1609(%rip), %rsi    # 0x2e5013
leaq 0x22c8a1(%rip), %rdx    # 0x3402b2
leaq 0x21e300(%rip), %rcx    # 0x331d18
leaq 0x21e317(%rip), %r8     # 0x331d36
pushq $0x26
jmp 0x113a4b
movq 0x32453e(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d15df(%rip), %rsi    # 0x2e5013
leaq 0x1d1784(%rip), %rdx    # 0x2e51bf
leaq 0x21e2d6(%rip), %rcx    # 0x331d18
leaq 0x21e2ed(%rip), %r8     # 0x331d36
pushq $0x27
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390