void bilinear_remap(double *restrict tgt_point,
                    const double *restrict src_array, const double wgts[4],
                    const int src_add[4]) {
  *tgt_point =
      src_array[src_add[0]] * wgts[0] + src_array[src_add[1]] * wgts[1] +
      src_array[src_add[2]] * wgts[2] + src_array[src_add[3]] * wgts[3];
}


x86 assembly (clang, -O0):
<bilinear_remap>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq 0x4(%rcx),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq 0x8(%rcx),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq 0xc(%rcx),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<bilinear_remap>:
movslq (%rcx),%rax
movsd  (%rsi,%rax,8),%xmm0
movslq 0x4(%rcx),%rax
movsd  (%rsi,%rax,8),%xmm1
mulsd  0x8(%rdx),%xmm1
mulsd  (%rdx),%xmm0
movslq 0x8(%rcx),%rax
movsd  (%rsi,%rax,8),%xmm2
mulsd  0x10(%rdx),%xmm2
addsd  %xmm1,%xmm0
addsd  %xmm0,%xmm2
movslq 0xc(%rcx),%rax
movsd  (%rsi,%rax,8),%xmm0
mulsd  0x18(%rdx),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,(%rdi)
ret

LLVM IR (-O0):
define void @bilinear_remap(double* noalias %0, double* noalias %1, double* %2, i32* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32*
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32* %3, i32** %8
%9 = load double*, double** %6
%10 = load i32*, i32** %8
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %9, i64 %13
%15 = load double, double* %14
%16 = load double*, double** %7
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = load double*, double** %6
%20 = load i32*, i32** %8
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %19, i64 %23
%25 = load double, double* %24
%26 = load double*, double** %7
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
%29 = fmul double %25, %28
%30 = call double @llvm.fmuladd.f64(double %15, double %18, double %29)
%31 = load double*, double** %6
%32 = load i32*, i32** %8
%33 = getelementptr inbounds i32, i32* %32, i64 2
%34 = load i32, i32* %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %31, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %7
%39 = getelementptr inbounds double, double* %38, i64 2
%40 = load double, double* %39
%41 = call double @llvm.fmuladd.f64(double %37, double %40, double %30)
%42 = load double*, double** %6
%43 = load i32*, i32** %8
%44 = getelementptr inbounds i32, i32* %43, i64 3
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %42, i64 %46
%48 = load double, double* %47
%49 = load double*, double** %7
%50 = getelementptr inbounds double, double* %49, i64 3
%51 = load double, double* %50
%52 = call double @llvm.fmuladd.f64(double %48, double %51, double %41)
%53 = load double*, double** %5
store double %52, double* %53
ret void
}

LLVM IR (-O2):
define void @bilinear_remap(double* noalias nocapture writeonly %0, double* noalias nocapture %1, double* nocapture %2, i32* nocapture %3) {
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds double, double* %1, i64 %6
%8 = load double, double* %7
%9 = load double, double* %2
%10 = getelementptr inbounds i32, i32* %3, i64 1
%11 = load i32, i32* %10
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds double, double* %1, i64 %12
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %2, i64 1
%16 = load double, double* %15
%17 = fmul double %14, %16
%18 = tail call double @llvm.fmuladd.f64(double %8, double %9, double %17)
%19 = getelementptr inbounds i32, i32* %3, i64 2
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %1, i64 %21
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %2, i64 2
%25 = load double, double* %24
%26 = tail call double @llvm.fmuladd.f64(double %23, double %25, double %18)
%27 = getelementptr inbounds i32, i32* %3, i64 3
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %1, i64 %29
%31 = load double, double* %30
%32 = getelementptr inbounds double, double* %2, i64 3
%33 = load double, double* %32
%34 = tail call double @llvm.fmuladd.f64(double %31, double %33, double %26)
store double %34, double* %0
ret void
}