// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/aligned_segment.c
// Function: gt_aligned_segment_align_using_cigar
static void gt_aligned_segment_align_using_cigar(GtAlignedSegment *as,
    GtSamAlignment *sa)
{
  GtUword srcpos, pos = 0;
  uint16_t clen, opnum, oplen, i;
  unsigned char opcode;
  gt_assert(as->alen >= gt_sam_alignment_read_length(sa));
  srcpos = as->alen - gt_sam_alignment_read_length(sa);
  clen = gt_sam_alignment_cigar_length(sa);
  for (opnum = 0; opnum < clen; opnum++)
  {
    opcode = gt_sam_alignment_cigar_i_operation(sa, opnum);
    oplen = gt_sam_alignment_cigar_i_length(sa, opnum);
    switch (opcode)
    {
      case 'S':
        if (opnum == 0)
          as->r_left -= oplen;
        else if (opnum == clen - 1UL)
          as->r_right += oplen;
        else
          gt_assert(false); /* not allowed by SAM format specification */
        /*@fallthrough@*/
      case 'X': /*@fallthrough@*/
      case '=': /*@fallthrough@*/
      case 'M':
        for (i = 0; i < oplen; i++)
        {
          if (pos != srcpos)
          {
            gt_assert(pos < srcpos);
            gt_assert(as->s[srcpos] != '-');
            gt_assert(as->q[srcpos] != GT_UNDEF_CHAR);
            as->s[pos] = as->s[srcpos];
            as->q[pos] = as->q[srcpos];
          }
          as->r[pos] = (opcode == '=') ? as->s[srcpos] : '?';
          pos++;
          srcpos++;
        }
        break;
      case 'I':
        for (i = 0; i < oplen; i++)
        {
          if (pos != srcpos)
          {
            gt_assert(pos < srcpos);
            gt_assert(as->s[srcpos] != '-');
            gt_assert(as->q[srcpos] != GT_UNDEF_CHAR);
            as->s[pos] = as->s[srcpos];
            as->q[pos] = as->q[srcpos];
          }
          as->r[pos] = '-';
          pos++;
          srcpos++;
        }
        as->has_indels = true;
        break;
      case 'N': /*@fallthrough@*/
      case 'D':
        for (i = 0; i < oplen; i++)
        {
          as->s[pos] = '-';
          as->q[pos] = GT_UNDEF_CHAR;
          as->r[pos] = '?';
          pos++;
        }
        as->has_indels = true;
        break;
      case 'P': /*@fallthrough@*/
      case 'H':
        /* ignore padding and hard clipping */
        break;
      default:
        exit(GT_EXIT_PROGRAMMING_ERROR);
    }
  }
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq $0x0, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rdi
callq 0x1ce180
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x489464
movq 0x1b2b6d(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8cbd6(%rip), %rsi     # 0x516013
leaq 0x128732(%rip), %rdx    # 0x5b1b76
leaq 0x128758(%rip), %rcx    # 0x5b1ba3
leaq 0x12829e(%rip), %r8     # 0x5b16f0
movl $0x55, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x489466
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rdi
callq 0x1ce180
movq %rax, %rcx
movq 0x18(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
callq 0x1ce850
movw %ax, 0x36(%rsp)
movw $0x0, 0x34(%rsp)
movzwl 0x34(%rsp), %eax
movzwl 0x36(%rsp), %ecx
cmpl %ecx, %eax
jge 0x48999b
movq 0x48(%rsp), %rdi
movzwl 0x34(%rsp), %esi
callq 0x1ce940
movb %al, 0x2f(%rsp)
movq 0x48(%rsp), %rdi
movzwl 0x34(%rsp), %esi
callq 0x1ce8b0
movw %ax, 0x32(%rsp)
movzbl 0x2f(%rsp), %eax
addl $-0x3d, %eax
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
subl $0x1b, %eax
ja 0x48997c
movq 0x10(%rsp), %rax
leaq 0x12817f(%rip), %rcx    # 0x5b1680
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x34(%rsp), %eax
cmpl $0x0, %eax
jne 0x48952d
movzwl 0x32(%rsp), %eax
movl %eax, %edx
movq 0x50(%rsp), %rax
movq 0x28(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x28(%rax)
jmp 0x489592
movzwl 0x34(%rsp), %eax
movzwl 0x36(%rsp), %ecx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x489556
movzwl 0x32(%rsp), %eax
movl %eax, %ecx
movq 0x50(%rsp), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
jmp 0x489590
jmp 0x489558
movq 0x1b2a41(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8caaa(%rip), %rsi     # 0x516013
leaq 0xcf7f3(%rip), %rdx     # 0x558d63
leaq 0x12862c(%rip), %rcx    # 0x5b1ba3
leaq 0x128172(%rip), %r8     # 0x5b16f0
movl $0x64, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x489592
jmp 0x489594
movw $0x0, 0x30(%rsp)
movzwl 0x30(%rsp), %eax
movzwl 0x32(%rsp), %ecx
cmpl %ecx, %eax
jge 0x48975e
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x4896ec
jmp 0x4895bf
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
jb 0x489603
movq 0x1b29ce(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8ca37(%rip), %rsi     # 0x516013
leaq 0x12835c(%rip), %rdx    # 0x5b193f
leaq 0x1285b9(%rip), %rcx    # 0x5b1ba3
leaq 0x1280ff(%rip), %r8     # 0x5b16f0
movl $0x6d, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x489605
jmp 0x489607
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
jne 0x489655
movq 0x1b297c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8c9e5(%rip), %rsi     # 0x516013
leaq 0x128593(%rip), %rdx    # 0x5b1bc8
leaq 0x128567(%rip), %rcx    # 0x5b1ba3
leaq 0x1280ad(%rip), %r8     # 0x5b16f0
movl $0x6e, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x489657
jmp 0x489659
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7f, %eax
jne 0x4896a8
movq 0x1b2929(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8c992(%rip), %rsi     # 0x516013
leaq 0x128300(%rip), %rdx    # 0x5b1988
leaq 0x128514(%rip), %rcx    # 0x5b1ba3
leaq 0x12805a(%rip), %r8     # 0x5b16f0
movl $0x6f, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4896aa
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movb %dl, (%rax,%rcx)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movb %dl, (%rax,%rcx)
movzbl 0x2f(%rsp), %eax
cmpl $0x3d, %eax
jne 0x48970d
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, 0xc(%rsp)
jmp 0x489718
movl $0x3f, %eax
movl %eax, 0xc(%rsp)
jmp 0x489718
movl 0xc(%rsp), %eax
movb %al, %dl
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x38(%rsp), %rcx
movb %dl, (%rax,%rcx)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
movw 0x30(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x30(%rsp)
jmp 0x48959b
jmp 0x489986
movw $0x0, 0x30(%rsp)
movzwl 0x30(%rsp), %eax
movzwl 0x32(%rsp), %ecx
cmpl %ecx, %eax
jge 0x4898fc
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x4898bb
jmp 0x48978e
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
jb 0x4897d2
movq 0x1b27ff(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8c868(%rip), %rsi     # 0x516013
leaq 0x12818d(%rip), %rdx    # 0x5b193f
leaq 0x1283ea(%rip), %rcx    # 0x5b1ba3
leaq 0x127f30(%rip), %r8     # 0x5b16f0
movl $0x7d, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4897d4
jmp 0x4897d6
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
jne 0x489824
movq 0x1b27ad(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8c816(%rip), %rsi     # 0x516013
leaq 0x1283c4(%rip), %rdx    # 0x5b1bc8
leaq 0x128398(%rip), %rcx    # 0x5b1ba3
leaq 0x127ede(%rip), %r8     # 0x5b16f0
movl $0x7e, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x489826
jmp 0x489828
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7f, %eax
jne 0x489877
movq 0x1b275a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8c7c3(%rip), %rsi     # 0x516013
leaq 0x128131(%rip), %rdx    # 0x5b1988
leaq 0x128345(%rip), %rcx    # 0x5b1ba3
leaq 0x127e8b(%rip), %r8     # 0x5b16f0
movl $0x7f, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x489879
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movb %dl, (%rax,%rcx)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movb %dl, (%rax,%rcx)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x38(%rsp), %rcx
movb $0x2d, (%rax,%rcx)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
movw 0x30(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x30(%rsp)
jmp 0x48976a
movq 0x50(%rsp), %rax
movb $0x1, 0x39(%rax)
jmp 0x489986
movw $0x0, 0x30(%rsp)
movzwl 0x30(%rsp), %eax
movzwl 0x32(%rsp), %ecx
cmpl %ecx, %eax
jge 0x48996f
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x38(%rsp), %rcx
movb $0x2d, (%rax,%rcx)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
movb $0x7f, (%rax,%rcx)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x38(%rsp), %rcx
movb $0x3f, (%rax,%rcx)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movw 0x30(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x30(%rsp)
jmp 0x48990e
movq 0x50(%rsp), %rax
movb $0x1, 0x39(%rax)
jmp 0x489986
jmp 0x489986
movl $0x2, %edi
callq 0x19890
jmp 0x489988
movw 0x34(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x34(%rsp)
jmp 0x4894a4
addq $0x58, %rsp
retq