// File: /workspace/github_c_makefile_star2_O3/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 0x138662
movl $0x0, 0x8(%rsp)
movl 0xc(%rdi), %eax
movl %eax, (%rsp)
testl %eax, %eax
je 0x138614
movq (%rdi), %r15
movzbl 0x15(%rdi), %r14d
movl $0x40, %eax
cmpl $0x41, %r14d
jb 0x138380
movl $0x1, 0x8(%rsp)
movl $0x80, %eax
movq (%r15), %rbx
subl %r14d, %eax
movl %eax, 0xc(%rsp)
movl $0x1, 0x4(%rsp)
addq %rsi, %rdx
sete %al
cmpl $0x1, (%rsp)
sete %cl
orb %al, %cl
jne 0x138617
movl $0x40, %ecx
subl %r14d, %ecx
movq %rcx, 0x18(%rsp)
shrq %cl, %rbx
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %rdx, 0x20(%rsp)
movq %rdi, 0x10(%rsp)
movq %rsi, %rbp
leaq 0x8(%rsp), %rsi
leaq 0x4(%rsp), %rdx
callq 0x137ea7
leaq (%rax,%r13), %r8
cmpq %rbp, %r8
jbe 0x138409
movq %rbp, %rsi
subq %r13, %rbp
movl $0x0, %edx
cmovaeq %rbp, %rdx
subq %rdx, %r12
addq %rax, %r12
movq 0x20(%rsp), %rdx
movq %rdx, %rax
subq %r8, %rax
jae 0x138411
addq %rax, %r12
jmp 0x138411
movq 0x20(%rsp), %rdx
movq %rbp, %rsi
movq 0x10(%rsp), %rax
movzbl 0x14(%rax), %ebp
leaq 0x1(%rbp), %rax
cmpq %rax, %rbx
jne 0x138516
movl 0xc(%rsp), %eax
xorl %r11d, %r11d
testl %eax, %eax
sete %r11b
movl $0x40, %ecx
cmovel %ecx, %eax
addl 0x8(%rsp), %r11d
movq (%r15,%r11,8), %rbx
movl %eax, %ecx
negb %cl
shlq %cl, %rbx
cmpl %r14d, %eax
jae 0x138463
incl %r11d
movq (%r15,%r11,8), %rdi
movl %eax, %ecx
shrq %cl, %rdi
orq %rdi, %rbx
addl $0x40, %eax
movl 0x4(%rsp), %edi
subl %r14d, %eax
movq 0x18(%rsp), %rcx
shrq %cl, %rbx
incl %edi
cmpq %rbp, %rbx
seta %cl
cmpq %r8, %rdx
setbe %r9b
cmpl (%rsp), %edi
seta %r10b
orb %r9b, %r10b
orb %cl, %r10b
jne 0x1385ef
movq %r8, %r13
movl %r11d, %ecx
cmpq %rbp, %rbx
setb %r8b
cmpq %rsi, %r13
setae %r9b
xorl %r11d, %r11d
testl %eax, %eax
sete %r11b
movl $0x40, %r10d
cmovel %r10d, %eax
addl %ecx, %r11d
movq (%r15,%r11,8), %rbx
movl %eax, %ecx
negb %cl
shlq %cl, %rbx
cmpl %r14d, %eax
jae 0x1384e0
incl %r11d
movq (%r15,%r11,8), %r10
movl %eax, %ecx
shrq %cl, %r10
orq %r10, %rbx
addl $0x40, %eax
andb %r9b, %r8b
movzbl %r8b, %ecx
addq %rcx, %r12
movq 0x18(%rsp), %rcx
shrq %cl, %rbx
incq %r13
subl %r14d, %eax
incl %edi
cmpq %rbp, %rbx
ja 0x1385f2
cmpq %rdx, %r13
jae 0x1385f2
cmpl (%rsp), %edi
jbe 0x138497
jmp 0x1385f2
leaq 0x2(%rbp), %rax
cmpq %rax, %rbx
jne 0x13865d
movl 0xc(%rsp), %eax
xorl %r11d, %r11d
testl %eax, %eax
sete %r11b
movl $0x40, %ecx
cmovel %ecx, %eax
addl 0x8(%rsp), %r11d
movq (%r15,%r11,8), %rbx
movl %eax, %ecx
negb %cl
shlq %cl, %rbx
cmpl %r14d, %eax
jae 0x13855f
incl %r11d
movq (%r15,%r11,8), %rdi
movl %eax, %ecx
shrq %cl, %rdi
orq %rdi, %rbx
addl $0x40, %eax
cmpq %r8, %rdx
setbe %r9b
movl 0x4(%rsp), %edi
subl %r14d, %eax
movq 0x18(%rsp), %rcx
shrq %cl, %rbx
incl %edi
cmpq %rbp, %rbx
seta %cl
cmpl (%rsp), %edi
seta %r10b
orb %r9b, %r10b
orb %cl, %r10b
jne 0x1385ef
xorl %r9d, %r9d
cmpq %rsi, %r8
seta %r9b
cmpq %rbp, %rbx
je 0x138658
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl $0x40, %r10d
cmovel %r10d, %eax
addl %ecx, %r11d
movq (%r15,%r11,8), %rbx
movl %eax, %ecx
negb %cl
shlq %cl, %rbx
cmpl %r14d, %eax
jae 0x1385d5
incl %r11d
movq (%r15,%r11,8), %r10
movl %eax, %ecx
shrq %cl, %r10
orq %r10, %rbx
addl $0x40, %eax
movq 0x18(%rsp), %rcx
shrq %cl, %rbx
addq %r9, %r12
subl %r14d, %eax
incl %edi
cmpq %rbp, %rbx
ja 0x1385ef
cmpl (%rsp), %edi
jbe 0x138596
movq %r8, %r13
movl %eax, 0xc(%rsp)
movl %edi, 0x4(%rsp)
movl %r11d, 0x8(%rsp)
cmpq %rdx, %r13
jae 0x138651
cmpl (%rsp), %edi
movq 0x10(%rsp), %rdi
jb 0x1383c7
jmp 0x13861d
addq %rsi, %rdx
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq %rdx, %r13
jae 0x13863f
movl 0x10(%rdi), %eax
xorl %ecx, %ecx
subq %r13, %rsi
cmovaeq %rsi, %rcx
subq %rcx, %r12
addq %rax, %r12
addq %rax, %r13
subq %r13, %rdx
jae 0x13863f
addq %rdx, %r12
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdi
jmp 0x13861d
callq 0x3fe7e
callq 0x3fe45
callq 0x3feb7