// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/fmi-locate.c
// Function: gt_fmfindtextpos
GtUword gt_fmfindtextpos (const Fmindex *fm,GtUword idx)
{
  GtUword offset = 0;
  GtUchar cc;

  while ((idx & fm->markdistminus1) != 0)
  {
    if (idx == fm->longestsuffixpos || GT_ISSPECIAL(cc = ACCESSBWTTEXT(idx)))
    {
      GtUword smallestgeq
               = searchsmallestgeq(fm->specpos.spaceGtPairBwtidx,
                                   fm->specpos.spaceGtPairBwtidx +
                                   fm->specpos.nextfreeGtPairBwtidx - 1,
                                   idx);
      return (smallestgeq + offset) % fm->bwtlength;
    }
    idx = fm->tfreq[cc] + fmoccurrence (fm, cc, idx);
    offset++;
  }
  return (fm->markpostable[idx / fm->markdist] + offset) % fm->bwtlength;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %rbx
testq %rsi, 0x48(%rdi)
je 0x1b67d0
xorl %r14d, %r14d
movq %r12, %r15
cmpq 0x30(%rbx), %r15
je 0x1b67aa
movq (%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xec1f8
cmpb $-0x2, %al
jae 0x1b67aa
movl %eax, %ebp
movzbl %al, %esi
movq 0x18(%rbx), %rax
movq 0x30(%rbx), %r8
movq (%rax,%rsi,8), %rax
movq %rax, (%rsp)
movl 0x88(%rbx), %eax
movq %r15, %r13
movl %eax, %ecx
shrq %cl, %r13
movq 0xa8(%rbx), %rdx
imulq %rsi, %rdx
movb 0x8c(%rbx), %cl
movq %r15, %rdi
shrq %cl, %rdi
imulq 0xb0(%rbx), %rsi
movq %r8, %rcx
subq %r15, %rcx
jae 0x1b6580
movq %r15, %rcx
subq %r8, %rcx
movl 0x7c(%rbx), %r8d
cmpq %r8, %rcx
jae 0x1b65fd
shlq $0x3, %rsi
addq 0x20(%rbx), %rsi
movq 0x40(%rbx), %r8
andq %r15, %r8
movl %eax, %ecx
shrq %cl, %r8
leaq (%rdx,%r13), %rax
movq (%rsi,%rdi,8), %r12
leaq (%r8,%rdx), %rcx
cmpq %rax, %rcx
jae 0x1b65c2
addq 0x8(%rbx), %rdx
movzbl (%rdx,%r8), %eax
addq %rax, %r12
incq %r8
cmpq %r8, %r13
jne 0x1b65b2
movq 0x38(%rbx), %r13
andq %r15, %r13
cmpq %r15, %r13
je 0x1b6766
cmpq 0x30(%rbx), %r13
je 0x1b65f0
movq (%rbx), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xec1f8
xorl %ecx, %ecx
cmpb %bpl, %al
sete %cl
addq %rcx, %r12
incq %r13
cmpq %r15, %r13
jb 0x1b65d2
jmp 0x1b6766
movl 0x84(%rbx), %ecx
movl %ecx, %r8d
shrl %r8d
testl %r8d, %r15d
je 0x1b66ad
movq 0x10(%rbx), %r8
subq %r15, %r8
cmpq %rcx, %r8
jbe 0x1b66ad
leaq 0x1(%rdi), %r8
movb 0x90(%rbx), %cl
shlq %cl, %r8
shlq $0x3, %rsi
addq 0x20(%rbx), %rsi
leaq (%r8,%rdx), %r9
movq 0x8(%rsi,%rdi,8), %r12
leaq (%rdx,%r13), %rcx
cmpq %r9, %rcx
jae 0x1b665f
addq 0x8(%rbx), %rdx
movq %r13, %rsi
movzbl (%rdx,%rsi), %edi
subq %rdi, %r12
incq %rsi
cmpq %rsi, %r8
jne 0x1b6650
testl %r15d, 0x80(%rbx)
je 0x1b677c
movq 0x8(%rbx), %rdx
movzbl (%rdx,%rcx), %ecx
addq %rcx, %r12
incq %r13
movl %eax, %ecx
shlq %cl, %r13
cmpq %r15, %r13
jbe 0x1b6766
movq (%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xec1f8
xorl %ecx, %ecx
cmpb %bpl, %al
sete %cl
subq %rcx, %r12
incq %r15
cmpq %r15, %r13
jne 0x1b6688
jmp 0x1b6766
shlq $0x3, %rsi
addq 0x20(%rbx), %rsi
movq 0x40(%rbx), %r8
andq %r15, %r8
movl %eax, %ecx
shrq %cl, %r8
leaq (%rdx,%r13), %rax
movq (%rsi,%rdi,8), %r12
leaq (%r8,%rdx), %rcx
cmpq %rax, %rcx
jae 0x1b66e6
addq 0x8(%rbx), %rdx
movzbl (%rdx,%r8), %ecx
addq %rcx, %r12
incq %r8
cmpq %r8, %r13
jne 0x1b66d6
testl %r15d, 0x80(%rbx)
je 0x1b673a
movq 0x10(%rbx), %rdx
subq %r15, %rdx
movl 0x7c(%rbx), %ecx
cmpq %rcx, %rdx
jbe 0x1b673a
movq 0x8(%rbx), %rdx
movzbl (%rdx,%rax), %eax
addq %rax, %r12
movq 0x38(%rbx), %r13
andq %r15, %r13
addq %rcx, %r13
cmpq %r15, %r13
jbe 0x1b6766
movq (%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xec1f8
xorl %ecx, %ecx
cmpb %bpl, %al
sete %cl
subq %rcx, %r12
incq %r15
cmpq %r13, %r15
jb 0x1b6718
jmp 0x1b6766
movq 0x38(%rbx), %r13
andq %r15, %r13
cmpq %r15, %r13
je 0x1b6766
movq (%rbx), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xec1f8
xorl %ecx, %ecx
cmpb %bpl, %al
sete %cl
addq %rcx, %r12
incq %r13
cmpq %r15, %r13
jb 0x1b6746
addq (%rsp), %r12
incq %r14
movq %r12, %r15
testq %r12, 0x48(%rbx)
jne 0x1b6511
jmp 0x1b67d3
movq 0x38(%rbx), %r13
andq %r15, %r13
cmpq %r15, %r13
je 0x1b6766
movq (%rbx), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xec1f8
xorl %ecx, %ecx
cmpb %bpl, %al
sete %cl
addq %rcx, %r12
incq %r13
cmpq %r15, %r13
jb 0x1b6788
jmp 0x1b6766
movq 0x50(%rbx), %rcx
testq %rcx, %rcx
je 0x1b6843
movq 0x60(%rbx), %rax
shlq $0x4, %rax
leaq (%rcx,%rax), %rdx
addq $-0x10, %rdx
cmpq %rdx, %rcx
jbe 0x1b67e9
xorl %eax, %eax
jmp 0x1b681c
xorl %r14d, %r14d
movq %r12, %rax
xorl %edx, %edx
divq 0xb8(%rbx)
shlq $0x3, %rax
addq 0x28(%rbx), %rax
jmp 0x1b6825
xorl %esi, %esi
movq %rdx, %rdi
subq %rcx, %rdi
sarq %rdi
andq $-0x10, %rdi
leaq (%rcx,%rdi), %rax
cmpq %r15, (%rcx,%rdi)
jbe 0x1b680b
leaq -0x10(%rax), %rdx
movq %rax, %rsi
jmp 0x1b6817
jae 0x1b6821
addq $0x10, %rax
movq %rax, %rcx
movq %rsi, %rax
cmpq %rdx, %rcx
jbe 0x1b67eb
testq %rax, %rax
je 0x1b6848
addq $0x8, %rax
addq (%rax), %r14
movq %r14, %rax
xorl %edx, %edx
divq 0x10(%rbx)
movq %rdx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x65db0
callq 0x65d79
nopl (%rax)