// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/mapspec.c
// Function: gt_mapspec_write
int gt_mapspec_write(GtMapspecSetupFunc setup, FILE *fp,
                     void *data, GtUword expectedsize, GtError *err)
{
  GtMapspecification *mapspecptr;
  GtUword byteoffset = 0;
  int had_err = 0;
  GtUword totalpadunits = 0;
  GtUword byteswritten;
  GtMapspec *ms = gt_malloc(sizeof (GtMapspec));

  gt_error_check(err);
  GT_INITARRAY(&ms->mapspectable,GtMapspecification);
  setup(ms, data, true);
  gt_assert(ms->mapspectable.spaceGtMapspecification != NULL);
  for (mapspecptr = ms->mapspectable.spaceGtMapspecification;
       mapspecptr < ms->mapspectable.spaceGtMapspecification +
                    ms->mapspectable.nextfreeGtMapspecification;
       mapspecptr++)
  {
#ifdef SKDEBUG
    printf("# %s",__func__);
    showmapspec(mapspecptr);
    printf(" at byteoffset "GT_WU"\n",byteoffset);
#endif
    if (mapspecptr->numofunits > 0)
    {
      switch (mapspecptr->typespec)
      {
        case GtCharType:
          WRITEACTIONWITHTYPE(char);
          break;
        case GtFilelengthvaluesType:
          WRITEACTIONWITHTYPE(GtFilelengthvalues);
          break;
        case GtUcharType:
          WRITEACTIONWITHTYPE(GtUchar);
          break;
        case Uint16Type:
          WRITEACTIONWITHTYPE(uint16_t);
          break;
        case Uint32Type:
          WRITEACTIONWITHTYPE(uint32_t);
          break;
        case GtUwordType:
          WRITEACTIONWITHTYPE(GtUword);
          break;
        case Uint64Type:
          WRITEACTIONWITHTYPE(uint64_t);
          break;
        case GtBitsequenceType:
          WRITEACTIONWITHTYPE(GtBitsequence);
          break;
        case GtUwordBoundType:
          WRITEACTIONWITHTYPE(GtUwordBound);
          break;
        case GtPairBwtidxType:
          WRITEACTIONWITHTYPE(GtPairBwtidx);
          break;
        case GtTwobitencodingType:
          WRITEACTIONWITHTYPE(GtTwobitencoding);
          break;
        case GtSpecialcharinfoType:
          WRITEACTIONWITHTYPE(GtSpecialcharinfo);
          break;
        case GtBitElemType:
          WRITEACTIONWITHTYPE(BitElem);
          break;
        case GtUintType:
          WRITEACTIONWITHTYPE(unsigned int);
          break;
        default:
           gt_error_set(err, "no map specification for size " GT_WU,
                        (GtUword) mapspecptr->sizeofunit);
           had_err = -1;
      }
    }
    if (had_err)
    {
      break;
    }
    byteoffset = CALLCASTFUNC(uint64_t,unsigned_long,
                              (uint64_t) (byteoffset +
                                          mapspecptr->sizeofunit *
                                          mapspecptr->numofunits));
    if (gt_mapspec_pad(fp,&byteswritten,byteoffset,err) != 0)
    {
      had_err = -1;
    }
    byteoffset += byteswritten;
    totalpadunits += byteswritten;
  }
  if (!had_err)
  {
    if (expectedsize + totalpadunits != byteoffset)
    {
      gt_error_set(err, "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 %r8, %rbp
movq %rcx, 0x10(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r15
leaq 0x32b67(%rip), %rsi     # 0x109358
movl $0x18, %edi
movl $0x177, %edx            # imm = 0x177
callq 0x35862
movq %rax, %rbx
testq %rbp, %rbp
je 0xd6818
movq %rbp, %rdi
callq 0x34fea
testb %al, %al
jne 0xd6980
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq *%r15
movq (%rbx), %r14
testq %r14, %r14
je 0xd697b
movq %rbp, 0x8(%rsp)
cmpq $0x0, 0x10(%rbx)
jle 0xd68e1
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0x20(%r14), %rdx
testq %rdx, %rdx
je 0xd687b
cmpl $0xe, (%r14)
jae 0xd6911
movq 0x10(%r14), %rax
movq 0x18(%r14), %rsi
movq (%rax), %rdi
movq %r13, %rcx
callq 0x3d320
movq 0x20(%r14), %r15
imulq 0x18(%r14), %r15
addq %r12, %r15
movq %r15, %rax
andq $0x7, %rax
je 0xd68b7
xorl %ecx, %ecx
movl %ecx, 0x3(%rsp)
movl %ecx, (%rsp)
movl $0x8, %r12d
subq %rax, %r12
movl $0x1, %esi
movq %rsp, %rdi
movq %r12, %rdx
movq %r13, %rcx
callq 0x3d320
jmp 0xd68ba
xorl %r12d, %r12d
addq %r12, %r15
addq %r12, %rbp
addq $0x28, %r14
movq 0x10(%rbx), %rax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
addq (%rbx), %rax
movq %r15, %r12
cmpq %rax, %r14
jb 0xd6855
jmp 0xd68e6
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x10(%rsp), %rdx
addq %rdx, %rbp
cmpq %r15, %rbp
movl $0x0, %r14d
je 0xd692e
leaq 0x32b1a(%rip), %rsi     # 0x10941a
movq 0x8(%rsp), %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x34f1f
jmp 0xd6928
movq 0x18(%r14), %rdx
leaq 0x32b78(%rip), %rsi     # 0x109494
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x34f1f
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xd6955
leaq 0x32a1b(%rip), %rsi     # 0x109358
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x35c27
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
leaq 0x329fc(%rip), %rsi     # 0x109358
movq %rbx, %rdi
movl $0x1d5, %edx            # imm = 0x1D5
callq 0x35c27
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x317ef
callq 0x317b6