// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %r9, %r12
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbp
leaq 0x33949(%rip), %rsi     # 0x109530
movl $0x18, %edi
movl $0xb3, %edx
callq 0x35ee2
movq %rax, %rbx
testq %r12, %r12
je 0xd5c0e
movq %r12, %rdi
callq 0x3566a
testb %al, %al
jne 0xd5dab
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq *%rbp
leaq 0x33900(%rip), %rdx     # 0x109530
leaq 0x20(%rsp), %rsi
movq %r13, %rdi
movl $0xbc, %ecx
movq %r12, %r8
callq 0x7460e
testq %rax, %rax
movq %r12, 0x8(%rsp)
je 0xd5d25
movq %rax, %r13
movq 0x18(%rsp), %rax
movq %r13, (%rax)
movq (%rbx), %rdi
xorl %r15d, %r15d
movq %r13, %rsi
xorl %edx, %edx
movq %r12, %rcx
callq 0xd5db5
movl $0x0, %r14d
movl $0x0, %r12d
testl %eax, %eax
jne 0xd5d2b
movq (%rbx), %rbp
testq %rbp, %rbp
je 0xd5db0
movq 0x20(%rbp), %r12
imulq 0x18(%rbp), %r12
movl %r12d, %eax
andl $0x7, %eax
movl $0x8, %r14d
subq %rax, %r14
testq %rax, %rax
cmoveq %rax, %r14
addq %r14, %r12
addq $0x28, %rbp
movq 0x10(%rbx), %rax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
addq (%rbx), %rax
movb $0x1, %r15b
cmpq %rax, %rbp
jae 0xd5d2b
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq 0x8(%rsp), %rcx
callq 0xd5db5
testl %eax, %eax
sete %r15b
jne 0xd5d2b
movq 0x20(%rbp), %rax
imulq 0x18(%rbp), %rax
addq %r12, %rax
movl %eax, %ecx
andl $0x7, %ecx
movl $0x8, %r12d
subq %rcx, %r12
testq %rcx, %rcx
cmoveq %rcx, %r12
addq %r12, %r14
addq %rax, %r12
addq $0x28, %rbp
movq 0x10(%rbx), %rax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
addq (%rbx), %rax
jmp 0xd5cc9
xorl %r14d, %r14d
xorl %r12d, %r12d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %r15b, %r15b
je 0xd5d5f
movq 0x10(%rsp), %rdx
addq %rdx, %r14
xorl %ebp, %ebp
cmpq %r12, %r14
je 0xd5d5f
leaq 0x33822(%rip), %rsi     # 0x10956d
movq 0x8(%rsp), %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xd5d86
leaq 0x337c2(%rip), %rsi     # 0x109530
movl $0xf9, %edx
callq 0x362a0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
leaq 0x337a3(%rip), %rsi     # 0x109530
movq %rbx, %rdi
movl $0xfa, %edx
callq 0x362a0
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x31c98
callq 0x31cd1