double advect_sample(const double const *v, int Ny, double s, double t) {
  return (1 - s) * ((1 - t) * v[0] + t * v[1]) +
         s * ((1 - t) * v[Ny] + t * v[Ny + 1]);
}


x86 assembly (clang, -O0):
<advect_sample>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  0xee3(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xed6(%rip),%xmm2
subsd  -0x20(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm3
movsd  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x18(%rbp),%xmm1
movsd  0xea6(%rip),%xmm3
subsd  -0x20(%rbp),%xmm3
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm5
movsd  -0x20(%rbp),%xmm4
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<advect_sample>:
movsd  0xef8(%rip),%xmm2
movapd %xmm2,%xmm3
subsd  %xmm0,%xmm3
subsd  %xmm1,%xmm2
movsd  0x8(%rdi),%xmm4
mulsd  %xmm1,%xmm4
movsd  (%rdi),%xmm5
mulsd  %xmm2,%xmm5
addsd  %xmm4,%xmm5
movslq %esi,%rax
mulsd  0x8(%rdi,%rax,8),%xmm1
mulsd  (%rdi,%rax,8),%xmm2
mulsd  %xmm3,%xmm5
addsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm5,%xmm0
ret

LLVM IR (-O0):
define double @advect_sample(double* %0, i32 %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %7
%10 = fsub double 1.000000e+00, %9
%11 = load double, double* %8
%12 = fsub double 1.000000e+00, %11
%13 = load double*, double** %5
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
%16 = load double, double* %8
%17 = load double*, double** %5
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = fmul double %16, %19
%21 = call double @llvm.fmuladd.f64(double %12, double %15, double %20)
%22 = load double, double* %7
%23 = load double, double* %8
%24 = fsub double 1.000000e+00, %23
%25 = load double*, double** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load double, double* %8
%31 = load double*, double** %5
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %31, i64 %34
%36 = load double, double* %35
%37 = fmul double %30, %36
%38 = call double @llvm.fmuladd.f64(double %24, double %29, double %37)
%39 = fmul double %22, %38
%40 = call double @llvm.fmuladd.f64(double %10, double %21, double %39)
ret double %40
}

LLVM IR (-O2):
define double @advect_sample(double* nocapture %0, i32 %1, double %2, double %3) {
%5 = fsub double 1.000000e+00, %2
%6 = fsub double 1.000000e+00, %3
%7 = load double, double* %0
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = load double, double* %8
%10 = fmul double %9, %3
%11 = tail call double @llvm.fmuladd.f64(double %6, double %7, double %10)
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds double, double* %0, i64 %12
%14 = load double, double* %13
%15 = add nsw i32 %1, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %0, i64 %16
%18 = load double, double* %17
%19 = fmul double %18, %3
%20 = tail call double @llvm.fmuladd.f64(double %6, double %14, double %19)
%21 = fmul double %20, %2
%22 = tail call double @llvm.fmuladd.f64(double %5, double %11, double %21)
ret double %22
}