// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/aligned_segment.c
// Function: gt_aligned_segment_orig_seqpos_for_refpos
GtUword gt_aligned_segment_orig_seqpos_for_refpos(
    const GtAlignedSegment *as, GtUword refpos)
{
  GtUword r_offset, gapped_pos, ungapped_pos_on_r, ungapped_pos_on_s_orig;
  gt_assert(as != NULL);
  gt_assert(as->s_orig != NULL);
  if (refpos < as->r_left || refpos > as->r_right)
    return GT_UNDEF_UWORD;
  r_offset = refpos - as->r_left;
  gapped_pos = 0;
  ungapped_pos_on_r = 0;
  ungapped_pos_on_s_orig = 0;
  while (ungapped_pos_on_r < r_offset)
  {
    if (as->r[gapped_pos] != '-')
      ungapped_pos_on_r++;
    if (as->s_orig[gapped_pos] != '-')
      ungapped_pos_on_s_orig++;
    gapped_pos++;
  }
  gt_assert(gapped_pos <= as->alen);
  if (as->r_reverse)
    return as->orig_seqlen - 1UL - ungapped_pos_on_s_orig;
  else
    return ungapped_pos_on_s_orig;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x48863e
movq 0x1b3993(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8d9fc(%rip), %rsi     # 0x516013
leaq 0x9207c(%rip), %rdx     # 0x51a69a
leaq 0x129295(%rip), %rcx    # 0x5b18ba
leaq 0x1290c4(%rip), %r8     # 0x5b16f0
movl $0x132, %r9d            # imm = 0x132
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x488640
jmp 0x488642
movq 0x28(%rsp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x488686
movq 0x1b394b(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8d9b4(%rip), %rsi     # 0x516013
leaq 0x12927e(%rip), %rdx    # 0x5b18e4
leaq 0x12924d(%rip), %rcx    # 0x5b18ba
leaq 0x12907c(%rip), %r8     # 0x5b16f0
movl $0x133, %r9d            # imm = 0x133
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x488688
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x4886a8
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jbe 0x4886b6
movq $-0x1, 0x30(%rsp)
jmp 0x4887bf
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq 0x28(%rcx), %rax
movq %rax, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
movq 0x8(%rsp), %rax
cmpq 0x18(%rsp), %rax
jae 0x488747
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
je 0x488714
movq 0x8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
je 0x488737
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x4886e3
jmp 0x488749
movq 0x10(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jbe 0x488791
movq 0x1b3840(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x8d8a9(%rip), %rsi     # 0x516013
leaq 0x129186(%rip), %rdx    # 0x5b18f7
leaq 0x129142(%rip), %rcx    # 0x5b18ba
leaq 0x128f71(%rip), %r8     # 0x5b16f0
movl $0x142, %r9d            # imm = 0x142
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x488793
movq 0x28(%rsp), %rax
testb $0x1, 0x38(%rax)
je 0x4887b6
movq 0x28(%rsp), %rax
movq 0x48(%rax), %rax
subq $0x1, %rax
subq (%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x4887bf
movq (%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
addq $0x38, %rsp
retq
nopl (%rax)