// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/mapspec.c
// Function: gt_mapspec_read_header
int  gt_mapspec_read_header(GtMapspecSetupFunc setup, void *data,
                            const char *filename, GtUword expectedsize,
                            void **mapped, GtError *err)
{
  void *mapptr;
  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;
  }
  if (!had_err)
    *mapped = mapptr;
  if (!had_err)
  {
    if (assigncorrecttype(ms->mapspectable.spaceGtMapspecification,
                          mapptr,0,err) != 0)
    {
      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 header 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, %r15
movq %r8, %r14
movq %rcx, 0x8(%rsp)
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, %r13
leaq 0x3300f(%rip), %rsi     # 0x109358
movl $0x18, %edi
movl $0xb3, %edx
callq 0x35862
movq %rax, %rbx
testq %r15, %r15
je 0xd6370
movq %r15, %rdi
callq 0x34fea
testb %al, %al
jne 0xd64d4
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq *%r13
leaq 0x32fc8(%rip), %rdx     # 0x109358
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
movl $0xbc, %ecx
movq %r15, %r8
callq 0x74b73
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xd6488
movq %rax, %r12
movq %rax, (%r14)
movq (%rbx), %rdi
movq %rax, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0xd64de
testl %eax, %eax
jne 0xd6488
movq (%rbx), %r14
testq %r14, %r14
je 0xd64d9
movq 0x20(%r14), %r13
imulq 0x18(%r14), %r13
movl %r13d, %eax
andl $0x7, %eax
movl $0x8, %ebp
subq %rax, %rbp
testq %rax, %rax
cmoveq %rax, %rbp
addq %rbp, %r13
cmpq $0x2, 0x10(%rbx)
jl 0xd645d
addq $0x28, %r14
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0xd64de
testl %eax, %eax
jne 0xd6483
movq 0x20(%r14), %rax
imulq 0x18(%r14), %rax
addq %r13, %rax
movl %eax, %ecx
andl $0x7, %ecx
movl $0x8, %r13d
subq %rcx, %r13
testq %rcx, %rcx
cmoveq %rcx, %r13
addq %r13, %rbp
addq %rax, %r13
addq $0x28, %r14
movq 0x10(%rbx), %rax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
addq (%rbx), %rax
cmpq %rax, %r14
jb 0xd6409
movq 0x8(%rsp), %rdx
addq %rdx, %rbp
cmpq %r13, %rbp
movl $0x0, %ebp
je 0xd6488
leaq 0x32f1f(%rip), %rsi     # 0x109395
movq %r15, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x34f1f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xd64af
leaq 0x32ec1(%rip), %rsi     # 0x109358
movl $0xf9, %edx
callq 0x35c27
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
leaq 0x32ea2(%rip), %rsi     # 0x109358
movq %rbx, %rdi
movl $0xfa, %edx
callq 0x35c27
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3169b
callq 0x316d4