void constantVelocityLevelSetEvaluate(const int nPoints, const int nSpace,
                                      const double *b, const double *x,
                                      const double *u, const double *gradu,
                                      double *m, double *dm, double *f,
                                      double *df, double *H, double *dH) {
  double bdotgrad;
  int k, id;
  for (k = 0; k < nPoints; k++) {
    m[k] = u[k];
    dm[k] = 1.0;
    bdotgrad = 0.0;
    for (id = 0; id < nSpace; id++) {
      f[k * nSpace + id] = 0.0;
      df[k * nSpace + id] = 0.0;
      bdotgrad += gradu[k * nSpace + id] * b[id];
      dH[k * nSpace + id] = b[id];
    }
    H[k] = bdotgrad;
  }
}


x86 assembly (clang, -O0):
<constantVelocityLevelSetEvaluate>:
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)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1247 <constantVelocityLevelSetEvaluate+0x147>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  0xe91(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1227 <constantVelocityLevelSetEvaluate+0x127>
mov    0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x38(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1183 <constantVelocityLevelSetEvaluate+0x83>
movsd  -0x30(%rbp),%xmm0
mov    0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1139 <constantVelocityLevelSetEvaluate+0x39>
pop    %rbp
ret

x86 assembly (clang, -O2):
<constantVelocityLevelSetEvaluate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,-0x20(%rsp)
test   %edi,%edi
jle    1298 <constantVelocityLevelSetEvaluate+0x198>
mov    %esi,%ebx
mov    0x60(%rsp),%rax
mov    0x50(%rsp),%r9
mov    0x48(%rsp),%r15
mov    0x40(%rsp),%r14
mov    0x38(%rsp),%r12
movslq %esi,%rsi
mov    %edi,%edi
mov    %esi,%ecx
mov    %rcx,-0x8(%rsp)
and    $0xfffffffe,%ecx
lea    0x8(%rax),%rbp
mov    %rsi,-0x18(%rsp)
lea    0x0(,%rsi,8),%r10
mov    -0x20(%rsp),%rax
lea    0x8(%rax),%r11
mov    %r14,%rax
lea    0x8(%r9),%r14
add    $0x8,%r15
xor    %r9d,%r9d
mov    %r8,-0x10(%rsp)
jmp    1194 <constantVelocityLevelSetEvaluate+0x94>
mov    0x58(%rsp),%rsi
movsd  %xmm0,(%rsi,%r9,8)
add    $0x1,%r9
add    %r10,%rbp
add    %r10,%r11
add    %r10,%r14
add    %r10,%r15
cmp    %rdi,%r9
je     1298 <constantVelocityLevelSetEvaluate+0x198>
movsd  (%r8,%r9,8),%xmm0
movsd  %xmm0,(%r12,%r9,8)
movabs $0x3ff0000000000000,%rsi
mov    %rsi,(%rax,%r9,8)
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
jle    1170 <constantVelocityLevelSetEvaluate+0x70>
xor    %r13d,%r13d
cmp    $0x1,%ebx
je     1223 <constantVelocityLevelSetEvaluate+0x123>
xchg   %ax,%ax
movq   $0x0,-0x8(%r15,%r13,8)
movq   $0x0,-0x8(%r14,%r13,8)
movsd  (%rdx,%r13,8),%xmm1
movsd  -0x8(%r11,%r13,8),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm1,-0x8(%rbp,%r13,8)
movq   $0x0,(%r15,%r13,8)
movq   $0x0,(%r14,%r13,8)
movsd  0x8(%rdx,%r13,8),%xmm1
movsd  (%r11,%r13,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm1,0x0(%rbp,%r13,8)
add    $0x2,%r13
cmp    %r13,%rcx
jne    11c0 <constantVelocityLevelSetEvaluate+0xc0>
testb  $0x1,-0x8(%rsp)
je     1170 <constantVelocityLevelSetEvaluate+0x70>
mov    %r12,%rsi
mov    %ebx,%r8d
mov    %rax,%r12
mov    %r9,%rax
imul   -0x18(%rsp),%rax
add    %r13,%rax
mov    %rdi,%rbx
mov    0x48(%rsp),%rdi
movq   $0x0,(%rdi,%rax,8)
mov    0x50(%rsp),%rdi
movq   $0x0,(%rdi,%rax,8)
mov    %rbx,%rdi
movsd  (%rdx,%r13,8),%xmm1
mov    -0x20(%rsp),%rbx
movsd  (%rbx,%rax,8),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
mov    0x60(%rsp),%rbx
movsd  %xmm1,(%rbx,%rax,8)
mov    %r12,%rax
mov    %r8d,%ebx
mov    %rsi,%r12
mov    -0x10(%rsp),%r8
jmp    1170 <constantVelocityLevelSetEvaluate+0x70>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @constantVelocityLevelSetEvaluate(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
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
store i32 0, i32* %26
br label %28
28: ; preds = %105, %12
%29 = load i32, i32* %26
%30 = load i32, i32* %13
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %108
32: ; preds = %28
%33 = load double*, double** %17
%34 = load i32, i32* %26
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %19
%39 = load i32, i32* %26
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
%42 = load double*, double** %20
%43 = load i32, i32* %26
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
store double 1.000000e+00, double* %45
store double 0.000000e+00, double* %25
store i32 0, i32* %27
br label %46
46: ; preds = %96, %32
%47 = load i32, i32* %27
%48 = load i32, i32* %14
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %99
50: ; preds = %46
%51 = load double*, double** %21
%52 = load i32, i32* %26
%53 = load i32, i32* %14
%54 = mul nsw i32 %52, %53
%55 = load i32, i32* %27
%56 = add nsw i32 %54, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %51, i64 %57
store double 0.000000e+00, double* %58
%59 = load double*, double** %22
%60 = load i32, i32* %26
%61 = load i32, i32* %14
%62 = mul nsw i32 %60, %61
%63 = load i32, i32* %27
%64 = add nsw i32 %62, %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %59, i64 %65
store double 0.000000e+00, double* %66
%67 = load double*, double** %18
%68 = load i32, i32* %26
%69 = load i32, i32* %14
%70 = mul nsw i32 %68, %69
%71 = load i32, i32* %27
%72 = add nsw i32 %70, %71
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %67, i64 %73
%75 = load double, double* %74
%76 = load double*, double** %15
%77 = load i32, i32* %27
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
%80 = load double, double* %79
%81 = load double, double* %25
%82 = call double @llvm.fmuladd.f64(double %75, double %80, double %81)
store double %82, double* %25
%83 = load double*, double** %15
%84 = load i32, i32* %27
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
%87 = load double, double* %86
%88 = load double*, double** %24
%89 = load i32, i32* %26
%90 = load i32, i32* %14
%91 = mul nsw i32 %89, %90
%92 = load i32, i32* %27
%93 = add nsw i32 %91, %92
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %88, i64 %94
store double %87, double* %95
br label %96
96: ; preds = %50
%97 = load i32, i32* %27
%98 = add nsw i32 %97, 1
store i32 %98, i32* %27
br label %46
99: ; preds = %46
%100 = load double, double* %25
%101 = load double*, double** %23
%102 = load i32, i32* %26
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %101, i64 %103
store double %100, double* %104
br label %105
105: ; preds = %99
%106 = load i32, i32* %26
%107 = add nsw i32 %106, 1
store i32 %107, i32* %26
br label %28
108: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @constantVelocityLevelSetEvaluate(i32 %0, i32 %1, double* nocapture %2, double* nocapture readnone %3, double* nocapture %4, double* nocapture %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 %76
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
%19 = and i64 %18, 1
%20 = icmp eq i32 %1, 1
%21 = and i64 %18, 4294967294
%22 = icmp eq i64 %19, 0
br label %23
23: ; preds = %14, %71
%24 = phi i64 [ 0, %14 ], [ %74, %71 ]
%25 = getelementptr inbounds double, double* %4, i64 %24
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %6, i64 %24
store double %26, double* %27
%28 = getelementptr inbounds double, double* %7, i64 %24
store double 1.000000e+00, double* %28
br i1 %15, label %29, label %71
29: ; preds = %23
%30 = mul nsw i64 %24, %16
br i1 %20, label %57, label %31
31: ; preds = %29, %31
%32 = phi i64 [ %54, %31 ], [ 0, %29 ]
%33 = phi double [ %52, %31 ], [ 0.000000e+00, %29 ]
%34 = phi i64 [ %55, %31 ], [ 0, %29 ]
%35 = add nsw i64 %32, %30
%36 = getelementptr inbounds double, double* %8, i64 %35
store double 0.000000e+00, double* %36
%37 = getelementptr inbounds double, double* %9, i64 %35
store double 0.000000e+00, double* %37
%38 = getelementptr inbounds double, double* %5, i64 %35
%39 = load double, double* %38
%40 = getelementptr inbounds double, double* %2, i64 %32
%41 = load double, double* %40
%42 = tail call double @llvm.fmuladd.f64(double %39, double %41, double %33)
%43 = getelementptr inbounds double, double* %11, i64 %35
store double %41, double* %43
%44 = or i64 %32, 1
%45 = add nsw i64 %44, %30
%46 = getelementptr inbounds double, double* %8, i64 %45
store double 0.000000e+00, double* %46
%47 = getelementptr inbounds double, double* %9, i64 %45
store double 0.000000e+00, double* %47
%48 = getelementptr inbounds double, double* %5, i64 %45
%49 = load double, double* %48
%50 = getelementptr inbounds double, double* %2, i64 %44
%51 = load double, double* %50
%52 = tail call double @llvm.fmuladd.f64(double %49, double %51, double %42)
%53 = getelementptr inbounds double, double* %11, i64 %45
store double %51, double* %53
%54 = add nuw nsw i64 %32, 2
%55 = add i64 %34, 2
%56 = icmp eq i64 %55, %21
br i1 %56, label %57, label %31
57: ; preds = %31, %29
%58 = phi double [ undef, %29 ], [ %52, %31 ]
%59 = phi i64 [ 0, %29 ], [ %54, %31 ]
%60 = phi double [ 0.000000e+00, %29 ], [ %52, %31 ]
br i1 %22, label %71, label %61
61: ; preds = %57
%62 = add nsw i64 %59, %30
%63 = getelementptr inbounds double, double* %8, i64 %62
store double 0.000000e+00, double* %63
%64 = getelementptr inbounds double, double* %9, i64 %62
store double 0.000000e+00, double* %64
%65 = getelementptr inbounds double, double* %5, i64 %62
%66 = load double, double* %65
%67 = getelementptr inbounds double, double* %2, i64 %59
%68 = load double, double* %67
%69 = tail call double @llvm.fmuladd.f64(double %66, double %68, double %60)
%70 = getelementptr inbounds double, double* %11, i64 %62
store double %68, double* %70
br label %71
71: ; preds = %61, %57, %23
%72 = phi double [ 0.000000e+00, %23 ], [ %58, %57 ], [ %69, %61 ]
%73 = getelementptr inbounds double, double* %10, i64 %24
store double %72, double* %73
%74 = add nuw nsw i64 %24, 1
%75 = icmp eq i64 %74, %17
br i1 %75, label %76, label %23
76: ; preds = %71, %12
ret void
}