// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/eis-blockcomp.c
// Function: writeIdxHeader
static size_t
writeIdxHeader(struct blockCompositionSeq *seqIdx,
               size_t numExtHeaders, const uint16_t *headerIDs,
               const uint32_t *extHeaderSizes,
               headerWriteFunc *extHeaderCallbacks,
               void **headerCBData, GT_UNUSED GtError *err)
{
  FILE *fp;
  /* construct memory buffer with header data */
  size_t i, bufLen;
  off_t offset, len;
  char *buf;
  gt_assert(seqIdx && err);
  fp = seqIdx->externalData.idxFP;
  bufLen = blockEncIdxSeqHeaderLength(seqIdx, 0, NULL);
  buf = gt_malloc(bufLen);
  /* account for ext headers */
  len = roundUp(bufLen, HEADER_PAGESIZE_ROUNDUP);
  /* 1. 4 identifier bytes at offset 0 */
  strcpy(buf, bdxHeader);
  /* 2. header length */
  *(uint32_t *)(buf + 4) = len;
  /* 3. block size */
  offset = HEADER_ID_BLOCK_LEN;
  *(uint32_t *)(buf + offset) = BKSZ_HEADER_FIELD;
  *(uint32_t *)(buf + offset + 4) = seqIdx->blockSize;
  offset += 8;
  *(uint32_t *)(buf + offset) = BBLK_HEADER_FIELD;
  *(uint32_t *)(buf + offset + 4) = seqIdx->bucketBlocks;
  offset += 8;
  *(uint32_t *)(buf + offset) = VOFF_HEADER_FIELD;
  *(uint64_t *)(buf + offset + 4) = seqIdx->externalData.varDataPos;
  offset += 12;
  *(uint32_t *)(buf + offset) = ROFF_HEADER_FIELD;
  *(uint64_t *)(buf + offset + 4) = seqIdx->externalData.rangeEncPos;
  offset += 12;
  *(uint32_t *)(buf + offset) = SELE_HEADER_FIELD;
  *(uint64_t *)(buf + offset + 4) = seqIdx->baseClass.seqLen;
  offset += 12;
  *(uint32_t *)(buf + offset) = SPBT_HEADER_FIELD;
  *(uint32_t *)(buf + offset + 4) = seqIdx->bitsPerUlong;
  offset += 8;
  *(uint32_t *)(buf + offset) = VDOB_HEADER_FIELD;
  *(uint32_t *)(buf + offset + 4) = seqIdx->bitsPerVarDiskOffset;
  offset += 8;
  *(uint32_t *)(buf + offset) = SSBT_HEADER_FIELD;
  *(uint32_t *)(buf + offset + 4) = seqIdx->blockMapAlphabetSize;
  for (i = 0; i < seqIdx->blockMapAlphabetSize; ++i)
    *(uint32_t *)(buf + offset + 8 + 4*i) = seqIdx->partialSymSumBits[i];
  offset += 8 + 4 * seqIdx->blockMapAlphabetSize;
  *(uint32_t *)(buf + offset) = BEFB_HEADER_FIELD;
  *(uint32_t *)(buf + offset + 4) = seqIdx->blockEncFallback;
  offset += 8;
  *(uint32_t *)(buf + offset) = REFB_HEADER_FIELD;
  *(uint32_t *)(buf + offset + 4) = seqIdx->rangeEncFallback;
  offset += 8;
  *(uint32_t *)(buf + offset) = NMRN_HEADER_FIELD;
  *(uint32_t *)(buf + offset + 4) = seqIdx->numModes;
  offset += 8;
  for (i = 0; i < seqIdx->numModes; ++i)
  {
    *(uint32_t *)(buf + offset) = seqIdx->modes[i];
    offset += 4;
  }
  if (seqIdx->callBackDataOffsetBits)
  {
    *(uint32_t *)(buf + offset) = CBMB_HEADER_FIELD;
    *(uint32_t *)(buf + offset + 4) = seqIdx->callBackDataOffsetBits;
    offset += 8;
    *(uint32_t *)(buf + offset) = CEXB_HEADER_FIELD;
    *(uint64_t *)(buf + offset + 4) = seqIdx->cwExtBitsPerBucket;
    offset += 12;
    *(uint32_t *)(buf + offset) = MEXB_HEADER_FIELD;
    *(uint64_t *)(buf + offset + 4) = seqIdx->maxVarExtBitsPerBucket;
    offset += 12;
  }
  gt_assert(offset == bufLen);
  if (fseeko(fp, 0, SEEK_SET))
    writeIdxHeaderErrRet(0);
  gt_xfwrite(buf, bufLen, 1, fp);
  if (numExtHeaders)
  {
    off_t offsetTargetValue = bufLen;
    if (!writeExtIdxHeader(fp, headerIDs[0], extHeaderSizes[0],
                          extHeaderCallbacks[0], headerCBData[0]))
      writeIdxHeaderErrRet(0);
    else
      appendExtHeaderPos(&seqIdx->extHeaderPos, seqIdx->numExtHeaders++,
                         bufLen + EXT_HEADER_PREFIX_SIZE,
                         EH_HEADER_PREFIX | headerIDs[0]);
    for (i = 1; i < numExtHeaders; ++i)
    {
      offsetTargetValue += EXT_HEADER_PREFIX_SIZE + extHeaderSizes[i - 1];
      if (fseeko(fp, offsetTargetValue, SEEK_SET))
        writeIdxHeaderErrRet(0);
      if (!writeExtIdxHeader(fp, headerIDs[i], extHeaderSizes[i],
                            extHeaderCallbacks[i], headerCBData[i]))
        writeIdxHeaderErrRet(0);
      else
        appendExtHeaderPos(&seqIdx->extHeaderPos, seqIdx->numExtHeaders++,
                           offsetTargetValue + EXT_HEADER_PREFIX_SIZE,
                           EH_HEADER_PREFIX | headerIDs[0]);
    }
    offset = offsetTargetValue + EXT_HEADER_PREFIX_SIZE
      + extHeaderSizes[numExtHeaders - 1];
    gt_assert(offset >= ftello(fp));
  }
  gt_assert(seqIdx->externalData.cwDataPos == len);
  gt_free(buf);
  return len;
}

// Assembly:
subq $0x78, %rsp
movq 0x80(%rsp), %rax
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq %r9, 0x40(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0x4a728d
cmpq $0x0, 0x80(%rsp)
jne 0x4a72c5
movq 0x194d0c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x6ed75(%rip), %rsi     # 0x516013
leaq 0x10f35a(%rip), %rdx    # 0x5b65ff
leaq 0x10f361(%rip), %rcx    # 0x5b660d
leaq 0x10ec55(%rip), %r8     # 0x5b5f08
movl $0x7cc, %r9d            # imm = 0x7CC
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4a72c7
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x68(%rsp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x4a68e0
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x10ec11(%rip), %rsi    # 0x5b5f08
movl $0x7cf, %edx            # imm = 0x7CF
callq 0xe80f0
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x4aa150
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x10fbe1(%rip), %rsi    # 0x5b6f07
callq 0x19700
movq 0x18(%rsp), %rax
movl %eax, %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x4(%rax)
movq $0x8, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x424b535a, (%rax,%rcx) # imm = 0x424B535A
movq 0x68(%rsp), %rax
movl 0xb4(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x42424c4b, (%rax,%rcx) # imm = 0x42424C4B
movq 0x68(%rsp), %rax
movl 0xb0(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x564f4646, (%rax,%rcx) # imm = 0x564F4646
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rdx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x524f4646, (%rax,%rcx) # imm = 0x524F4646
movq 0x68(%rsp), %rax
movq 0x40(%rax), %rdx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rdx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x53454c45, (%rax,%rcx) # imm = 0x53454C45
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rdx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rdx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x53504254, (%rax,%rcx) # imm = 0x53504254
movq 0x68(%rsp), %rax
movl 0xbc(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x56444f42, (%rax,%rcx) # imm = 0x56444F42
movq 0x68(%rsp), %rax
movl 0xc0(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x53534254, (%rax,%rcx) # imm = 0x53534254
movq 0x68(%rsp), %rax
movzwl 0xc4(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq $0x0, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x68(%rsp), %rcx
movzwl 0xc4(%rcx), %ecx
cmpq %rcx, %rax
jae 0x4a754d
movq 0x68(%rsp), %rax
movq 0xd0(%rax), %rax
movq 0x30(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
addq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
shlq $0x2, %rcx
movl %edx, 0x8(%rax,%rcx)
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x4a74fc
movq 0x68(%rsp), %rax
movzwl 0xc4(%rax), %eax
shll $0x2, %eax
addl $0x8, %eax
cltq
addq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x42454642, (%rax,%rcx) # imm = 0x42454642
movq 0x68(%rsp), %rax
movzbl 0xc6(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x52454642, (%rax,%rcx) # imm = 0x52454642
movq 0x68(%rsp), %rax
movzbl 0xc7(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x4e4d524e, (%rax,%rcx) # imm = 0x4E4D524E
movq 0x68(%rsp), %rax
movl 0xc8(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x68(%rsp), %rcx
movslq 0xc8(%rcx), %rcx
cmpq %rcx, %rax
jae 0x4a7673
movq 0x68(%rsp), %rax
movq 0xa8(%rax), %rax
movq 0x30(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, (%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x4a761e
movq 0x68(%rsp), %rax
cmpl $0x0, 0xb8(%rax)
je 0x4a7731
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x43424d42, (%rax,%rcx) # imm = 0x43424D42
movq 0x68(%rsp), %rax
movl 0xb8(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x43455842, (%rax,%rcx) # imm = 0x43455842
movq 0x68(%rsp), %rax
movq 0x90(%rax), %rdx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rdx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl $0x4d455842, (%rax,%rcx) # imm = 0x4D455842
movq 0x68(%rsp), %rax
movq 0x88(%rax), %rdx
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rdx, 0x4(%rax,%rcx)
movq 0x20(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x20(%rsp)
jmp 0x4a7733
movq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
je 0x4a7777
movq 0x19485a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x6e8c3(%rip), %rsi     # 0x516013
leaq 0x10eec5(%rip), %rdx    # 0x5b661c
leaq 0x10eeaf(%rip), %rcx    # 0x5b660d
leaq 0x10e7a3(%rip), %r8     # 0x5b5f08
movl $0x80c, %r9d            # imm = 0x80C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4a7779
movq 0x38(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x19c10
cmpl $0x0, %eax
je 0x4a77b4
jmp 0x4a7790
movq 0x10(%rsp), %rdi
leaq 0x10e76c(%rip), %rsi    # 0x5b5f08
movl $0x80e, %edx            # imm = 0x80E
callq 0xe88c0
movq $0x0, 0x70(%rsp)
jmp 0x4a7a9e
movq 0x10(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x38(%rsp), %rcx
movl $0x1, %edx
callq 0x126d30
cmpq $0x0, 0x60(%rsp)
je 0x4a7a32
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %rax
movw (%rax), %ax
movq 0x50(%rsp), %rcx
movl (%rcx), %ecx
movl %ecx, %edx
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movq 0x40(%rsp), %rsi
movq (%rsi), %r8
movzwl %ax, %esi
callq 0x4aa250
cmpl $0x0, %eax
jne 0x4a783c
jmp 0x4a7818
movq 0x10(%rsp), %rdi
leaq 0x10e6e4(%rip), %rsi    # 0x5b5f08
movl $0x815, %edx            # imm = 0x815
callq 0xe88c0
movq $0x0, 0x70(%rsp)
jmp 0x4a7a9e
movq 0x68(%rsp), %rdi
addq $0x78, %rdi
movq 0x68(%rsp), %rax
movq 0x80(%rax), %rsi
movq %rsi, %rcx
addq $0x1, %rcx
movq %rcx, 0x80(%rax)
movq 0x28(%rsp), %rdx
addq $0x8, %rdx
movq 0x58(%rsp), %rax
movzwl (%rax), %ecx
orl $0x45480000, %ecx       # imm = 0x45480000
callq 0x4a9540
movq $0x1, 0x30(%rsp)
movq 0x30(%rsp), %rax
cmpq 0x60(%rsp), %rax
jae 0x4a79b5
movq 0x50(%rsp), %rax
movq 0x30(%rsp), %rcx
subq $0x1, %rcx
movl (%rax,%rcx,4), %eax
addl $0x8, %eax
movl %eax, %eax
addq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x19c10
cmpl $0x0, %eax
je 0x4a78f0
jmp 0x4a78cc
movq 0x10(%rsp), %rdi
leaq 0x10e630(%rip), %rsi    # 0x5b5f08
movl $0x81e, %edx            # imm = 0x81E
callq 0xe88c0
movq $0x0, 0x70(%rsp)
jmp 0x4a7a9e
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %rax
movq 0x30(%rsp), %rcx
movw (%rax,%rcx,2), %ax
movq 0x50(%rsp), %rcx
movq 0x30(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, %edx
movq 0x48(%rsp), %rcx
movq 0x30(%rsp), %rsi
movq (%rcx,%rsi,8), %rcx
movq 0x40(%rsp), %rsi
movq 0x30(%rsp), %r8
movq (%rsi,%r8,8), %r8
movzwl %ax, %esi
callq 0x4aa250
cmpl $0x0, %eax
jne 0x4a7961
jmp 0x4a793d
movq 0x10(%rsp), %rdi
leaq 0x10e5bf(%rip), %rsi    # 0x5b5f08
movl $0x821, %edx            # imm = 0x821
callq 0xe88c0
movq $0x0, 0x70(%rsp)
jmp 0x4a7a9e
movq 0x68(%rsp), %rdi
addq $0x78, %rdi
movq 0x68(%rsp), %rax
movq 0x80(%rax), %rsi
movq %rsi, %rcx
addq $0x1, %rcx
movq %rcx, 0x80(%rax)
movq 0x8(%rsp), %rdx
addq $0x8, %rdx
movq 0x58(%rsp), %rax
movzwl (%rax), %ecx
orl $0x45480000, %ecx       # imm = 0x45480000
callq 0x4a9540
jmp 0x4a79a2
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x4a7884
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq 0x50(%rsp), %rcx
movq 0x60(%rsp), %rdx
subq $0x1, %rdx
movl (%rcx,%rdx,4), %ecx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rdi
callq 0x19af0
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jge 0x4a7a2e
movq 0x1945a3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x6e60c(%rip), %rsi     # 0x516013
leaq 0x10ec1f(%rip), %rdx    # 0x5b662d
leaq 0x10ebf8(%rip), %rcx    # 0x5b660d
leaq 0x10e4ec(%rip), %r8     # 0x5b5f08
movl $0x829, %r9d            # imm = 0x829
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4a7a30
jmp 0x4a7a32
jmp 0x4a7a34
movq 0x68(%rsp), %rax
movq 0x30(%rax), %rax
cmpq 0x18(%rsp), %rax
je 0x4a7a7c
movq 0x194555(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x6e5be(%rip), %rsi     # 0x516013
leaq 0x10ebe6(%rip), %rdx    # 0x5b6642
leaq 0x10ebaa(%rip), %rcx    # 0x5b660d
leaq 0x10e49e(%rip), %r8     # 0x5b5f08
movl $0x82b, %r9d            # imm = 0x82B
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4a7a7e
movq 0x10(%rsp), %rdi
leaq 0x10e47e(%rip), %rsi    # 0x5b5f08
movl $0x82c, %edx            # imm = 0x82C
callq 0xe88c0
movq 0x18(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
addq $0x78, %rsp
retq
nopl (%rax,%rax)