void norm_weight(double norm_factor, double *weights, double src_centroid_lat,
                 double src_centroid_lon) {
  double weight0 = weights[0];
  weights[0] = weight0 * norm_factor;
  weights[1] = (weights[1] - weight0 * src_centroid_lat) * norm_factor;
  weights[2] = (weights[2] - weight0 * src_centroid_lon) * norm_factor;
}


x86 assembly (clang, -O0):
<norm_weight>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<norm_weight>:
movsd  (%rdi),%xmm3
movsd  0x8(%rdi),%xmm4
mulsd  %xmm3,%xmm1
subsd  %xmm1,%xmm4
mulsd  %xmm3,%xmm2
unpcklpd %xmm4,%xmm3
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
mulpd  %xmm3,%xmm1
movupd %xmm1,(%rdi)
movsd  0x10(%rdi),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rdi)
ret

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

LLVM IR (-O2):
define void @norm_weight(double %0, double* nocapture %1, double %2, double %3) {
%5 = load double, double* %1
%6 = getelementptr inbounds double, double* %1, i64 1
%7 = load double, double* %6
%8 = fneg double %5
%9 = tail call double @llvm.fmuladd.f64(double %8, double %2, double %7)
%10 = insertelement <2 x double> poison, double %5, i64 0
%11 = insertelement <2 x double> %10, double %9, i64 1
%12 = insertelement <2 x double> poison, double %0, i64 0
%13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
%14 = fmul <2 x double> %11, %13
%15 = bitcast double* %1 to <2 x double>*
store <2 x double> %14, <2 x double>* %15
%16 = getelementptr inbounds double, double* %1, i64 2
%17 = load double, double* %16
%18 = tail call double @llvm.fmuladd.f64(double %8, double %3, double %17)
%19 = fmul double %18, %0
store double %19, double* %16
ret void
}