void burgersDiagonalVelHJEvaluate(const int nPoints, const int nSpace,
                                  const double self_a, const double *self_v,
                                  const double *u, const double *grad_u,
                                  double *m, double *dm, double *H, double *dH,
                                  double *a, double *phi, double *dphi) {
  double u2;
  int k, I;
  const int nSpace2 = nSpace * nSpace;
  for (k = 0; k < nPoints; k++) {
    m[k] = phi[k] = u[k];
    dm[k] = dphi[k] = 1.0;
    u2 = u[k] * u[k];
    H[k] = 0.0;
    for (I = 0; I < nSpace; I++) {
      a[k * nSpace2 + I * nSpace + I] = self_a;
      H[k] += self_v[I] * grad_u[k * nSpace + I] * u[k];
      dH[k * nSpace + I] = self_v[I] * u[k];
    }
  }
}


x86 assembly (clang, -O0):
<burgersDiagonalVelHJEvaluate>:
push   %rbp
mov    %rsp,%rbp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12a6 <burgersDiagonalVelHJEvaluate+0x1a6>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xe60(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1293 <burgersDiagonalVelHJEvaluate+0x193>
movsd  -0x10(%rbp),%xmm0
mov    0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x44(%rbp),%ecx
mov    -0x40(%rbp),%edx
imul   -0x8(%rbp),%edx
add    %edx,%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11db <burgersDiagonalVelHJEvaluate+0xdb>
jmp    1298 <burgersDiagonalVelHJEvaluate+0x198>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1148 <burgersDiagonalVelHJEvaluate+0x48>
pop    %rbp
ret

x86 assembly (clang, -O2):
<burgersDiagonalVelHJEvaluate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,-0x8(%rsp)
mov    %esi,-0x14(%rsp)
test   %edi,%edi
jle    1207 <burgersDiagonalVelHJEvaluate+0x107>
mov    0x50(%rsp),%r14
mov    0x48(%rsp),%rbx
mov    0x40(%rsp),%rax
movslq -0x14(%rsp),%r12
mov    %edi,%esi
mov    %rsi,-0x10(%rsp)
mov    %r12d,%edi
mov    %r12d,%ebp
imul   %r12d,%ebp
lea    0x1(%r12),%r10d
shl    $0x3,%r12
xor    %r9d,%r9d
movabs $0x3ff0000000000000,%r15
xor    %r13d,%r13d
jmp    1178 <burgersDiagonalVelHJEvaluate+0x78>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
add    %ebp,%r9d
add    %r12,%r8
add    %r12,%rbx
cmp    -0x10(%rsp),%r13
je     1207 <burgersDiagonalVelHJEvaluate+0x107>
movsd  (%rcx,%r13,8),%xmm1
mov    0x58(%rsp),%rsi
movsd  %xmm1,(%rsi,%r13,8)
mov    -0x8(%rsp),%rsi
movsd  %xmm1,(%rsi,%r13,8)
mov    0x60(%rsp),%rsi
mov    %r15,(%rsi,%r13,8)
mov    0x38(%rsp),%rsi
mov    %r15,(%rsi,%r13,8)
movq   $0x0,(%rax,%r13,8)
cmpl   $0x0,-0x14(%rsp)
jle    1160 <burgersDiagonalVelHJEvaluate+0x60>
mov    %r9d,%r11d
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movslq %r11d,%r11
movsd  %xmm0,(%r14,%r11,8)
movsd  (%rdx,%rsi,8),%xmm1
mulsd  (%r8,%rsi,8),%xmm1
mulsd  (%rcx,%r13,8),%xmm1
addsd  (%rax,%r13,8),%xmm1
movsd  %xmm1,(%rax,%r13,8)
movsd  (%rdx,%rsi,8),%xmm1
mulsd  (%rcx,%r13,8),%xmm1
movsd  %xmm1,(%rbx,%rsi,8)
add    $0x1,%rsi
add    %r10d,%r11d
cmp    %rsi,%rdi
jne    11c0 <burgersDiagonalVelHJEvaluate+0xc0>
jmp    1160 <burgersDiagonalVelHJEvaluate+0x60>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @burgersDiagonalVelHJEvaluate(i32 %0, i32 %1, double %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double* nocapture writeonly %6, double* nocapture writeonly %7, double* nocapture %8, double* nocapture writeonly %9, double* nocapture writeonly %10, double* nocapture writeonly %11, double* nocapture writeonly %12) {
%14 = icmp sgt i32 %0, 0
br i1 %14, label %15, label %60
15: ; preds = %13
%16 = icmp sgt i32 %1, 0
%17 = sext i32 %1 to i64
%18 = zext i32 %0 to i64
%19 = zext i32 %1 to i64
br label %20
20: ; preds = %15, %57
%21 = phi i64 [ 0, %15 ], [ %58, %57 ]
%22 = getelementptr inbounds double, double* %4, i64 %21
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %11, i64 %21
store double %23, double* %24
%25 = getelementptr inbounds double, double* %6, i64 %21
store double %23, double* %25
%26 = getelementptr inbounds double, double* %12, i64 %21
store double 1.000000e+00, double* %26
%27 = getelementptr inbounds double, double* %7, i64 %21
store double 1.000000e+00, double* %27
%28 = getelementptr inbounds double, double* %8, i64 %21
store double 0.000000e+00, double* %28
br i1 %16, label %29, label %57
29: ; preds = %20
%30 = trunc i64 %21 to i32
%31 = mul i32 %30, %1
%32 = mul nsw i64 %21, %17
br label %33
33: ; preds = %29, %33
%34 = phi i64 [ 0, %29 ], [ %55, %33 ]
%35 = trunc i64 %34 to i32
%36 = add i32 %31, %35
%37 = mul i32 %36, %1
%38 = trunc i64 %34 to i32
%39 = add i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %10, i64 %40
store double %2, double* %41
%42 = getelementptr inbounds double, double* %3, i64 %34
%43 = load double, double* %42
%44 = add nsw i64 %34, %32
%45 = getelementptr inbounds double, double* %5, i64 %44
%46 = load double, double* %45
%47 = fmul double %43, %46
%48 = load double, double* %22
%49 = load double, double* %28
%50 = tail call double @llvm.fmuladd.f64(double %47, double %48, double %49)
store double %50, double* %28
%51 = load double, double* %42
%52 = load double, double* %22
%53 = fmul double %51, %52
%54 = getelementptr inbounds double, double* %9, i64 %44
store double %53, double* %54
%55 = add nuw nsw i64 %34, 1
%56 = icmp eq i64 %55, %19
br i1 %56, label %57, label %33
57: ; preds = %33, %20
%58 = add nuw nsw i64 %21, 1
%59 = icmp eq i64 %58, %18
br i1 %59, label %60, label %20
60: ; preds = %57, %13
ret void
}