// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/tools/gt_encseq_bitextract.c
// Function: gt_encseq_bitextract_runner
static int gt_encseq_bitextract_runner(GT_UNUSED int argc, const char **argv,
                                       GT_UNUSED int parsed_args,
                                       void *tool_arguments,
                                       GT_UNUSED GtError *err)
{
  GtEncseqBitextractArguments *arguments = tool_arguments;
  GtEncseqLoader *el;
  GtEncseq *encseq;
  int had_err = 0;
  bool fwd, it1, GT_UNUSED it2;
  char buffer[BUFSIZ];
  GtEndofTwobitencoding etbe;
  GtEncseqReader *esr;
  GtSpecialrangeiterator *sri;
  GtRange srng;
  GtReadmode rm;

  gt_error_check(err);
  gt_assert(arguments);

  el = gt_encseq_loader_new();
  encseq = gt_encseq_loader_load(el, argv[parsed_args], err);
  if (!encseq)
    had_err = -1;

  if (!had_err && arguments->mirror) {
    had_err = gt_encseq_mirror(encseq, err);
  }

  if (!had_err) {
    rm = gt_readmode_parse(gt_str_get(arguments->readmode), NULL);
    fwd = GT_ISDIRREVERSE(rm) ? false : true;
  }

  if (!had_err && arguments->bitpos != GT_UNDEF_UWORD) {
    if (arguments->bitpos >= gt_encseq_total_length(encseq)) {
      gt_error_set(err,
                   "position "GT_WU" exceeds encoded sequence "
                   "length of "GT_WU"",
                   arguments->bitpos, gt_encseq_total_length(encseq));
      had_err = -1;
    }

    if (!had_err) {
      GtUword ret;
      esr = gt_encseq_create_reader_with_readmode(encseq, rm,
                                                  arguments->bitpos);
      ret = gt_encseq_extract2bitencwithtwobitencodingstoppos(&etbe, esr,
                                                        encseq,
                                                        rm, arguments->bitpos);
      gt_bitsequence_tostring(buffer, etbe.tbe);
      printf("Twobitencoding   %s\n"
             "unitsnotspecial  %u\n"
             "position         "GT_WU"\n"
             "returnvalue      "GT_WU"\n",
             buffer,
             etbe.unitsnotspecial,
             arguments->bitpos,
             ret);
      gt_encseq_reader_delete(esr);
    }
  }

  if (!had_err && arguments->stoppos != GT_UNDEF_UWORD) {
    if (arguments->stoppos >= gt_encseq_total_length(encseq)) {
      gt_error_set(err,
                   "position "GT_WU" exceeds encoded sequence "
                   "length of "GT_WU"",
                   arguments->stoppos, gt_encseq_total_length(encseq));
      had_err = -1;
    }
    if (!had_err) {
      esr = gt_encseq_create_reader_with_readmode(encseq, rm, 0);
      /* check stoppos stuff */
      gt_encseq_reader_reinit_with_readmode(esr, encseq, rm,
                                            arguments->stoppos);
      printf(""GT_WU": "GT_WU"\n", arguments->stoppos,
                           gt_getnexttwobitencodingstoppos(fwd, esr));
      gt_encseq_reader_delete(esr);
    }
  }

  if (!had_err && arguments->specialranges) {
    /* check specialrangeiterator stuff */
    if (gt_encseq_has_specialranges(encseq)) {
      sri = gt_specialrangeiterator_new(encseq, fwd);
      while (true) {
        it1 = gt_specialrangeiterator_next(sri, &srng);
        if (it1)
          printf(""GT_WU":"GT_WU"\n", srng.start, srng.end);
        else break;
      }
      gt_specialrangeiterator_delete(sri);
    }
  }

  gt_encseq_delete(encseq);
  gt_encseq_loader_delete(el);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2048, %rsp           # imm = 0x2048
movq %r8, %r12
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r14
testq %r8, %r8
je 0x25563
movq %r12, %rdi
callq 0x89eb7
testb %al, %al
jne 0x257e8
testq %r15, %r15
je 0x257be
callq 0x791cd
movq %rax, %rbx
movslq %ebp, %rax
movq (%r14,%rax,8), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x7921d
movq %rax, %r14
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x2578e
cmpb $0x1, (%r15)
jne 0x255b0
movq %r14, %rdi
movq %r12, %rsi
callq 0x7d4ca
movl %eax, %ebp
testl %eax, %eax
jne 0x2578e
movq 0x8(%r15), %rdi
callq 0xad1fa
movq %rax, %rdi
xorl %esi, %esi
callq 0xa45d3
movq 0x10(%r15), %rbp
cmpq $-0x1, %rbp
movl %eax, 0xc(%rsp)
je 0x2568a
movq %r14, %rdi
callq 0x7055e
movq 0x10(%r15), %r13
movq %r14, %rdi
cmpq %rax, %rbp
jae 0x25643
movl 0xc(%rsp), %ebp
movl %ebp, %esi
movq %r13, %rdx
callq 0x72260
movq 0x10(%r15), %r8
leaq 0x28(%rsp), %r13
movq %r13, %rdi
movq %rax, 0x10(%rsp)
movq %rax, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x76841
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorl %edx, %edx
movq (%r13), %rsi
cmpq $0x40, %rdx
je 0x2565a
testq %rsi, %rcx
sete %dil
xorb $0x31, %dil
movb %dil, 0x40(%rsp,%rdx)
incq %rdx
shrq %rcx
jmp 0x25625
callq 0x7055e
leaq 0x2c5b55(%rip), %rsi    # 0x2eb1a4
movq %r12, %rdi
movq %r13, %rdx
jmp 0x25781
leaq 0x40(%rsp), %rsi
movb $0x0, 0x40(%rsi)
movl 0x30(%rsp), %edx
movq 0x10(%r15), %rcx
leaq 0x2c5b66(%rip), %rdi    # 0x2eb1d8
movq %rax, %r8
xorl %eax, %eax
callq 0x17070
movq 0x10(%rsp), %rdi
callq 0x722ae
movl 0xc(%rsp), %eax
movl %eax, %r13d
andl $-0x3, %r13d
movq 0x18(%r15), %rbp
cmpq $-0x1, %rbp
je 0x2570d
movq %r14, %rdi
callq 0x7055e
cmpq %rax, %rbp
jae 0x25768
xorl %r12d, %r12d
cmpl $0x1, %r13d
setne %r12b
movq %r14, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %esi
xorl %edx, %edx
callq 0x72260
movq %rax, 0x10(%rsp)
movq 0x18(%r15), %rcx
movq %rax, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x71f38
movq 0x18(%r15), %rbp
movl %r12d, %edi
movq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0x7669f
leaq 0x2d886b(%rip), %rdi    # 0x2fdf63
movq %rbp, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x17070
movq %r12, %rdi
callq 0x722ae
xorl %ebp, %ebp
cmpb $0x1, 0x1(%r15)
jne 0x2578e
movq %r14, %rdi
callq 0x740a6
testb %al, %al
je 0x2578e
xorl %esi, %esi
cmpl $0x1, %r13d
setne %sil
movq %r14, %rdi
callq 0x741f0
movq %rax, %r15
leaq 0x18(%rsp), %r12
leaq 0x2c5ae8(%rip), %r13    # 0x2eb22b
movq %r15, %rdi
movq %r12, %rsi
callq 0x7428b
testb %al, %al
je 0x257b2
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x17070
jmp 0x25743
movq 0x18(%r15), %r15
movq %r14, %rdi
callq 0x7055e
leaq 0x2c5a29(%rip), %rsi    # 0x2eb1a4
movq %r12, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %rbp
movq %r14, %rdi
callq 0x735fd
movq %rbx, %rdi
callq 0x79f01
movl %ebp, %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x74a09
xorl %ebp, %ebp
jmp 0x2578e
movq 0x4127a3(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2bf844(%rip), %rsi    # 0x2e5013
leaq 0x322e7d(%rip), %rdx    # 0x348653
leaq 0x2c59ab(%rip), %rcx    # 0x2eb188
leaq 0x2c589f(%rip), %r8     # 0x2eb083
pushq $0x67
jmp 0x25810
movq 0x412779(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2bf81a(%rip), %rsi    # 0x2e5013
leaq 0x2bf9bf(%rip), %rdx    # 0x2e51bf
leaq 0x2c5981(%rip), %rcx    # 0x2eb188
leaq 0x2c5875(%rip), %r8     # 0x2eb083
pushq $0x66
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390
nop