// File: /workspace/github_c_makefile_star2_O3/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 (%rdi), %r10d
movl 0x10(%rdi), %r9d
movslq 0x4(%rdi), %r8
movslq %r10d, %rax
testl %r9d, %r9d
je 0x45be
cmpl %r8d, %r10d
jle 0x45a3
movq %rax, %r10
shlq $0x20, %r10
movabsq $-0x300000000, %r11     # imm = 0xFFFFFFFD00000000
movl %r9d, %ebx
subl (%rcx,%rax,4), %ebx
cmpl %esi, %ebx
jg 0x4626
movl %eax, %ebx
movl 0x8(%rcx,%rax,4), %ebp
addl 0xc(%rdi), %ebp
movl %r9d, %r14d
subl %ebp, %r14d
addl 0x4(%rcx,%rax,4), %r14d
addl %r14d, 0x8(%rdi)
movl %r9d, %ebp
subl (%rcx,%rax,4), %ebp
movl %ebp, 0xc(%rdi)
addq $-0x3, %rax
addl $-0x3, %ebx
movl %ebx, (%rdi)
addq %r11, %r10
cmpq %r8, %rax
jg 0x4560
movl %eax, %r10d
movslq %r10d, %rax
subl 0x8(%rcx,%rax,4), %r9d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %esi, %r9d
jge 0x46d6
jmp 0x46ee
cmpl %r8d, %r10d
jge 0x460e
movq %rax, %r9
shlq $0x20, %r9
movabsq $0x300000000, %r10      # imm = 0x300000000
cmpl %esi, (%rcx,%rax,4)
jg 0x467b
movl -0x8(%rcx,%rax,4), %r11d
subl 0xc(%rdi), %r11d
addl -0x4(%rcx,%rax,4), %r11d
addl %r11d, 0x8(%rdi)
movl %eax, %r11d
movl (%rcx,%rax,4), %ebx
movl %ebx, 0xc(%rdi)
addq $0x3, %rax
addl $0x3, %r11d
movl %r11d, (%rdi)
addq %r10, %r9
cmpq %r8, %rax
jl 0x45d4
movl %eax, %r10d
movslq %r10d, %r8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %esi, -0x8(%rcx,%r8,4)
jge 0x46d6
jmp 0x46ee
sarq $0x1e, %r10
movl %r9d, %eax
subl 0x8(%rcx,%r10), %eax
movl %esi, %r8d
subl %eax, %r8d
jle 0x46d6
subl (%rcx,%r10), %r9d
movl %r9d, %r10d
subl %esi, %r10d
cmpl %r10d, %r8d
cmovll %r8d, %r10d
movl %r10d, (%rdx)
subl %eax, %r9d
addl 0x8(%rdi), %eax
subl 0xc(%rdi), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sd %r8d, %xmm1
cvtsi2sd %r9d, %xmm2
divsd %xmm2, %xmm1
movslq (%rdi), %rax
xorps %xmm2, %xmm2
cvtsi2sdl 0x4(%rcx,%rax,4), %xmm2
jmp 0x46c8
sarq $0x1e, %r9
movl -0x8(%rcx,%r9), %r8d
movl %esi, %eax
subl %r8d, %eax
jle 0x46d6
movl (%rcx,%r9), %r9d
movl %r9d, %r10d
subl %esi, %r10d
cmpl %r10d, %eax
cmovll %eax, %r10d
movl %r10d, (%rdx)
subl %r8d, %r9d
addl 0x8(%rdi), %r8d
subl 0xc(%rdi), %r8d
cvtsi2sd %r8d, %xmm0
cvtsi2sd %eax, %xmm1
cvtsi2sd %r9d, %xmm2
divsd %xmm2, %xmm1
movslq (%rdi), %rax
xorps %xmm2, %xmm2
cvtsi2sdl -0x4(%rcx,%rax,4), %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %eax
jmp 0x46ee
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %esi, 0xc(%rdi)
jg 0x46ee
movl $0x0, (%rdx)
addl 0x8(%rdi), %esi
subl 0xc(%rdi), %esi
movl %esi, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop