// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/DASrealign.c
// Function: where
static inline int where(Finger *cur, int pos, int *acc)
{ int blen, *map;

  map  = cur->map;
  blen = cur->blen;
  if (blen == 0)
    { while (cur->cidx < cur->lidx && pos >= map[cur->cidx])
        { cur->dist += (map[cur->cidx-2] - cur->last) + map[cur->cidx-1];
          cur->last  = map[cur->cidx];
          cur->cidx += 3; 
        }
      if (pos <= map[cur->cidx-2])
        { if (pos < cur->last)
            return (-1);
          else
            { *acc = 0;
              return (cur->dist + (pos-cur->last));
            }
        }
      if (cur->cidx >= cur->lidx)
        return (-1);
      else
        { int ab, ae;
    
          ab = map[cur->cidx-2];
          ae = map[cur->cidx];
          if (pos-ab < ae-pos)
            *acc = pos-ab;
          else
            *acc = ae-pos;
          return (cur->dist + (ab-cur->last) + ((1.*(pos-ab))/(ae-ab)) * map[cur->cidx-1]);
        }
    }
  else
    { while (cur->cidx > cur->lidx && pos >= blen - map[cur->cidx])
        { cur->dist += ((blen - map[cur->cidx+2]) - cur->last) + map[cur->cidx+1];
          cur->last  = blen - map[cur->cidx];
          cur->cidx -= 3; 
        }
      if (pos <= blen - map[cur->cidx+2])
        { if (pos < cur->last)
            return (-1);
          else
            { *acc = 0;
              return (cur->dist + (pos-cur->last));
            }
        }
      if (cur->cidx <= cur->lidx)
        return (-1);
      else
        { int ab, ae;
    
          ab = blen - map[cur->cidx+2];
          ae = blen - map[cur->cidx];
          if (pos-ab < ae-pos)
            *acc = pos-ab;
          else
            *acc = ae-pos;
          return (cur->dist + (ab-cur->last) + ((1.*(pos-ab))/(ae-ab)) * map[cur->cidx+1]);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0x18(%rdi), %rcx
movl 0x10(%rdi), %r10d
movslq 0x4(%rdi), %r8
movslq (%rdi), %r9
testl %r10d, %r10d
je 0x2ea0
movq %r9, %r11
shlq $0x20, %r11
leal -0x3(%r9), %ebx
movabsq $-0x300000000, %r14     # imm = 0xFFFFFFFD00000000
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %r8, %r9
jle 0x2eef
movl %r10d, %ebp
subl (%rcx,%r9,4), %ebp
cmpl %esi, %ebp
jg 0x2f02
movl 0x8(%rcx,%r9,4), %eax
addl 0xc(%rdi), %eax
movl %r10d, %ebp
subl %eax, %ebp
addl 0x4(%rcx,%r9,4), %ebp
addl %ebp, 0x8(%rdi)
movl %r10d, %eax
subl (%rcx,%r9,4), %eax
movl %eax, 0xc(%rdi)
addq $-0x3, %r9
movl %ebx, (%rdi)
addq %r14, %r11
addl $-0x3, %ebx
jmp 0x2e56
movq %r9, %rax
shlq $0x20, %rax
leal 0x3(%r9), %r10d
movabsq $0x300000000, %r11      # imm = 0x300000000
cmpq %r8, %r9
jge 0x2f58
cmpl %esi, (%rcx,%r9,4)
jg 0x2f64
movl -0x8(%rcx,%r9,4), %ebx
subl 0xc(%rdi), %ebx
addl -0x4(%rcx,%r9,4), %ebx
addl %ebx, 0x8(%rdi)
movl (%rcx,%r9,4), %ebx
movl %ebx, 0xc(%rdi)
addq $0x3, %r9
movl %r10d, (%rdi)
addq %r11, %rax
addl $0x3, %r10d
jmp 0x2eb5
sarq $0x1e, %r11
subl 0x8(%rcx,%r11), %r10d
cmpl %esi, %r10d
jge 0x2f51
jmp 0x2fd3
sarq $0x1e, %r11
movl %r10d, %r8d
subl 0x8(%rcx,%r11), %r8d
movl %esi, %r9d
subl %r8d, %r9d
jle 0x2f51
subl (%rcx,%r11), %r10d
movl %r10d, %eax
subl %esi, %eax
cmpl %eax, %r9d
cmovll %r9d, %eax
movl %eax, (%rdx)
subl %r8d, %r10d
addl 0x8(%rdi), %r8d
subl 0xc(%rdi), %r8d
cvtsi2sd %r8d, %xmm0
cvtsi2sd %r9d, %xmm1
cvtsi2sd %r10d, %xmm2
divsd %xmm2, %xmm1
movslq (%rdi), %rax
cvtsi2sdl 0x4(%rcx,%rax,4), %xmm2
jmp 0x2fae
cmpl %esi, 0xc(%rdi)
jle 0x2fc8
jmp 0x2fd3
sarq $0x1e, %rax
cmpl %esi, -0x8(%rcx,%rax)
jge 0x2fbc
jmp 0x2fc1
sarq $0x1e, %rax
movl -0x8(%rcx,%rax), %r9d
movl %esi, %r8d
subl %r9d, %r8d
jle 0x2fbc
movl (%rcx,%rax), %eax
movl %eax, %r10d
subl %esi, %r10d
cmpl %r10d, %r8d
cmovll %r8d, %r10d
movl %r10d, (%rdx)
subl %r9d, %eax
addl 0x8(%rdi), %r9d
subl 0xc(%rdi), %r9d
cvtsi2sd %r9d, %xmm0
cvtsi2sd %r8d, %xmm1
cvtsi2sd %eax, %xmm2
divsd %xmm2, %xmm1
movslq (%rdi), %rax
cvtsi2sdl -0x4(%rcx,%rax,4), %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %eax
jmp 0x2fd3
cmpl %esi, 0xc(%rdi)
jle 0x2fc8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x2fd3
andl $0x0, (%rdx)
addl 0x8(%rdi), %esi
subl 0xc(%rdi), %esi
movl %esi, %eax
popq %rbx
popq %r14
popq %rbp
retq