void ReynoldsAveragedNavierStokes_kEpsilon_2D_Update(
    const int nPoints, const double nu, const double c_mu, const double *k,
    const double *grad_k, const double *epsilon, double *mom_u_diff_ten,
    double *mom_v_diff_ten, double *mom_uv_diff_ten, double *mom_vu_diff_ten,
    double *mom_u_source, double *mom_v_source) {
  int i;
  double nu_t, eval, kval;
  const double twoThirds = 2.0 / 3.0;
  const double div_zero = 1.0e-6;
  for (i = 0; i < nPoints; i++) {
    eval = epsilon[i] >= 0.0 ? epsilon[i] : 0.0;
    kval = k[i] >= 0.0 ? k[i] : 0.0;
    nu_t = c_mu * kval * kval / (eval + div_zero);
    mom_u_diff_ten[i * 4 + 0] += 2.0 * nu_t;
    mom_u_diff_ten[i * 4 + 3] += nu_t;
    mom_uv_diff_ten[i * 4 + 2] += nu_t;
    mom_v_diff_ten[i * 4 + 0] += nu_t;
    mom_v_diff_ten[i * 4 + 3] += 2.0 * nu_t;
    mom_vu_diff_ten[i * 4 + 1] += nu_t;
    mom_u_source[i] += twoThirds * grad_k[i * 2 + 0];
    mom_v_source[i] += twoThirds * grad_k[i * 2 + 1];
  }
}


x86 assembly (clang, -O0):
<ReynoldsAveragedNavierStokes_kEpsilon_2D_Update>:
push   %rbp
mov    %rsp,%rbp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    135d <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0x25d>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1193 <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0x93>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    11a0 <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0xa0>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    11a0 <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0xa0>
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11db <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0xdb>
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    11e8 <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0xe8>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    11e8 <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0xe8>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  0xdf7(%rip),%xmm1
addsd  -0x58(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    0x18(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  0xcfd(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  0xcc6(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1156 <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0x56>
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReynoldsAveragedNavierStokes_kEpsilon_2D_Update>:
push   %r14
push   %rbx
test   %edi,%edi
jle    1216 <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0x116>
mov    0x30(%rsp),%r10
mov    0x28(%rsp),%r11
mov    0x20(%rsp),%r14
mov    0x18(%rsp),%rbx
mov    %edi,%edi
shl    $0x3,%rdi
xor    %eax,%eax
movsd  0xed1(%rip),%xmm0
movsd  0xed1(%rip),%xmm2
nopw   0x0(%rax,%rax,1)
movsd  (%rcx,%rax,1),%xmm3
xorpd  %xmm4,%xmm4
cmplesd %xmm3,%xmm4
andpd  %xmm3,%xmm4
movsd  (%rsi,%rax,1),%xmm3
xorpd  %xmm5,%xmm5
cmplesd %xmm3,%xmm5
andpd  %xmm3,%xmm5
movapd %xmm5,%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm5,%xmm3
addsd  %xmm0,%xmm4
divsd  %xmm4,%xmm3
movapd %xmm3,%xmm4
addsd  %xmm3,%xmm4
movsd  (%r8,%rax,4),%xmm5
addsd  %xmm4,%xmm5
movsd  %xmm5,(%r8,%rax,4)
movsd  0x18(%r8,%rax,4),%xmm5
addsd  %xmm3,%xmm5
movsd  %xmm5,0x18(%r8,%rax,4)
movsd  0x10(%rbx,%rax,4),%xmm5
addsd  %xmm3,%xmm5
movsd  %xmm5,0x10(%rbx,%rax,4)
movsd  (%r9,%rax,4),%xmm5
addsd  %xmm3,%xmm5
movsd  %xmm5,(%r9,%rax,4)
addsd  0x18(%r9,%rax,4),%xmm4
movsd  %xmm4,0x18(%r9,%rax,4)
addsd  0x8(%r14,%rax,4),%xmm3
movsd  %xmm3,0x8(%r14,%rax,4)
movsd  (%rdx,%rax,2),%xmm3
mulsd  %xmm2,%xmm3
addsd  (%r11,%rax,1),%xmm3
movsd  %xmm3,(%r11,%rax,1)
movsd  0x8(%rdx,%rax,2),%xmm3
mulsd  %xmm2,%xmm3
addsd  (%r10,%rax,1),%xmm3
movsd  %xmm3,(%r10,%rax,1)
add    $0x8,%rax
cmp    %rax,%rdi
jne    1140 <ReynoldsAveragedNavierStokes_kEpsilon_2D_Update+0x40>
pop    %rbx
pop    %r14
ret

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

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