void StokesP_2D_Evaluate(const int nPoints, const double rho, const double nu,
                         const double *g, const double *p, const double *u,
                         const double *v, double *mom_u_acc,
                         double *dmom_u_acc_u, double *mom_v_acc,
                         double *dmom_v_acc_v, double *mass_adv,
                         double *dmass_adv_u, double *dmass_adv_v,
                         double *mom_u_adv, double *dmom_u_adv_p,
                         double *mom_v_adv, double *dmom_v_adv_p,
                         double *mom_u_diff_ten, double *mom_v_diff_ten,
                         double *mom_u_source, double *mom_v_source) {
  int k;
  for (k = 0; k < nPoints; k++) {
    mom_u_acc[k] = u[k];
    dmom_u_acc_u[k] = 1.0;
    mom_v_acc[k] = v[k];
    dmom_v_acc_v[k] = 1.0;
    mass_adv[k * 2 + 0] = u[k];
    mass_adv[k * 2 + 1] = v[k];
    dmass_adv_u[k * 2 + 0] = 1.0;
    dmass_adv_v[k * 2 + 1] = 1.0;
    mom_u_adv[k * 2 + 0] = p[k] / rho;
    dmom_u_adv_p[k * 2 + 0] = 1.0 / rho;
    mom_v_adv[k * 2 + 1] = p[k] / rho;
    dmom_v_adv_p[k * 2 + 1] = 1.0 / rho;
    mom_u_diff_ten[k * 4 + 0] = nu;
    mom_u_diff_ten[k * 4 + 3] = nu;
    mom_v_diff_ten[k * 4 + 0] = nu;
    mom_v_diff_ten[k * 4 + 3] = nu;
    mom_u_source[k] = -g[0];
    mom_v_source[k] = -g[1];
  }
}


x86 assembly (clang, -O0):
<StokesP_2D_Evaluate>:
push   %rbp
mov    %rsp,%rbp
mov    0x78(%rbp),%rax
mov    0x70(%rbp),%rax
mov    0x68(%rbp),%rax
mov    0x60(%rbp),%rax
mov    0x58(%rbp),%rax
mov    0x50(%rbp),%rax
mov    0x48(%rbp),%rax
mov    0x40(%rbp),%rax
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)
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)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13ad <StokesP_2D_Evaluate+0x2ad>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0xe66(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0xe37(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x28(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x28(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x30(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  0xdd6(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xdb9(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    0x40(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xd85(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    0x48(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    0x50(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xd3c(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    0x58(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
mov    0x60(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
mov    0x60(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
mov    0x68(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
mov    0x68(%rbp),%rax
mov    -0x44(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    0x70(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    0x78(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1164 <StokesP_2D_Evaluate+0x64>
pop    %rbp
ret

x86 assembly (clang, -O2):
<StokesP_2D_Evaluate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
jle    1254 <StokesP_2D_Evaluate+0x154>
mov    %edi,%eax
mov    0x90(%rsp),%r14
mov    0x88(%rsp),%rbx
mov    0x50(%rsp),%rdi
mov    0x38(%rsp),%r15
movsd  0xeca(%rip),%xmm2
divsd  %xmm0,%xmm2
mov    %eax,%r12d
shl    $0x2,%r12
movaps 0xec8(%rip),%xmm3
xor    %r13d,%r13d
movabs $0x3ff0000000000000,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rcx,%r13,2),%xmm4
movsd  %xmm4,(%r9,%r13,2)
mov    %rbp,(%r15,%r13,2)
movsd  (%r8,%r13,2),%xmm4
mov    0x40(%rsp),%rax
movsd  %xmm4,(%rax,%r13,2)
mov    0x48(%rsp),%rax
mov    %rbp,(%rax,%r13,2)
movsd  (%rcx,%r13,2),%xmm4
movsd  %xmm4,(%rdi,%r13,4)
movsd  (%r8,%r13,2),%xmm4
movsd  %xmm4,0x8(%rdi,%r13,4)
mov    0x58(%rsp),%rax
mov    %rbp,(%rax,%r13,4)
mov    0x60(%rsp),%rax
mov    %rbp,0x8(%rax,%r13,4)
movsd  (%rdx,%r13,2),%xmm4
divsd  %xmm0,%xmm4
mov    0x68(%rsp),%rax
movsd  %xmm4,(%rax,%r13,4)
mov    0x70(%rsp),%rax
movsd  %xmm2,(%rax,%r13,4)
movsd  (%rdx,%r13,2),%xmm4
divsd  %xmm0,%xmm4
mov    0x78(%rsp),%rax
movsd  %xmm4,0x8(%rax,%r13,4)
mov    0x80(%rsp),%rax
movsd  %xmm2,0x8(%rax,%r13,4)
mov    %r13d,%r10d
shl    $0x3,%r10
movsd  %xmm1,(%rbx,%r10,1)
lea    0x3(%r13),%r11d
movsd  %xmm1,(%rbx,%r11,8)
movsd  %xmm1,(%r14,%r10,1)
movsd  %xmm1,(%r14,%r11,8)
movsd  (%rsi),%xmm4
xorps  %xmm3,%xmm4
mov    0x98(%rsp),%rax
movlps %xmm4,(%rax,%r13,2)
movsd  0x8(%rsi),%xmm4
xorps  %xmm3,%xmm4
mov    0xa0(%rsp),%rax
movlps %xmm4,(%rax,%r13,2)
add    $0x4,%r13
cmp    %r13,%r12
jne    1160 <StokesP_2D_Evaluate+0x60>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @StokesP_2D_Evaluate(i32 %0, double %1, double %2, double* %3, double* %4, double* %5, double* %6, double* %7, double* %8, double* %9, double* %10, double* %11, double* %12, double* %13, double* %14, double* %15, double* %16, double* %17, double* %18, double* %19, double* %20, double* %21) {
%23 = alloca i32
%24 = alloca double
%25 = alloca double
%26 = alloca double*
%27 = alloca double*
%28 = alloca double*
%29 = alloca double*
%30 = alloca double*
%31 = alloca double*
%32 = alloca double*
%33 = alloca double*
%34 = alloca double*
%35 = alloca double*
%36 = alloca double*
%37 = alloca double*
%38 = alloca double*
%39 = alloca double*
%40 = alloca double*
%41 = alloca double*
%42 = alloca double*
%43 = alloca double*
%44 = alloca double*
%45 = alloca i32
store i32 %0, i32* %23
store double %1, double* %24
store double %2, double* %25
store double* %3, double** %26
store double* %4, double** %27
store double* %5, double** %28
store double* %6, double** %29
store double* %7, double** %30
store double* %8, double** %31
store double* %9, double** %32
store double* %10, double** %33
store double* %11, double** %34
store double* %12, double** %35
store double* %13, double** %36
store double* %14, double** %37
store double* %15, double** %38
store double* %16, double** %39
store double* %17, double** %40
store double* %18, double** %41
store double* %19, double** %42
store double* %20, double** %43
store double* %21, double** %44
store i32 0, i32* %45
br label %46
46: ; preds = %197, %22
%47 = load i32, i32* %45
%48 = load i32, i32* %23
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %200
50: ; preds = %46
%51 = load double*, double** %28
%52 = load i32, i32* %45
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load double*, double** %30
%57 = load i32, i32* %45
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
store double %55, double* %59
%60 = load double*, double** %31
%61 = load i32, i32* %45
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
store double 1.000000e+00, double* %63
%64 = load double*, double** %29
%65 = load i32, i32* %45
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = load double*, double** %32
%70 = load i32, i32* %45
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
store double %68, double* %72
%73 = load double*, double** %33
%74 = load i32, i32* %45
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
store double 1.000000e+00, double* %76
%77 = load double*, double** %28
%78 = load i32, i32* %45
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = load double*, double** %34
%83 = load i32, i32* %45
%84 = mul nsw i32 %83, 2
%85 = add nsw i32 %84, 0
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %82, i64 %86
store double %81, double* %87
%88 = load double*, double** %29
%89 = load i32, i32* %45
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
%92 = load double, double* %91
%93 = load double*, double** %34
%94 = load i32, i32* %45
%95 = mul nsw i32 %94, 2
%96 = add nsw i32 %95, 1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %93, i64 %97
store double %92, double* %98
%99 = load double*, double** %35
%100 = load i32, i32* %45
%101 = mul nsw i32 %100, 2
%102 = add nsw i32 %101, 0
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %99, i64 %103
store double 1.000000e+00, double* %104
%105 = load double*, double** %36
%106 = load i32, i32* %45
%107 = mul nsw i32 %106, 2
%108 = add nsw i32 %107, 1
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds double, double* %105, i64 %109
store double 1.000000e+00, double* %110
%111 = load double*, double** %27
%112 = load i32, i32* %45
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
%115 = load double, double* %114
%116 = load double, double* %24
%117 = fdiv double %115, %116
%118 = load double*, double** %37
%119 = load i32, i32* %45
%120 = mul nsw i32 %119, 2
%121 = add nsw i32 %120, 0
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %118, i64 %122
store double %117, double* %123
%124 = load double, double* %24
%125 = fdiv double 1.000000e+00, %124
%126 = load double*, double** %38
%127 = load i32, i32* %45
%128 = mul nsw i32 %127, 2
%129 = add nsw i32 %128, 0
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds double, double* %126, i64 %130
store double %125, double* %131
%132 = load double*, double** %27
%133 = load i32, i32* %45
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double, double* %132, i64 %134
%136 = load double, double* %135
%137 = load double, double* %24
%138 = fdiv double %136, %137
%139 = load double*, double** %39
%140 = load i32, i32* %45
%141 = mul nsw i32 %140, 2
%142 = add nsw i32 %141, 1
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds double, double* %139, i64 %143
store double %138, double* %144
%145 = load double, double* %24
%146 = fdiv double 1.000000e+00, %145
%147 = load double*, double** %40
%148 = load i32, i32* %45
%149 = mul nsw i32 %148, 2
%150 = add nsw i32 %149, 1
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds double, double* %147, i64 %151
store double %146, double* %152
%153 = load double, double* %25
%154 = load double*, double** %41
%155 = load i32, i32* %45
%156 = mul nsw i32 %155, 4
%157 = add nsw i32 %156, 0
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %154, i64 %158
store double %153, double* %159
%160 = load double, double* %25
%161 = load double*, double** %41
%162 = load i32, i32* %45
%163 = mul nsw i32 %162, 4
%164 = add nsw i32 %163, 3
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds double, double* %161, i64 %165
store double %160, double* %166
%167 = load double, double* %25
%168 = load double*, double** %42
%169 = load i32, i32* %45
%170 = mul nsw i32 %169, 4
%171 = add nsw i32 %170, 0
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds double, double* %168, i64 %172
store double %167, double* %173
%174 = load double, double* %25
%175 = load double*, double** %42
%176 = load i32, i32* %45
%177 = mul nsw i32 %176, 4
%178 = add nsw i32 %177, 3
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds double, double* %175, i64 %179
store double %174, double* %180
%181 = load double*, double** %26
%182 = getelementptr inbounds double, double* %181, i64 0
%183 = load double, double* %182
%184 = fneg double %183
%185 = load double*, double** %43
%186 = load i32, i32* %45
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds double, double* %185, i64 %187
store double %184, double* %188
%189 = load double*, double** %26
%190 = getelementptr inbounds double, double* %189, i64 1
%191 = load double, double* %190
%192 = fneg double %191
%193 = load double*, double** %44
%194 = load i32, i32* %45
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds double, double* %193, i64 %195
store double %192, double* %196
br label %197
197: ; preds = %50
%198 = load i32, i32* %45
%199 = add nsw i32 %198, 1
store i32 %199, i32* %45
br label %46
200: ; preds = %46
ret void
}

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