// File: /workspace/github_c_makefile_star2_O1/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), %eax
movl 0x10(%rdi), %r10d
movslq 0x4(%rdi), %r8
movslq %eax, %r9
testl %r10d, %r10d
je 0x45fd
cmpl %r8d, %eax
setg %r11b
jle 0x4661
movl %r10d, %ebx
subl (%rcx,%r9,4), %ebx
cmpl %esi, %ebx
jg 0x4661
movl 0x8(%rdi), %ebx
movl 0xc(%rdi), %ebp
addq $-0x3, %r9
movl %ebx, %r11d
addl 0x14(%rcx,%r9,4), %ebp
movl %r10d, %ebx
subl %ebp, %ebx
addl 0x10(%rcx,%r9,4), %ebx
addl %r11d, %ebx
movl %ebx, 0x8(%rdi)
movl %r10d, %ebp
subl 0xc(%rcx,%r9,4), %ebp
movl %ebp, 0xc(%rdi)
leal -0x3(%rax), %r14d
movl %r14d, (%rdi)
cmpq %r8, %r9
setg %r11b
jle 0x465e
movl %r10d, %r14d
subl (%rcx,%r9,4), %r14d
addq $-0x3, %r9
addl $-0x3, %eax
cmpl %esi, %r14d
jle 0x45b5
jmp 0x4661
cmpl %r8d, %eax
setl %r10b
jge 0x46c6
cmpl %esi, (%rcx,%r9,4)
jg 0x46c6
movl 0x8(%rdi), %r11d
movl 0xc(%rdi), %ebx
addq $0x3, %r9
movl %r11d, %r10d
movl -0x14(%rcx,%r9,4), %r11d
subl %ebx, %r11d
addl -0x10(%rcx,%r9,4), %r11d
addl %r10d, %r11d
movl %r11d, 0x8(%rdi)
movl -0xc(%rcx,%r9,4), %ebx
movl %ebx, 0xc(%rdi)
leal 0x3(%rax), %ebp
movl %ebp, (%rdi)
cmpq %r8, %r9
setl %r10b
jge 0x46c4
leaq 0x3(%r9), %r14
addl $0x3, %eax
cmpl %esi, (%rcx,%r9,4)
movq %r14, %r9
jle 0x461f
jmp 0x46c6
movl %r14d, %eax
movslq %eax, %rbx
movl %r10d, %r8d
subl 0x8(%rcx,%rbx,4), %r8d
movl %esi, %r9d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl %r8d, %r9d
jle 0x472b
testb %r11b, %r11b
je 0x473e
subl (%rcx,%rbx,4), %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
xorps %xmm2, %xmm2
cvtsi2sdl 0x4(%rcx,%rax,4), %xmm2
jmp 0x471d
movl %ebp, %eax
movslq %eax, %r11
movl -0x8(%rcx,%r11,4), %r9d
movl %esi, %r8d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl %r9d, %r8d
jle 0x472b
testb %r10b, %r10b
je 0x473e
movl (%rcx,%r11,4), %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
xorps %xmm2, %xmm2
cvtsi2sdl -0x4(%rcx,%rax,4), %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
cvttsd2si %xmm2, %eax
jmp 0x473e
cmpl %esi, 0xc(%rdi)
jg 0x473e
movl $0x0, (%rdx)
addl 0x8(%rdi), %esi
subl 0xc(%rdi), %esi
movl %esi, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop