// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rsi, %r12
movq %rdi, %r15
leaq 0x33425(%rip), %rsi     # 0x109530
movl $0x18, %edi
movl $0x177, %edx            # imm = 0x177
callq 0x35ee2
movq %rax, %rbx
testq %rbp, %rbp
je 0xd6132
movq %rbp, %rdi
callq 0x3566a
testb %al, %al
jne 0xd62a7
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq *%r15
movq (%rbx), %r14
testq %r14, %r14
je 0xd62a2
movq %rbp, 0x8(%rsp)
movq 0x10(%rbx), %rax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
addq (%rbx), %rax
cmpq %rax, %r14
jae 0xd6208
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0x20(%r14), %rdx
testq %rdx, %rdx
je 0xd61a2
cmpl $0xe, (%r14)
jae 0xd6238
movq 0x10(%r14), %rax
movq 0x18(%r14), %rsi
movq (%rax), %rdi
movq %r12, %rcx
callq 0x3dc94
movq 0x20(%r14), %r15
imulq 0x18(%r14), %r15
addq %r13, %r15
movq %r15, %rax
andq $0x7, %rax
je 0xd61de
xorl %ecx, %ecx
movl %ecx, 0x3(%rsp)
movl %ecx, (%rsp)
movl $0x8, %r13d
subq %rax, %r13
movl $0x1, %esi
movq %rsp, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x3dc94
jmp 0xd61e1
xorl %r13d, %r13d
addq %r13, %r15
addq %r13, %rbp
addq $0x28, %r14
movq 0x10(%rbx), %rax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
addq (%rbx), %rax
movq %r15, %r13
cmpq %rax, %r14
jb 0xd617c
jmp 0xd620d
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x10(%rsp), %rdx
addq %rdx, %rbp
cmpq %r15, %rbp
movl $0x0, %r14d
je 0xd6255
leaq 0x333cb(%rip), %rsi     # 0x1095f2
movq 0x8(%rsp), %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x3559f
jmp 0xd624f
movq 0x18(%r14), %rdx
leaq 0x33429(%rip), %rsi     # 0x10966c
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xd627c
leaq 0x332cc(%rip), %rsi     # 0x109530
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x362a0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
leaq 0x332ad(%rip), %rsi     # 0x109530
movq %rbx, %rdi
movl $0x1d5, %edx            # imm = 0x1D5
callq 0x362a0
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x31dec
callq 0x31db3