void matrix_ij_HT(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[1 * n + 0] += +2.0 * h1xz;
  mat[2 * n + 0] += -2.0 * h1xy;
  mat[0 * n + 1] += -h1xz;
  mat[1 * n + 1] += +h1yz;
  mat[2 * n + 1] += +h1xx - h1yy;
  mat[0 * n + 2] += +h1xy;
  mat[1 * n + 2] += -h1xx + h1zz;
  mat[2 * n + 2] += -h1yz;
  mat[0 * n + 3] += +h1yy - h1zz;
  mat[1 * n + 3] += -h1xy;
  mat[2 * n + 3] += +h1xz;
  mat[0 * n + 4] += -2.0 * h1yz;
  mat[2 * n + 4] += +2.0 * h1xy;
}


x86 assembly (clang, -O0):
<matrix_ij_HT>:
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
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x0,%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
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%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
imul   $0x0,-0x4(%rbp),%ecx
add    $0x1,%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    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x2,%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    $0x0,%ecx
add    $0x2,%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   $0x0,-0x4(%rbp),%ecx
add    $0x3,%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
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm1
mov    -0x10(%rbp),%rax
imul   $0x0,-0x4(%rbp),%ecx
add    $0x4,%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    $0x1,%ecx
add    $0x4,%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_HT>:
movapd %xmm0,%xmm6
mulsd  %xmm0,%xmm6
movapd %xmm1,%xmm4
mulsd  %xmm1,%xmm4
movapd %xmm0,%xmm5
mulsd  %xmm1,%xmm5
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm2
mulsd  %xmm3,%xmm6
mulsd  %xmm3,%xmm5
mulsd  %xmm3,%xmm0
mulsd  %xmm3,%xmm4
mulsd  %xmm3,%xmm1
movslq %edi,%rcx
movapd %xmm0,%xmm7
addsd  %xmm0,%xmm7
addsd  (%rsi,%rcx,8),%xmm7
mulsd  %xmm3,%xmm2
movsd  %xmm7,(%rsi,%rcx,8)
lea    (%rcx,%rcx,1),%eax
cltq
movsd  (%rsi,%rax,8),%xmm7
movapd %xmm5,%xmm3
addsd  %xmm5,%xmm3
subsd  %xmm3,%xmm7
movsd  %xmm7,(%rsi,%rax,8)
movsd  0x8(%rsi),%xmm7
subsd  %xmm0,%xmm7
movsd  %xmm7,0x8(%rsi)
movsd  0x8(%rsi,%rcx,8),%xmm7
addsd  %xmm1,%xmm7
movsd  %xmm7,0x8(%rsi,%rcx,8)
movapd %xmm2,%xmm7
subsd  %xmm6,%xmm7
subsd  %xmm4,%xmm6
lea    0x1(%rcx,%rcx,1),%edx
movslq %edx,%rdx
addsd  (%rsi,%rdx,8),%xmm6
movsd  %xmm6,(%rsi,%rdx,8)
movsd  0x10(%rsi),%xmm6
addsd  %xmm5,%xmm6
movsd  %xmm6,0x10(%rsi)
addsd  0x10(%rsi,%rcx,8),%xmm7
movsd  %xmm7,0x10(%rsi,%rcx,8)
movsd  0x10(%rsi,%rax,8),%xmm6
subsd  %xmm1,%xmm6
movsd  %xmm6,0x10(%rsi,%rax,8)
subsd  %xmm2,%xmm4
addsd  0x18(%rsi),%xmm4
movsd  %xmm4,0x18(%rsi)
movsd  0x18(%rsi,%rcx,8),%xmm2
subsd  %xmm5,%xmm2
movsd  %xmm2,0x18(%rsi,%rcx,8)
addsd  0x18(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x18(%rsi,%rax,8)
movsd  0x20(%rsi),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsi)
addsd  0x20(%rsi,%rax,8),%xmm3
movsd  %xmm3,0x20(%rsi,%rax,8)
ret

LLVM IR (-O0):
define void @matrix_ij_HT(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 1, %65
%67 = add nsw i32 %66, 0
%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 2, %74
%76 = add nsw i32 %75, 0
%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 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 = 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 2, %104
%106 = add nsw i32 %105, 1
%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 0, %113
%115 = add nsw i32 %114, 2
%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 1, %125
%127 = add nsw i32 %126, 2
%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 0, %146
%148 = add nsw i32 %147, 3
%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 1, %156
%158 = add nsw i32 %157, 3
%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 2, %165
%167 = add nsw i32 %166, 3
%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 0, %174
%176 = add nsw i32 %175, 4
%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 2, %183
%185 = add nsw i32 %184, 4
%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_HT(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 = fmul double %2, %3
%11 = fmul double %3, %4
%12 = fmul double %2, %4
%13 = fmul double %7, %5
%14 = fmul double %10, %5
%15 = fmul double %12, %5
%16 = fmul double %8, %5
%17 = fmul double %11, %5
%18 = fmul double %9, %5
%19 = sext i32 %0 to i64
%20 = getelementptr inbounds double, double* %1, i64 %19
%21 = load double, double* %20
%22 = tail call double @llvm.fmuladd.f64(double %15, double 2.000000e+00, double %21)
store double %22, double* %20
%23 = shl nsw i32 %0, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %1, i64 %24
%26 = load double, double* %25
%27 = tail call double @llvm.fmuladd.f64(double %14, double -2.000000e+00, double %26)
store double %27, double* %25
%28 = getelementptr inbounds double, double* %1, i64 1
%29 = load double, double* %28
%30 = fsub double %29, %15
store double %30, double* %28
%31 = add nsw i32 %0, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %1, i64 %32
%34 = load double, double* %33
%35 = fadd double %17, %34
store double %35, double* %33
%36 = fsub double %13, %16
%37 = or i32 %23, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %1, i64 %38
%40 = load double, double* %39
%41 = fadd double %36, %40
store double %41, double* %39
%42 = getelementptr inbounds double, double* %1, i64 2
%43 = load double, double* %42
%44 = fadd double %14, %43
store double %44, double* %42
%45 = fsub double %18, %13
%46 = add nsw i32 %0, 2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %1, i64 %47
%49 = load double, double* %48
%50 = fadd double %45, %49
store double %50, double* %48
%51 = add nsw i32 %23, 2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %1, i64 %52
%54 = load double, double* %53
%55 = fsub double %54, %17
store double %55, double* %53
%56 = fsub double %16, %18
%57 = getelementptr inbounds double, double* %1, i64 3
%58 = load double, double* %57
%59 = fadd double %56, %58
store double %59, double* %57
%60 = add nsw i32 %0, 3
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %1, i64 %61
%63 = load double, double* %62
%64 = fsub double %63, %14
store double %64, double* %62
%65 = add nsw i32 %23, 3
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %1, i64 %66
%68 = load double, double* %67
%69 = fadd double %15, %68
store double %69, double* %67
%70 = getelementptr inbounds double, double* %1, i64 4
%71 = load double, double* %70
%72 = tail call double @llvm.fmuladd.f64(double %17, double -2.000000e+00, double %71)
store double %72, double* %70
%73 = add nsw i32 %23, 4
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %1, i64 %74
%76 = load double, double* %75
%77 = tail call double @llvm.fmuladd.f64(double %14, double 2.000000e+00, double %76)
store double %77, double* %75
ret void
}