// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/core/encseq.c
// Function: gt_encseq_check_external_twobitencoding_to_file
int gt_encseq_check_external_twobitencoding_to_file(const char *indexname,
                                                    GtError *err)
{
  GtEncseqLoader *el;
  GtEncseq *encseq;
  bool haserr = false;

  el = gt_encseq_loader_new();
  encseq = gt_encseq_loader_load(el, indexname, err);
  if (encseq == NULL)
    haserr = true;
  else {
    char *indexnamecopy;
    size_t indexname_len = strlen(indexname);
    GtUword numofdbsequences = gt_encseq_num_of_sequences(encseq);

    indexnamecopy = gt_malloc(sizeof(char) * (indexname_len+1+1));
    strcpy(indexnamecopy, indexname);
    indexnamecopy[indexname_len] = '2';
    indexnamecopy[indexname_len+1] = '\0';
    if (encseq->sat == GT_ACCESS_TYPE_EQUALLENGTH) {
      gt_assert(encseq->equallength.defined);
      if (gt_encseq_equallength_write_twobitencoding_to_file(indexnamecopy,
                                        gt_encseq_total_length(encseq),
                                        encseq->equallength.valueunsignedlong,
                                        encseq->twobitencoding,
                                        numofdbsequences,
                                        gt_encseq_num_of_files(encseq),
                                        encseq->headerptr.filelengthtab,
                                        encseq->filenametab,
                                        encseq->headerptr.characterdistribution,
                                        err) != 0) {
        haserr = true;
      }
    }
    else {
      gt_assert(gt_encseq_wildcards(encseq) == 0);
      if (gt_encseq_generic_write_twobitencoding_to_file(indexnamecopy,
                                   gt_encseq_total_length(encseq),
                                   encseq->sat,
                                   0,
                                   gt_encseq_min_seq_length(encseq),
                                   gt_encseq_max_seq_length(encseq),
                                   gt_encseq_lengthofspecialprefix(encseq),
                                   gt_encseq_lengthofspecialsuffix(encseq),
                                   gt_encseq_lengthoflongestnonspecial(encseq),
                                   encseq->twobitencoding,
                                   numofdbsequences,
                                   gt_encseq_num_of_files(encseq),
                                   encseq->headerptr.filelengthtab,
                                   encseq->filenametab,
                                   encseq->headerptr.characterdistribution,
                                   err) != 0) {
        haserr = true;
      }
      if (!haserr && numofdbsequences > 1UL) {
        GtUword seqnum, *seppostab;

        seppostab = gt_malloc(sizeof (*seppostab) * (numofdbsequences-1));
        for (seqnum = 0; seqnum < numofdbsequences - 1; seqnum++) {
          if (seqnum == 0)
            seppostab[seqnum] = gt_encseq_seqlength(encseq, seqnum);
          else {
            seppostab[seqnum] = seppostab[seqnum-1] +
                                gt_encseq_seqlength(encseq, seqnum) + 1;
          }
        }
        if (gt_encseq_seppos2ssptab(indexnamecopy,
                                    gt_encseq_total_length(encseq),
                                    numofdbsequences,
                                    seppostab,
                                    err) != 0) {
          haserr = true;
        }
        gt_free(seppostab);
      }
    }
    gt_free(indexnamecopy);
  }
  gt_encseq_delete(encseq);
  gt_encseq_loader_delete(el);
  return haserr ? -1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbp
callq 0xc6473
movq %rax, %rbx
movq %rax, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0xc64cf
movq %rax, %r14
testq %rax, %rax
je 0xc626f
movq %r15, 0x10(%rsp)
movq %rbp, %rdi
callq 0xb260
movq %rax, %r13
movq %r14, %rdi
callq 0xbef6c
movq %rax, 0x8(%rsp)
leaq 0x2(%r13), %rdi
leaq 0x3c84b(%rip), %rsi     # 0x102a2a
movl $0x1f5d, %edx           # imm = 0x1F5D
callq 0x35ee2
movq %rax, %r15
movq %rax, %rdi
movq %rbp, %rsi
callq 0xb600
movw $0x32, (%r15,%r13)
movl (%r14), %ebp
cmpl $0x2, %ebp
jne 0xc6279
cmpb $0x0, 0x1e8(%r14)
je 0xc6469
movq 0x38(%r14), %r13
movq 0x1f0(%r14), %rbp
movq 0x280(%r14), %r12
movq %r14, %rdi
callq 0xc6fb7
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq 0x8(%rsp), %r8
movq %rax, %r9
pushq 0x10(%rsp)
pushq 0xf8(%r14)
pushq 0x1f8(%r14)
pushq 0xf0(%r14)
callq 0xc1b97
addq $0x20, %rsp
testl %eax, %eax
setne %r12b
jmp 0xc641d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xc6437
movq %r15, (%rsp)
movq %rbx, 0x18(%rsp)
movb 0x3a8(%r14), %cl
movq 0x1a0(%r14), %rax
shlq %cl, %rax
testq %rax, %rax
jne 0xc646e
movq 0x38(%r14), %r12
movq 0x3b0(%r14), %rax
movq %rax, 0x28(%rsp)
movq 0x3b8(%r14), %rax
movq %rax, 0x20(%rsp)
movups 0x190(%r14), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x1c8(%r14), %rbx
movq 0x280(%r14), %r13
movq %r14, %rdi
callq 0xc6fb7
movq 0x1f8(%r14), %rcx
movq 0xf0(%r14), %rdx
movq 0xf8(%r14), %rsi
subq $0x50, %rsp
movq 0x60(%rsp), %rdi
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movq 0x58(%rsp), %r15
movq %r15, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movaps 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
movq 0x50(%rsp), %rdi
movq %r12, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
movq 0x78(%rsp), %r8
movq 0x70(%rsp), %r9
callq 0xc06da
addq $0x50, %rsp
testl %eax, %eax
setne %r12b
cmpq $0x2, %r15
setb %al
orb %r12b, %al
je 0xc6371
movq 0x18(%rsp), %rbx
movq (%rsp), %r15
jmp 0xc641d
leaq -0x8(,%r15,8), %rdi
movq %r15, %rbx
decq %rbx
leaq 0x3c6a4(%rip), %rsi     # 0x102a2a
movl $0x1f87, %edx           # imm = 0x1F87
callq 0x35ee2
movq %rax, %rbp
testq %rbx, %rbx
je 0xc63d3
xorl %r13d, %r13d
testq %r13, %r13
je 0xc63bd
movq -0x8(%rbp,%r13,8), %r15
movq %r14, %rdi
movq %r13, %rsi
callq 0xc2d57
addq %r15, %rax
incq %rax
movq %rax, (%rbp,%r13,8)
jmp 0xc63cb
movq %r14, %rdi
xorl %esi, %esi
callq 0xc2d57
movq %rax, (%rbp)
incq %r13
cmpq %r13, %rbx
jne 0xc639b
movq 0x38(%r14), %rsi
movq (%rsp), %r15
movq %r15, %rdi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
movq 0x10(%rsp), %r8
callq 0xc30f5
testl %eax, %eax
movl $0x0, %eax
movb %r12b, %al
movl $0x1, %r12d
cmovel %eax, %r12d
leaq 0x3c61f(%rip), %rsi     # 0x102a2a
movq %rbp, %rdi
movl $0x1f97, %edx           # imm = 0x1F97
callq 0x362a0
movq 0x18(%rsp), %rbx
leaq 0x3c606(%rip), %rsi     # 0x102a2a
movq %r15, %rdi
movl $0x1f9a, %edx           # imm = 0x1F9A
callq 0x362a0
movzbl %r12b, %ebp
negl %ebp
movq %r14, %rdi
callq 0xc1690
testq %rbx, %rbx
je 0xc6458
leaq 0x3c5df(%rip), %rsi     # 0x102a2a
movq %rbx, %rdi
movl $0x2279, %edx           # imm = 0x2279
callq 0x362a0
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2c8b2
callq 0x2c879