// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdx, 0x70(%rsp)
movq %rcx, 0x68(%rsp)
movq %r8, 0x60(%rsp)
movq %r9, 0x58(%rsp)
movq $0x0, 0x40(%rsp)
movl $0x18, %edi
leaq 0x46a03(%rip), %rsi     # 0x18c390
movl $0x106, %edx            # imm = 0x106
callq 0xd2e0
movq %rax, 0x30(%rsp)
movl $0x0, 0x24(%rsp)
movq $0x0, 0x18(%rsp)
cmpq $0x0, 0x58(%rsp)
je 0x1459fd
movq 0x58(%rsp), %rdi
callq 0xc270
testb $0x1, %al
jne 0x1459c5
jmp 0x1459fd
movq 0x6e60c(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x18690(%rip), %rsi     # 0x15e066
leaq 0x18c6b(%rip), %rdx     # 0x15e648
leaq 0x46a2c(%rip), %rcx     # 0x18c410
leaq 0x469a5(%rip), %r8      # 0x18c390
movl $0x10b, %r9d            # imm = 0x10B
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x1459ff
jmp 0x145a01
movq 0x30(%rsp), %rax
movq $0x0, (%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x10(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0x80(%rsp), %rax
movq 0x30(%rsp), %rdi
movq 0x78(%rsp), %rsi
xorl %edx, %edx
callq *%rax
movq 0x70(%rsp), %rdi
movq 0x58(%rsp), %r8
leaq 0x38(%rsp), %rsi
leaq 0x4693d(%rip), %rdx     # 0x18c390
movl $0x10f, %ecx            # imm = 0x10F
callq 0x80cb0
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x50(%rsp)
jne 0x145a72
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
movq 0x50(%rsp), %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
cmpl $0x0, 0x24(%rsp)
jne 0x145ab0
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x1454c0
cmpl $0x0, %eax
je 0x145aae
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x145ab0
cmpl $0x0, 0x24(%rsp)
jne 0x145afe
movq 0x30(%rsp), %rdi
callq 0x145d60
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0x145afc
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rdx
movq 0x70(%rsp), %rcx
movq 0x48(%rsp), %r8
leaq 0x46933(%rip), %rsi     # 0x18c420
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x145afe
cmpl $0x0, 0x24(%rsp)
jne 0x145cab
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x145b56
movq 0x6e4b3(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x18537(%rip), %rsi     # 0x15e066
leaq 0x46884(%rip), %rdx     # 0x18c3ba
leaq 0x468d3(%rip), %rcx     # 0x18c410
leaq 0x4684c(%rip), %r8      # 0x18c390
movl $0x12e, %r9d            # imm = 0x12E
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x145b58
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdx
movq 0x28(%rsp), %rax
imulq 0x20(%rax), %rdx
leaq 0x4681e(%rip), %rdi     # 0x18c390
movl $0x131, %esi            # imm = 0x131
callq 0x145930
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
andq $0x7, %rax
cmpq $0x0, %rax
jbe 0x145bc4
movq 0x40(%rsp), %rcx
andq $0x7, %rcx
movl $0x8, %eax
subq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rax
addq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rax
addq $0x28, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rsp), %rdx
imulq $0x28, 0x10(%rdx), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x145ca9
movq 0x28(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x58(%rsp), %rcx
callq 0x1454c0
cmpl $0x0, %eax
je 0x145c20
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x145ca9
movq 0x40(%rsp), %rdx
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rsp), %rcx
imulq 0x20(%rcx), %rax
addq %rax, %rdx
leaq 0x4674e(%rip), %rdi     # 0x18c390
movl $0x145, %esi            # imm = 0x145
callq 0x145930
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
andq $0x7, %rax
cmpq $0x0, %rax
jbe 0x145c94
movq 0x40(%rsp), %rcx
andq $0x7, %rcx
movl $0x8, %eax
subq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%rsp), %rax
addq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x145c96
movq 0x28(%rsp), %rax
addq $0x28, %rax
movq %rax, 0x28(%rsp)
jmp 0x145bd2
jmp 0x145cab
cmpl $0x0, 0x24(%rsp)
jne 0x145cea
movq 0x68(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x145ce8
movq 0x58(%rsp), %rdi
movq 0x68(%rsp), %rdx
movq 0x40(%rsp), %rcx
leaq 0x46770(%rip), %rsi     # 0x18c449
movb $0x0, %al
callq 0xc0d0
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x145cea
jmp 0x145cec
movq 0x30(%rsp), %rax
cmpq $0x0, (%rax)
je 0x145d36
movq 0x30(%rsp), %rax
movq (%rax), %rdi
leaq 0x4668a(%rip), %rsi     # 0x18c390
movl $0x159, %edx            # imm = 0x159
callq 0xdab0
movq 0x30(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x10(%rax)
movq 0x30(%rsp), %rax
movq $0x0, (%rax)
jmp 0x145d38
movq 0x30(%rsp), %rdi
leaq 0x4664c(%rip), %rsi     # 0x18c390
movl $0x15a, %edx            # imm = 0x15A
callq 0xdab0
movl 0x24(%rsp), %eax
addq $0x88, %rsp
retq
nopw (%rax,%rax)