// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/sfx-mappedstr.c
// Function: gt_kmercodeiterator_reset
void gt_kmercodeiterator_reset(GtKmercodeiterator *kmercodeiterator,
                               GtReadmode readmode,
                               GtUword startpos)
{
  GtUchar charcode;
  const GtEncseq *encseq = kmercodeiterator->encseq;
  GtUword kmersize = (GtUword) kmercodeiterator->spwp->kmersize;

  gt_assert(!GT_ISDIRREVERSE(readmode) || startpos == 0);
  kmercodeiterator->totallength = gt_encseq_total_length(encseq);
  kmercodeiterator->startpos = startpos;
  gt_assert(startpos < kmercodeiterator->totallength);
  kmercodeiterator->fb = NULL;
  if (kmercodeiterator->totallength - startpos < kmersize)
  {
    kmercodeiterator->inputexhausted = true;
    gt_encseq_reader_delete(kmercodeiterator->esr);
    kmercodeiterator->esr = NULL;
    gt_kmerstream_delete(kmercodeiterator->spwp);
    kmercodeiterator->spwp = NULL;
  } else
  {
    kmercodeiterator->inputexhausted = false;
    kmercodeiterator->readmode = readmode;
    gt_encseq_reader_reinit_with_readmode(kmercodeiterator->esr,
                                          encseq,
                                          readmode,
                                          startpos);
    gt_kmerstream_reset(kmercodeiterator->spwp);
    kmercodeiterator->hasprocessedfirst = false;
    for (kmercodeiterator->currentposition = startpos;
         kmercodeiterator->currentposition < startpos+(GtUword) kmersize;
         kmercodeiterator->currentposition++)
    {
      charcode = gt_encseq_reader_next_encoded_char(kmercodeiterator->esr);
      kmercodeiterator->spwp->windowwidth++;
      gt_kmerstream_updatespecialpositions(kmercodeiterator->spwp,charcode,
                                           false,0);
      kmercodeiterator->spwp->cyclicwindow[kmercodeiterator->
                                           spwp->windowwidth-1] = charcode;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %eax
andl $-0x3, %eax
cmpl $0x1, %eax
setne %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
je 0x1f7c36
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
movq 0x20(%rdi), %r15
movq 0x38(%rdi), %rax
movl 0x44(%rax), %r12d
movq %r15, %rdi
callq 0xec1d8
movq %rax, (%rbx)
movq %r14, 0x8(%rbx)
subq %r14, %rax
jbe 0x1f7c3b
movq $0x0, 0x50(%rbx)
cmpq %r12, %rax
jae 0x1f7b93
movb $0x1, 0x19(%rbx)
movq 0x28(%rbx), %rdi
callq 0xed7bf
xorl %r14d, %r14d
movq %r14, 0x28(%rbx)
movq 0x38(%rbx), %rdi
callq 0x1f7c40
movq %r14, 0x38(%rbx)
jmp 0x1f7c27
xorl %r13d, %r13d
movb %r13b, 0x19(%rbx)
movl %ebp, 0x30(%rbx)
movq 0x28(%rbx), %rdi
movq %r15, %rsi
movl %ebp, %edx
movq %r14, %rcx
callq 0xed48e
movq 0x38(%rbx), %rax
movl %r13d, 0x50(%rax)
movq %r13, 0x58(%rax)
movq %r13, 0x48(%rax)
movl %r13d, 0x1c(%rax)
movq (%rax), %rcx
movl 0x18(%rax), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
addq $-0x10, %rcx
movq %rcx, 0x8(%rax)
movq %rcx, 0x10(%rax)
movb %r13b, 0x18(%rbx)
addq %r14, %r12
movq %r14, 0x10(%rbx)
cmpq %r14, %r12
jbe 0x1f7c27
movq 0x28(%rbx), %rdi
callq 0xec7be
movq 0x38(%rbx), %rdi
incl 0x48(%rdi)
movzbl %al, %ebp
movl %ebp, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1f7c95
movq 0x38(%rbx), %rax
movl 0x48(%rax), %ecx
decl %ecx
movb %bpl, 0x20(%rax,%rcx)
movq 0x10(%rbx), %rax
incq %rax
movq %rax, 0x10(%rbx)
cmpq %r12, %rax
jb 0x1f7beb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7aef5
callq 0x7af2e