// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/core/mapspec.c
// Function: gt_mapspec_read
int  gt_mapspec_read(GtMapspecSetupFunc setup, void *data,
                     const char *filename, GtUword expectedsize,
                     void **mapped, GtError *err)
{
  void *mapptr;
  uint64_t expectedaccordingtomapspec;
  GtUword byteoffset = 0;
  size_t numofbytes;
  GtMapspec *ms = gt_malloc(sizeof (GtMapspec));
  GtMapspecification *mapspecptr;
  int had_err = 0;
  GtUword totalpadunits = 0;

  gt_error_check(err);
  GT_INITARRAY(&ms->mapspectable, GtMapspecification);
  setup(ms, data, false);

  mapptr = gt_fa_mmap_read(filename, &numofbytes, err);
  if (mapptr == NULL)
  {
    had_err = -1;
  }
  *mapped = mapptr;
  if (!had_err)
  {
    if (assigncorrecttype(ms->mapspectable.spaceGtMapspecification,
                          mapptr,0,err) != 0)
    {
      had_err = -1;
    }
  }
  if (!had_err)
  {
    expectedaccordingtomapspec =
                               detexpectedaccordingtomapspec(&ms->mapspectable);
    if (expectedaccordingtomapspec != (uint64_t) numofbytes)
    {
      gt_error_set(err, GT_WU " bytes read from %s, but " Formatuint64_t
                   " expected",
                   (GtUword) numofbytes,
                   filename,
                   PRINTuint64_tcast(expectedaccordingtomapspec));
      had_err = -1;
    }
  }
  if (!had_err)
  {
    mapspecptr = ms->mapspectable.spaceGtMapspecification;
    gt_assert(mapspecptr != NULL);
    byteoffset = CALLCASTFUNC(uint64_t,unsigned_long,
                              (uint64_t) (mapspecptr->sizeofunit *
                                          mapspecptr->numofunits));
    if (byteoffset % (GtUword) GT_WORDSIZE_INBYTES > 0)
    {
      size_t padunits
        = GT_WORDSIZE_INBYTES - (byteoffset % GT_WORDSIZE_INBYTES);
      byteoffset += (GtUword) padunits;
      totalpadunits += (GtUword) padunits;
    }
    for (mapspecptr++;
         mapspecptr < ms->mapspectable.spaceGtMapspecification +
                      ms->mapspectable.nextfreeGtMapspecification; mapspecptr++)
    {
      if (assigncorrecttype(mapspecptr,mapptr,byteoffset,err) != 0)
      {
        had_err = -1;
        break;
      }
      byteoffset = CALLCASTFUNC(uint64_t,unsigned_long,
                                (uint64_t) (byteoffset +
                                            mapspecptr->sizeofunit *
                                            mapspecptr->numofunits));
      if (byteoffset % (GtUword) GT_WORDSIZE_INBYTES > 0)
      {
        size_t padunits
          = GT_WORDSIZE_INBYTES - (byteoffset % GT_WORDSIZE_INBYTES);
        byteoffset += (GtUword) padunits;
        totalpadunits += (GtUword) padunits;
      }
    }
  }
  if (!had_err)
  {
    if (expectedsize + totalpadunits != byteoffset)
    {
      gt_error_set(err,"mapping: expected file size is "GT_WU" bytes, "
                       "but file has "GT_WU" bytes",
                       expectedsize,byteoffset);
      had_err = -1;
    }
  }
  GT_FREEARRAY(&ms->mapspectable,GtMapspecification);
  gt_free(ms);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r14
movq %r8, %rbp
movq %rcx, 0x8(%rsp)
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r12
leaq 0x35022(%rip), %rsi     # 0xf2604
pushq $0x18
popq %rdi
movl $0x106, %edx            # imm = 0x106
callq 0xccb0
movq %rax, %rbx
testq %r14, %r14
je 0xbd607
movq %r14, %rdi
callq 0xc103
testb %al, %al
jne 0xbd7aa
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq *%r12
leaq 0x34fe0(%rip), %rdx     # 0xf2604
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
movl $0x10f, %ecx            # imm = 0x10F
movq %r14, %r8
callq 0x5272d
movq %rax, (%rbp)
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0xbd761
movq %rax, %r12
movq (%rbx), %rdi
movq %rax, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0xbd503
testl %eax, %eax
jne 0xbd761
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
imulq $0x28, %rcx, %rdx
addq %rax, %rdx
xorl %r8d, %r8d
movq %rax, %rsi
cmpq %rdx, %rsi
jae 0xbd697
movq 0x20(%rsi), %rdi
imulq 0x18(%rsi), %rdi
addq %rdi, %r8
addq $0x7, %r8
andq $-0x8, %r8
addq $0x28, %rsi
jmp 0xbd678
movq 0x10(%rsp), %rdx
cmpq %rdx, %r8
jne 0xbd725
testq %rax, %rax
je 0xbd7e2
movq 0x20(%rax), %r13
imulq 0x18(%rax), %r13
movl %r13d, %edx
andl $0x7, %edx
pushq $0x8
popq %r15
subq %rdx, %r15
testq %rdx, %rdx
cmoveq %rdx, %r15
addq %r15, %r13
leaq 0x28(%rax), %rbp
imulq $0x28, %rcx, %rcx
addq %rax, %rcx
cmpq %rcx, %rbp
jae 0xbd73b
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xbd503
testl %eax, %eax
jne 0xbd75e
movq 0x20(%rbp), %rax
imulq 0x18(%rbp), %rax
addq %r13, %rax
movl %eax, %ecx
andl $0x7, %ecx
pushq $0x8
popq %r13
subq %rcx, %r13
testq %rcx, %rcx
cmoveq %rcx, %r13
addq %r13, %r15
addq %rax, %r13
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
addq $0x28, %rbp
jmp 0xbd6d2
leaq 0x34f68(%rip), %rsi     # 0xf2694
movq %r14, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0xc007
jmp 0xbd761
movq 0x8(%rsp), %rdx
addq %rdx, %r15
xorl %ebp, %ebp
cmpq %r13, %r15
je 0xbd761
leaq 0x34f6c(%rip), %rsi     # 0xf26bd
movq %r14, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0xc007
pushq $-0x1
popq %rbp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xbd785
leaq 0x34e94(%rip), %rsi     # 0xf2604
movl $0x159, %edx            # imm = 0x159
callq 0xd249
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x34e78(%rip), %rsi     # 0xf2604
movq %rbx, %rdi
movl $0x15a, %edx            # imm = 0x15A
callq 0xd249
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x70807(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xc8ab(%rip), %rsi      # 0xca066
leaq 0xce97(%rip), %rdx      # 0xca659
leaq 0x34ebb(%rip), %rcx     # 0xf2684
leaq 0x34e34(%rip), %r8      # 0xf2604
movl $0x10b, %r9d            # imm = 0x10B
xorl %eax, %eax
callq 0xb8c0
callq 0xb300
movq 0x707cf(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xc873(%rip), %rsi      # 0xca066
leaq 0x34e34(%rip), %rdx     # 0xf262e
leaq 0x34e83(%rip), %rcx     # 0xf2684
leaq 0x34dfc(%rip), %r8      # 0xf2604
movl $0x12e, %r9d            # imm = 0x12E
jmp 0xbd7d6