// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/editscript.c
// Function: gt_editscript_get_sub_sequence_v
GtUword gt_editscript_get_sub_sequence_v(const GtEditscript *editscript,
                                         const GtEncseq *encseq,
                                         GtUword start,
                                         GtReadmode dir,
                                         GtUword vfrompos,
                                         GtUword vtopos,
                                         GtUchar *buffer)
{
  GtEditscriptPos pos;
  GtBitsequence elem = 0;
  GtUword vidx = 0,
          uidx,
          bufidx = 0;
  uint32_t j, elems_served = 0,
           matchcount;

  editscript_pos_reset(&pos);

  gt_assert(encseq != NULL && editscript != NULL);

  uidx = start;

  if (editscript->num_elems != 0) {
    bool mismatch_or_deletion;
    elem = editscript_space_get_next(editscript, &pos);
    elems_served++;
    while (elems_served < editscript->num_elems && vidx <= vtopos) {
      gt_assert(elem <= GT_EDITSCRIPT_INS_SYM(editscript));
      matchcount = (uint32_t) editscript_space_get_length(editscript, &pos,
                                                          &elems_served);
      for (j = 0; vidx <= vtopos && j < matchcount; ++j) {
        if (vidx >= vfrompos) {
          buffer[bufidx++] =
            gt_encseq_get_encoded_char(encseq, uidx, dir);
        }
        vidx++;
        uidx++;
      }
      mismatch_or_deletion = elem == GT_EDITSCRIPT_MISDEL_SYM(editscript);
      while (elems_served < editscript->num_elems && vidx <= vtopos) {
        elem = editscript_space_get_next(editscript, &pos);
        elems_served++;
        if (elem > (GtBitsequence) editscript->del) {
          break;
        }
        if (elem < (GtBitsequence) editscript->del) {
          if (vidx >= vfrompos) {
            buffer[bufidx++] =
              (elem == (GtBitsequence) editscript->del - 1) ?
              (GtUchar) GT_WILDCARD :
              (GtUchar) elem;
          }
          vidx++;
        }
        if (mismatch_or_deletion) uidx++;
      }
    }
  }
  for (j = 0;
       vidx <= vtopos && j < (uint32_t) editscript->trailing_matches;
       ++j) {
    if (vidx >= vfrompos) {
      buffer[bufidx++] = gt_encseq_get_encoded_char(encseq, uidx, dir);
    }
    vidx++;
    uidx++;
  }
  gt_assert(vidx == vtopos + 1);
  gt_assert(bufidx == vtopos - vfrompos + 1);
  return(bufidx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, 0x14(%rsp)
movl $0x0, 0xc(%rsp)
testq %rdi, %rdi
je 0x138d3c
testq %rsi, %rsi
je 0x138d3c
movq %rdx, %r15
movq %rdi, %r12
movq %rsi, 0x30(%rsp)
movl 0xc(%rdi), %esi
testl %esi, %esi
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
je 0x138b15
movq (%r12), %rax
movzbl 0x15(%r12), %ecx
movl $0x40, %edx
cmpl $0x41, %ecx
jb 0x138aff
movl $0x1, 0xc(%rsp)
movl $0x80, %edx
movq (%rax), %rbx
subl %ecx, %edx
movl %edx, 0x10(%rsp)
movl $0x1, 0x8(%rsp)
cmpl $0x1, %esi
jne 0x138b72
xorl %r14d, %r14d
xorl %ebp, %ebp
xorl %ebx, %ebx
leaq (%r14,%rbx), %rax
cmpl 0x10(%r12), %ebx
jae 0x138b6a
cmpq %r8, %rax
jb 0x138b53
leaq (%r15,%rbx), %rsi
movq 0x30(%rsp), %rdi
movl 0x14(%rsp), %edx
callq 0xe7bbc
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %r9
movq 0x70(%rsp), %rcx
movb %al, (%rcx,%rbp)
incq %rbp
leaq (%r14,%rbx), %rax
incq %rax
incq %rbx
cmpq %r9, %rax
jbe 0x138b1c
addq %rbx, %r14
jmp 0x138d11
movq %rax, %r14
jmp 0x138d11
negb %cl
shrq %cl, %rbx
xorl %r14d, %r14d
xorl %ebp, %ebp
movl %esi, %r13d
movq %r12, 0x28(%rsp)
movzbl 0x14(%r12), %eax
addq $0x2, %rax
cmpq %rax, %rbx
ja 0x138d37
movq %r12, %rdi
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x137ea7
movq %rax, %r12
movq 0x20(%rsp), %r9
cmpq %r9, %r14
setbe %al
testl %r12d, %r12d
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x138c1d
movl $0x1, %r13d
movq 0x18(%rsp), %r8
cmpq %r8, %r14
jb 0x138bfa
movq 0x30(%rsp), %rdi
movq %r15, %rsi
movl 0x14(%rsp), %edx
callq 0xe7bbc
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %r9
movq 0x70(%rsp), %rcx
movb %al, (%rcx,%rbp)
incq %rbp
incq %r14
incq %r15
cmpq %r9, %r14
ja 0x138c11
leal 0x1(%r13), %eax
cmpl %r12d, %r13d
movl %eax, %r13d
jb 0x138bcf
movq 0x28(%rsp), %r12
movl 0xc(%r12), %r13d
jmp 0x138c27
movq 0x18(%rsp), %r8
movq 0x28(%rsp), %r12
movl 0x8(%rsp), %edi
movl 0xc(%rsp), %esi
movl 0x10(%rsp), %eax
cmpl %r13d, %edi
jae 0x138cee
cmpq %r9, %r14
ja 0x138cee
movzbl 0x14(%r12), %ecx
incq %rcx
xorl %r11d, %r11d
cmpq %rcx, %rbx
sete %r11b
incl %edi
movl %edi, %edx
movl %esi, %ecx
xorl %esi, %esi
testl %eax, %eax
sete %sil
movl $0x40, %edi
cmovel %edi, %eax
addl %ecx, %esi
movq (%r12), %r10
movq (%r10,%rsi,8), %rbx
movl %eax, %ecx
negb %cl
shlq %cl, %rbx
movl %edx, %edi
movzbl 0x15(%r12), %edx
cmpl %edx, %eax
jae 0x138c9c
incl %esi
movq (%r10,%rsi,8), %r10
movl %eax, %ecx
shrq %cl, %r10
orq %r10, %rbx
addl $0x40, %eax
subl %edx, %eax
negb %dl
movl %edx, %ecx
shrq %cl, %rbx
movzbl 0x14(%r12), %ecx
cmpq %rcx, %rbx
ja 0x138cee
jae 0x138cda
cmpq %r8, %r14
jb 0x138cd7
decq %rcx
cmpq %rcx, %rbx
movl %ebx, %ecx
movl $0xfe, %edx
cmovel %edx, %ecx
movq 0x70(%rsp), %rdx
movb %cl, (%rdx,%rbp)
incq %rbp
movl 0xc(%r12), %r13d
incq %r14
addq %r11, %r15
cmpl %r13d, %edi
jae 0x138cee
leal 0x1(%rdi), %edx
cmpq %r9, %r14
jbe 0x138c5c
movl %edi, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl %esi, 0xc(%rsp)
cmpl %r13d, %edi
jae 0x138d08
cmpq %r9, %r14
jbe 0x138b84
cmpq %r9, %r14
jbe 0x138b1a
leaq 0x1(%r9), %rax
cmpq %rax, %r14
jne 0x138d41
subq %r8, %r9
incq %r9
cmpq %r9, %rbp
jne 0x138d46
movq %rbp, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4000d
callq 0x3ffd4
callq 0x40046
callq 0x4007f