#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 calculateSubgridErrorStokes2D_1_sd(
    int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element,
    int nSpace, double *elementDiameter, double *u, double *v, double *a,
    double *pdeResidualP, double *dpdeResidualP_du, double *dpdeResidualP_dv,
    double *pdeResidualU, double *dpdeResidualU_dp, double *dpdeResidualU_du,
    double *pdeResidualV, double *dpdeResidualV_dp, double *dpdeResidualV_dv,
    double *subgridErrorP, double *dsubgridErrorP_dp, double *dsubgridErrorP_du,
    double *dsubgridErrorP_dv, double *subgridErrorU, double *dsubgridErrorU_dp,
    double *dsubgridErrorU_du, double *dsubgridErrorU_dv, double *subgridErrorV,
    double *dsubgridErrorV_dp, double *dsubgridErrorV_du,
    double *dsubgridErrorV_dv) {
  int eN, k, j;
  double h, velocity_norm, viscosity, tau1, tau2, U, V;
  for (eN = 0; eN < nElements_global; eN++) {
    h = elementDiameter[eN];
    for (k = 0; k < nQuadraturePoints_element; k++) {
      U = u[eN * nQuadraturePoints_element + k];
      V = v[eN * nQuadraturePoints_element + k];
      velocity_norm = sqrt(U * U + V * V);
      viscosity = a[eN * nQuadraturePoints_element * nSpace + k * nSpace];
      tau1 =
          1.0 / (4.0 * viscosity / (h * h) + 2.0 * velocity_norm / h + 1.0e-8);
      tau2 = 4.0 * viscosity + 2.0 * velocity_norm * h;
      tau1 = h * h / (12.0 * viscosity);
      subgridErrorU[eN * nQuadraturePoints_element + k] =
          tau1 * pdeResidualU[eN * nQuadraturePoints_element + k];
      subgridErrorV[eN * nQuadraturePoints_element + k] =
          tau1 * pdeResidualV[eN * nQuadraturePoints_element + k];
      tau2 = 6.0 * viscosity;
      subgridErrorP[eN * nQuadraturePoints_element + k] =
          tau2 * pdeResidualP[eN * nQuadraturePoints_element + k];
      for (j = 0; j < nDOF_trial_element; j++) {
        dsubgridErrorU_dp[eN * nQuadraturePoints_element * nDOF_trial_element +
                          k * nDOF_trial_element + j] =
            tau1 * dpdeResidualU_dp[eN * nQuadraturePoints_element *
                                        nDOF_trial_element +
                                    k * nDOF_trial_element + j];
        dsubgridErrorU_du[eN * nQuadraturePoints_element * nDOF_trial_element +
                          k * nDOF_trial_element + j] =
            tau1 * dpdeResidualU_du[eN * nQuadraturePoints_element *
                                        nDOF_trial_element +
                                    k * nDOF_trial_element + j];
        dsubgridErrorV_dp[eN * nQuadraturePoints_element * nDOF_trial_element +
                          k * nDOF_trial_element + j] =
            tau1 * dpdeResidualV_dp[eN * nQuadraturePoints_element *
                                        nDOF_trial_element +
                                    k * nDOF_trial_element + j];
        dsubgridErrorV_dv[eN * nQuadraturePoints_element * nDOF_trial_element +
                          k * nDOF_trial_element + j] =
            tau1 * dpdeResidualV_dv[eN * nQuadraturePoints_element *
                                        nDOF_trial_element +
                                    k * nDOF_trial_element + j];
        dsubgridErrorP_du[eN * nQuadraturePoints_element * nDOF_trial_element +
                          k * nDOF_trial_element + j] =
            tau2 * dpdeResidualP_du[eN * nQuadraturePoints_element *
                                        nDOF_trial_element +
                                    k * nDOF_trial_element + j];
        dsubgridErrorP_dv[eN * nQuadraturePoints_element * nDOF_trial_element +
                          k * nDOF_trial_element + j] =
            tau2 * dpdeResidualP_dv[eN * nQuadraturePoints_element *
                                        nDOF_trial_element +
                                    k * nDOF_trial_element + j];
      }
    }
  }
}


x86 assembly (clang, -O0):
<calculateSubgridErrorStokes2D_1_sd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0xc0(%rbp),%rax
mov    0xb8(%rbp),%rax
mov    0xb0(%rbp),%rax
mov    0xa8(%rbp),%rax
mov    0xa0(%rbp),%rax
mov    0x98(%rbp),%rax
mov    0x90(%rbp),%rax
mov    0x88(%rbp),%rax
mov    0x80(%rbp),%rax
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)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    15b9 <calculateSubgridErrorStokes2D_1_sd+0x4a9>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    15a6 <calculateSubgridErrorStokes2D_1_sd+0x496>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
mov    0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0x10(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0x10(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdac(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xd99(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  0xd93(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xd7f(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xd61(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  0xd47(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xd20(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    0x38(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x88(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    0x50(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0xa8(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xc9a(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x68(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1593 <calculateSubgridErrorStokes2D_1_sd+0x483>
movsd  -0x50(%rbp),%xmm0
mov    0x40(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x90(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    0x48(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x98(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    0x58(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0xb0(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    0x60(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0xc0(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mov    0x28(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x78(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mov    0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x80(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    -0x28(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    13a8 <calculateSubgridErrorStokes2D_1_sd+0x298>
jmp    1598 <calculateSubgridErrorStokes2D_1_sd+0x488>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11cf <calculateSubgridErrorStokes2D_1_sd+0xbf>
jmp    15ab <calculateSubgridErrorStokes2D_1_sd+0x49b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11aa <calculateSubgridErrorStokes2D_1_sd+0x9a>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculateSubgridErrorStokes2D_1_sd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,-0x28(%rsp)
mov    %ecx,-0x34(%rsp)
mov    %esi,-0x58(%rsp)
test   %edi,%edi
jle    137b <calculateSubgridErrorStokes2D_1_sd+0x27b>
mov    %edi,%eax
mov    %rax,-0x20(%rsp)
mov    %edx,%r8d
mov    %edx,%ecx
mov    -0x58(%rsp),%eax
imul   %eax,%ecx
mov    %ecx,-0x3c(%rsp)
shl    $0x3,%r8
movsd  0xebe(%rip),%xmm0
movsd  0xebe(%rip),%xmm1
cltq
mov    %rax,-0x30(%rsp)
mov    %eax,%eax
mov    %rax,-0x18(%rsp)
xor    %eax,%eax
mov    %rax,-0x48(%rsp)
xor    %eax,%eax
mov    %rax,-0x50(%rsp)
mov    %edx,-0x38(%rsp)
jmp    119a <calculateSubgridErrorStokes2D_1_sd+0x9a>
nopl   0x0(%rax)
mov    -0x50(%rsp),%rcx
add    $0x1,%rcx
mov    -0x48(%rsp),%rax
add    -0x3c(%rsp),%eax
mov    %rax,-0x48(%rsp)
mov    %rcx,%rax
mov    %rcx,-0x50(%rsp)
cmp    -0x20(%rsp),%rcx
je     137b <calculateSubgridErrorStokes2D_1_sd+0x27b>
cmpl   $0x0,-0x58(%rsp)
jle    1170 <calculateSubgridErrorStokes2D_1_sd+0x70>
mov    -0x28(%rsp),%rax
mov    -0x50(%rsp),%rcx
movsd  (%rax,%rcx,8),%xmm2
imul   -0x30(%rsp),%rcx
mov    %rcx,-0x10(%rsp)
mulsd  %xmm2,%xmm2
mov    -0x48(%rsp),%rax
mov    %eax,-0x54(%rsp)
xor    %ecx,%ecx
jmp    11e8 <calculateSubgridErrorStokes2D_1_sd+0xe8>
nopl   0x0(%rax)
mov    -0x8(%rsp),%rcx
add    $0x1,%rcx
mov    -0x38(%rsp),%edx
add    %edx,-0x54(%rsp)
cmp    -0x18(%rsp),%rcx
je     1170 <calculateSubgridErrorStokes2D_1_sd+0x70>
mov    -0x10(%rsp),%rax
mov    %rcx,-0x8(%rsp)
add    %rcx,%rax
mov    %eax,%ecx
imul   -0x34(%rsp),%ecx
movslq %ecx,%rcx
mov    0x40(%rsp),%rsi
movsd  (%rsi,%rcx,8),%xmm3
movapd %xmm3,%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm2,%xmm4
divsd  %xmm5,%xmm4
mov    0x60(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm5
mulsd  %xmm4,%xmm5
mov    0xb0(%rsp),%rcx
movsd  %xmm5,(%rcx,%rax,8)
mov    0x78(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm5
mulsd  %xmm4,%xmm5
mov    0xd0(%rsp),%rcx
movsd  %xmm5,(%rcx,%rax,8)
mulsd  %xmm1,%xmm3
mov    0x48(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm5
mulsd  %xmm3,%xmm5
mov    0x90(%rsp),%rcx
movsd  %xmm5,(%rcx,%rax,8)
test   %edx,%edx
jle    11d0 <calculateSubgridErrorStokes2D_1_sd+0xd0>
movslq -0x54(%rsp),%rdx
mov    0x68(%rsp),%rax
lea    (%rax,%rdx,8),%r13
mov    0xb8(%rsp),%rax
lea    (%rax,%rdx,8),%rbx
mov    0x70(%rsp),%rax
lea    (%rax,%rdx,8),%rax
mov    0xc0(%rsp),%rcx
lea    (%rcx,%rdx,8),%rdi
mov    0x80(%rsp),%rcx
lea    (%rcx,%rdx,8),%r14
mov    0xd8(%rsp),%rcx
lea    (%rcx,%rdx,8),%r11
mov    0x88(%rsp),%rcx
lea    (%rcx,%rdx,8),%r12
mov    0xe8(%rsp),%rcx
lea    (%rcx,%rdx,8),%rbp
mov    0x50(%rsp),%rcx
lea    (%rcx,%rdx,8),%r9
mov    0xa0(%rsp),%rcx
lea    (%rcx,%rdx,8),%rcx
mov    0x58(%rsp),%rsi
lea    (%rsi,%rdx,8),%r10
mov    0xa8(%rsp),%rsi
lea    (%rsi,%rdx,8),%r15
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x0(%r13,%rdx,1),%xmm5
mulsd  %xmm4,%xmm5
movsd  %xmm5,(%rbx,%rdx,1)
movsd  (%rax,%rdx,1),%xmm5
mulsd  %xmm4,%xmm5
movsd  %xmm5,(%rdi,%rdx,1)
movsd  (%r14,%rdx,1),%xmm5
mulsd  %xmm4,%xmm5
movsd  %xmm5,(%r11,%rdx,1)
movsd  (%r12,%rdx,1),%xmm5
mulsd  %xmm4,%xmm5
movsd  %xmm5,0x0(%rbp,%rdx,1)
movsd  (%r9,%rdx,1),%xmm5
mulsd  %xmm3,%xmm5
movsd  %xmm5,(%rcx,%rdx,1)
movsd  (%r10,%rdx,1),%xmm5
mulsd  %xmm3,%xmm5
movsd  %xmm5,(%r15,%rdx,1)
add    $0x8,%rdx
cmp    %rdx,%r8
jne    1310 <calculateSubgridErrorStokes2D_1_sd+0x210>
jmp    11d0 <calculateSubgridErrorStokes2D_1_sd+0xd0>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calculateSubgridErrorStokes2D_1_sd(i32 %0, i32 %1, i32 %2, i32 %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, double* %22, double* %23, double* %24, double* %25, double* %26, double* %27, double* %28) {
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%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 double*
%46 = alloca double*
%47 = alloca double*
%48 = alloca double*
%49 = alloca double*
%50 = alloca double*
%51 = alloca double*
%52 = alloca double*
%53 = alloca double*
%54 = alloca double*
%55 = alloca double*
%56 = alloca double*
%57 = alloca double*
%58 = alloca double*
%59 = alloca i32
%60 = alloca i32
%61 = alloca i32
%62 = alloca double
%63 = alloca double
%64 = alloca double
%65 = alloca double
%66 = alloca double
%67 = alloca double
%68 = alloca double
store i32 %0, i32* %30
store i32 %1, i32* %31
store i32 %2, i32* %32
store i32 %3, i32* %33
store double* %4, double** %34
store double* %5, double** %35
store double* %6, double** %36
store double* %7, double** %37
store double* %8, double** %38
store double* %9, double** %39
store double* %10, double** %40
store double* %11, double** %41
store double* %12, double** %42
store double* %13, double** %43
store double* %14, double** %44
store double* %15, double** %45
store double* %16, double** %46
store double* %17, double** %47
store double* %18, double** %48
store double* %19, double** %49
store double* %20, double** %50
store double* %21, double** %51
store double* %22, double** %52
store double* %23, double** %53
store double* %24, double** %54
store double* %25, double** %55
store double* %26, double** %56
store double* %27, double** %57
store double* %28, double** %58
store i32 0, i32* %59
br label %69
69: ; preds = %405, %29
%70 = load i32, i32* %59
%71 = load i32, i32* %30
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %408
73: ; preds = %69
%74 = load double*, double** %34
%75 = load i32, i32* %59
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
%78 = load double, double* %77
store double %78, double* %62
store i32 0, i32* %60
br label %79
79: ; preds = %401, %73
%80 = load i32, i32* %60
%81 = load i32, i32* %31
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %404
83: ; preds = %79
%84 = load double*, double** %35
%85 = load i32, i32* %59
%86 = load i32, i32* %31
%87 = mul nsw i32 %85, %86
%88 = load i32, i32* %60
%89 = add nsw i32 %87, %88
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %84, i64 %90
%92 = load double, double* %91
store double %92, double* %67
%93 = load double*, double** %36
%94 = load i32, i32* %59
%95 = load i32, i32* %31
%96 = mul nsw i32 %94, %95
%97 = load i32, i32* %60
%98 = add nsw i32 %96, %97
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %93, i64 %99
%101 = load double, double* %100
store double %101, double* %68
%102 = load double, double* %67
%103 = load double, double* %67
%104 = load double, double* %68
%105 = load double, double* %68
%106 = fmul double %104, %105
%107 = call double @llvm.fmuladd.f64(double %102, double %103, double %106)
%108 = call double @sqrt(double %107)
store double %108, double* %63
%109 = load double*, double** %37
%110 = load i32, i32* %59
%111 = load i32, i32* %31
%112 = mul nsw i32 %110, %111
%113 = load i32, i32* %33
%114 = mul nsw i32 %112, %113
%115 = load i32, i32* %60
%116 = load i32, i32* %33
%117 = mul nsw i32 %115, %116
%118 = add nsw i32 %114, %117
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %109, i64 %119
%121 = load double, double* %120
store double %121, double* %64
%122 = load double, double* %64
%123 = fmul double 4.000000e+00, %122
%124 = load double, double* %62
%125 = load double, double* %62
%126 = fmul double %124, %125
%127 = fdiv double %123, %126
%128 = load double, double* %63
%129 = fmul double 2.000000e+00, %128
%130 = load double, double* %62
%131 = fdiv double %129, %130
%132 = fadd double %127, %131
%133 = fadd double %132, 1.000000e-08
%134 = fdiv double 1.000000e+00, %133
store double %134, double* %65
%135 = load double, double* %64
%136 = load double, double* %63
%137 = fmul double 2.000000e+00, %136
%138 = load double, double* %62
%139 = fmul double %137, %138
%140 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %135, double %139)
store double %140, double* %66
%141 = load double, double* %62
%142 = load double, double* %62
%143 = fmul double %141, %142
%144 = load double, double* %64
%145 = fmul double 1.200000e+01, %144
%146 = fdiv double %143, %145
store double %146, double* %65
%147 = load double, double* %65
%148 = load double*, double** %41
%149 = load i32, i32* %59
%150 = load i32, i32* %31
%151 = mul nsw i32 %149, %150
%152 = load i32, i32* %60
%153 = add nsw i32 %151, %152
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double, double* %148, i64 %154
%156 = load double, double* %155
%157 = fmul double %147, %156
%158 = load double*, double** %51
%159 = load i32, i32* %59
%160 = load i32, i32* %31
%161 = mul nsw i32 %159, %160
%162 = load i32, i32* %60
%163 = add nsw i32 %161, %162
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds double, double* %158, i64 %164
store double %157, double* %165
%166 = load double, double* %65
%167 = load double*, double** %44
%168 = load i32, i32* %59
%169 = load i32, i32* %31
%170 = mul nsw i32 %168, %169
%171 = load i32, i32* %60
%172 = add nsw i32 %170, %171
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds double, double* %167, i64 %173
%175 = load double, double* %174
%176 = fmul double %166, %175
%177 = load double*, double** %55
%178 = load i32, i32* %59
%179 = load i32, i32* %31
%180 = mul nsw i32 %178, %179
%181 = load i32, i32* %60
%182 = add nsw i32 %180, %181
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %177, i64 %183
store double %176, double* %184
%185 = load double, double* %64
%186 = fmul double 6.000000e+00, %185
store double %186, double* %66
%187 = load double, double* %66
%188 = load double*, double** %38
%189 = load i32, i32* %59
%190 = load i32, i32* %31
%191 = mul nsw i32 %189, %190
%192 = load i32, i32* %60
%193 = add nsw i32 %191, %192
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds double, double* %188, i64 %194
%196 = load double, double* %195
%197 = fmul double %187, %196
%198 = load double*, double** %47
%199 = load i32, i32* %59
%200 = load i32, i32* %31
%201 = mul nsw i32 %199, %200
%202 = load i32, i32* %60
%203 = add nsw i32 %201, %202
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds double, double* %198, i64 %204
store double %197, double* %205
store i32 0, i32* %61
br label %206
206: ; preds = %397, %83
%207 = load i32, i32* %61
%208 = load i32, i32* %32
%209 = icmp slt i32 %207, %208
br i1 %209, label %210, label %400
210: ; preds = %206
%211 = load double, double* %65
%212 = load double*, double** %42
%213 = load i32, i32* %59
%214 = load i32, i32* %31
%215 = mul nsw i32 %213, %214
%216 = load i32, i32* %32
%217 = mul nsw i32 %215, %216
%218 = load i32, i32* %60
%219 = load i32, i32* %32
%220 = mul nsw i32 %218, %219
%221 = add nsw i32 %217, %220
%222 = load i32, i32* %61
%223 = add nsw i32 %221, %222
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds double, double* %212, i64 %224
%226 = load double, double* %225
%227 = fmul double %211, %226
%228 = load double*, double** %52
%229 = load i32, i32* %59
%230 = load i32, i32* %31
%231 = mul nsw i32 %229, %230
%232 = load i32, i32* %32
%233 = mul nsw i32 %231, %232
%234 = load i32, i32* %60
%235 = load i32, i32* %32
%236 = mul nsw i32 %234, %235
%237 = add nsw i32 %233, %236
%238 = load i32, i32* %61
%239 = add nsw i32 %237, %238
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds double, double* %228, i64 %240
store double %227, double* %241
%242 = load double, double* %65
%243 = load double*, double** %43
%244 = load i32, i32* %59
%245 = load i32, i32* %31
%246 = mul nsw i32 %244, %245
%247 = load i32, i32* %32
%248 = mul nsw i32 %246, %247
%249 = load i32, i32* %60
%250 = load i32, i32* %32
%251 = mul nsw i32 %249, %250
%252 = add nsw i32 %248, %251
%253 = load i32, i32* %61
%254 = add nsw i32 %252, %253
%255 = sext i32 %254 to i64
%256 = getelementptr inbounds double, double* %243, i64 %255
%257 = load double, double* %256
%258 = fmul double %242, %257
%259 = load double*, double** %53
%260 = load i32, i32* %59
%261 = load i32, i32* %31
%262 = mul nsw i32 %260, %261
%263 = load i32, i32* %32
%264 = mul nsw i32 %262, %263
%265 = load i32, i32* %60
%266 = load i32, i32* %32
%267 = mul nsw i32 %265, %266
%268 = add nsw i32 %264, %267
%269 = load i32, i32* %61
%270 = add nsw i32 %268, %269
%271 = sext i32 %270 to i64
%272 = getelementptr inbounds double, double* %259, i64 %271
store double %258, double* %272
%273 = load double, double* %65
%274 = load double*, double** %45
%275 = load i32, i32* %59
%276 = load i32, i32* %31
%277 = mul nsw i32 %275, %276
%278 = load i32, i32* %32
%279 = mul nsw i32 %277, %278
%280 = load i32, i32* %60
%281 = load i32, i32* %32
%282 = mul nsw i32 %280, %281
%283 = add nsw i32 %279, %282
%284 = load i32, i32* %61
%285 = add nsw i32 %283, %284
%286 = sext i32 %285 to i64
%287 = getelementptr inbounds double, double* %274, i64 %286
%288 = load double, double* %287
%289 = fmul double %273, %288
%290 = load double*, double** %56
%291 = load i32, i32* %59
%292 = load i32, i32* %31
%293 = mul nsw i32 %291, %292
%294 = load i32, i32* %32
%295 = mul nsw i32 %293, %294
%296 = load i32, i32* %60
%297 = load i32, i32* %32
%298 = mul nsw i32 %296, %297
%299 = add nsw i32 %295, %298
%300 = load i32, i32* %61
%301 = add nsw i32 %299, %300
%302 = sext i32 %301 to i64
%303 = getelementptr inbounds double, double* %290, i64 %302
store double %289, double* %303
%304 = load double, double* %65
%305 = load double*, double** %46
%306 = load i32, i32* %59
%307 = load i32, i32* %31
%308 = mul nsw i32 %306, %307
%309 = load i32, i32* %32
%310 = mul nsw i32 %308, %309
%311 = load i32, i32* %60
%312 = load i32, i32* %32
%313 = mul nsw i32 %311, %312
%314 = add nsw i32 %310, %313
%315 = load i32, i32* %61
%316 = add nsw i32 %314, %315
%317 = sext i32 %316 to i64
%318 = getelementptr inbounds double, double* %305, i64 %317
%319 = load double, double* %318
%320 = fmul double %304, %319
%321 = load double*, double** %58
%322 = load i32, i32* %59
%323 = load i32, i32* %31
%324 = mul nsw i32 %322, %323
%325 = load i32, i32* %32
%326 = mul nsw i32 %324, %325
%327 = load i32, i32* %60
%328 = load i32, i32* %32
%329 = mul nsw i32 %327, %328
%330 = add nsw i32 %326, %329
%331 = load i32, i32* %61
%332 = add nsw i32 %330, %331
%333 = sext i32 %332 to i64
%334 = getelementptr inbounds double, double* %321, i64 %333
store double %320, double* %334
%335 = load double, double* %66
%336 = load double*, double** %39
%337 = load i32, i32* %59
%338 = load i32, i32* %31
%339 = mul nsw i32 %337, %338
%340 = load i32, i32* %32
%341 = mul nsw i32 %339, %340
%342 = load i32, i32* %60
%343 = load i32, i32* %32
%344 = mul nsw i32 %342, %343
%345 = add nsw i32 %341, %344
%346 = load i32, i32* %61
%347 = add nsw i32 %345, %346
%348 = sext i32 %347 to i64
%349 = getelementptr inbounds double, double* %336, i64 %348
%350 = load double, double* %349
%351 = fmul double %335, %350
%352 = load double*, double** %49
%353 = load i32, i32* %59
%354 = load i32, i32* %31
%355 = mul nsw i32 %353, %354
%356 = load i32, i32* %32
%357 = mul nsw i32 %355, %356
%358 = load i32, i32* %60
%359 = load i32, i32* %32
%360 = mul nsw i32 %358, %359
%361 = add nsw i32 %357, %360
%362 = load i32, i32* %61
%363 = add nsw i32 %361, %362
%364 = sext i32 %363 to i64
%365 = getelementptr inbounds double, double* %352, i64 %364
store double %351, double* %365
%366 = load double, double* %66
%367 = load double*, double** %40
%368 = load i32, i32* %59
%369 = load i32, i32* %31
%370 = mul nsw i32 %368, %369
%371 = load i32, i32* %32
%372 = mul nsw i32 %370, %371
%373 = load i32, i32* %60
%374 = load i32, i32* %32
%375 = mul nsw i32 %373, %374
%376 = add nsw i32 %372, %375
%377 = load i32, i32* %61
%378 = add nsw i32 %376, %377
%379 = sext i32 %378 to i64
%380 = getelementptr inbounds double, double* %367, i64 %379
%381 = load double, double* %380
%382 = fmul double %366, %381
%383 = load double*, double** %50
%384 = load i32, i32* %59
%385 = load i32, i32* %31
%386 = mul nsw i32 %384, %385
%387 = load i32, i32* %32
%388 = mul nsw i32 %386, %387
%389 = load i32, i32* %60
%390 = load i32, i32* %32
%391 = mul nsw i32 %389, %390
%392 = add nsw i32 %388, %391
%393 = load i32, i32* %61
%394 = add nsw i32 %392, %393
%395 = sext i32 %394 to i64
%396 = getelementptr inbounds double, double* %383, i64 %395
store double %382, double* %396
br label %397
397: ; preds = %210
%398 = load i32, i32* %61
%399 = add nsw i32 %398, 1
store i32 %399, i32* %61
br label %206
400: ; preds = %206
br label %401
401: ; preds = %400
%402 = load i32, i32* %60
%403 = add nsw i32 %402, 1
store i32 %403, i32* %60
br label %79
404: ; preds = %79
br label %405
405: ; preds = %404
%406 = load i32, i32* %59
%407 = add nsw i32 %406, 1
store i32 %407, i32* %59
br label %69
408: ; preds = %69
ret void
}

LLVM IR (-O2):
define void @calculateSubgridErrorStokes2D_1_sd(i32 %0, i32 %1, i32 %2, i32 %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, double* nocapture %12, double* nocapture %13, double* nocapture %14, double* nocapture %15, double* nocapture %16, double* nocapture writeonly %17, double* nocapture readnone %18, double* nocapture writeonly %19, double* nocapture writeonly %20, double* nocapture writeonly %21, double* nocapture writeonly %22, double* nocapture writeonly %23, double* nocapture readnone %24, double* nocapture writeonly %25, double* nocapture writeonly %26, double* nocapture readnone %27, double* nocapture writeonly %28) {
%30 = icmp sgt i32 %0, 0
br i1 %30, label %31, label %106
31: ; preds = %29
%32 = icmp sgt i32 %1, 0
%33 = icmp sgt i32 %2, 0
%34 = sext i32 %1 to i64
%35 = zext i32 %0 to i64
%36 = zext i32 %1 to i64
%37 = zext i32 %2 to i64
br label %38
38: ; preds = %31, %103
%39 = phi i64 [ 0, %31 ], [ %104, %103 ]
br i1 %32, label %40, label %103
40: ; preds = %38
%41 = getelementptr inbounds double, double* %4, i64 %39
%42 = load double, double* %41
%43 = mul nsw i64 %39, %34
%44 = fmul double %42, %42
br label %45
45: ; preds = %40, %100
%46 = phi i64 [ 0, %40 ], [ %101, %100 ]
%47 = add nsw i64 %46, %43
%48 = trunc i64 %47 to i32
%49 = mul i32 %48, %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %7, i64 %50
%52 = load double, double* %51
%53 = fmul double %52, 1.200000e+01
%54 = fdiv double %44, %53
%55 = getelementptr inbounds double, double* %11, i64 %47
%56 = load double, double* %55
%57 = fmul double %56, %54
%58 = getelementptr inbounds double, double* %21, i64 %47
store double %57, double* %58
%59 = getelementptr inbounds double, double* %14, i64 %47
%60 = load double, double* %59
%61 = fmul double %54, %60
%62 = getelementptr inbounds double, double* %25, i64 %47
store double %61, double* %62
%63 = fmul double %52, 6.000000e+00
%64 = getelementptr inbounds double, double* %8, i64 %47
%65 = load double, double* %64
%66 = fmul double %63, %65
%67 = getelementptr inbounds double, double* %17, i64 %47
store double %66, double* %67
br i1 %33, label %68, label %100
68: ; preds = %45
%69 = mul i32 %48, %2
%70 = sext i32 %69 to i64
br label %71
71: ; preds = %68, %71
%72 = phi i64 [ 0, %68 ], [ %98, %71 ]
%73 = add nsw i64 %72, %70
%74 = getelementptr inbounds double, double* %12, i64 %73
%75 = load double, double* %74
%76 = fmul double %54, %75
%77 = getelementptr inbounds double, double* %22, i64 %73
store double %76, double* %77
%78 = getelementptr inbounds double, double* %13, i64 %73
%79 = load double, double* %78
%80 = fmul double %54, %79
%81 = getelementptr inbounds double, double* %23, i64 %73
store double %80, double* %81
%82 = getelementptr inbounds double, double* %15, i64 %73
%83 = load double, double* %82
%84 = fmul double %54, %83
%85 = getelementptr inbounds double, double* %26, i64 %73
store double %84, double* %85
%86 = getelementptr inbounds double, double* %16, i64 %73
%87 = load double, double* %86
%88 = fmul double %54, %87
%89 = getelementptr inbounds double, double* %28, i64 %73
store double %88, double* %89
%90 = getelementptr inbounds double, double* %9, i64 %73
%91 = load double, double* %90
%92 = fmul double %63, %91
%93 = getelementptr inbounds double, double* %19, i64 %73
store double %92, double* %93
%94 = getelementptr inbounds double, double* %10, i64 %73
%95 = load double, double* %94
%96 = fmul double %63, %95
%97 = getelementptr inbounds double, double* %20, i64 %73
store double %96, double* %97
%98 = add nuw nsw i64 %72, 1
%99 = icmp eq i64 %98, %37
br i1 %99, label %100, label %71
100: ; preds = %71, %45
%101 = add nuw nsw i64 %46, 1
%102 = icmp eq i64 %101, %36
br i1 %102, label %103, label %45
103: ; preds = %100, %38
%104 = add nuw nsw i64 %39, 1
%105 = icmp eq i64 %104, %35
br i1 %105, label %106, label %38
106: ; preds = %103, %29
ret void
}