#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double sqrt(double);
void calculateEddyViscosity_Smagorinsky_2D(const int nElements_global,
                                           const int nQuadraturePoints_element,
                                           const double smagorinskyConstant,
                                           const double *h_e,
                                           const double *grad_u,
                                           const double *grad_v, double *nu_t) {
  int eN, k;
  const int nSpace = 2;
  double norm_S2, norm_S;
  for (eN = 0; eN < nElements_global; eN++) {
    for (k = 0; k < nQuadraturePoints_element; k++) {
      norm_S2 =
          grad_u[eN * nQuadraturePoints_element * nSpace + k * nSpace + 0] *
              grad_u[eN * nQuadraturePoints_element * nSpace + k * nSpace + 0] +
          grad_v[eN * nQuadraturePoints_element * nSpace + k * nSpace + 1] *
              grad_v[eN * nQuadraturePoints_element * nSpace + k * nSpace + 1] +
          0.5 *
              (grad_u[eN * nQuadraturePoints_element * nSpace + k * nSpace +
                      1] +
               grad_v[eN * nQuadraturePoints_element * nSpace + k * nSpace +
                      0]) *
              (grad_u[eN * nQuadraturePoints_element * nSpace + k * nSpace +
                      1] +
               grad_v[eN * nQuadraturePoints_element * nSpace + k * nSpace +
                      0]);
      norm_S = sqrt(2.0 * norm_S2);
      nu_t[eN * nQuadraturePoints_element + k] = smagorinskyConstant *
                                                 smagorinskyConstant * h_e[eN] *
                                                 h_e[eN] * norm_S;
    }
  }
}


x86 assembly (clang, -O0):
<calculateEddyViscosity_Smagorinsky_2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x2,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1300 <calculateEddyViscosity_Smagorinsky_2D+0x1f0>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ed <calculateEddyViscosity_Smagorinsky_2D+0x1dd>
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm2
movsd  0xdd2(%rip),%xmm0
mulsd  %xmm2,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd6f(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x30(%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    1154 <calculateEddyViscosity_Smagorinsky_2D+0x44>
jmp    12f2 <calculateEddyViscosity_Smagorinsky_2D+0x1e2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1141 <calculateEddyViscosity_Smagorinsky_2D+0x31>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculateEddyViscosity_Smagorinsky_2D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
test   %edi,%edi
jle    1275 <calculateEddyViscosity_Smagorinsky_2D+0x165>
mov    %r9,%r13
mov    %rcx,%rbx
mov    %rdx,%r15
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
mov    %edi,%eax
mov    %rax,0x20(%rsp)
mov    %esi,%eax
mov    %rax,0x18(%rsp)
lea    (%rsi,%rsi,1),%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
movl   $0x1,0x4(%rsp)
movsd  0xe9d(%rip),%xmm4
xorpd  %xmm5,%xmm5
xor    %edi,%edi
mov    %r8,0x38(%rsp)
movsd  %xmm3,0x30(%rsp)
mov    %rsi,0x28(%rsp)
jmp    11ac <calculateEddyViscosity_Smagorinsky_2D+0x9c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rdi
mov    0x28(%rsp),%rsi
mov    0x8(%rsp),%rax
add    %esi,%eax
mov    %rax,0x8(%rsp)
mov    0x4(%rsp),%eax
add    0x14(%rsp),%eax
mov    %eax,0x4(%rsp)
cmp    0x20(%rsp),%rdi
je     1275 <calculateEddyViscosity_Smagorinsky_2D+0x165>
test   %esi,%esi
jle    1180 <calculateEddyViscosity_Smagorinsky_2D+0x70>
mov    0x18(%rsp),%rbp
mov    0x4(%rsp),%eax
mov    %eax,%r14d
mov    0x8(%rsp),%r12
mov    %rdi,0x40(%rsp)
jmp    1223 <calculateEddyViscosity_Smagorinsky_2D+0x113>
nopl   0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
mov    0x40(%rsp),%rdi
xorpd  %xmm5,%xmm5
movsd  0xe1a(%rip),%xmm4
movsd  0x30(%rsp),%xmm3
mov    0x38(%rsp),%r8
movsd  (%r15,%rdi,8),%xmm1
movapd %xmm3,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
movslq %r12d,%r12
movsd  %xmm2,0x0(%r13,%r12,8)
add    $0x1,%r12d
add    $0x2,%r14d
add    $0xffffffffffffffff,%rbp
je     1180 <calculateEddyViscosity_Smagorinsky_2D+0x70>
lea    -0x1(%r14),%eax
cltq
movsd  (%rbx,%rax,8),%xmm1
movslq %r14d,%rsi
movsd  (%r8,%rsi,8),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  (%rbx,%rsi,8),%xmm2
addsd  (%r8,%rax,8),%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm4,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
ucomisd %xmm5,%xmm0
jb     11d0 <calculateEddyViscosity_Smagorinsky_2D+0xc0>
sqrtsd %xmm0,%xmm0
jmp    11f1 <calculateEddyViscosity_Smagorinsky_2D+0xe1>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @calculateEddyViscosity_Smagorinsky_2D(i32 %0, i32 %1, double %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double* nocapture writeonly %6) {
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %54
9: ; preds = %7
%10 = icmp sgt i32 %1, 0
%11 = fmul double %2, %2
%12 = zext i32 %0 to i64
%13 = zext i32 %1 to i64
br label %14
14: ; preds = %9, %51
%15 = phi i64 [ 0, %9 ], [ %52, %51 ]
br i1 %10, label %16, label %51
16: ; preds = %14
%17 = trunc i64 %15 to i32
%18 = mul nsw i32 %17, %1
%19 = getelementptr inbounds double, double* %3, i64 %15
br label %20
20: ; preds = %16, %20
%21 = phi i64 [ 0, %16 ], [ %49, %20 ]
%22 = trunc i64 %21 to i32
%23 = add i32 %18, %22
%24 = shl i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %4, i64 %25
%27 = load double, double* %26
%28 = or i32 %24, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %5, i64 %29
%31 = load double, double* %30
%32 = fmul double %31, %31
%33 = tail call double @llvm.fmuladd.f64(double %27, double %27, double %32)
%34 = getelementptr inbounds double, double* %4, i64 %29
%35 = load double, double* %34
%36 = getelementptr inbounds double, double* %5, i64 %25
%37 = load double, double* %36
%38 = fadd double %35, %37
%39 = fmul double %38, 5.000000e-01
%40 = tail call double @llvm.fmuladd.f64(double %39, double %38, double %33)
%41 = fmul double %40, 2.000000e+00
%42 = tail call double @sqrt(double %41)
%43 = load double, double* %19
%44 = fmul double %11, %43
%45 = fmul double %43, %44
%46 = fmul double %42, %45
%47 = sext i32 %23 to i64
%48 = getelementptr inbounds double, double* %6, i64 %47
store double %46, double* %48
%49 = add nuw nsw i64 %21, 1
%50 = icmp eq i64 %49, %13
br i1 %50, label %51, label %20
51: ; preds = %20, %14
%52 = add nuw nsw i64 %15, 1
%53 = icmp eq i64 %52, %12
br i1 %53, label %54, label %14
54: ; preds = %51, %7
ret void
}