// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movl $0x0, 0x14(%rsp)
testq %rdi, %rdi
je 0x13ede6
movq %rsi, %r11
movabsq $0x4000000000, %rax     # imm = 0x4000000000
movq %rax, 0x8(%rsp)
movl 0xc(%rdi), %eax
movl %eax, 0x10(%rsp)
testl %eax, %eax
movq %rdx, 0x30(%rsp)
je 0x13ed5a
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %eax
movq (%rdi), %rbx
movq (%rbx,%rsi,8), %rbp
movl %eax, %ecx
negb %cl
shlq %cl, %rbp
movzbl 0x15(%rdi), %r15d
cmpl %r15d, %eax
jae 0x13eaae
incl %esi
movl %esi, 0x8(%rsp)
movq (%rbx,%rsi,8), %rsi
movl %eax, %ecx
shrq %cl, %rsi
orq %rsi, %rbp
addl $0x40, %eax
subl %r15d, %eax
movl %eax, 0xc(%rsp)
movl $0x1, 0x14(%rsp)
movq %rdx, %r14
addq %r11, %r14
movq %r14, 0x18(%rsp)
sete %al
cmpl $0x1, 0x10(%rsp)
sete %cl
orb %al, %cl
jne 0x13ed5a
movl $0x40, %ecx
subl %r15d, %ecx
movq %rcx, 0x20(%rsp)
shrq %cl, %rbp
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %rdi, 0x28(%rsp)
leaq 0x8(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movq %r11, %r14
callq 0x13e5a1
movq %r14, %r11
leaq (%rax,%r13), %r14
cmpq %r11, %r14
jbe 0x13eb36
movq %r11, %rcx
subq %r13, %rcx
movl $0x0, %edx
cmovaeq %rcx, %rdx
subq %rdx, %r12
addq %rax, %r12
movq 0x18(%rsp), %rax
subq %r14, %rax
jae 0x13eb36
addq %rax, %r12
movq 0x28(%rsp), %rdi
movzbl 0x14(%rdi), %edx
leaq 0x1(%rdx), %rax
cmpq %rax, %rbp
jne 0x13ec4a
cmpl $0x0, 0xc(%rsp)
jne 0x13eb5f
incl 0x8(%rsp)
movl $0x40, 0xc(%rsp)
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %eax
movq (%rbx,%rsi,8), %rbp
movl %eax, %ecx
negb %cl
shlq %cl, %rbp
cmpl %r15d, %eax
jae 0x13eb8c
incl %esi
movl %esi, 0x8(%rsp)
movq (%rbx,%rsi,8), %rsi
movl %eax, %ecx
shrq %cl, %rsi
orq %rsi, %rbp
addl $0x40, %eax
movl 0x14(%rsp), %esi
movl 0x8(%rsp), %r8d
subl %r15d, %eax
movq 0x20(%rsp), %rcx
shrq %cl, %rbp
incl %esi
cmpq %rdx, %rbp
seta %cl
cmpq %r14, 0x18(%rsp)
setbe %r9b
cmpl 0x10(%rsp), %esi
seta %r10b
orb %r9b, %r10b
orb %cl, %r10b
jne 0x13ed37
movq %r14, %r13
movl %r8d, %ecx
cmpq %rdx, %rbp
setb %r14b
cmpq %r11, %r13
setae %r9b
xorl %r8d, %r8d
testl %eax, %eax
sete %r8b
movl $0x40, %r10d
cmovel %r10d, %eax
addl %ecx, %r8d
movq (%rbx,%r8,8), %rbp
movl %eax, %ecx
negb %cl
shlq %cl, %rbp
cmpl %r15d, %eax
jae 0x13ec11
incl %r8d
movq (%rbx,%r8,8), %r10
movl %eax, %ecx
shrq %cl, %r10
orq %r10, %rbp
addl $0x40, %eax
andb %r9b, %r14b
movzbl %r14b, %ecx
addq %rcx, %r12
movq 0x20(%rsp), %rcx
shrq %cl, %rbp
incq %r13
subl %r15d, %eax
incl %esi
cmpq %rdx, %rbp
ja 0x13ed3a
cmpq 0x18(%rsp), %r13
jae 0x13ed3a
cmpl 0x10(%rsp), %esi
jbe 0x13ebc8
jmp 0x13ed3a
leaq 0x2(%rdx), %rax
cmpq %rax, %rbp
jne 0x13ede1
cmpl $0x0, 0xc(%rsp)
jne 0x13ec6a
incl 0x8(%rsp)
movl $0x40, 0xc(%rsp)
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %eax
movq (%rbx,%rsi,8), %rbp
movl %eax, %ecx
negb %cl
shlq %cl, %rbp
cmpl %r15d, %eax
jae 0x13ec97
incl %esi
movl %esi, 0x8(%rsp)
movq (%rbx,%rsi,8), %rsi
movl %eax, %ecx
shrq %cl, %rsi
orq %rsi, %rbp
addl $0x40, %eax
cmpq %r14, 0x18(%rsp)
setbe %r9b
movl 0x14(%rsp), %esi
movl 0x8(%rsp), %r8d
subl %r15d, %eax
movq 0x20(%rsp), %rcx
shrq %cl, %rbp
incl %esi
cmpq %rdx, %rbp
seta %cl
cmpl 0x10(%rsp), %esi
seta %r10b
orb %r9b, %r10b
orb %cl, %r10b
jne 0x13ed37
xorl %r9d, %r9d
cmpq %r11, %r14
seta %r9b
cmpq %rdx, %rbp
je 0x13ed9c
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl $0x40, %r10d
cmovel %r10d, %eax
addl %ecx, %r8d
movq (%rbx,%r8,8), %rbp
movl %eax, %ecx
negb %cl
shlq %cl, %rbp
cmpl %r15d, %eax
jae 0x13ed15
incl %r8d
movq (%rbx,%r8,8), %r10
movl %eax, %ecx
shrq %cl, %r10
orq %r10, %rbp
addl $0x40, %eax
movq 0x20(%rsp), %rcx
shrq %cl, %rbp
addq %r9, %r12
subl %r15d, %eax
incl %esi
cmpq %r14, 0x18(%rsp)
jbe 0x13ed37
cmpq %rdx, %rbp
ja 0x13ed37
cmpl 0x10(%rsp), %esi
jbe 0x13ecd6
movq %r14, %r13
movl %eax, 0xc(%rsp)
movl %esi, 0x14(%rsp)
movl %r8d, 0x8(%rsp)
cmpq 0x18(%rsp), %r13
jae 0x13ed60
cmpl 0x10(%rsp), %esi
jb 0x13eaf6
jmp 0x13ed60
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x30(%rsp), %rdx
addq %r11, %rdx
cmpq %rdx, %r13
jae 0x13ed8a
movl 0x10(%rdi), %eax
xorl %ecx, %ecx
subq %r13, %r11
cmovaeq %r11, %rcx
subq %rcx, %r12
addq %rax, %r12
addq %rax, %r13
subq %r13, %rdx
jae 0x13ed8a
addq %rdx, %r12
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, 0xc(%rsp)
movl %esi, 0x14(%rsp)
movl %r8d, 0x8(%rsp)
movq 0x3851d0(%rip), %rax    # 0x4c3f80
movq (%rax), %rdi
leaq 0x20f259(%rip), %rsi    # 0x34e013
leaq 0x245c6d(%rip), %rdx    # 0x384a2e
leaq 0x245c18(%rip), %rcx    # 0x3849e0
leaq 0x245ab9(%rip), %r8     # 0x384888
movl $0x1f2, %r9d            # imm = 0x1F2
xorl %eax, %eax
callq 0x17ab0
callq 0x173b0
callq 0x409a0
callq 0x409d9