// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/core/encseq.c
// Function: gt_encseq_generic_write_twobitencoding_to_file
int gt_encseq_generic_write_twobitencoding_to_file(const char *indexname,
                                     GtUword totallength,
                                     GtEncseqAccessType sat,
                                     GtUword lengthofsinglesequence,
                                     GtUword minseqlen,
                                     GtUword maxseqlen,
                                     GtUword lengthofspecialprefix,
                                     GtUword lengthofspecialsuffix,
                                     GtUword lengthoflongestnonspecial,
                                     GtTwobitencoding *twobitencoding,
                                     GtUword numofsequences,
                                     GtUword numoffiles,
                                     const GtFilelengthvalues *filelengthtab,
                                     const GtStrArray *filenametab,
                                     const GtUword *characterdistribution,
                                     GtError *err)
{
  FILE *fp;
  bool haserr = false;
  GtEncseq *encseq = NULL;

  gt_error_check(err);
  fp = gt_fa_fopen_with_suffix(indexname, GT_ENCSEQFILESUFFIX, "wb", err);
  if (fp == NULL)
    haserr = true;
  if (!haserr) {
    GtUword idx;
    Definedunsignedlong equallength;
    GtAlphabet *alphabet = gt_alphabet_new_dna();

    if (lengthofsinglesequence > 0) {
      equallength.defined = true;
      equallength.valueunsignedlong = lengthofsinglesequence;
      gt_assert(sat == GT_ACCESS_TYPE_EQUALLENGTH);
    }
    else {
      equallength.defined = false;
      equallength.valueunsignedlong = 0;
      gt_assert(sat == GT_ACCESS_TYPE_UCHARTABLES ||
                sat == GT_ACCESS_TYPE_USHORTTABLES ||
                sat == GT_ACCESS_TYPE_UINT32TABLES);
    }
    encseq = determineencseqkeyvalues(sat,
                                      totallength,
                                      numofsequences,
                                      numoffiles,
                                      determinelengthofdbfilenames(filenametab),
                                      0, /* wildcardranges */
                                      0, /* exceptionranges */
                                      minseqlen,
                                      maxseqlen,
                                      false, /* oistab */
                                      false,
                                      lengthofsinglesequence > 0
                                        ? &equallength
                                        : NULL,
                                      alphabet,
                                      false,
                                      NULL);
    encseq->twobitencoding = twobitencoding;
    encseq->unitsoftwobitencoding = gt_unitsoftwobitencoding(totallength);
    encseq->numofchars = 4U;
    encseq->maxsubalphasize = 1U;
    gt_assert(numofsequences > 0);
    encseq->filenametab = gt_str_array_new();
    for (idx = 0; idx < gt_str_array_size(filenametab); idx++) {
      gt_str_array_add(encseq->filenametab,
                       gt_str_array_get_str(filenametab, idx));
    }
    encseq->headerptr.filelengthtab
      = gt_malloc((size_t) numoffiles *
                  sizeof (*encseq->headerptr.filelengthtab));
    for (idx = 0; idx < numoffiles; idx++) {
      encseq->headerptr.filelengthtab[idx] = filelengthtab[idx];
    }
    encseq->headerptr.characterdistribution
      = gt_malloc(encseq->numofchars *
                  sizeof (*encseq->headerptr.characterdistribution));
    encseq->numofallchars = 0;
    for (idx = 0; idx < (GtUword) encseq->numofchars; idx++) {
      encseq->headerptr.characterdistribution[idx] = characterdistribution[idx];
      if (encseq->headerptr.characterdistribution[idx] > 0)
        encseq->numofallchars++;
    }
    encseq->specialcharinfo.specialcharacters = numofsequences - 1;
    encseq->specialcharinfo.specialranges = numofsequences - 1;
    encseq->specialcharinfo.realspecialranges = numofsequences - 1;
    encseq->specialcharinfo.lengthofspecialprefix = lengthofspecialprefix;
    encseq->specialcharinfo.lengthofspecialsuffix = lengthofspecialsuffix;
    encseq->specialcharinfo.wildcards = 0UL;
    encseq->specialcharinfo.wildcardranges = 0UL;
    encseq->specialcharinfo.realwildcardranges = 0UL;
    encseq->specialcharinfo.lengthofwildcardprefix = 0UL;
    encseq->specialcharinfo.lengthofwildcardsuffix = 0UL;
    encseq->specialcharinfo.lengthoflongestnonspecial
      = lengthoflongestnonspecial;
    encseq->specialcharinfo.exceptioncharacters = 0UL;
    encseq->specialcharinfo.exceptionranges = 0UL;
    encseq->specialcharinfo.realexceptionranges = 0UL;
    encseq->minseqlen = minseqlen;
    encseq->maxseqlen = maxseqlen;
    alphabet_to_key_values(alphabet, &encseq->alphatype,
                           &encseq->lengthofalphadef,
                           &encseq->alphadef, false);
    encseq->lengthofdbfilenames
      = determinelengthofdbfilenames(encseq->filenametab);
    if (gt_mapspec_write(gt_encseq_assign_mapspec, fp, encseq,
                         encseq->sizeofrep, err) != 0) {
      haserr = true;
    }
    encseq->twobitencoding = NULL;
  }
  if (encseq != NULL)
    gt_encseq_headerptr_delete(&encseq->headerptr);
  gt_encseq_delete(encseq);
  gt_fa_xfclose(fp);
  return haserr ? -1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, 0x58(%rsp)
movq %r8, 0x50(%rsp)
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movq 0xf8(%rsp), %r12
testq %r12, %r12
je 0xa3f46
movq %r12, %rdi
callq 0xc103
testb %al, %al
jne 0xa4290
leaq 0x46d37(%rip), %rsi     # 0xeac84
leaq 0x464ce(%rip), %rdx     # 0xea422
leaq 0x47c3f(%rip), %rcx     # 0xebb9a
movq %rbx, %rdi
movl $0x5e6, %r8d            # imm = 0x5E6
movq %r12, %r9
callq 0x51b2d
movq %rax, %r12
testq %rax, %rax
je 0xa3fa2
callq 0x9b273
movq %rax, 0x48(%rsp)
testq %r14, %r14
movq %r12, 0x70(%rsp)
je 0xa3fad
movb $0x1, 0x60(%rsp)
movq %r14, 0x68(%rsp)
cmpl $0x2, %ebp
jne 0xa42ef
leaq 0x60(%rsp), %r14
jmp 0xa3fc7
pushq $-0x1
popq %r14
xorl %ebp, %ebp
jmp 0xa426e
movb $0x0, 0x60(%rsp)
andq $0x0, 0x68(%rsp)
leal -0x4(%rbp), %eax
cmpl $0x3, %eax
jae 0xa431d
xorl %r14d, %r14d
movq 0xe8(%rsp), %r12
movq 0xd8(%rsp), %r13
movq 0xd0(%rsp), %rbx
movq %r12, %rdi
callq 0xa4874
andq $0x0, 0x40(%rsp)
andl $0x0, 0x38(%rsp)
andl $0x0, 0x20(%rsp)
movq 0x48(%rsp), %rcx
movq %rcx, 0x30(%rsp)
andl $0x0, 0x18(%rsp)
movq %r14, 0x28(%rsp)
andq $0x0, (%rsp)
movq 0x58(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq 0x50(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movl %ebp, %edi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq %rax, %r8
xorl %r9d, %r9d
callq 0xa4355
movq %rax, %rbp
movq 0xc8(%rsp), %rax
movq %rax, 0x280(%rbp)
leaq -0x1(%r15), %rax
shrq $0x5, %rax
addq $0x2, %rax
cmpq $0x20, %r15
pushq $0x2
popq %rcx
cmovaeq %rax, %rcx
movq %rcx, 0x288(%rbp)
movl $0x4, 0x2a8(%rbp)
movb $0x1, 0x360(%rbp)
testq %rbx, %rbx
je 0xa42c1
movq 0xe0(%rsp), %r14
callq 0x1532c
movq %rax, 0x1f8(%rbp)
xorl %r15d, %r15d
movq %r12, %rdi
callq 0x157f4
cmpq %rax, %r15
jae 0xa40ca
movq 0x1f8(%rbp), %rbx
movq %r12, %rdi
movq %r15, %rsi
callq 0x155ca
movq %rbx, %rdi
movq %rax, %rsi
callq 0x154f5
incq %r15
jmp 0xa409b
movq %r13, %rdi
shlq $0x4, %rdi
leaq 0x47ac2(%rip), %rsi     # 0xebb9a
movl $0x617, %edx            # imm = 0x617
callq 0xccb0
movq %rax, 0xf0(%rbp)
xorl %eax, %eax
movq 0x70(%rsp), %r12
subq $0x1, %r13
jb 0xa410c
movq 0xf0(%rbp), %rcx
movups (%r14,%rax), %xmm0
movups %xmm0, (%rcx,%rax)
addq $0x10, %rax
jmp 0xa40f0
movl 0x2a8(%rbp), %edi
shlq $0x3, %rdi
leaq 0x47a7d(%rip), %rsi     # 0xebb9a
movl $0x61d, %edx            # imm = 0x61D
callq 0xccb0
movq %rax, 0xf8(%rbp)
andq $0x0, 0x340(%rbp)
movl 0x2a8(%rbp), %ecx
xorl %edx, %edx
movq 0xf8(%rsp), %r14
movq 0xf0(%rsp), %rdi
cmpq %rcx, %rdx
jae 0xa416c
movq (%rdi,%rdx,8), %rsi
movq %rsi, (%rax,%rdx,8)
testq %rsi, %rsi
je 0xa4167
incq 0x340(%rbp)
incq %rdx
jmp 0xa414e
testq %r12, %r12
sete %bl
movq 0xd0(%rsp), %rax
decq %rax
movq %rax, 0x178(%rbp)
movq %rax, 0x180(%rbp)
movq %rax, 0x188(%rbp)
movq 0xb0(%rsp), %rax
movq %rax, 0x190(%rbp)
movq 0xb8(%rsp), %rax
movq %rax, 0x198(%rbp)
xorps %xmm0, %xmm0
andq $0x0, 0x1c0(%rbp)
movups %xmm0, 0x1a0(%rbp)
movups %xmm0, 0x1b0(%rbp)
movq 0xc0(%rsp), %rax
movq %rax, 0x1c8(%rbp)
movups %xmm0, 0x1d0(%rbp)
andq $0x0, 0x1e0(%rbp)
movq 0x50(%rsp), %rax
movq %rax, 0x3b0(%rbp)
movq 0x58(%rsp), %rax
movq %rax, 0x3b8(%rbp)
leaq 0x238(%rbp), %rsi
leaq 0x230(%rbp), %rdx
leaq 0x228(%rbp), %rcx
movq 0x48(%rsp), %rdi
xorl %r8d, %r8d
callq 0xa48b6
movq 0x1f8(%rbp), %rdi
callq 0xa4874
movq %rax, 0x58(%rbp)
movq 0x60(%rbp), %rcx
leaq 0x778(%rip), %rdi       # 0xa49b4
movq %r12, %rsi
movq %rbp, %rdx
movq %r14, %r8
callq 0xbd84e
testl %eax, %eax
setne %r14b
andq $0x0, 0x280(%rbp)
orb %bl, %r14b
movq %rbp, %rdi
addq $0x70, %rdi
callq 0xa4e75
movzbl %r14b, %r14d
negl %r14d
movq %rbp, %rdi
callq 0xa4fe9
movq %r12, %rdi
callq 0x51cc9
movl %r14d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x89d21(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x25dc5(%rip), %rsi     # 0xca066
leaq 0x263b1(%rip), %rdx     # 0xca659
leaq 0x47ef2(%rip), %rcx     # 0xec1a1
leaq 0x478e4(%rip), %r8      # 0xebb9a
movl $0x5e5, %r9d            # imm = 0x5E5
jmp 0xa4349
movq 0x89cf0(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x25d94(%rip), %rsi     # 0xca066
leaq 0x47f87(%rip), %rdx     # 0xec260
leaq 0x47ec1(%rip), %rcx     # 0xec1a1
leaq 0x478b3(%rip), %r8      # 0xebb9a
movl $0x60f, %r9d            # imm = 0x60F
jmp 0xa4349
movq 0x89cc2(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x25d66(%rip), %rsi     # 0xca066
leaq 0x47ec9(%rip), %rdx     # 0xec1d0
leaq 0x47e93(%rip), %rcx     # 0xec1a1
leaq 0x47885(%rip), %r8      # 0xebb9a
movl $0x5f1, %r9d            # imm = 0x5F1
jmp 0xa4349
movq 0x89c94(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x25d38(%rip), %rsi     # 0xca066
leaq 0x47ebd(%rip), %rdx     # 0xec1f2
leaq 0x47e65(%rip), %rcx     # 0xec1a1
leaq 0x47857(%rip), %r8      # 0xebb9a
movl $0x5f8, %r9d            # imm = 0x5F8
xorl %eax, %eax
callq 0xb8c0
callq 0xb300