void matrix_ij_H(int n, double *mat, double ex, double ey, double ez,
                 double yh) {
  double h1;
  double h1xx, h1xy, h1xz, h1yy, h1yz, h1zz;
  double exx, eyy, ezz, exy, eyz, exz;
  h1 = yh;
  exx = ex * ex;
  eyy = ey * ey;
  ezz = ez * ez;
  exy = ex * ey;
  eyz = ey * ez;
  exz = ez * ex;
  h1xx = h1 * exx;
  h1xy = h1 * exy;
  h1xz = h1 * exz;
  h1yy = h1 * eyy;
  h1yz = h1 * eyz;
  h1zz = h1 * ezz;
  mat[0 * n + 1] += +2.0 * h1xz;
  mat[0 * n + 2] += -2.0 * h1xy;
  mat[1 * n + 0] += -h1xz;
  mat[1 * n + 1] += +h1yz;
  mat[1 * n + 2] += +h1xx - h1yy;
  mat[2 * n + 0] += +h1xy;
  mat[2 * n + 1] += -h1xx + h1zz;
  mat[2 * n + 2] += -h1yz;
  mat[3 * n + 0] += +h1yy - h1zz;
  mat[3 * n + 1] += -h1xy;
  mat[3 * n + 2] += +h1xz;
  mat[4 * n + 0] += -2.0 * h1yz;
  mat[4 * n + 2] += +2.0 * h1xy;
}


x86 assembly (clang, -O0):
<matrix_ij_H>:
push   %rbp
mov    %rsp,%rbp
sub    $0x18,%rsp
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  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm1
mov    -0x10(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%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),%xmm0
subsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x68(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%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  -0x58(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3,-0x4(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3,-0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3,-0x4(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x18,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_ij_H>:
movapd %xmm0,%xmm6
mulsd  %xmm0,%xmm6
movapd %xmm1,%xmm4
mulsd  %xmm1,%xmm4
movapd %xmm2,%xmm7
mulsd  %xmm2,%xmm7
movapd %xmm0,%xmm5
unpcklpd %xmm1,%xmm5
unpcklpd %xmm2,%xmm2
mulpd  %xmm5,%xmm2
mulsd  %xmm3,%xmm6
mulsd  %xmm3,%xmm4
movapd %xmm3,%xmm5
unpcklpd %xmm3,%xmm5
mulpd  %xmm2,%xmm5
unpcklpd %xmm7,%xmm0
unpcklpd %xmm3,%xmm1
mulpd  %xmm0,%xmm1
movupd 0x8(%rsi),%xmm2
unpcklpd %xmm6,%xmm3
movapd %xmm1,%xmm0
mulpd  %xmm3,%xmm0
movapd %xmm1,%xmm7
subpd  %xmm3,%xmm7
movapd %xmm5,%xmm3
unpcklpd %xmm0,%xmm3
mulpd  0xe8f(%rip),%xmm3
movsd  %xmm0,%xmm7
addpd  %xmm2,%xmm3
movupd %xmm3,0x8(%rsi)
movslq %edi,%rax
movupd (%rsi,%rax,8),%xmm2
movapd %xmm2,%xmm3
subpd  %xmm5,%xmm3
addpd  %xmm5,%xmm2
movsd  %xmm3,%xmm2
movupd %xmm2,(%rsi,%rax,8)
subsd  %xmm4,%xmm6
addsd  0x10(%rsi,%rax,8),%xmm6
movsd  %xmm6,0x10(%rsi,%rax,8)
lea    (%rax,%rax,1),%ecx
movslq %ecx,%rcx
movupd (%rsi,%rcx,8),%xmm2
addpd  %xmm7,%xmm2
movupd %xmm2,(%rsi,%rcx,8)
movsd  0x10(%rsi,%rcx,8),%xmm3
movapd %xmm5,%xmm2
unpckhpd %xmm5,%xmm2
subsd  %xmm2,%xmm3
movsd  %xmm3,0x10(%rsi,%rcx,8)
unpckhpd %xmm1,%xmm1
subsd  %xmm1,%xmm4
lea    (%rax,%rax,2),%ecx
movslq %ecx,%rcx
addsd  (%rsi,%rcx,8),%xmm4
movsd  %xmm4,(%rsi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsi,%rcx,8)
movsd  0x10(%rsi,%rcx,8),%xmm1
addsd  %xmm5,%xmm1
movsd  %xmm1,0x10(%rsi,%rcx,8)
lea    0x2(,%rax,4),%ecx
shl    $0x2,%eax
cltq
movsd  (%rsi,%rax,8),%xmm1
addsd  %xmm2,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,(%rsi,%rax,8)
movslq %ecx,%rax
addsd  %xmm0,%xmm0
addsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,(%rsi,%rax,8)
ret

LLVM IR (-O0):
define void @matrix_ij_H(i32 %0, double* %1, double %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca double*
%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
%23 = alloca double
%24 = alloca double
%25 = alloca double
store i32 %0, i32* %7
store double* %1, double** %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%26 = load double, double* %12
store double %26, double* %13
%27 = load double, double* %9
%28 = load double, double* %9
%29 = fmul double %27, %28
store double %29, double* %20
%30 = load double, double* %10
%31 = load double, double* %10
%32 = fmul double %30, %31
store double %32, double* %21
%33 = load double, double* %11
%34 = load double, double* %11
%35 = fmul double %33, %34
store double %35, double* %22
%36 = load double, double* %9
%37 = load double, double* %10
%38 = fmul double %36, %37
store double %38, double* %23
%39 = load double, double* %10
%40 = load double, double* %11
%41 = fmul double %39, %40
store double %41, double* %24
%42 = load double, double* %11
%43 = load double, double* %9
%44 = fmul double %42, %43
store double %44, double* %25
%45 = load double, double* %13
%46 = load double, double* %20
%47 = fmul double %45, %46
store double %47, double* %14
%48 = load double, double* %13
%49 = load double, double* %23
%50 = fmul double %48, %49
store double %50, double* %15
%51 = load double, double* %13
%52 = load double, double* %25
%53 = fmul double %51, %52
store double %53, double* %16
%54 = load double, double* %13
%55 = load double, double* %21
%56 = fmul double %54, %55
store double %56, double* %17
%57 = load double, double* %13
%58 = load double, double* %24
%59 = fmul double %57, %58
store double %59, double* %18
%60 = load double, double* %13
%61 = load double, double* %22
%62 = fmul double %60, %61
store double %62, double* %19
%63 = load double, double* %16
%64 = load double*, double** %8
%65 = load i32, i32* %7
%66 = mul nsw i32 0, %65
%67 = add nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %64, i64 %68
%70 = load double, double* %69
%71 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %63, double %70)
store double %71, double* %69
%72 = load double, double* %15
%73 = load double*, double** %8
%74 = load i32, i32* %7
%75 = mul nsw i32 0, %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 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %72, double %79)
store double %80, double* %78
%81 = load double, double* %16
%82 = fneg double %81
%83 = load double*, double** %8
%84 = load i32, i32* %7
%85 = mul nsw i32 1, %84
%86 = add nsw i32 %85, 0
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double, double* %83, i64 %87
%89 = load double, double* %88
%90 = fadd double %89, %82
store double %90, double* %88
%91 = load double, double* %18
%92 = load double*, double** %8
%93 = load i32, i32* %7
%94 = mul nsw i32 1, %93
%95 = add nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %92, i64 %96
%98 = load double, double* %97
%99 = fadd double %98, %91
store double %99, double* %97
%100 = load double, double* %14
%101 = load double, double* %17
%102 = fsub double %100, %101
%103 = load double*, double** %8
%104 = load i32, i32* %7
%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 = fadd double %109, %102
store double %110, double* %108
%111 = load double, double* %15
%112 = load double*, double** %8
%113 = load i32, i32* %7
%114 = mul nsw i32 2, %113
%115 = add nsw i32 %114, 0
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %112, i64 %116
%118 = load double, double* %117
%119 = fadd double %118, %111
store double %119, double* %117
%120 = load double, double* %14
%121 = fneg double %120
%122 = load double, double* %19
%123 = fadd double %121, %122
%124 = load double*, double** %8
%125 = load i32, i32* %7
%126 = mul nsw i32 2, %125
%127 = add nsw i32 %126, 1
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %124, i64 %128
%130 = load double, double* %129
%131 = fadd double %130, %123
store double %131, double* %129
%132 = load double, double* %18
%133 = fneg double %132
%134 = load double*, double** %8
%135 = load i32, i32* %7
%136 = mul nsw i32 2, %135
%137 = add nsw i32 %136, 2
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds double, double* %134, i64 %138
%140 = load double, double* %139
%141 = fadd double %140, %133
store double %141, double* %139
%142 = load double, double* %17
%143 = load double, double* %19
%144 = fsub double %142, %143
%145 = load double*, double** %8
%146 = load i32, i32* %7
%147 = mul nsw i32 3, %146
%148 = add nsw i32 %147, 0
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds double, double* %145, i64 %149
%151 = load double, double* %150
%152 = fadd double %151, %144
store double %152, double* %150
%153 = load double, double* %15
%154 = fneg double %153
%155 = load double*, double** %8
%156 = load i32, i32* %7
%157 = mul nsw i32 3, %156
%158 = add nsw i32 %157, 1
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds double, double* %155, i64 %159
%161 = load double, double* %160
%162 = fadd double %161, %154
store double %162, double* %160
%163 = load double, double* %16
%164 = load double*, double** %8
%165 = load i32, i32* %7
%166 = mul nsw i32 3, %165
%167 = add nsw i32 %166, 2
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds double, double* %164, i64 %168
%170 = load double, double* %169
%171 = fadd double %170, %163
store double %171, double* %169
%172 = load double, double* %18
%173 = load double*, double** %8
%174 = load i32, i32* %7
%175 = mul nsw i32 4, %174
%176 = add nsw i32 %175, 0
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds double, double* %173, i64 %177
%179 = load double, double* %178
%180 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %172, double %179)
store double %180, double* %178
%181 = load double, double* %15
%182 = load double*, double** %8
%183 = load i32, i32* %7
%184 = mul nsw i32 4, %183
%185 = add nsw i32 %184, 2
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds double, double* %182, i64 %186
%188 = load double, double* %187
%189 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %181, double %188)
store double %189, double* %187
ret void
}

LLVM IR (-O2):
define void @matrix_ij_H(i32 %0, double* nocapture %1, double %2, double %3, double %4, double %5) {
%7 = fmul double %2, %2
%8 = fmul double %3, %3
%9 = fmul double %4, %4
%10 = insertelement <2 x double> poison, double %2, i64 0
%11 = insertelement <2 x double> %10, double %3, i64 1
%12 = insertelement <2 x double> poison, double %4, i64 0
%13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
%14 = fmul <2 x double> %11, %13
%15 = fmul double %7, %5
%16 = fmul double %8, %5
%17 = insertelement <2 x double> poison, double %5, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
%19 = fmul <2 x double> %14, %18
%20 = insertelement <2 x double> %10, double %9, i64 1
%21 = insertelement <2 x double> poison, double %3, i64 0
%22 = insertelement <2 x double> %21, double %5, i64 1
%23 = fmul <2 x double> %20, %22
%24 = getelementptr inbounds double, double* %1, i64 1
%25 = extractelement <2 x double> %19, i64 0
%26 = bitcast double* %24 to <2 x double>*
%27 = load <2 x double>, <2 x double>* %26
%28 = insertelement <2 x double> %17, double %15, i64 1
%29 = fmul <2 x double> %23, %28
%30 = fsub <2 x double> %23, %28
%31 = shufflevector <2 x double> %29, <2 x double> %30, <2 x i32> <i32 0, i32 3>
%32 = extractelement <2 x double> %29, i64 0
%33 = shufflevector <2 x double> %19, <2 x double> %29, <2 x i32> <i32 0, i32 2>
%34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> <double 2.000000e+00, double -2.000000e+00>, <2 x double> %27)
%35 = bitcast double* %24 to <2 x double>*
store <2 x double> %34, <2 x double>* %35
%36 = sext i32 %0 to i64
%37 = getelementptr inbounds double, double* %1, i64 %36
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = fsub <2 x double> %39, %19
%41 = fadd <2 x double> %39, %19
%42 = shufflevector <2 x double> %40, <2 x double> %41, <2 x i32> <i32 0, i32 3>
%43 = bitcast double* %37 to <2 x double>*
store <2 x double> %42, <2 x double>* %43
%44 = fsub double %15, %16
%45 = add nsw i32 %0, 2
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %1, i64 %46
%48 = load double, double* %47
%49 = fadd double %44, %48
store double %49, double* %47
%50 = shl nsw i32 %0, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %1, i64 %51
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = fadd <2 x double> %31, %54
%56 = bitcast double* %52 to <2 x double>*
store <2 x double> %55, <2 x double>* %56
%57 = add nsw i32 %50, 2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %1, i64 %58
%60 = load double, double* %59
%61 = extractelement <2 x double> %19, i64 1
%62 = fsub double %60, %61
store double %62, double* %59
%63 = extractelement <2 x double> %23, i64 1
%64 = fsub double %16, %63
%65 = mul nsw i32 %0, 3
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %1, i64 %66
%68 = load double, double* %67
%69 = fadd double %64, %68
store double %69, double* %67
%70 = add nsw i32 %65, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %1, i64 %71
%73 = load double, double* %72
%74 = fsub double %73, %32
store double %74, double* %72
%75 = add nsw i32 %65, 2
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %1, i64 %76
%78 = load double, double* %77
%79 = fadd double %25, %78
store double %79, double* %77
%80 = shl nsw i32 %0, 2
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %1, i64 %81
%83 = load double, double* %82
%84 = tail call double @llvm.fmuladd.f64(double %61, double -2.000000e+00, double %83)
store double %84, double* %82
%85 = or i32 %80, 2
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %1, i64 %86
%88 = load double, double* %87
%89 = tail call double @llvm.fmuladd.f64(double %32, double 2.000000e+00, double %88)
store double %89, double* %87
ret void
}