void constant_rotating_frame_gradient_3d(double t, double *pars, double *qp,
                                         int n_dim, double *dH) {
  double Cx, Cy, Cz;
  Cx = pars[1] * qp[2] - pars[2] * qp[1];
  Cy = -pars[0] * qp[2] + pars[2] * qp[0];
  Cz = pars[0] * qp[1] - pars[1] * qp[0];
  dH[0] = dH[0] + qp[0 + n_dim] - Cx;
  dH[1] = dH[1] + qp[1 + n_dim] - Cy;
  dH[2] = dH[2] + qp[2 + n_dim] - Cz;
  Cx = pars[1] * qp[2 + n_dim] - pars[2] * qp[1 + n_dim];
  Cy = -pars[0] * qp[2 + n_dim] + pars[2] * qp[0 + n_dim];
  Cz = pars[0] * qp[1 + n_dim] - pars[1] * qp[0 + n_dim];
  dH[3] = dH[3] + Cx;
  dH[4] = dH[4] + Cy;
  dH[5] = dH[5] + Cz;
}


x86 assembly (clang, -O0):
<constant_rotating_frame_gradient_3d>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x28(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
subsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movsd  0x18(%rax),%xmm0
addsd  -0x30(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x28(%rbp),%rax
movsd  0x20(%rax),%xmm0
addsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x28(%rbp),%rax
movsd  0x28(%rax),%xmm0
addsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x28(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<constant_rotating_frame_gradient_3d>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm2
movsd  0x10(%rsi),%xmm3
movsd  0x10(%rdi),%xmm4
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm5
movapd %xmm2,%xmm6
mulsd  %xmm3,%xmm6
mulsd  %xmm0,%xmm3
mulsd  %xmm5,%xmm0
mulsd  %xmm4,%xmm5
subsd  %xmm5,%xmm6
mulsd  %xmm1,%xmm4
subsd  %xmm3,%xmm4
mulsd  %xmm2,%xmm1
movslq %edx,%rax
movsd  (%rcx),%xmm2
movsd  0x8(%rcx),%xmm3
addsd  (%rsi,%rax,8),%xmm2
subsd  %xmm6,%xmm2
movsd  %xmm2,(%rcx)
addsd  0x8(%rsi,%rax,8),%xmm3
subsd  %xmm4,%xmm3
movsd  %xmm3,0x8(%rcx)
movsd  0x10(%rcx),%xmm2
addsd  0x10(%rsi,%rax,8),%xmm2
subsd  %xmm1,%xmm0
subsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rcx)
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
movapd 0xe6f(%rip),%xmm2
movsd  0x10(%rdi),%xmm3
movapd %xmm3,%xmm4
xorpd  %xmm2,%xmm4
xorpd  %xmm0,%xmm2
movupd (%rsi,%rax,8),%xmm5
unpcklpd %xmm4,%xmm3
mulpd  %xmm5,%xmm3
unpcklpd %xmm1,%xmm2
movsd  0x10(%rsi,%rax,8),%xmm4
unpcklpd %xmm4,%xmm4
mulpd  %xmm2,%xmm4
addpd  %xmm3,%xmm4
shufpd $0x1,%xmm4,%xmm4
mulsd  %xmm5,%xmm1
unpckhpd %xmm5,%xmm5
mulsd  %xmm0,%xmm5
subsd  %xmm1,%xmm5
movupd 0x18(%rcx),%xmm0
addpd  %xmm4,%xmm0
movupd %xmm0,0x18(%rcx)
addsd  0x28(%rcx),%xmm5
movsd  %xmm5,0x28(%rcx)
ret

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

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