// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/editscript.c
// Function: gt_editscript_get_target_subseq_len
GtUword gt_editscript_get_target_subseq_len(const GtEditscript *editscript,
                                            GtUword srcfrom,
                                            GtUword srclen)
{
  GtEditscriptPos pos;
  GtBitsequence elem;
  GtUword upos = 0,
          vlength = 0;
  uint32_t served = 0;

  gt_assert(editscript != NULL);
  editscript_pos_reset(&pos);
  if (editscript->num_elems != 0) {
    elem = editscript_space_get_next(editscript, &pos);
    served++;
    while (upos < srcfrom + srclen &&
           served < editscript->num_elems) {
      GtBitsequence matchlen = editscript_space_get_length(editscript, &pos,
                                                           &served);
      /* add matches */
      if (upos + matchlen > srcfrom) {
        vlength += matchlen;
        /* remove overhang in front */
        if (upos < srcfrom)
          vlength -= srcfrom - upos;
        /* remove overhang at end */
        if (srcfrom + srclen < upos + matchlen)
          vlength -= (upos + matchlen) - (srcfrom + srclen);
      }
      upos += matchlen;
      if (elem == GT_EDITSCRIPT_MISDEL_SYM(editscript)) {
        elem = editscript_space_get_next(editscript, &pos);
        served++;
        while ((elem <= (GtBitsequence) editscript->del) &&
               upos < srcfrom + srclen &&
               served <= editscript->num_elems) {
          if (elem < (GtBitsequence) editscript->del && upos >= srcfrom)
            vlength++;
          upos++;
          elem = editscript_space_get_next(editscript, &pos);
          served++;
        }
      }
      else {
        gt_assert(elem == GT_EDITSCRIPT_INS_SYM(editscript));
        elem = editscript_space_get_next(editscript, &pos);
        served++;
        while (elem <= (GtBitsequence) editscript->del &&
               upos < srcfrom + srclen &&
               served <= editscript->num_elems) {
          gt_assert(elem != (GtBitsequence) editscript->del &&
                    "insertion can not be deletion symbol");
          /* count insertions only within range, not in front */
          if (upos > srcfrom)
            vlength++;
          elem = editscript_space_get_next(editscript, &pos);
          served++;
        }
      }
    }
  }
  if (upos < srcfrom + srclen) {
    vlength += editscript->trailing_matches;
    /* remove overhang in front */
    if (upos < srcfrom)
      vlength -= srcfrom - upos;
    /* remove overhang at end */
    if (srcfrom + srclen < upos + editscript->trailing_matches)
      vlength -= (upos + editscript->trailing_matches) - (srcfrom + srclen);
  }
  return vlength;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0xcf10c
movq %rdx, %r14
movq %rsi, %rbx
movabsq $0x4000000000, %rax     # imm = 0x4000000000
movq %rax, 0x8(%rsp)
movl 0xc(%rdi), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
movq %rdi, 0x20(%rsp)
je 0xcf064
leaq 0x8(%rsp), %rsi
callq 0xceb8d
movq %rax, %rbp
movq %rsp, %rax
movl $0x1, (%rax)
movq %rbx, 0x18(%rsp)
addq %rbx, %r14
pushq $0x1
popq %rbx
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %r14, 0x10(%rsp)
cmpq %r14, %r15
jae 0xcf05d
cmpl 0x4(%rsp), %ebx
jae 0xcf05d
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
callq 0xcebdc
leaq (%rax,%r15), %r13
movq 0x18(%rsp), %rsi
cmpq %rsi, %r13
jbe 0xcef87
movq %rsi, %rcx
subq %r15, %rcx
movl $0x0, %edx
cmovaeq %rcx, %rdx
subq %rdx, %r12
addq %rax, %r12
movq %r14, %rax
subq %r13, %rax
jae 0xcef87
addq %rax, %r12
movzbl 0x14(%rbx), %r15d
leaq 0x1(%r15), %rax
cmpq %rax, %rbp
jne 0xceff3
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0xceb8d
movq %rax, %rbp
movl (%rsp), %ebx
incl %ebx
cmpq %r15, %rbp
ja 0xcf052
cmpq %r14, %r13
jae 0xcf052
cmpl 0x4(%rsp), %ebx
ja 0xcf052
cmpq %r15, %rbp
setb %al
cmpq 0x18(%rsp), %r13
setae %cl
andb %al, %cl
movzbl %cl, %eax
addq %rax, %r12
incq %r13
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xceb8d
movq %rax, %rbp
jmp 0xcefa8
leaq 0x2(%r15), %rax
cmpq %rax, %rbp
jne 0xcf0de
xorl %r14d, %r14d
cmpq %rsi, %r13
seta %r14b
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0xceb8d
movq %rax, %rbp
movl (%rsp), %ebx
incl %ebx
cmpq %r13, 0x10(%rsp)
jbe 0xcf04d
cmpq %r15, %rbp
ja 0xcf04d
cmpl 0x4(%rsp), %ebx
ja 0xcf04d
cmpq %r15, %rbp
je 0xcf0a6
addq %r14, %r12
movq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xceb8d
movq %rax, %rbp
jmp 0xcf01d
movq 0x10(%rsp), %r14
movl %ebx, (%rsp)
movq %r13, %r15
jmp 0xcef31
movq 0x18(%rsp), %rbx
jmp 0xcf06d
addq %rbx, %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq %r14, %r15
jae 0xcf094
movq 0x20(%rsp), %rax
movl 0x10(%rax), %eax
xorl %ecx, %ecx
subq %r15, %rbx
cmovaeq %rbx, %rcx
subq %rcx, %r12
addq %rax, %r12
addq %rax, %r15
subq %r15, %r14
jae 0xcf094
addq %r14, %r12
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x368ebb(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215f5c(%rip), %rsi    # 0x2e5013
leaq 0x24c9a0(%rip), %rdx    # 0x31ba5e
leaq 0x24c94b(%rip), %rcx    # 0x31ba10
leaq 0x24c7ec(%rip), %r8     # 0x31b8b8
movl $0x1f2, %r9d            # imm = 0x1F2
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x368e83(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215f24(%rip), %rsi    # 0x2e5013
leaq 0x24c93e(%rip), %rdx    # 0x31ba34
leaq 0x24c913(%rip), %rcx    # 0x31ba10
leaq 0x24c7b4(%rip), %r8     # 0x31b8b8
movl $0x1eb, %r9d            # imm = 0x1EB
jmp 0xcf0d2
movq 0x368e55(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215ef6(%rip), %rsi    # 0x2e5013
leaq 0x24c99e(%rip), %rdx    # 0x31bac2
leaq 0x24c8e5(%rip), %rcx    # 0x31ba10
leaq 0x24c786(%rip), %r8     # 0x31b8b8
movl $0x1c9, %r9d            # imm = 0x1C9
jmp 0xcf0d2