// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %r8, 0x28(%rsp)
movl %ecx, 0x24(%rsp)
movabsq $0x4000000000, %rax     # imm = 0x4000000000
movq %rax, 0x38(%rsp)
testq %rdi, %rdi
je 0xcf7b0
movq %rsi, %r15
testq %rsi, %rsi
je 0xcf7b0
movq %rdx, %rbp
movl 0xc(%rdi), %r12d
testl %r12d, %r12d
movq %r9, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
je 0xcf6f7
movq %r15, 0x30(%rsp)
leaq 0x38(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0xceb8d
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %r9
movq %rax, %r15
leaq 0x14(%rsp), %rax
movl $0x1, (%rax)
pushq $0x1
popq %r14
xorl %r13d, %r13d
xorl %ebx, %ebx
cmpl %r12d, %r14d
jae 0xcf6f0
cmpq %r9, %rbx
ja 0xcf6f0
movzbl 0x14(%rdi), %eax
addq $0x2, %rax
cmpq %rax, %r15
ja 0xcf778
leaq 0x38(%rsp), %rsi
leaq 0x14(%rsp), %rdx
callq 0xcebdc
movq %rax, %r14
xorl %r12d, %r12d
movq 0x8(%rsp), %r9
leaq (%r12,%rbp), %rsi
leaq (%rbx,%r12), %rax
cmpq %r9, %rax
ja 0xcf64a
cmpl %r14d, %r12d
jae 0xcf64a
cmpq 0x28(%rsp), %rax
jb 0xcf645
movq 0x30(%rsp), %rdi
movl 0x24(%rsp), %edx
callq 0x705e4
movq 0x8(%rsp), %r9
movq 0x80(%rsp), %rcx
movb %al, (%rcx,%r13)
incq %r13
incq %r12
jmp 0xcf60a
movq 0x18(%rsp), %rdi
movzbl 0x14(%rdi), %ecx
incq %rcx
xorl %edx, %edx
cmpq %rcx, %r15
sete %dl
movq %rdx, 0x40(%rsp)
movl 0x14(%rsp), %r14d
movq %rsi, %rbp
movq %rax, %rbx
movl 0xc(%rdi), %r12d
cmpl %r12d, %r14d
jae 0xcf6e6
cmpq %r9, %rbx
ja 0xcf6e6
movq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xceb8d
movq 0x18(%rsp), %rdi
movq %rax, %r15
movzbl 0x14(%rdi), %eax
cmpq %rax, %r15
ja 0xcf6de
jae 0xcf6cf
cmpq 0x28(%rsp), %rbx
movq 0x8(%rsp), %r9
jb 0xcf6ca
decq %rax
cmpq %rax, %r15
movl %r15d, %eax
movl $0xfe, %ecx
cmovel %ecx, %eax
movq 0x80(%rsp), %rcx
movb %al, (%rcx,%r13)
incq %r13
incq %rbx
jmp 0xcf6d4
movq 0x8(%rsp), %r9
addq 0x40(%rsp), %rbp
incl %r14d
jmp 0xcf66e
incl %r14d
movq 0x8(%rsp), %r9
movl %r14d, 0x14(%rsp)
jmp 0xcf5cd
movq 0x30(%rsp), %r15
jmp 0xcf6fc
xorl %r13d, %r13d
xorl %ebx, %ebx
xorl %r14d, %r14d
leaq (%rbx,%r14), %rax
cmpq %r9, %rax
ja 0xcf743
cmpl 0x10(%rdi), %r14d
jae 0xcf743
cmpq 0x28(%rsp), %rax
jb 0xcf73e
leaq (%r14,%rbp), %rsi
movq %r15, %rdi
movl 0x24(%rsp), %edx
callq 0x705e4
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %r9
movq 0x80(%rsp), %rcx
movb %al, (%rcx,%r13)
incq %r13
incq %r14
jmp 0xcf6ff
movq %r9, %rax
subq %rbx, %rax
incq %rax
cmpq %r14, %rax
jne 0xcf7de
subq 0x28(%rsp), %r9
incq %r9
cmpq %r9, %r13
jne 0xcf80c
movq %r13, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3687e9(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x21588a(%rip), %rsi    # 0x2e5013
leaq 0x24c3ab(%rip), %rdx    # 0x31bb3b
leaq 0x24c3e9(%rip), %rcx    # 0x31bb80
leaq 0x24c11a(%rip), %r8     # 0x31b8b8
movl $0x27d, %r9d            # imm = 0x27D
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x3687b1(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215852(%rip), %rsi    # 0x2e5013
leaq 0x24c2e8(%rip), %rdx    # 0x31bab0
leaq 0x24c3b1(%rip), %rcx    # 0x31bb80
leaq 0x24c0e2(%rip), %r8     # 0x31b8b8
movl $0x274, %r9d            # imm = 0x274
jmp 0xcf7a4
movq 0x368783(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215824(%rip), %rsi    # 0x2e5013
leaq 0x24c3ab(%rip), %rdx    # 0x31bba1
leaq 0x24c383(%rip), %rcx    # 0x31bb80
leaq 0x24c0b4(%rip), %r8     # 0x31b8b8
movl $0x2a5, %r9d            # imm = 0x2A5
jmp 0xcf7a4
movq 0x368755(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2157f6(%rip), %rsi    # 0x2e5013
leaq 0x24c390(%rip), %rdx    # 0x31bbb4
leaq 0x24c355(%rip), %rcx    # 0x31bb80
leaq 0x24c086(%rip), %r8     # 0x31b8b8
movl $0x2a6, %r9d            # imm = 0x2A6
jmp 0xcf7a4