void matrix_ij_A(int n, double *mat, double ex, double ey, double ez, double xa,
                 double ya) {
  double a1, a2;
  double exx, eyy, ezz, exy, eyz, exz;
  a1 = ya;
  a2 = xa - ya;
  exx = ex * ex;
  eyy = ey * ey;
  ezz = ez * ez;
  exy = ex * ey;
  eyz = ey * ez;
  exz = ez * ex;
  mat[0 * n + 0] += a1 + a2 * exx;
  mat[1 * n + 1] += a1 + a2 * eyy;
  mat[2 * n + 2] += a1 + a2 * ezz;
  mat[0 * n + 1] += a2 * exy;
  mat[1 * n + 0] += a2 * exy;
  mat[1 * n + 2] += a2 * eyz;
  mat[2 * n + 1] += a2 * eyz;
  mat[2 * n + 0] += a2 * exz;
  mat[0 * n + 2] += a2 * exz;
}


x86 assembly (clang, -O0):
<matrix_ij_A>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
mov    -0x10(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm2
mov    -0x10(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_ij_A>:
subsd  %xmm4,%xmm3
movapd %xmm0,%xmm6
mulsd  %xmm0,%xmm6
movapd %xmm0,%xmm5
mulsd  %xmm1,%xmm5
unpcklpd %xmm1,%xmm0
mulsd  %xmm1,%xmm1
movapd %xmm2,%xmm7
mulsd  %xmm3,%xmm6
addsd  %xmm4,%xmm6
addsd  (%rsi),%xmm6
movsd  %xmm6,(%rsi)
mulsd  %xmm3,%xmm1
addsd  %xmm4,%xmm1
movslq %edi,%rax
addsd  0x8(%rsi,%rax,8),%xmm1
mulsd  %xmm2,%xmm7
movsd  %xmm1,0x8(%rsi,%rax,8)
mulsd  %xmm3,%xmm7
addsd  %xmm4,%xmm7
lea    (%rax,%rax,1),%ecx
movslq %ecx,%rcx
addsd  0x10(%rsi,%rcx,8),%xmm7
unpcklpd %xmm2,%xmm2
movsd  %xmm7,0x10(%rsi,%rcx,8)
mulsd  %xmm3,%xmm5
movsd  0x8(%rsi),%xmm1
addsd  %xmm5,%xmm1
movsd  %xmm1,0x8(%rsi)
addsd  (%rsi,%rax,8),%xmm5
mulpd  %xmm0,%xmm2
movsd  %xmm5,(%rsi,%rax,8)
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
mulsd  %xmm3,%xmm0
addsd  0x10(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x10(%rsi,%rax,8)
movupd (%rsi,%rcx,8),%xmm0
movapd %xmm3,%xmm1
unpcklpd %xmm3,%xmm1
mulpd  %xmm2,%xmm1
addpd  %xmm0,%xmm1
movupd %xmm1,(%rsi,%rcx,8)
mulsd  %xmm3,%xmm2
addsd  0x10(%rsi),%xmm2
movsd  %xmm2,0x10(%rsi)
ret

LLVM IR (-O0):
define void @matrix_ij_A(i32 %0, double* %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca i32
%9 = alloca double*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
store i32 %0, i32* %8
store double* %1, double** %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%23 = load double, double* %14
store double %23, double* %15
%24 = load double, double* %13
%25 = load double, double* %14
%26 = fsub double %24, %25
store double %26, double* %16
%27 = load double, double* %10
%28 = load double, double* %10
%29 = fmul double %27, %28
store double %29, double* %17
%30 = load double, double* %11
%31 = load double, double* %11
%32 = fmul double %30, %31
store double %32, double* %18
%33 = load double, double* %12
%34 = load double, double* %12
%35 = fmul double %33, %34
store double %35, double* %19
%36 = load double, double* %10
%37 = load double, double* %11
%38 = fmul double %36, %37
store double %38, double* %20
%39 = load double, double* %11
%40 = load double, double* %12
%41 = fmul double %39, %40
store double %41, double* %21
%42 = load double, double* %12
%43 = load double, double* %10
%44 = fmul double %42, %43
store double %44, double* %22
%45 = load double, double* %15
%46 = load double, double* %16
%47 = load double, double* %17
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double %45)
%49 = load double*, double** %9
%50 = load i32, i32* %8
%51 = mul nsw i32 0, %50
%52 = add nsw i32 %51, 0
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %49, i64 %53
%55 = load double, double* %54
%56 = fadd double %55, %48
store double %56, double* %54
%57 = load double, double* %15
%58 = load double, double* %16
%59 = load double, double* %18
%60 = call double @llvm.fmuladd.f64(double %58, double %59, double %57)
%61 = load double*, double** %9
%62 = load i32, i32* %8
%63 = mul nsw i32 1, %62
%64 = add nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %61, i64 %65
%67 = load double, double* %66
%68 = fadd double %67, %60
store double %68, double* %66
%69 = load double, double* %15
%70 = load double, double* %16
%71 = load double, double* %19
%72 = call double @llvm.fmuladd.f64(double %70, double %71, double %69)
%73 = load double*, double** %9
%74 = load i32, i32* %8
%75 = mul nsw i32 2, %74
%76 = add nsw i32 %75, 2
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %73, i64 %77
%79 = load double, double* %78
%80 = fadd double %79, %72
store double %80, double* %78
%81 = load double, double* %16
%82 = load double, double* %20
%83 = load double*, double** %9
%84 = load i32, i32* %8
%85 = mul nsw i32 0, %84
%86 = add nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double, double* %83, i64 %87
%89 = load double, double* %88
%90 = call double @llvm.fmuladd.f64(double %81, double %82, double %89)
store double %90, double* %88
%91 = load double, double* %16
%92 = load double, double* %20
%93 = load double*, double** %9
%94 = load i32, i32* %8
%95 = mul nsw i32 1, %94
%96 = add nsw i32 %95, 0
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %93, i64 %97
%99 = load double, double* %98
%100 = call double @llvm.fmuladd.f64(double %91, double %92, double %99)
store double %100, double* %98
%101 = load double, double* %16
%102 = load double, double* %21
%103 = load double*, double** %9
%104 = load i32, i32* %8
%105 = mul nsw i32 1, %104
%106 = add nsw i32 %105, 2
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds double, double* %103, i64 %107
%109 = load double, double* %108
%110 = call double @llvm.fmuladd.f64(double %101, double %102, double %109)
store double %110, double* %108
%111 = load double, double* %16
%112 = load double, double* %21
%113 = load double*, double** %9
%114 = load i32, i32* %8
%115 = mul nsw i32 2, %114
%116 = add nsw i32 %115, 1
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %113, i64 %117
%119 = load double, double* %118
%120 = call double @llvm.fmuladd.f64(double %111, double %112, double %119)
store double %120, double* %118
%121 = load double, double* %16
%122 = load double, double* %22
%123 = load double*, double** %9
%124 = load i32, i32* %8
%125 = mul nsw i32 2, %124
%126 = add nsw i32 %125, 0
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %123, i64 %127
%129 = load double, double* %128
%130 = call double @llvm.fmuladd.f64(double %121, double %122, double %129)
store double %130, double* %128
%131 = load double, double* %16
%132 = load double, double* %22
%133 = load double*, double** %9
%134 = load i32, i32* %8
%135 = mul nsw i32 0, %134
%136 = add nsw i32 %135, 2
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds double, double* %133, i64 %137
%139 = load double, double* %138
%140 = call double @llvm.fmuladd.f64(double %131, double %132, double %139)
store double %140, double* %138
ret void
}

LLVM IR (-O2):
define void @matrix_ij_A(i32 %0, double* nocapture %1, double %2, double %3, double %4, double %5, double %6) {
%8 = fsub double %5, %6
%9 = fmul double %2, %2
%10 = fmul double %3, %3
%11 = fmul double %4, %4
%12 = fmul double %2, %3
%13 = insertelement <2 x double> poison, double %2, i64 0
%14 = insertelement <2 x double> %13, double %3, i64 1
%15 = insertelement <2 x double> poison, double %4, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = fmul <2 x double> %14, %16
%18 = tail call double @llvm.fmuladd.f64(double %8, double %9, double %6)
%19 = load double, double* %1
%20 = fadd double %18, %19
store double %20, double* %1
%21 = tail call double @llvm.fmuladd.f64(double %8, double %10, double %6)
%22 = add nsw i32 %0, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %1, i64 %23
%25 = load double, double* %24
%26 = fadd double %21, %25
store double %26, double* %24
%27 = tail call double @llvm.fmuladd.f64(double %8, double %11, double %6)
%28 = shl nsw i32 %0, 1
%29 = add nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %1, i64 %30
%32 = load double, double* %31
%33 = fadd double %27, %32
store double %33, double* %31
%34 = getelementptr inbounds double, double* %1, i64 1
%35 = load double, double* %34
%36 = tail call double @llvm.fmuladd.f64(double %8, double %12, double %35)
store double %36, double* %34
%37 = sext i32 %0 to i64
%38 = getelementptr inbounds double, double* %1, i64 %37
%39 = load double, double* %38
%40 = tail call double @llvm.fmuladd.f64(double %8, double %12, double %39)
store double %40, double* %38
%41 = add nsw i32 %0, 2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %1, i64 %42
%44 = load double, double* %43
%45 = extractelement <2 x double> %17, i64 1
%46 = tail call double @llvm.fmuladd.f64(double %8, double %45, double %44)
store double %46, double* %43
%47 = sext i32 %28 to i64
%48 = getelementptr inbounds double, double* %1, i64 %47
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = insertelement <2 x double> poison, double %8, i64 0
%52 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> zeroinitializer
%53 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %17, <2 x double> %50)
%54 = bitcast double* %48 to <2 x double>*
store <2 x double> %53, <2 x double>* %54
%55 = getelementptr inbounds double, double* %1, i64 2
%56 = load double, double* %55
%57 = extractelement <2 x double> %17, i64 0
%58 = tail call double @llvm.fmuladd.f64(double %8, double %57, double %56)
store double %58, double* %55
ret void
}