void bicubic_remap(double *restrict tgt_point, const double *restrict src_array,
                   double wgts[4][4], const int src_add[4],
                   const double *restrict grad1, const double *restrict grad2,
                   const double *restrict grad3) {
  *tgt_point = 0.;
  for (int n = 0; n < 4; ++n)
    *tgt_point +=
        src_array[src_add[n]] * wgts[n][0] + grad1[src_add[n]] * wgts[n][1] +
        grad2[src_add[n]] * wgts[n][2] + grad3[src_add[n]] * wgts[n][3];
}


x86 assembly (clang, -O0):
<bicubic_remap>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    1211 <bicubic_remap+0x111>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm2
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1132 <bicubic_remap+0x32>
pop    %rbp
ret

x86 assembly (clang, -O2):
<bicubic_remap>:
movslq (%rcx),%rax
movsd  (%rsi,%rax,8),%xmm0
movsd  (%r8,%rax,8),%xmm1
mulsd  0x8(%rdx),%xmm1
mulsd  (%rdx),%xmm0
mov    0x8(%rsp),%r10
movsd  (%r9,%rax,8),%xmm2
mulsd  0x10(%rdx),%xmm2
addsd  %xmm1,%xmm0
movsd  (%r10,%rax,8),%xmm1
mulsd  0x18(%rdx),%xmm1
addsd  %xmm0,%xmm2
addsd  %xmm2,%xmm1
xorpd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movslq 0x4(%rcx),%rax
movsd  (%r8,%rax,8),%xmm0
mulsd  0x28(%rdx),%xmm0
movsd  (%rsi,%rax,8),%xmm1
mulsd  0x20(%rdx),%xmm1
addsd  %xmm0,%xmm1
movsd  (%r9,%rax,8),%xmm3
mulsd  0x30(%rdx),%xmm3
addsd  %xmm1,%xmm3
movsd  (%r10,%rax,8),%xmm0
mulsd  0x38(%rdx),%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movslq 0x8(%rcx),%rax
movsd  (%rsi,%rax,8),%xmm1
movsd  (%r8,%rax,8),%xmm2
mulsd  0x48(%rdx),%xmm2
mulsd  0x40(%rdx),%xmm1
addsd  %xmm2,%xmm1
movsd  (%r9,%rax,8),%xmm2
mulsd  0x50(%rdx),%xmm2
addsd  %xmm1,%xmm2
movsd  (%r10,%rax,8),%xmm1
mulsd  0x58(%rdx),%xmm1
addsd  %xmm2,%xmm1
movslq 0xc(%rcx),%rax
movsd  (%rsi,%rax,8),%xmm2
movsd  (%r8,%rax,8),%xmm3
mulsd  0x68(%rdx),%xmm3
mulsd  0x60(%rdx),%xmm2
addsd  %xmm0,%xmm1
movsd  (%r9,%rax,8),%xmm0
mulsd  0x70(%rdx),%xmm0
addsd  %xmm3,%xmm2
movsd  (%r10,%rax,8),%xmm3
mulsd  0x78(%rdx),%xmm3
addsd  %xmm2,%xmm0
addsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,(%rdi)
ret

LLVM IR (-O0):
define void @bicubic_remap(double* noalias %0, double* noalias %1, [4 x double]* %2, i32* %3, double* noalias %4, double* noalias %5, double* noalias %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca [4 x double]*
%11 = alloca i32*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
store double* %0, double** %8
store double* %1, double** %9
store [4 x double]* %2, [4 x double]** %10
store i32* %3, i32** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
%16 = load double*, double** %8
store double 0.000000e+00, double* %16
store i32 0, i32* %15
br label %17
17: ; preds = %88, %7
%18 = load i32, i32* %15
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %91
20: ; preds = %17
%21 = load double*, double** %9
%22 = load i32*, i32** %11
%23 = load i32, i32* %15
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %21, i64 %27
%29 = load double, double* %28
%30 = load [4 x double]*, [4 x double]** %10
%31 = load i32, i32* %15
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 %32
%34 = getelementptr inbounds [4 x double], [4 x double]* %33, i64 0, i64 0
%35 = load double, double* %34
%36 = load double*, double** %12
%37 = load i32*, i32** %11
%38 = load i32, i32* %15
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %36, i64 %42
%44 = load double, double* %43
%45 = load [4 x double]*, [4 x double]** %10
%46 = load i32, i32* %15
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [4 x double], [4 x double]* %45, i64 %47
%49 = getelementptr inbounds [4 x double], [4 x double]* %48, i64 0, i64 1
%50 = load double, double* %49
%51 = fmul double %44, %50
%52 = call double @llvm.fmuladd.f64(double %29, double %35, double %51)
%53 = load double*, double** %13
%54 = load i32*, i32** %11
%55 = load i32, i32* %15
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
%58 = load i32, i32* %57
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %53, i64 %59
%61 = load double, double* %60
%62 = load [4 x double]*, [4 x double]** %10
%63 = load i32, i32* %15
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [4 x double], [4 x double]* %62, i64 %64
%66 = getelementptr inbounds [4 x double], [4 x double]* %65, i64 0, i64 2
%67 = load double, double* %66
%68 = call double @llvm.fmuladd.f64(double %61, double %67, double %52)
%69 = load double*, double** %14
%70 = load i32*, i32** %11
%71 = load i32, i32* %15
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %70, i64 %72
%74 = load i32, i32* %73
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %69, i64 %75
%77 = load double, double* %76
%78 = load [4 x double]*, [4 x double]** %10
%79 = load i32, i32* %15
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [4 x double], [4 x double]* %78, i64 %80
%82 = getelementptr inbounds [4 x double], [4 x double]* %81, i64 0, i64 3
%83 = load double, double* %82
%84 = call double @llvm.fmuladd.f64(double %77, double %83, double %68)
%85 = load double*, double** %8
%86 = load double, double* %85
%87 = fadd double %86, %84
store double %87, double* %85
br label %88
88: ; preds = %20
%89 = load i32, i32* %15
%90 = add nsw i32 %89, 1
store i32 %90, i32* %15
br label %17
91: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @bicubic_remap(double* noalias nocapture %0, double* noalias nocapture %1, [4 x double]* nocapture %2, i32* nocapture %3, double* noalias nocapture %4, double* noalias nocapture %5, double* noalias nocapture %6) {
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds double, double* %1, i64 %9
%11 = load double, double* %10
%12 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 0
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %4, i64 %9
%15 = load double, double* %14
%16 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 1
%17 = load double, double* %16
%18 = fmul double %15, %17
%19 = tail call double @llvm.fmuladd.f64(double %11, double %13, double %18)
%20 = getelementptr inbounds double, double* %5, i64 %9
%21 = load double, double* %20
%22 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 2
%23 = load double, double* %22
%24 = tail call double @llvm.fmuladd.f64(double %21, double %23, double %19)
%25 = getelementptr inbounds double, double* %6, i64 %9
%26 = load double, double* %25
%27 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 3
%28 = load double, double* %27
%29 = tail call double @llvm.fmuladd.f64(double %26, double %28, double %24)
%30 = fadd double %29, 0.000000e+00
%31 = getelementptr inbounds i32, i32* %3, i64 1
%32 = load i32, i32* %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %1, i64 %33
%35 = load double, double* %34
%36 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 1, i64 0
%37 = load double, double* %36
%38 = getelementptr inbounds double, double* %4, i64 %33
%39 = load double, double* %38
%40 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 1, i64 1
%41 = load double, double* %40
%42 = fmul double %39, %41
%43 = tail call double @llvm.fmuladd.f64(double %35, double %37, double %42)
%44 = getelementptr inbounds double, double* %5, i64 %33
%45 = load double, double* %44
%46 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 1, i64 2
%47 = load double, double* %46
%48 = tail call double @llvm.fmuladd.f64(double %45, double %47, double %43)
%49 = getelementptr inbounds double, double* %6, i64 %33
%50 = load double, double* %49
%51 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 1, i64 3
%52 = load double, double* %51
%53 = tail call double @llvm.fmuladd.f64(double %50, double %52, double %48)
%54 = fadd double %30, %53
%55 = getelementptr inbounds i32, i32* %3, i64 2
%56 = load i32, i32* %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %1, i64 %57
%59 = load double, double* %58
%60 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 2, i64 0
%61 = load double, double* %60
%62 = getelementptr inbounds double, double* %4, i64 %57
%63 = load double, double* %62
%64 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 2, i64 1
%65 = load double, double* %64
%66 = fmul double %63, %65
%67 = tail call double @llvm.fmuladd.f64(double %59, double %61, double %66)
%68 = getelementptr inbounds double, double* %5, i64 %57
%69 = load double, double* %68
%70 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 2, i64 2
%71 = load double, double* %70
%72 = tail call double @llvm.fmuladd.f64(double %69, double %71, double %67)
%73 = getelementptr inbounds double, double* %6, i64 %57
%74 = load double, double* %73
%75 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 2, i64 3
%76 = load double, double* %75
%77 = tail call double @llvm.fmuladd.f64(double %74, double %76, double %72)
%78 = fadd double %54, %77
%79 = getelementptr inbounds i32, i32* %3, i64 3
%80 = load i32, i32* %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %1, i64 %81
%83 = load double, double* %82
%84 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 3, i64 0
%85 = load double, double* %84
%86 = getelementptr inbounds double, double* %4, i64 %81
%87 = load double, double* %86
%88 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 3, i64 1
%89 = load double, double* %88
%90 = fmul double %87, %89
%91 = tail call double @llvm.fmuladd.f64(double %83, double %85, double %90)
%92 = getelementptr inbounds double, double* %5, i64 %81
%93 = load double, double* %92
%94 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 3, i64 2
%95 = load double, double* %94
%96 = tail call double @llvm.fmuladd.f64(double %93, double %95, double %91)
%97 = getelementptr inbounds double, double* %6, i64 %81
%98 = load double, double* %97
%99 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 3, i64 3
%100 = load double, double* %99
%101 = tail call double @llvm.fmuladd.f64(double %98, double %100, double %96)
%102 = fadd double %78, %101
store double %102, double* %0
ret void
}