// File: /workspace/github_c_makefile_star2_O3/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, 0x38(%rsp)
movl %ecx, 0x2c(%rsp)
testq %rdi, %rdi
je 0x138a8c
movq %rsi, %r14
testq %rsi, %rsi
je 0x138a8c
movq %r9, %r13
movq %rdi, %rsi
movl $0x0, 0x10(%rsp)
movq %r9, %rdi
subq 0x38(%rsp), %rdi
jbe 0x138a87
testq %rdi, %rdi
jle 0x138a87
movq %rdx, %rbx
movq 0xb8(%rsp), %rcx
movq 0xb0(%rsp), %rax
cmpq $0x0, (%rax)
movq %rsi, (%rsp)
jne 0x1386fb
addq %rdi, %rdi
movq %rdi, (%rcx)
leaq 0x242e36(%rip), %rsi    # 0x37b518
movl $0x226, %edx            # imm = 0x226
callq 0x104226
movq (%rsp), %rsi
movq 0xb0(%rsp), %rcx
movq %rax, (%rcx)
movl 0xc(%rsi), %r9d
testl %r9d, %r9d
movq %rbx, 0x48(%rsp)
je 0x13873e
movq (%rsi), %rax
movzbl 0x15(%rsi), %ecx
movl $0x40, %edx
cmpl $0x41, %ecx
jb 0x138727
movl $0x1, 0x10(%rsp)
movl $0x80, %edx
movq (%rax), %rbp
subl %ecx, %edx
movl %edx, 0x14(%rsp)
movl $0x1, 0xc(%rsp)
cmpl $0x1, %r9d
jne 0x13879f
xorl %r12d, %r12d
addq 0x48(%rsp), %r13
cmpq %r13, %rbx
ja 0x138781
xorl %ebp, %ebp
cmpl 0x10(%rsi), %ebp
jae 0x138781
movq %r14, %rdi
movq %rbx, %rsi
movl 0x2c(%rsp), %edx
callq 0xe7bbc
movq (%rsp), %rsi
movq 0xb0(%rsp), %rcx
movq (%rcx), %rcx
movb %al, (%rcx,%r12)
incq %r12
incq %rbx
incl %ebp
cmpq %r13, %rbx
jbe 0x13874d
incq %r13
cmpq %r13, %rbx
jne 0x138a91
movq %r12, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
negb %cl
shrq %cl, %rbp
leaq (%rbx,%r13), %rdi
movq 0x38(%rsp), %rax
leaq (%rax,%rbx), %r8
xorl %r12d, %r12d
movq %r13, 0x50(%rsp)
movq %r14, 0x40(%rsp)
movq %rdi, 0x20(%rsp)
movq %r8, 0x18(%rsp)
cmpq %rdi, %rbx
ja 0x138741
movzbl 0x14(%rsi), %eax
movq %rax, %r14
addq $0x2, %rax
movq %rbp, 0x30(%rsp)
cmpq %rax, %rbp
ja 0x138a82
movl %r9d, %r15d
movq %rsi, %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x137ea7
movq %rax, %r13
testl %r13d, %r13d
je 0x1388c4
movq 0x20(%rsp), %rdi
movq %rdi, %rax
subq %rbx, %rax
leaq 0x1(,%rax,2), %r14
movl $0x1, %r15d
movq (%rsp), %rsi
movq 0x18(%rsp), %r8
cmpq %r8, %rbx
jb 0x13889d
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
movl 0x2c(%rsp), %edx
callq 0xe7bbc
movq 0xb0(%rsp), %rdx
movq (%rdx), %rcx
leaq 0x1(%r12), %rbp
movb %al, (%rcx,%r12)
movq 0xb8(%rsp), %rax
cmpq (%rax), %rbp
jne 0x13888c
addq %r14, %r12
movq %r12, (%rax)
movq (%rdx), %rdi
movq %r12, %rsi
leaq 0x242ca1(%rip), %rdx    # 0x37b518
movl $0x23a, %ecx            # imm = 0x23A
callq 0x104461
movq 0xb0(%rsp), %rcx
movq %rax, (%rcx)
movq %rbp, %r12
movq (%rsp), %rsi
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
incq %rbx
cmpq %rdi, %rbx
ja 0x1388b9
addq $-0x2, %r14
leal 0x1(%r15), %eax
cmpl %r13d, %r15d
movl %eax, %r15d
jb 0x13882d
movzbl 0x14(%rsi), %r10d
movl 0xc(%rsi), %r9d
jmp 0x1388d8
movq (%rsp), %rsi
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
movl %r15d, %r9d
movq %r14, %r10
movl 0xc(%rsp), %r11d
movl 0x10(%rsp), %r15d
movl 0x14(%rsp), %r13d
cmpl %r9d, %r11d
jae 0x138a56
cmpq %rdi, %rbx
ja 0x138a56
incq %r10
xorl %ecx, %ecx
cmpq %r10, 0x30(%rsp)
sete %cl
movq %rdi, %rax
subq %rbx, %rax
leaq 0x1(,%rax,2), %r14
movq %rcx, 0x70(%rsp)
addl %ecx, %ecx
movq %rcx, 0x68(%rsp)
incl %r11d
movl %r11d, %eax
movl %r15d, %ecx
xorl %r15d, %r15d
testl %r13d, %r13d
sete %r15b
movl $0x40, %edx
cmovel %edx, %r13d
addl %ecx, %r15d
movq (%rsi), %rdx
movq (%rdx,%r15,8), %rbp
movl %r13d, %ecx
negb %cl
shlq %cl, %rbp
movl %eax, %r11d
movzbl 0x15(%rsi), %eax
cmpl %eax, %r13d
jae 0x13896e
incl %r15d
movq (%rdx,%r15,8), %rdx
movl %r13d, %ecx
shrq %cl, %rdx
orq %rdx, %rbp
addl $0x40, %r13d
subl %eax, %r13d
negb %al
movl %eax, %ecx
shrq %cl, %rbp
movzbl 0x14(%rsi), %eax
cmpq %rax, %rbp
ja 0x138a5b
jae 0x138a34
movq 0x30(%rsp), %rcx
xorq %r10, %rcx
movq 0x38(%rsp), %rdx
xorq %rbx, %rdx
orq %rcx, %rdx
sete %cl
cmpq %r8, %rbx
ja 0x1389ae
testb %cl, %cl
je 0x138a34
decq %rax
cmpq %rax, %rbp
movl %ebp, %eax
movl $0xfe, %ecx
cmovel %ecx, %eax
movq 0xb0(%rsp), %r9
movq (%r9), %rcx
leaq 0x1(%r12), %rdx
movb %al, (%rcx,%r12)
movq 0xb8(%rsp), %rax
cmpq (%rax), %rdx
jne 0x138a31
addq %r14, %r12
movq %r12, (%rax)
movq (%r9), %rdi
movq %r12, %rsi
movq %rdx, 0x58(%rsp)
leaq 0x242b21(%rip), %rdx    # 0x37b518
movl $0x24f, %ecx            # imm = 0x24F
movq %r10, %r12
movq %r11, 0x60(%rsp)
callq 0x104461
movq 0x60(%rsp), %r11
movq %r12, %r10
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %rdi
movq (%rsp), %rsi
movq 0xb0(%rsp), %rcx
movq %rax, (%rcx)
movq 0x58(%rsp), %r12
jmp 0x138a34
movq %rdx, %r12
addq 0x70(%rsp), %rbx
movl 0xc(%rsi), %r9d
cmpl %r9d, %r11d
jae 0x138a5b
subq 0x68(%rsp), %r14
leal 0x1(%r11), %eax
cmpq %rdi, %rbx
jbe 0x138926
jmp 0x138a5b
movq 0x30(%rsp), %rbp
movl %r11d, 0xc(%rsp)
movl %r13d, 0x14(%rsp)
movl %r15d, 0x10(%rsp)
cmpl %r9d, %r11d
movq 0x50(%rsp), %r13
movq 0x40(%rsp), %r14
jb 0x1387c8
jmp 0x138741
callq 0x3ff62
callq 0x3ff29
callq 0x3fef0
callq 0x3ff9b