void twophaseLevelSetCoefficientsEvaluate(int nPoints, int nSpace, double *B,
                                          double t, double *x, double *u,
                                          double *grad_u, double *m, double *dm,
                                          double *h, double *dh, double *rh) {
  int i, I;
  for (i = 0; i < nPoints; i++) {
    rh[i] = 0.0;
    h[i] = 0.0;
    m[i] = u[i];
    dm[i] = 1.0;
    for (I = 0; I < nSpace; I++) {
      h[i] += B[i * nSpace + I] * grad_u[i * nSpace + I];
      dh[i * nSpace + I] = B[i * nSpace + I];
    }
  }
}


x86 assembly (clang, -O0):
<twophaseLevelSetCoefficientsEvaluate>:
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)
mov    %rdx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    123b <twophaseLevelSetCoefficientsEvaluate+0x13b>
mov    0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%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  0xe70(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1228 <twophaseLevelSetCoefficientsEvaluate+0x128>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x28(%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    119c <twophaseLevelSetCoefficientsEvaluate+0x9c>
jmp    122d <twophaseLevelSetCoefficientsEvaluate+0x12d>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    113a <twophaseLevelSetCoefficientsEvaluate+0x3a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<twophaseLevelSetCoefficientsEvaluate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,-0x18(%rsp)
mov    %rdx,-0x20(%rsp)
test   %edi,%edi
jle    128a <twophaseLevelSetCoefficientsEvaluate+0x18a>
mov    0x50(%rsp),%rbp
mov    0x48(%rsp),%rcx
mov    0x40(%rsp),%r14
mov    0x38(%rsp),%r13
movslq %esi,%rdx
mov    %edi,%r11d
mov    %edx,%eax
mov    %rax,-0x8(%rsp)
and    $0xfffffffe,%eax
lea    0x8(%rbp),%rbx
mov    %rdx,-0x10(%rsp)
lea    0x0(,%rdx,8),%rbp
mov    -0x18(%rsp),%rdi
lea    0x8(%rdi),%r10
mov    %r14,%rdi
mov    -0x20(%rsp),%rdx
lea    0x8(%rdx),%r14
xor    %r12d,%r12d
mov    %esi,-0x24(%rsp)
jmp    1186 <twophaseLevelSetCoefficientsEvaluate+0x86>
nop
add    $0x1,%r12
add    %rbp,%rbx
add    %rbp,%r10
add    %rbp,%r14
cmp    %r11,%r12
je     128a <twophaseLevelSetCoefficientsEvaluate+0x18a>
mov    0x58(%rsp),%rdx
movq   $0x0,(%rdx,%r12,8)
movq   $0x0,(%rcx,%r12,8)
movsd  (%r8,%r12,8),%xmm0
movsd  %xmm0,0x0(%r13,%r12,8)
movabs $0x3ff0000000000000,%rdx
mov    %rdx,(%rdi,%r12,8)
test   %esi,%esi
jle    1170 <twophaseLevelSetCoefficientsEvaluate+0x70>
xor    %r15d,%r15d
cmp    $0x1,%esi
je     1225 <twophaseLevelSetCoefficientsEvaluate+0x125>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  -0x8(%r14,%r15,8),%xmm0
mulsd  -0x8(%r10,%r15,8),%xmm0
addsd  (%rcx,%r12,8),%xmm0
movsd  %xmm0,(%rcx,%r12,8)
movsd  -0x8(%r14,%r15,8),%xmm0
movsd  %xmm0,-0x8(%rbx,%r15,8)
movsd  (%r14,%r15,8),%xmm0
mulsd  (%r10,%r15,8),%xmm0
addsd  (%rcx,%r12,8),%xmm0
movsd  %xmm0,(%rcx,%r12,8)
movsd  (%r14,%r15,8),%xmm0
movsd  %xmm0,(%rbx,%r15,8)
add    $0x2,%r15
cmp    %r15,%rax
jne    11d0 <twophaseLevelSetCoefficientsEvaluate+0xd0>
testb  $0x1,-0x8(%rsp)
je     1170 <twophaseLevelSetCoefficientsEvaluate+0x70>
mov    %r11,%rsi
mov    %r13,%r11
mov    %rdi,%r13
mov    %r12,%r9
imul   -0x10(%rsp),%r9
add    %r9,%r15
mov    -0x20(%rsp),%rdx
movsd  (%rdx,%r15,8),%xmm0
mov    -0x18(%rsp),%rdi
mulsd  (%rdi,%r15,8),%xmm0
addsd  (%rcx,%r12,8),%xmm0
movsd  %xmm0,(%rcx,%r12,8)
movsd  (%rdx,%r15,8),%xmm0
mov    0x50(%rsp),%rdi
movsd  %xmm0,(%rdi,%r15,8)
mov    %r13,%rdi
mov    %r11,%r13
mov    %rsi,%r11
mov    -0x24(%rsp),%esi
jmp    1170 <twophaseLevelSetCoefficientsEvaluate+0x70>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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