// File: /workspace/github_c_makefile_star2_O1/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 0xa5b79
movq %r12, %rdi
callq 0x101a9a
testb %al, %al
jne 0xa5e29
testq %r15, %r15
je 0xa5e24
callq 0xf36ef
movq %rax, %rbx
movslq %ebp, %rax
movq (%r14,%rax,8), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xf374b
movq %rax, %r14
testq %rax, %rax
je 0xa5bbd
xorl %r13d, %r13d
cmpb $0x1, (%r15)
jne 0xa5bc3
movq %r14, %rdi
movq %r12, %rsi
callq 0xf6aed
movl %eax, %r13d
jmp 0xa5bc3
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %r13d, %r13d
je 0xa5bca
jmp 0xa5bec
movq 0x8(%r15), %rdi
callq 0x120d23
movq %rax, %rdi
xorl %esi, %esi
callq 0x1187a3
movl %eax, 0xc(%rsp)
andl $-0x3, %eax
cmpl $0x1, %eax
setne 0xb(%rsp)
testl %r13d, %r13d
je 0xa5c96
testl %r13d, %r13d
je 0xa5d48
testl %r13d, %r13d
jne 0xa5c71
cmpb $0x1, 0x1(%r15)
jne 0xa5c71
movq %r14, %rdi
callq 0xef27f
testb %al, %al
je 0xa5c71
movzbl 0xb(%rsp), %esi
andl $0x1, %esi
movq %r14, %rdi
callq 0xef3d9
movq %rax, %r15
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0xef451
testb %al, %al
je 0xa5c69
leaq 0x2ae5f9(%rip), %r12    # 0x35423a
leaq 0x18(%rsp), %rbp
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x17070
movq %r15, %rdi
movq %rbp, %rsi
callq 0xef451
testb %al, %al
jne 0xa5c46
movq %r15, %rdi
callq 0xefa48
movq %r14, %rdi
callq 0xee90c
movq %rbx, %rdi
callq 0xf424d
movl %r13d, %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %rbp
cmpq $-0x1, %rbp
je 0xa5dbf
movq %r14, %rdi
callq 0xec1d8
movq 0x10(%r15), %r13
movq %r14, %rdi
cmpq %rax, %rbp
jae 0xa5dcf
movl 0xc(%rsp), %ebp
movl %ebp, %esi
movq %r13, %rdx
callq 0xed76d
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 0xf1097
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 0xa5cf8
leaq 0x40(%rsp), %rsi
movb $0x0, 0x40(%rsi)
movl 0x30(%rsp), %edx
movq 0x10(%r15), %rcx
leaq 0x2ae4bb(%rip), %rdi    # 0x3541e7
xorl %r13d, %r13d
movq %rax, %r8
xorl %eax, %eax
callq 0x17070
movq 0x10(%rsp), %rdi
callq 0xed7bf
jmp 0xa5bf5
movq 0x18(%r15), %r13
cmpq $-0x1, %r13
je 0xa5dc7
movq %r14, %rdi
callq 0xec1d8
cmpq %rax, %r13
jae 0xa5df6
xorl %r13d, %r13d
movq %r14, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %esi
xorl %edx, %edx
callq 0xed76d
movq %rax, %r12
movq 0x18(%r15), %rcx
movq %rax, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0xed48e
movq 0x18(%r15), %rbp
movzbl 0xb(%rsp), %edi
andl $0x1, %edi
movq %r12, %rsi
callq 0xf0eda
leaq 0x2c1306(%rip), %rdi    # 0x3670ab
movq %rbp, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x17070
movq %r12, %rdi
callq 0xed7bf
jmp 0xa5bfe
xorl %r13d, %r13d
jmp 0xa5bf5
xorl %r13d, %r13d
jmp 0xa5bfe
callq 0xec1d8
leaq 0x2ae3d8(%rip), %rsi    # 0x3541b3
movq %r12, %rdi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xa5bf5
movq 0x18(%r15), %r13
movq %r14, %rdi
callq 0xec1d8
leaq 0x2ae3aa(%rip), %rsi    # 0x3541b3
movq %r12, %rdi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xa5bfe
callq 0x1a227
callq 0x1a1f0
nop