// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rdi, %rbp
callq 0xaabb9
movq %rax, %r15
movq %rax, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0xaac09
movq %rax, %r14
testq %rax, %rax
je 0xaa978
movq %rbx, 0x8(%rsp)
movq %rbp, %rdi
callq 0xb260
movq %rax, %rbx
movq %r14, %rdi
callq 0xa1f8d
movq %rax, (%rsp)
leaq 0x2(%rbx), %rdi
leaq 0x412b1(%rip), %rsi     # 0xebb9a
movl $0x1f5d, %edx           # imm = 0x1F5D
callq 0xccb0
movq %rax, %r12
movq %rax, %rdi
movq %rbp, %rsi
callq 0xb600
movw $0x32, (%r12,%rbx)
movl (%r14), %ebp
cmpl $0x2, %ebp
jne 0xaa980
cmpb $0x0, 0x1e8(%r14)
je 0xaab53
movq 0x38(%r14), %rbx
movq 0x1f0(%r14), %rbp
movq 0x280(%r14), %r13
movq %r14, %rdi
callq 0xab8a0
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq (%rsp), %r8
movq %rax, %r9
pushq 0x8(%rsp)
pushq 0xf8(%r14)
pushq 0x1f8(%r14)
pushq 0xf0(%r14)
callq 0xa5488
addq $0x20, %rsp
testl %eax, %eax
setne %r13b
jmp 0xaab18
pushq $-0x1
popq %rbx
jmp 0xaab32
movq %r12, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movb 0x3a8(%r14), %cl
movq 0x1a0(%r14), %rax
shlq %cl, %rax
testq %rax, %rax
jne 0xaab81
movq 0x38(%r14), %rbx
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), %r12
movq 0x280(%r14), %r13
movq %r14, %rdi
callq 0xab8a0
movq 0x1f8(%r14), %rcx
movq 0xf0(%r14), %rdx
movq 0xf8(%r14), %rsi
subq $0x50, %rsp
movq 0x58(%rsp), %rdi
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movq 0x50(%rsp), %r15
movq %r15, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %r12, 0x10(%rsp)
movaps 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
movq 0x68(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
movq 0x78(%rsp), %r8
movq 0x70(%rsp), %r9
callq 0xa3f06
addq $0x50, %rsp
testl %eax, %eax
setne %r13b
cmpq $0x2, %r15
setb %al
orb %r13b, %al
jne 0xaab13
leaq -0x8(,%r15,8), %rdi
movq %r15, %r12
decq %r12
leaq 0x41113(%rip), %rsi     # 0xebb9a
movl $0x1f87, %edx           # imm = 0x1F87
callq 0xccb0
movq %rax, %rbp
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0xaaad0
testq %rbx, %rbx
je 0xaaabd
movq -0x8(%rbp,%rbx,8), %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa6b5f
addq %r15, %rax
incq %rax
movq %rax, (%rbp,%rbx,8)
jmp 0xaaacb
movq %r14, %rdi
xorl %esi, %esi
callq 0xa6b5f
movq %rax, (%rbp)
incq %rbx
jmp 0xaaa96
movq 0x38(%r14), %rsi
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq (%rsp), %rdx
movq %rbp, %rcx
movq 0x8(%rsp), %r8
callq 0xa6ff7
testl %eax, %eax
movl $0x0, %eax
movb %r13b, %al
pushq $0x1
popq %r13
cmovel %eax, %r13d
leaq 0x41094(%rip), %rsi     # 0xebb9a
movq %rbp, %rdi
movl $0x1f97, %edx           # imm = 0x1F97
callq 0xd249
movq 0x10(%rsp), %r15
leaq 0x4107b(%rip), %rsi     # 0xebb9a
movq %r12, %rdi
movl $0x1f9a, %edx           # imm = 0x1F9A
callq 0xd249
movzbl %r13b, %ebx
negl %ebx
movq %r14, %rdi
callq 0xa4fe9
movq %r15, %rdi
callq 0xab8ed
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8345e(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x1f502(%rip), %rsi     # 0xca066
leaq 0x42723(%rip), %rdx     # 0xed28e
leaq 0x42738(%rip), %rcx     # 0xed2aa
leaq 0x41021(%rip), %r8      # 0xebb9a
movl $0x1f62, %r9d           # imm = 0x1F62
jmp 0xaabad
movq 0x83430(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x1f4d4(%rip), %rsi     # 0xca066
leaq 0x42741(%rip), %rdx     # 0xed2da
leaq 0x4270a(%rip), %rcx     # 0xed2aa
leaq 0x40ff3(%rip), %r8      # 0xebb9a
movl $0x1f71, %r9d           # imm = 0x1F71
xorl %eax, %eax
callq 0xb8c0
callq 0xb300