// File: /workspace/github_c_makefile_star2_O3/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 0xc7495
movq %rax, %r15
movq %rax, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0xc74f1
testq %rax, %rax
je 0xc72a2
movq %rax, %r14
movq %rbp, %rdi
callq 0xb260
movq %rax, %r13
movq %r14, %rdi
callq 0xbff74
movq %rax, (%rsp)
leaq 0x2(%r13), %rdi
leaq 0x3b70b(%rip), %rsi     # 0x10291a
movl $0x1f5d, %edx           # imm = 0x1F5D
callq 0x35862
movq %rax, %r12
movq %rax, %rdi
movq %rbp, %rsi
callq 0xb600
movw $0x32, (%r12,%r13)
movl (%r14), %ebp
cmpl $0x2, %ebp
movq %rbx, 0x8(%rsp)
jne 0xc72ac
cmpb $0x0, 0x1e8(%r14)
je 0xc748b
movq 0x38(%r14), %r13
movq 0x1f0(%r14), %rbp
movq 0x280(%r14), %rbx
movq %r14, %rdi
callq 0xc7f91
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
movq (%rsp), %r8
movq %rax, %r9
pushq 0x8(%rsp)
pushq 0xf8(%r14)
pushq 0x1f8(%r14)
pushq 0xf0(%r14)
callq 0xc2c4a
addq $0x20, %rsp
testl %eax, %eax
setne %bl
jmp 0xc7440
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xc7461
movq %r12, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movb 0x3a8(%r14), %cl
movq 0x1a0(%r14), %rax
shlq %cl, %rax
testq %rax, %rax
jne 0xc7490
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 0xc7f91
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 0xc175f
addq $0x50, %rsp
testl %eax, %eax
setne %bl
cmpq $0x2, %r15
setb %al
orb %bl, %al
jne 0xc743b
leaq -0x8(,%r15,8), %rdi
movq %r15, %r12
decq %r12
leaq 0x3b569(%rip), %rsi     # 0x10291a
movl $0x1f87, %edx           # imm = 0x1F87
callq 0x35862
movq %rax, %rbp
xorl %r13d, %r13d
testq %r13, %r13
je 0xc73e3
movq -0x8(%rbp,%r13,8), %r15
movq %r14, %rdi
movq %r13, %rsi
callq 0xc3d9a
addq %r15, %rax
incq %rax
movq %rax, (%rbp,%r13,8)
jmp 0xc73f1
movq %r14, %rdi
xorl %esi, %esi
callq 0xc3d9a
movq %rax, (%rbp)
incq %r13
cmpq %r13, %r12
jne 0xc73c1
movq 0x38(%r14), %rsi
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq (%rsp), %rdx
movq %rbp, %rcx
movq 0x8(%rsp), %r8
callq 0xc4138
testl %eax, %eax
movl $0x0, %eax
movb %bl, %al
movl $0x1, %ebx
cmovel %eax, %ebx
leaq 0x3b4ec(%rip), %rsi     # 0x10291a
movq %rbp, %rdi
movl $0x1f97, %edx           # imm = 0x1F97
callq 0x35c27
movq 0x10(%rsp), %r15
leaq 0x3b4d3(%rip), %rsi     # 0x10291a
movq %r12, %rdi
movl $0x1f9a, %edx           # imm = 0x1F9A
callq 0x35c27
movq %r14, %rdi
callq 0xc273d
movzbl %bl, %ebp
negl %ebp
testq %r15, %r15
je 0xc747a
leaq 0x3b4ad(%rip), %rsi     # 0x10291a
movq %r15, %rdi
movl $0x2279, %edx           # imm = 0x2279
callq 0x35c27
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2c59a
callq 0x2c561