// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/core/encseq.c
// Function: gt_encseq_reader_reinit_with_readmode
void gt_encseq_reader_reinit_with_readmode(GtEncseqReader *esr,
                                           const GtEncseq *encseq,
                                           GtReadmode readmode,
                                           GtUword startpos)
{
  gt_assert(esr != NULL && encseq != NULL);
  if (encseq != esr->encseq) {
    if (esr->encseq != NULL)
      gt_encseq_delete(esr->encseq);
    esr->encseq = gt_encseq_ref((GtEncseq*) encseq);
  }
  gt_assert(esr->encseq);

  /* translate reverse positions into forward positions */
  if (GT_ISDIRREVERSE(readmode))
    startpos = GT_REVERSEPOS(encseq->logicaltotallength, startpos);
  esr->originalreadmode = readmode;

  /* if inside virtual mirror sequence, adjust start position and reading
     direction */
  if (encseq->hasmirror) {
    if (startpos >= encseq->totallength) {
      esr->startedonmiddle = (startpos == encseq->totallength);
      startpos = GT_REVERSEPOS(encseq->totallength,
                               startpos - encseq->totallength - 1);
      switch (readmode) {
        case GT_READMODE_REVERSE:
          if (esr->startedonmiddle)
            readmode = GT_READMODE_REVERSE;
          else
            gt_readmode_invert(readmode);
          break;
        case GT_READMODE_REVCOMPL:
          if (esr->startedonmiddle)
            readmode = GT_READMODE_REVCOMPL;
          else
            gt_readmode_invert(readmode);
          break;
        default:
          gt_readmode_invert(readmode);
          break;
      }
    }
  }
  gt_assert(startpos <= encseq->totallength);
  esr->readmode = readmode;
  esr->currentpos = startpos;
  if (encseq->accesstype_via_utables) {
    /* Do not need this in once all is done by wildcards */
    if (encseq->has_wildcardranges) {
      if (esr->wildcardrangestate == NULL) {
        esr->wildcardrangestate =
          gt_calloc((size_t) 1, sizeof (*esr->wildcardrangestate));
      }
      binpreparenextrangeGtEncseqReader(esr, SWtable_wildcardrange);
#ifdef GT_RANGEDEBUG
      printf("wildcardranges: start advance "
             "at ("GT_WU", "GT_WU") in page "GT_WU"\n",
                       esr->wildcardrangestate->firstcell,
                       esr->wildcardrangestate->lastcell,
                       esr->wildcardrangestate->nextpage);
#endif
      advancerangeGtEncseqReader(esr, SWtable_wildcardrange);
    }
    if (esr->encseq->numofdbsequences > 1UL) {
      gt_assert(esr->encseq->satsep != GT_ACCESS_TYPE_UNDEFINED);
      if (esr->ssptabstate == NULL) {
        esr->ssptabstate =
          gt_calloc((size_t) 1, sizeof (*esr->ssptabstate));
      }
      binpreparenextrangeGtEncseqReader(esr, SWtable_ssptab);
#ifdef GT_RANGEDEBUG
      printf("ssptab: start advance at ("GT_WU", "GT_WU") in page "GT_WU"\n",
                       esr->ssptabstate->firstcell,
                       esr->ssptabstate->lastcell,
                       esr->ssptabstate->nextpage);
#endif
      advancerangeGtEncseqReader(esr, SWtable_ssptab);
    }
  }
  else {
    if (esr->wildcardrangestate != NULL) {
      gt_free(esr->wildcardrangestate);
      esr->wildcardrangestate = NULL;
    }
    if (esr->ssptabstate != NULL) {
      gt_free(esr->ssptabstate);
      esr->ssptabstate = NULL;
    }
    if (encseq->sat == GT_ACCESS_TYPE_EQUALLENGTH) {
      if (issinglepositioninspecialrangeViaequallength(esr->encseq, startpos)) {
        esr->nextseparatorpos = startpos;
      }
      else {
        GtUword seqnum = (startpos + 1)/
                               (encseq->equallength.valueunsignedlong + 1);
        if (!GT_ISDIRREVERSE(esr->readmode)) {
          esr->nextseparatorpos = encseq->equallength.valueunsignedlong +
                                  seqnum *
                                  (encseq->equallength.valueunsignedlong + 1);
        }
        else {
          if (seqnum > 0) {
            esr->nextseparatorpos = encseq->equallength.valueunsignedlong +
                                    (seqnum-1) *
                                    (encseq->equallength.valueunsignedlong + 1);
          }
          else {
            esr->nextseparatorpos = 0;
          }
        }
      }
    }
  }
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movl %edx, 0x24(%rsp)
movq %rcx, 0x18(%rsp)
cmpq $0x0, 0x30(%rsp)
je 0x115fb7
cmpq $0x0, 0x28(%rsp)
jne 0x115fef
movq 0x9e01a(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x4809e(%rip), %rsi     # 0x15e066
leaq 0x6fdb6(%rip), %rdx     # 0x185d85
leaq 0x6fdcd(%rip), %rcx     # 0x185da3
leaq 0x6f681(%rip), %r8      # 0x18565e
movl $0xbeb, %r9d            # imm = 0xBEB
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x115ff1
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
cmpq (%rcx), %rax
je 0x11602d
movq 0x30(%rsp), %rax
cmpq $0x0, (%rax)
je 0x116018
movq 0x30(%rsp), %rax
movq (%rax), %rdi
callq 0x118250
movq 0x28(%rsp), %rdi
callq 0x118da0
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, (%rax)
jmp 0x11602f
movq 0x30(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x116072
movq 0x9df97(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x4801b(%rip), %rsi     # 0x15e066
leaq 0x6fd77(%rip), %rdx     # 0x185dc9
leaq 0x6fd4a(%rip), %rcx     # 0x185da3
leaq 0x6f5fe(%rip), %r8      # 0x18565e
movl $0xbf1, %r9d            # imm = 0xBF1
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x116074
cmpl $0x1, 0x24(%rsp)
je 0x116082
cmpl $0x3, 0x24(%rsp)
jne 0x116099
movq 0x28(%rsp), %rax
movq 0x38(%rax), %rax
subq $0x1, %rax
subq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x24(%rsp), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x28(%rsp), %rax
testb $0x1, 0x3a8(%rax)
je 0x116174
movq 0x18(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jb 0x116172
movq 0x18(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x30(%rcx), %rcx
subq %rcx, %rax
movq 0x30(%rsp), %rax
sete 0x20(%rax)
movq 0x28(%rsp), %rax
movq 0x30(%rax), %rax
movq 0x18(%rsp), %rdx
movq %rax, %rcx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0xc(%rsp)
subl $0x1, %eax
je 0x11611b
jmp 0x116110
movl 0xc(%rsp), %eax
subl $0x3, %eax
je 0x11613f
jmp 0x116163
movq 0x30(%rsp), %rax
testb $0x1, 0x20(%rax)
je 0x116130
movl $0x1, 0x24(%rsp)
jmp 0x11613d
movl $0x3, %eax
subl 0x24(%rsp), %eax
movl %eax, 0x24(%rsp)
jmp 0x116170
movq 0x30(%rsp), %rax
testb $0x1, 0x20(%rax)
je 0x116154
movl $0x3, 0x24(%rsp)
jmp 0x116161
movl $0x3, %eax
subl 0x24(%rsp), %eax
movl %eax, 0x24(%rsp)
jmp 0x116170
movl $0x3, %eax
subl 0x24(%rsp), %eax
movl %eax, 0x24(%rsp)
jmp 0x116172
jmp 0x116174
jmp 0x116176
movq 0x18(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jbe 0x1161be
movq 0x9de4b(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x47ecf(%rip), %rsi     # 0x15e066
leaq 0x6fc37(%rip), %rdx     # 0x185dd5
leaq 0x6fbfe(%rip), %rcx     # 0x185da3
leaq 0x6f4b2(%rip), %r8      # 0x18565e
movl $0xc12, %r9d            # imm = 0xC12
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x1161c0
movl 0x24(%rsp), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x28(%rsp), %rax
testb $0x1, 0x3a9(%rax)
je 0x1162f5
movq 0x28(%rsp), %rax
testb $0x1, 0x29(%rax)
je 0x116242
movq 0x30(%rsp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x11622a
movl $0x1, %edi
movl $0x40, %esi
leaq 0x6f44a(%rip), %rdx     # 0x18565e
movl $0xc1a, %ecx            # imm = 0xC1A
callq 0xd5b0
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x115450
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x115520
movq 0x30(%rsp), %rax
movq (%rax), %rax
cmpq $0x1, 0x40(%rax)
jbe 0x1162f0
jmp 0x116257
movq 0x30(%rsp), %rax
movq (%rax), %rax
cmpl $0x7, 0x4(%rax)
jne 0x11629d
movq 0x9dd6c(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x47df0(%rip), %rsi     # 0x15e066
leaq 0x6fb78(%rip), %rdx     # 0x185df5
leaq 0x6fb1f(%rip), %rcx     # 0x185da3
leaq 0x6f3d3(%rip), %r8      # 0x18565e
movl $0xc27, %r9d            # imm = 0xC27
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x11629f
movq 0x30(%rsp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x1162d2
movl $0x1, %edi
movl $0x40, %esi
leaq 0x6f3a2(%rip), %rdx     # 0x18565e
movl $0xc2a, %ecx            # imm = 0xC2A
callq 0xd5b0
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x115450
movq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x115520
jmp 0x116454
movq 0x30(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x116328
movq 0x30(%rsp), %rax
movq 0x28(%rax), %rdi
leaq 0x6f34d(%rip), %rsi     # 0x18565e
movl $0xc38, %edx            # imm = 0xC38
callq 0xdab0
movq 0x30(%rsp), %rax
movq $0x0, 0x28(%rax)
movq 0x30(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0x11635b
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rdi
leaq 0x6f31a(%rip), %rsi     # 0x18565e
movl $0xc3c, %edx            # imm = 0xC3C
callq 0xdab0
movq 0x30(%rsp), %rax
movq $0x0, 0x30(%rax)
movq 0x28(%rsp), %rax
cmpl $0x2, (%rax)
jne 0x116452
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x18(%rsp), %rsi
callq 0x1144a0
testb $0x1, %al
jne 0x116381
jmp 0x116394
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x116450
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq 0x28(%rsp), %rcx
movq 0x1f0(%rcx), %rcx
addq $0x1, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
cmpl $0x1, 0x8(%rax)
je 0x116400
movq 0x30(%rsp), %rax
cmpl $0x3, 0x8(%rax)
je 0x116400
movq 0x28(%rsp), %rax
movq 0x1f0(%rax), %rcx
movq 0x10(%rsp), %rax
movq 0x28(%rsp), %rdx
movq 0x1f0(%rdx), %rdx
addq $0x1, %rdx
imulq %rdx, %rax
addq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x11644e
cmpq $0x0, 0x10(%rsp)
jbe 0x11643f
movq 0x28(%rsp), %rax
movq 0x1f0(%rax), %rcx
movq 0x10(%rsp), %rax
subq $0x1, %rax
movq 0x28(%rsp), %rdx
movq 0x1f0(%rdx), %rdx
addq $0x1, %rdx
imulq %rdx, %rax
addq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x11644c
movq 0x30(%rsp), %rax
movq $0x0, 0x18(%rax)
jmp 0x11644e
jmp 0x116450
jmp 0x116452
jmp 0x116454
addq $0x38, %rsp
retq
nopl (%rax)