// File: /workspace/github_c_makefile_star2_O3/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 0xa3895
movq %r12, %rdi
callq 0xfcc32
testb %al, %al
jne 0xa3b0d
testq %r15, %r15
je 0xa3b08
callq 0xef0cd
movq %rax, %rbx
movslq %ebp, %rax
movq (%r14,%rax,8), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xef129
movq %rax, %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xa3ae4
cmpb $0x1, (%r15)
jne 0xa38e4
movq %r14, %rdi
movq %r12, %rsi
callq 0xf24ac
movl %eax, %ebp
testl %eax, %eax
jne 0xa3ae4
movq 0x8(%r15), %rdi
callq 0x11b0a1
movq %rax, %rdi
xorl %esi, %esi
callq 0x113107
movq 0x10(%r15), %rbp
cmpq $-0x1, %rbp
movl %eax, 0xc(%rsp)
je 0xa39a9
movq %r14, %rdi
callq 0xe7b9c
movq 0x10(%r15), %r13
movq %r14, %rdi
cmpq %rax, %rbp
jae 0xa3aa8
movl 0xc(%rsp), %ebp
movl %ebp, %esi
movq %r13, %rdx
callq 0xe91b2
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 0xeca81
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorl %edx, %edx
movq (%r13), %rsi
testq %rsi, %rcx
sete %dil
xorb $0x31, %dil
movb %dil, 0x40(%rsp,%rdx)
incq %rdx
shrq %rcx
cmpq $0x40, %rdx
jne 0xa395d
leaq 0x40(%rsp), %rsi
movb $0x0, 0x40(%rsi)
movl 0x30(%rsp), %edx
movq 0x10(%r15), %rcx
leaq 0x2a7847(%rip), %rdi    # 0x34b1d8
movq %rax, %r8
xorl %eax, %eax
callq 0x17070
movq 0x10(%rsp), %rdi
callq 0xe9204
movl 0xc(%rsp), %eax
movl %eax, %r13d
andl $-0x3, %r13d
movq 0x18(%r15), %rbp
cmpq $-0x1, %rbp
je 0xa3a2c
movq %r14, %rdi
callq 0xe7b9c
cmpq %rax, %rbp
jae 0xa3abc
xorl %r12d, %r12d
cmpl $0x1, %r13d
setne %r12b
movq %r14, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %esi
xorl %edx, %edx
callq 0xe91b2
movq %rax, 0x10(%rsp)
movq 0x18(%r15), %rcx
movq %rax, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0xe8eed
movq 0x18(%r15), %rbp
movl %r12d, %edi
movq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xec8db
leaq 0x2ba5c4(%rip), %rdi    # 0x35dfdb
movq %rbp, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x17070
movq %r12, %rdi
callq 0xe9204
xorl %ebp, %ebp
cmpb $0x1, 0x1(%r15)
jne 0xa3ae4
movq %r14, %rdi
callq 0xeacd6
testb %al, %al
je 0xa3ae4
xorl %esi, %esi
cmpl $0x1, %r13d
setne %sil
movq %r14, %rdi
callq 0xeae2c
movq %rax, %r15
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0xeae9a
testb %al, %al
je 0xa3a9e
leaq 0x2a77b5(%rip), %r12    # 0x34b22b
leaq 0x18(%rsp), %r13
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x17070
movq %r15, %rdi
movq %r13, %rsi
callq 0xeae9a
testb %al, %al
jne 0xa3a7b
movq %r15, %rdi
callq 0xeb455
jmp 0xa3ae4
callq 0xe7b9c
leaq 0x2a76f0(%rip), %rsi    # 0x34b1a4
movq %r12, %rdi
movq %r13, %rdx
jmp 0xa3ad5
movq 0x18(%r15), %r15
movq %r14, %rdi
callq 0xe7b9c
leaq 0x2a76d5(%rip), %rsi    # 0x34b1a4
movq %r12, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r14, %rdi
callq 0xea375
movq %rbx, %rdi
callq 0xefbe3
movl %ebp, %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1a1d6
callq 0x1a19f
nop