// File: /workspace/github_c_makefile_star2_O1/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, 0x8(%rsp)
movabsq $0x4000000000, %rax     # imm = 0x4000000000
movq %rax, 0xc(%rsp)
testq %rdi, %rdi
je 0x13f4dd
testq %rsi, %rsi
je 0x13f4dd
movq %rdx, %r15
movq %rdi, %rbp
movq %rsi, 0x28(%rsp)
cmpl $0x0, 0xc(%rdi)
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
je 0x13f45a
movl 0xc(%rsp), %esi
movl 0x10(%rsp), %eax
movq (%rbp), %rdi
movq (%rdi,%rsi,8), %rbx
movl %eax, %ecx
negb %cl
shlq %cl, %rbx
movzbl 0x15(%rbp), %edx
cmpl %edx, %eax
jae 0x13f2b5
incl %esi
movl %esi, 0xc(%rsp)
movq (%rdi,%rsi,8), %rsi
movl %eax, %ecx
shrq %cl, %rsi
orq %rsi, %rbx
addl $0x40, %eax
subl %edx, %eax
movl %eax, 0x10(%rsp)
movl $0x1, 0x8(%rsp)
cmpl $0x2, 0xc(%rbp)
jb 0x13f45a
negb %dl
movl %edx, %ecx
shrq %cl, %rbx
xorl %r14d, %r14d
xorl %r12d, %r12d
movq %rbp, 0x30(%rsp)
movzbl 0x14(%rbp), %eax
addq $0x2, %rax
cmpq %rax, %rbx
ja 0x13f4d8
movq %r12, %r13
movq %rbp, %rdi
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x13e5a1
movq %rax, %r12
movq 0x20(%rsp), %r9
cmpq %r9, %r14
setbe %al
testl %r12d, %r12d
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x13f36d
movl $0x1, %ebp
movq 0x18(%rsp), %r8
cmpq %r8, %r14
jb 0x13f356
movq 0x28(%rsp), %rdi
movq %r15, %rsi
movl 0x14(%rsp), %edx
callq 0xec1f8
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %r9
movq 0x70(%rsp), %rcx
movb %al, (%rcx,%r13)
incq %r13
incq %r14
incq %r15
cmpq %r9, %r14
ja 0x13f372
leal 0x1(%rbp), %eax
cmpl %r12d, %ebp
movl %eax, %ebp
jb 0x13f32a
jmp 0x13f372
movq 0x18(%rsp), %r8
movl 0x8(%rsp), %edi
movl 0xc(%rsp), %esi
movl 0x10(%rsp), %eax
movq 0x30(%rsp), %rbp
cmpl 0xc(%rbp), %edi
jae 0x13f43b
cmpq %r9, %r14
movq %r13, %r12
ja 0x13f43e
movzbl 0x14(%rbp), %ecx
incq %rcx
xorl %r11d, %r11d
cmpq %rcx, %rbx
sete %r11b
incl %edi
movl %edi, %edx
movl $0x40, %r13d
movl %esi, %ecx
xorl %esi, %esi
testl %eax, %eax
sete %sil
cmovel %r13d, %eax
addl %ecx, %esi
movq (%rbp), %r10
movq (%r10,%rsi,8), %rbx
movl %eax, %ecx
negb %cl
shlq %cl, %rbx
movl %edx, %edi
movzbl 0x15(%rbp), %edx
cmpl %edx, %eax
jae 0x13f3ed
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(%rbp), %ecx
cmpq %rcx, %rbx
ja 0x13f43e
jae 0x13f425
cmpq %r8, %r14
jb 0x13f422
decq %rcx
cmpq %rcx, %rbx
movl %ebx, %ecx
movl $0xfe, %edx
cmovel %edx, %ecx
movq 0x70(%rsp), %rdx
movb %cl, (%rdx,%r12)
incq %r12
incq %r14
addq %r11, %r15
cmpl 0xc(%rbp), %edi
jae 0x13f43e
leal 0x1(%rdi), %edx
cmpq %r9, %r14
jbe 0x13f3b3
jmp 0x13f43e
movq %r13, %r12
movl %edi, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl %esi, 0xc(%rsp)
cmpl 0xc(%rbp), %edi
jae 0x13f460
cmpq %r9, %r14
jbe 0x13f2df
jmp 0x13f460
xorl %r12d, %r12d
xorl %r14d, %r14d
cmpq %r9, %r14
ja 0x13f4af
xorl %ebx, %ebx
leaq (%r14,%rbx), %rax
cmpl 0x10(%rbp), %ebx
jae 0x13f4b2
cmpq %r8, %rax
jb 0x13f49d
leaq (%r15,%rbx), %rsi
movq 0x28(%rsp), %rdi
movl 0x14(%rsp), %edx
callq 0xec1f8
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %r9
movq 0x70(%rsp), %rcx
movb %al, (%rcx,%r12)
incq %r12
leaq (%r14,%rbx), %rax
incq %rax
incq %rbx
cmpq %r9, %rax
jbe 0x13f467
addq %rbx, %r14
movq %r14, %rax
leaq 0x1(%r9), %rcx
cmpq %rcx, %rax
jne 0x13f4e2
subq %r8, %r9
incq %r9
cmpq %r9, %r12
jne 0x13f4e7
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x40b2f
callq 0x40af6
callq 0x40b68
callq 0x40ba1