// File: /workspace/github_c_makefile_star2_O1/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 $0x78, %rsp
movq %r8, 0x30(%rsp)
movl %ecx, 0x2c(%rsp)
movl $0x0, 0x4(%rsp)
testq %rdi, %rdi
je 0x13f21d
movq %rsi, %r13
testq %rsi, %rsi
je 0x13f21d
movq %r9, %r14
movq %rdi, %r8
movabsq $0x4000000000, %rax     # imm = 0x4000000000
movq %rax, 0x8(%rsp)
movq %r9, %rdi
subq 0x30(%rsp), %rdi
jbe 0x13f218
testq %rdi, %rdi
jle 0x13f218
movq %rdx, %rbx
movq 0xb8(%rsp), %rbp
movq 0xb0(%rsp), %rax
cmpq $0x0, (%rax)
movq %r8, 0x10(%rsp)
jne 0x13ee91
addq %rdi, %rdi
movq %rdi, (%rbp)
leaq 0x245a11(%rip), %rsi    # 0x384888
movl $0x226, %edx            # imm = 0x226
callq 0x1092b2
movq 0x10(%rsp), %r8
movq 0xb0(%rsp), %rcx
movq %rax, (%rcx)
cmpl $0x0, 0xc(%r8)
movq %rbx, 0x50(%rsp)
je 0x13f1b0
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %eax
movq (%r8), %rdi
movq (%rdi,%rsi,8), %r15
movl %eax, %ecx
negb %cl
shlq %cl, %r15
movzbl 0x15(%r8), %edx
cmpl %edx, %eax
jae 0x13eed5
incl %esi
movl %esi, 0x8(%rsp)
movq (%rdi,%rsi,8), %rsi
movl %eax, %ecx
shrq %cl, %rsi
orq %rsi, %r15
addl $0x40, %eax
subl %edx, %eax
movl %eax, 0xc(%rsp)
movl $0x1, 0x4(%rsp)
cmpl $0x2, 0xc(%r8)
jb 0x13f1b0
negb %dl
movl %edx, %ecx
shrq %cl, %r15
leaq (%r14,%rbx), %rdi
movq 0x30(%rsp), %rax
leaq (%rax,%rbx), %r9
xorl %r12d, %r12d
movq %r14, 0x58(%rsp)
movq %r13, 0x48(%rsp)
movq %rdi, 0x20(%rsp)
movq %r9, 0x18(%rsp)
cmpq %rdi, %rbx
ja 0x13f1b3
movzbl 0x14(%r8), %eax
addq $0x2, %rax
cmpq %rax, %r15
ja 0x13f213
movq %r15, 0x38(%rsp)
movq %r8, %rdi
leaq 0x8(%rsp), %rsi
leaq 0x4(%rsp), %rdx
callq 0x13e5a1
movq %rax, %r13
testl %r13d, %r13d
je 0x13effd
movq 0x20(%rsp), %rdi
movq %rdi, %r14
subq %rbx, %r14
addq %r14, %r14
movl $0x1, %r15d
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
cmpq %r9, %rbx
jb 0x13efdf
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
movl 0x2c(%rsp), %edx
callq 0xec1f8
movq 0xb0(%rsp), %r8
movq (%r8), %rcx
movb %al, (%rcx,%r12)
incq %r12
movq (%rbp), %rsi
cmpq %rsi, %r12
jne 0x13efd0
addq %r14, %rsi
movq %rsi, (%rbp)
movq (%r8), %rdi
leaq 0x2458d1(%rip), %rdx    # 0x384888
movl $0x23a, %ecx            # imm = 0x23A
movq %r8, %rbp
callq 0x1094e6
movq %rax, (%rbp)
movq 0xb8(%rsp), %rbp
movq 0x10(%rsp), %r8
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r9
incq %rbx
cmpq %rdi, %rbx
ja 0x13f00c
addq $-0x2, %r14
leal 0x1(%r15), %eax
cmpl %r13d, %r15d
movl %eax, %r15d
jb 0x13ef75
jmp 0x13f00c
movq 0x10(%rsp), %r8
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r9
movl 0x4(%rsp), %r10d
movl 0x8(%rsp), %ebp
movl 0xc(%rsp), %r13d
cmpl 0xc(%r8), %r10d
jae 0x13f17f
cmpq %rdi, %rbx
movq 0x38(%rsp), %r15
ja 0x13f184
movzbl 0x14(%r8), %r11d
incq %r11
xorl %esi, %esi
cmpq %r11, %r15
sete %sil
movq %rdi, %r14
subq %rbx, %r14
addq %r14, %r14
movl %esi, %eax
addl %eax, %eax
movq %rax, 0x70(%rsp)
incl %r10d
movl %r10d, %eax
movq %r11, 0x60(%rsp)
movq %rsi, 0x40(%rsp)
movl %ebp, %ecx
xorl %ebp, %ebp
testl %r13d, %r13d
sete %bpl
movl $0x40, %edx
cmovel %edx, %r13d
addl %ecx, %ebp
movq (%r8), %rdx
movq (%rdx,%rbp,8), %r15
movl %r13d, %ecx
negb %cl
shlq %cl, %r15
movl %eax, %r10d
movzbl 0x15(%r8), %eax
cmpl %eax, %r13d
jae 0x13f0aa
incl %ebp
movq (%rdx,%rbp,8), %rdx
movl %r13d, %ecx
shrq %cl, %rdx
orq %rdx, %r15
addl $0x40, %r13d
subl %eax, %r13d
negb %al
movl %eax, %ecx
shrq %cl, %r15
movzbl 0x14(%r8), %eax
cmpq %rax, %r15
ja 0x13f184
jae 0x13f162
movq 0x38(%rsp), %rcx
xorq %r11, %rcx
movq 0x30(%rsp), %rdx
xorq %rbx, %rdx
orq %rcx, %rdx
sete %cl
cmpq %r9, %rbx
ja 0x13f0e7
testb %cl, %cl
je 0x13f162
decq %rax
cmpq %rax, %r15
movl %r15d, %eax
movl $0xfe, %ecx
cmovel %ecx, %eax
movq 0xb0(%rsp), %rdx
movq (%rdx), %rcx
movb %al, (%rcx,%r12)
incq %r12
movq 0xb8(%rsp), %rax
movq (%rax), %rsi
cmpq %rsi, %r12
jne 0x13f15d
addq %r14, %rsi
movq %rsi, (%rax)
movq (%rdx), %rdi
leaq 0x24575e(%rip), %rdx    # 0x384888
movl $0x24f, %ecx            # imm = 0x24F
movq %r10, 0x68(%rsp)
callq 0x1094e6
movq 0x60(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x18(%rsp), %r9
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %r8
movq 0xb0(%rsp), %rcx
movq %rax, (%rcx)
movq 0x40(%rsp), %rsi
addq %rsi, %rbx
cmpl 0xc(%r8), %r10d
jae 0x13f184
subq 0x70(%rsp), %r14
leal 0x1(%r10), %eax
cmpq %rdi, %rbx
jbe 0x13f065
jmp 0x13f184
movq 0x38(%rsp), %r15
movl %r10d, 0x4(%rsp)
movl %r13d, 0xc(%rsp)
movl %ebp, 0x8(%rsp)
cmpl 0xc(%r8), %r10d
movq 0x58(%rsp), %r14
movq 0x48(%rsp), %r13
movq 0xb8(%rsp), %rbp
jb 0x13ef19
jmp 0x13f1b3
xorl %r12d, %r12d
addq 0x50(%rsp), %r14
cmpq %r14, %rbx
ja 0x13f1f9
movl 0x2c(%rsp), %r15d
xorl %ebp, %ebp
cmpl 0x10(%r8), %ebp
jae 0x13f1f9
movq %r13, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0xec1f8
movq 0x10(%rsp), %r8
movq 0xb0(%rsp), %rcx
movq (%rcx), %rcx
movb %al, (%rcx,%r12)
incq %r12
incq %rbx
incl %ebp
cmpq %r14, %rbx
jbe 0x13f1c4
incq %r14
cmpq %r14, %rbx
jne 0x13f222
movq %r12, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x40a84
callq 0x40a4b
callq 0x40a12
callq 0x40abd