// File: /workspace/github_c_makefile_star2_O2/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, %r13
movq %rcx, 0x8(%rsp)
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbp
leaq 0x352d7(%rip), %rsi     # 0xf2604
pushq $0x18
popq %rdi
movl $0xb3, %edx
callq 0xccb0
movq %rax, %rbx
testq %r15, %r15
je 0xbd352
movq %r15, %rdi
callq 0xc103
testb %al, %al
jne 0xbd49d
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq *%rbp
leaq 0x35296(%rip), %rdx     # 0xf2604
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
movl $0xbc, %ecx
movq %r15, %r8
callq 0x5272d
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0xbd454
movq %rax, %r12
movq %rax, (%r13)
movq (%rbx), %rdi
movq %rax, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0xbd503
testl %eax, %eax
jne 0xbd454
movq (%rbx), %rax
testq %rax, %rax
je 0xbd4cb
movq 0x20(%rax), %r13
imulq 0x18(%rax), %r13
movl %r13d, %ecx
andl $0x7, %ecx
pushq $0x8
popq %r14
subq %rcx, %r14
testq %rcx, %rcx
cmoveq %rcx, %r14
addq %r14, %r13
leaq 0x28(%rax), %rbp
imulq $0x28, 0x10(%rbx), %rcx
addq %rax, %rcx
cmpq %rcx, %rbp
jae 0xbd42e
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0xbd503
testl %eax, %eax
jne 0xbd451
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, %r14
addq %rax, %r13
movq (%rbx), %rax
addq $0x28, %rbp
jmp 0xbd3de
movq 0x8(%rsp), %rdx
addq %rdx, %r14
xorl %ebp, %ebp
cmpq %r13, %r14
je 0xbd454
leaq 0x351fd(%rip), %rsi     # 0xf2641
movq %r15, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0xc007
pushq $-0x1
popq %rbp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xbd478
leaq 0x351a1(%rip), %rsi     # 0xf2604
movl $0xf9, %edx
callq 0xd249
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x35185(%rip), %rsi     # 0xf2604
movq %rbx, %rdi
movl $0xfa, %edx
callq 0xd249
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x70b14(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xcbb8(%rip), %rsi      # 0xca066
leaq 0xd1a4(%rip), %rdx      # 0xca659
leaq 0x3515b(%rip), %rcx     # 0xf2617
leaq 0x35141(%rip), %r8      # 0xf2604
movl $0xb8, %r9d
jmp 0xbd4f7
movq 0x70ae6(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xcb8a(%rip), %rsi      # 0xca066
leaq 0x3514b(%rip), %rdx     # 0xf262e
leaq 0x3512d(%rip), %rcx     # 0xf2617
leaq 0x35113(%rip), %r8      # 0xf2604
movl $0xce, %r9d
xorl %eax, %eax
callq 0xb8c0
callq 0xb300