void burgersDiagonalVelEvaluate(const int nPoints, const int nSpace,
                                const double self_a, const double *self_v,
                                const double *u, double *m, double *dm,
                                double *f, double *df, 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];
    for (I = 0; I < nSpace; I++) {
      a[k * nSpace2 + I * nSpace + I] = self_a;
      f[k * nSpace + I] = self_v[I] * u[k] * u[k] * 0.5;
      df[k * nSpace + I] = self_v[I] * u[k];
    }
  }
}


x86 assembly (clang, -O0):
<burgersDiagonalVelEvaluate>:
push   %rbp
mov    %rsp,%rbp
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    1291 <burgersDiagonalVelEvaluate+0x191>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xe64(%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)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    127e <burgersDiagonalVelEvaluate+0x17e>
movsd  -0x10(%rbp),%xmm0
mov    0x20(%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    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  0xde2(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x8(%rbp),%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    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x18(%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    11c7 <burgersDiagonalVelEvaluate+0xc7>
jmp    1283 <burgersDiagonalVelEvaluate+0x183>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1144 <burgersDiagonalVelEvaluate+0x44>
pop    %rbp
ret

x86 assembly (clang, -O2):
<burgersDiagonalVelEvaluate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,-0x8(%rsp)
mov    %r8,-0x10(%rsp)
mov    %esi,-0x1c(%rsp)
test   %edi,%edi
jle    121a <burgersDiagonalVelEvaluate+0x11a>
mov    0x48(%rsp),%r14
mov    0x40(%rsp),%rbx
mov    0x38(%rsp),%rax
movslq -0x1c(%rsp),%r15
mov    %edi,%esi
mov    %rsi,-0x18(%rsp)
mov    %r15d,%edi
mov    %r15d,%r13d
imul   %r15d,%r13d
lea    0x1(%r15),%ebp
shl    $0x3,%r15
xor    %r9d,%r9d
movabs $0x3ff0000000000000,%r11
movsd  0xe9e(%rip),%xmm1
xor    %r12d,%r12d
jmp    1188 <burgersDiagonalVelEvaluate+0x88>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
add    %r13d,%r9d
add    %r15,%rax
add    %r15,%rbx
cmp    -0x18(%rsp),%r12
je     121a <burgersDiagonalVelEvaluate+0x11a>
movsd  (%rcx,%r12,8),%xmm2
mov    0x50(%rsp),%rsi
movsd  %xmm2,(%rsi,%r12,8)
mov    -0x10(%rsp),%rsi
movsd  %xmm2,(%rsi,%r12,8)
mov    0x58(%rsp),%rsi
mov    %r11,(%rsi,%r12,8)
mov    -0x8(%rsp),%rsi
mov    %r11,(%rsi,%r12,8)
cmpl   $0x0,-0x1c(%rsp)
jle    1170 <burgersDiagonalVelEvaluate+0x70>
mov    %r9d,%r10d
xor    %r8d,%r8d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %r10d,%r10
movsd  %xmm0,(%r14,%r10,8)
movsd  (%rcx,%r12,8),%xmm2
movsd  (%rdx,%r8,8),%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm3,(%rax,%r8,8)
movsd  (%rdx,%r8,8),%xmm2
mulsd  (%rcx,%r12,8),%xmm2
movsd  %xmm2,(%rbx,%r8,8)
add    $0x1,%r8
add    %ebp,%r10d
cmp    %r8,%rdi
jne    11d0 <burgersDiagonalVelEvaluate+0xd0>
jmp    1170 <burgersDiagonalVelEvaluate+0x70>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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