// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/editscript.c
// Function: gt_editscript_get_sub_sequence_u
GtUword gt_editscript_get_sub_sequence_u(const GtEditscript *editscript,
                                         const GtEncseq *encseq,
                                         GtUword start,
                                         GtReadmode dir,
                                         GtUword ufrompos,
                                         GtUword utopos,
                                         GtUchar **buffer,
                                         GtUword *bufsize)
{
  GtEditscriptPos pos;
  GtBitsequence elem = 0;
  GtUword uidx,
          bufidx = 0;
  uint32_t j,
           elems_served = 0,
           matchcount;

  gt_assert(encseq != NULL && editscript != NULL);

  editscript_pos_reset(&pos);

  uidx = start;

  /* overflow check */
  gt_assert(ufrompos < utopos &&
            utopos - ufrompos < GT_MULT2(utopos - ufrompos));
  /* as v can be longer than the range from u (due to insertions), we use a
     larger buffer */
  if (*buffer == NULL) {
    *bufsize = GT_MULT2(utopos - ufrompos);
    *buffer = gt_malloc(sizeof (**buffer) * *bufsize);
  }

  if (editscript->num_elems != 0) {
    bool mismatch_or_deletion;
    elem = editscript_space_get_next(editscript, &pos);
    elems_served++;
    while (elems_served < editscript->num_elems && uidx <= start + utopos) {
      gt_assert(elem <= GT_EDITSCRIPT_INS_SYM(editscript));
      matchcount = (uint32_t) editscript_space_get_length(editscript, &pos,
                                                          &elems_served);
      for (j = 0;
           uidx <= start + utopos &&
           j < matchcount;
           ++j) {
        if (uidx >= start + ufrompos) {
          (*buffer)[bufidx++] =
            gt_encseq_get_encoded_char(encseq, uidx, dir);
          if (bufidx == *bufsize) {
            *bufsize += GT_MULT2(start + utopos - uidx);
            *buffer = gt_realloc(*buffer, sizeof (**buffer) * *bufsize);
          }
        }
        uidx++;
      }
      mismatch_or_deletion = elem == GT_EDITSCRIPT_MISDEL_SYM(editscript);
      while (elems_served < editscript->num_elems && uidx <= start + utopos) {
        elem = editscript_space_get_next(editscript, &pos);
        elems_served++;
        if (elem > (GtBitsequence) editscript->del) {
          break;
        }
        if (elem < (GtBitsequence) editscript->del) {
          if (uidx > start + ufrompos ||
              (mismatch_or_deletion && uidx == ufrompos)) {
            (*buffer)[bufidx++] =
              (elem == (GtBitsequence) editscript->del - 1) ?
              (GtUchar) GT_WILDCARD :
              (GtUchar) elem;
            if (bufidx == *bufsize) {
              *bufsize += GT_MULT2(start + utopos - uidx);
              *buffer = gt_realloc(*buffer, sizeof (**buffer) * *bufsize);
            }
          }
        }
        if (mismatch_or_deletion) uidx++;
      }
    }
  }
  for (j = 0;
       uidx <= start + utopos &&
         j < (uint32_t) editscript->trailing_matches;
       ++j) {
    (*buffer)[bufidx++] = gt_encseq_get_encoded_char(encseq, uidx, dir);
    uidx++;
  }
  gt_assert(uidx == start + utopos + 1);
  return(bufidx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, (%rsp)
movq %r8, 0x30(%rsp)
movl %ecx, 0x1c(%rsp)
testq %rdi, %rdi
je 0xcf4e4
movq %rsi, %rbx
testq %rsi, %rsi
je 0xcf4e4
movq %rdi, %r8
movabsq $0x4000000000, %rax     # imm = 0x4000000000
movq %rax, 0x38(%rsp)
movq (%rsp), %rdi
subq 0x30(%rsp), %rdi
jbe 0xcf4b6
testq %rdi, %rdi
jle 0xcf4b6
movq %rdx, %r12
movq 0xa8(%rsp), %rax
movq 0xa0(%rsp), %rbp
cmpq $0x0, (%rbp)
movq %r8, 0x10(%rsp)
jne 0xcf1d3
addq %rdi, %rdi
movq %rdi, (%rax)
leaq 0x24c6f8(%rip), %rsi    # 0x31b8b8
movl $0x226, %edx            # imm = 0x226
callq 0x93160
movq 0x10(%rsp), %r8
movq %rax, (%rbp)
movq %rbx, 0x48(%rsp)
movl 0xc(%r8), %r14d
testl %r14d, %r14d
je 0xcf41d
leaq 0x38(%rsp), %rsi
movq %r8, %rdi
callq 0xceb8d
movq 0x10(%rsp), %r8
movq %rax, 0x20(%rsp)
leaq 0xc(%rsp), %rax
movl $0x1, (%rax)
addq %r12, (%rsp)
movq 0x30(%rsp), %rax
addq %r12, %rax
movq %rax, 0x50(%rsp)
pushq $0x1
popq %r15
xorl %r13d, %r13d
cmpl %r14d, %r15d
jae 0xcf424
cmpq (%rsp), %r12
ja 0xcf424
movzbl 0x14(%r8), %eax
addq $0x2, %rax
cmpq %rax, 0x20(%rsp)
ja 0xcf47e
movq %r8, %rdi
leaq 0x38(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0xcebdc
movq (%rsp), %rcx
subq %r12, %rcx
leaq 0x1(,%rcx,2), %rbx
xorl %r14d, %r14d
movq %rax, 0x28(%rsp)
leaq (%r12,%r14), %rsi
cmpq (%rsp), %rsi
ja 0xcf2f5
cmpl %eax, %r14d
jae 0xcf2f5
cmpq 0x50(%rsp), %rsi
jae 0xcf28a
movq %r13, %r15
jmp 0xcf2e6
movq %r12, %rbp
movq 0x48(%rsp), %rdi
movl 0x1c(%rsp), %edx
callq 0x705e4
movq 0xa0(%rsp), %r12
movq (%r12), %rcx
leaq 0x1(%r13), %r15
movb %al, (%rcx,%r13)
movq 0xa8(%rsp), %rax
cmpq (%rax), %r15
jne 0xcf2de
addq %rbx, %r13
movq %r13, (%rax)
movq (%r12), %rdi
movq %r13, %rsi
leaq 0x24c5e8(%rip), %rdx    # 0x31b8b8
movl $0x23a, %ecx            # imm = 0x23A
callq 0x93472
movq %rax, (%r12)
movq %rbp, %r12
movq 0x28(%rsp), %rax
incq %r14
addq $-0x2, %rbx
movq %r15, %r13
jmp 0xcf26f
movq 0x10(%rsp), %r8
movzbl 0x14(%r8), %eax
incq %rax
xorl %ecx, %ecx
movq 0x20(%rsp), %rbp
movq %rax, 0x58(%rsp)
cmpq %rax, %rbp
sete %cl
movl 0xc(%rsp), %r15d
movq %rcx, 0x28(%rsp)
addl %ecx, %ecx
movq %rcx, 0x60(%rsp)
movq %rsi, %r12
movl 0xc(%r8), %r14d
cmpl %r14d, %r15d
jae 0xcf406
cmpq (%rsp), %r12
ja 0xcf406
movq %r8, %rdi
leaq 0x38(%rsp), %rsi
callq 0xceb8d
movq 0x10(%rsp), %r8
movq %rax, %rbp
movzbl 0x14(%r8), %eax
cmpq %rax, %rbp
ja 0xcf403
jae 0xcf387
movq 0x20(%rsp), %rcx
xorq 0x58(%rsp), %rcx
movq 0x30(%rsp), %rdx
xorq %r12, %rdx
orq %rcx, %rdx
sete %cl
cmpq 0x50(%rsp), %r12
ja 0xcf38c
testb %cl, %cl
jne 0xcf38c
movq %r13, %r14
jmp 0xcf3ee
movq %r12, 0x40(%rsp)
decq %rax
cmpq %rax, %rbp
movl %ebp, %eax
movl $0xfe, %ecx
cmovel %ecx, %eax
movq 0xa0(%rsp), %r12
movq (%r12), %rcx
leaq 0x1(%r13), %r14
movb %al, (%rcx,%r13)
movq 0xa8(%rsp), %rax
cmpq (%rax), %r14
jne 0xcf3e9
addq %rbx, %r13
movq %r13, (%rax)
movq (%r12), %rdi
movq %r13, %rsi
leaq 0x24c4e2(%rip), %rdx    # 0x31b8b8
movl $0x24f, %ecx            # imm = 0x24F
callq 0x93472
movq 0x10(%rsp), %r8
movq %rax, (%r12)
movq 0x40(%rsp), %r12
addq 0x28(%rsp), %r12
subq 0x60(%rsp), %rbx
incl %r15d
movq %r14, %r13
jmp 0xcf328
incl %r15d
movl %r15d, 0xc(%rsp)
movq %rbp, 0x20(%rsp)
movq 0xa0(%rsp), %rbp
jmp 0xcf21f
addq %r12, (%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
leaq (%r12,%rbx), %rsi
cmpq (%rsp), %rsi
ja 0xcf459
cmpl 0x10(%r8), %ebx
jae 0xcf459
movq 0x48(%rsp), %rdi
movl 0x1c(%rsp), %edx
callq 0x705e4
movq 0x10(%rsp), %r8
movq (%rbp), %rcx
movb %al, (%rcx,%r13)
incq %r13
incq %rbx
jmp 0xcf426
movq (%rsp), %rax
subq %r12, %rax
incq %rax
cmpq %rbx, %rax
jne 0xcf512
movq %r13, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x368ae3(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215b84(%rip), %rsi    # 0x2e5013
leaq 0x24c6a5(%rip), %rdx    # 0x31bb3b
leaq 0x24c638(%rip), %rcx    # 0x31bad5
leaq 0x24c414(%rip), %r8     # 0x31b8b8
movl $0x22e, %r9d            # imm = 0x22E
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x368aab(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215b4c(%rip), %rsi    # 0x2e5013
leaq 0x24c628(%rip), %rdx    # 0x31baf6
leaq 0x24c600(%rip), %rcx    # 0x31bad5
leaq 0x24c3dc(%rip), %r8     # 0x31b8b8
movl $0x221, %r9d            # imm = 0x221
jmp 0xcf4aa
movq 0x368a7d(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215b1e(%rip), %rsi    # 0x2e5013
leaq 0x24c5b4(%rip), %rdx    # 0x31bab0
leaq 0x24c5d2(%rip), %rcx    # 0x31bad5
leaq 0x24c3ae(%rip), %r8     # 0x31b8b8
movl $0x219, %r9d            # imm = 0x219
jmp 0xcf4aa
movq 0x368a4f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x215af0(%rip), %rsi    # 0x2e5013
leaq 0x24c63b(%rip), %rdx    # 0x31bb65
leaq 0x24c5a4(%rip), %rcx    # 0x31bad5
leaq 0x24c380(%rip), %r8     # 0x31b8b8
movl $0x25e, %r9d            # imm = 0x25E
jmp 0xcf4aa