// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rcx, 0x8(%rsp)
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %r13
leaq 0x34d90(%rip), %rsi     # 0xf2604
pushq $0x18
popq %rdi
movl $0x177, %edx            # imm = 0x177
callq 0xccb0
movq %rax, %rbx
testq %r14, %r14
je 0xbd899
movq %r14, %rdi
callq 0xc103
testb %al, %al
jne 0xbd9e1
movq %r14, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq *%r13
movq (%rbx), %rax
testq %rax, %rax
je 0xbd9b3
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %rax, %rbp
imulq $0x28, 0x10(%rbx), %rcx
addq %rax, %rcx
cmpq %rcx, %rbp
jae 0xbd92b
movq 0x20(%rbp), %rdx
testq %rdx, %rdx
je 0xbd8f8
cmpl $0xe, (%rbp)
jae 0xbd951
movq 0x10(%rbp), %rax
movq 0x18(%rbp), %rsi
movq (%rax), %rdi
movq %r12, %rcx
callq 0x1650c
movq 0x20(%rbp), %r13
imulq 0x18(%rbp), %r13
addq %r15, %r13
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
callq 0xbd810
movq 0x10(%rsp), %rax
addq %rax, %r13
addq %rax, %r14
addq $0x28, %rbp
movq (%rbx), %rax
movq %r13, %r15
jmp 0xbd8c9
movq 0x8(%rsp), %rdx
addq %rdx, %r14
xorl %ebp, %ebp
cmpq %r15, %r14
je 0xbd96a
leaq 0x34d85(%rip), %rsi     # 0xf26c6
movq (%rsp), %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0xc007
jmp 0xbd967
movq 0x18(%rbp), %rdx
leaq 0x34de4(%rip), %rsi     # 0xf2740
movq (%rsp), %rdi
xorl %eax, %eax
callq 0xc007
pushq $-0x1
popq %rbp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xbd98e
leaq 0x34c8b(%rip), %rsi     # 0xf2604
movl $0x1d4, %edx            # imm = 0x1D4
callq 0xd249
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x34c6f(%rip), %rsi     # 0xf2604
movq %rbx, %rdi
movl $0x1d5, %edx            # imm = 0x1D5
callq 0xd249
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x705fe(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xc6a2(%rip), %rsi      # 0xca066
leaq 0x34d44(%rip), %rdx     # 0xf270f
leaq 0x34d2c(%rip), %rcx     # 0xf26fe
leaq 0x34c2b(%rip), %r8      # 0xf2604
movl $0x17c, %r9d            # imm = 0x17C
jmp 0xbda0d
movq 0x705d0(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0xc674(%rip), %rsi      # 0xca066
leaq 0xcc60(%rip), %rdx      # 0xca659
leaq 0x34cfe(%rip), %rcx     # 0xf26fe
leaq 0x34bfd(%rip), %r8      # 0xf2604
movl $0x179, %r9d            # imm = 0x179
xorl %eax, %eax
callq 0xb8c0
callq 0xb300