void ncLevelSetCoefficientsEvaluate(int nPoints, int nSpace, double *v,
                                    double *u, double *grad_u, double *m,
                                    double *dm, double *H, double *dH) {
  int i, I;
  for (i = 0; i < nPoints; i++) {
    m[i] = u[i];
    dm[i] = 1.0;
    H[i] = 0.0;
    for (I = 0; I < nSpace; I++) {
      H[i] += v[i * nSpace + I] * grad_u[i * nSpace + I];
      dH[i * nSpace + I] = v[i * nSpace + I];
    }
  }
}


x86 assembly (clang, -O0):
<ncLevelSetCoefficientsEvaluate>:
push   %rbp
mov    %rsp,%rbp
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,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121e <ncLevelSetCoefficientsEvaluate+0x11e>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xe9d(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120b <ncLevelSetCoefficientsEvaluate+0x10b>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    117f <ncLevelSetCoefficientsEvaluate+0x7f>
jmp    1210 <ncLevelSetCoefficientsEvaluate+0x110>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    112d <ncLevelSetCoefficientsEvaluate+0x2d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<ncLevelSetCoefficientsEvaluate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,-0x8(%rsp)
mov    %r8,-0x30(%rsp)
test   %edi,%edi
jle    12ba <ncLevelSetCoefficientsEvaluate+0x1ba>
mov    0x48(%rsp),%r12
mov    0x40(%rsp),%r13
movslq %esi,%rax
mov    %edi,%edi
mov    %rdi,-0x10(%rsp)
mov    %eax,%r14d
add    $0xffffffffffffffff,%r14
lea    0x8(%r12),%r8
mov    %rax,-0x18(%rsp)
lea    0x0(,%rax,8),%r9
mov    -0x30(%rsp),%rax
lea    0x8(%rax),%rdi
lea    0x8(%rdx),%rbp
mov    %r14,-0x28(%rsp)
and    $0xfffffffffffffffe,%r14
neg    %r14
xor    %r11d,%r11d
xorpd  %xmm0,%xmm0
mov    %rdx,-0x20(%rsp)
movabs $0x3ff0000000000000,%rbx
jmp    1198 <ncLevelSetCoefficientsEvaluate+0x98>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r11
add    %r9,%r8
add    %r9,%rdi
add    %r9,%rbp
cmp    -0x10(%rsp),%r11
je     12ba <ncLevelSetCoefficientsEvaluate+0x1ba>
movsd  (%rcx,%r11,8),%xmm1
mov    -0x8(%rsp),%rax
movsd  %xmm1,(%rax,%r11,8)
mov    0x38(%rsp),%rax
mov    %rbx,(%rax,%r11,8)
movq   $0x0,0x0(%r13,%r11,8)
test   %esi,%esi
jle    1180 <ncLevelSetCoefficientsEvaluate+0x80>
mov    %r11,%r10
imul   -0x18(%rsp),%r10
movsd  (%rdx,%r10,8),%xmm1
mov    -0x30(%rsp),%rax
mulsd  (%rax,%r10,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%r11,8)
movsd  (%rdx,%r10,8),%xmm1
movsd  %xmm1,(%r12,%r10,8)
cmp    $0x1,%esi
je     1180 <ncLevelSetCoefficientsEvaluate+0x80>
mov    %r12,%rdx
mov    $0x1,%r15d
cmp    $0x2,%esi
je     1274 <ncLevelSetCoefficientsEvaluate+0x174>
mov    $0x1,%r15d
nopl   0x0(%rax)
movsd  -0x8(%rbp,%r15,8),%xmm1
mulsd  -0x8(%rdi,%r15,8),%xmm1
addsd  0x0(%r13,%r11,8),%xmm1
movsd  %xmm1,0x0(%r13,%r11,8)
movsd  -0x8(%rbp,%r15,8),%xmm1
movsd  %xmm1,-0x8(%r8,%r15,8)
movsd  0x0(%rbp,%r15,8),%xmm1
mulsd  (%rdi,%r15,8),%xmm1
addsd  0x0(%r13,%r11,8),%xmm1
movsd  %xmm1,0x0(%r13,%r11,8)
movsd  0x0(%rbp,%r15,8),%xmm1
movsd  %xmm1,(%r8,%r15,8)
lea    (%r14,%r15,1),%r12
add    $0x2,%r12
add    $0x2,%r15
cmp    $0x1,%r12
jne    1210 <ncLevelSetCoefficientsEvaluate+0x110>
testb  $0x1,-0x28(%rsp)
mov    %rdx,%r12
mov    -0x20(%rsp),%rdx
je     1180 <ncLevelSetCoefficientsEvaluate+0x80>
add    %r10,%r15
movsd  (%rdx,%r15,8),%xmm1
mov    -0x30(%rsp),%rax
mulsd  (%rax,%r15,8),%xmm1
addsd  0x0(%r13,%r11,8),%xmm1
movsd  %xmm1,0x0(%r13,%r11,8)
movsd  (%rdx,%r15,8),%xmm1
movsd  %xmm1,(%r12,%r15,8)
jmp    1180 <ncLevelSetCoefficientsEvaluate+0x80>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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