#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 fabs(double);
double fmax(double, double);
double sqrt(double);
void calculateNumericalDiffusionResGrad(
    int nElements_global, int nQuadraturePoints_element, int nSpace,
    double shockCapturingDiffusion, double *elementDiameter,
    double *strong_residual, double *grad_u, double *numDiff) {
  int eN, k, I;
  double h, num, den, n_grad_u[nQuadraturePoints_element], n_R_eN, maxNumDiff;
  for (eN = 0; eN < nElements_global; eN++) {
    h = elementDiameter[eN];
    n_R_eN = 0.0;
    for (k = 0; k < nQuadraturePoints_element; k++) {
      n_grad_u[k] = 0.0;
      for (I = 0; I < nSpace; I++) {
        n_grad_u[k] +=
            grad_u[eN * nQuadraturePoints_element * nSpace + k * nSpace + I] *
            grad_u[eN * nQuadraturePoints_element * nSpace + k * nSpace + I];
      }
      n_grad_u[k] = sqrt(n_grad_u[k]);
      num = shockCapturingDiffusion * 0.5 * h *
            fabs(strong_residual[eN * nQuadraturePoints_element + k]);
      den = n_grad_u[k];
      if (den > num * 1.0e-8)
        numDiff[eN * nQuadraturePoints_element + k] = num / den;
      else
        numDiff[eN * nQuadraturePoints_element + k] = 0.0;
      n_R_eN = fmax(n_R_eN,
                    fabs(strong_residual[eN * nQuadraturePoints_element + k]));
    }
    maxNumDiff = 0.0;
    for (k = 0; k < nQuadraturePoints_element; k++) {
      num = shockCapturingDiffusion * 0.5 * h * n_R_eN;
      den = n_grad_u[k];
      if (den > num * 1.0e-8)
        numDiff[eN * nQuadraturePoints_element + k] = num / den;
      else
        numDiff[eN * nQuadraturePoints_element + k] = 0.0;
      maxNumDiff =
          fmax(maxNumDiff, numDiff[eN * nQuadraturePoints_element + k]);
    }
    for (k = 0; k < nQuadraturePoints_element; k++)
      numDiff[eN * nQuadraturePoints_element + k] = maxNumDiff;
  }
}


x86 assembly (clang, -O0):
<calculateNumericalDiffusionResGrad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1489 <calculateNumericalDiffusionResGrad+0x379>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    134b <calculateNumericalDiffusionResGrad+0x23b>
mov    -0x80(%rbp),%rax
movslq -0x38(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1231 <calculateNumericalDiffusionResGrad+0x121>
mov    -0x80(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%edx
imul   -0x8(%rbp),%edx
imul   -0xc(%rbp),%edx
mov    -0x38(%rbp),%esi
imul   -0xc(%rbp),%esi
add    %esi,%edx
add    -0x3c(%rbp),%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%edx
imul   -0x8(%rbp),%edx
imul   -0xc(%rbp),%edx
mov    -0x38(%rbp),%esi
imul   -0xc(%rbp),%esi
add    %esi,%edx
add    -0x3c(%rbp),%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm2
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11b7 <calculateNumericalDiffusionResGrad+0xa7>
mov    -0x80(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrt@plt>
mov    -0x80(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xdb0(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rcx
mov    -0x34(%rbp),%edx
imul   -0x8(%rbp),%edx
add    -0x38(%rbp),%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm1
movaps 0xd91(%rip),%xmm2
pand   %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xd59(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    12db <calculateNumericalDiffusionResGrad+0x1cb>
movsd  -0x50(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
mov    0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12f4 <calculateNumericalDiffusionResGrad+0x1e4>
mov    0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x70(%rbp),%xmm3
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movaps 0xcfa(%rip),%xmm0
pand   %xmm0,%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordsd %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
maxsd  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1194 <calculateNumericalDiffusionResGrad+0x84>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    143a <calculateNumericalDiffusionResGrad+0x32a>
mov    -0x80(%rbp),%rax
movsd  0xc96(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xc5f(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    13d5 <calculateNumericalDiffusionResGrad+0x2c5>
movsd  -0x50(%rbp),%xmm0
divsd  -0x58(%rbp),%xmm0
mov    0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    13ee <calculateNumericalDiffusionResGrad+0x2de>
mov    0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x78(%rbp),%xmm3
mov    0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordsd %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
maxsd  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    135a <calculateNumericalDiffusionResGrad+0x24a>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1476 <calculateNumericalDiffusionResGrad+0x366>
movsd  -0x78(%rbp),%xmm0
mov    0x10(%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    1441 <calculateNumericalDiffusionResGrad+0x331>
jmp    147b <calculateNumericalDiffusionResGrad+0x36b>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1167 <calculateNumericalDiffusionResGrad+0x57>
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculateNumericalDiffusionResGrad>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %r9,-0x60(%rbp)
mov    %rcx,-0x98(%rbp)
movsd  %xmm0,-0x30(%rbp)
mov    %esi,%r9d
mov    %rsp,%r11
lea    0xf(,%r9,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r11
mov    %r11,%rsp
test   %edi,%edi
jle    15e4 <calculateNumericalDiffusionResGrad+0x4d4>
mov    %edx,%r13d
mov    0x10(%rbp),%r12
movsd  -0x30(%rbp),%xmm0
mulsd  0xe98(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movslq %esi,%r14
mov    %edi,%eax
mov    %rax,-0xa8(%rbp)
mov    %edx,%r10d
lea    -0x1(%r10),%rax
mov    %rax,-0xe0(%rbp)
mov    %r9d,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x80(%rbp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x78(%rbp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %r10d,%ebx
and    $0x3,%ebx
and    $0xfffffffc,%r10d
mov    %eax,%ecx
and    $0x3,%ecx
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0xb0(%rbp)
mov    %edx,%eax
imul   %esi,%eax
mov    %eax,-0x48(%rbp)
mov    %rcx,-0x70(%rbp)
mov    %rcx,%r15
shl    $0x5,%r15
xorpd  %xmm8,%xmm8
movapd 0xe29(%rip),%xmm6
movsd  0xe19(%rip),%xmm7
mov    %r14,-0x90(%rbp)
lea    0x0(,%r14,8),%rax
mov    %rax,-0xa0(%rbp)
lea    0x10(%r12),%rax
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
mov    %r12,%r14
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
mov    %esi,-0x44(%rbp)
mov    %r10,-0xc0(%rbp)
mov    %rbx,-0xb8(%rbp)
mov    %r15,-0x88(%rbp)
jmp    1275 <calculateNumericalDiffusionResGrad+0x165>
nopw   0x0(%rax,%rax,1)
mov    -0x38(%rbp),%rcx
add    $0x1,%rcx
mov    -0x40(%rbp),%rax
add    -0x48(%rbp),%eax
mov    %rax,-0x40(%rbp)
mov    -0xa0(%rbp),%rax
add    %rax,%r14
add    %rax,-0x58(%rbp)
mov    %rcx,%rax
mov    %rcx,-0x38(%rbp)
cmp    -0xa8(%rbp),%rcx
je     15e4 <calculateNumericalDiffusionResGrad+0x4d4>
test   %esi,%esi
jle    1240 <calculateNumericalDiffusionResGrad+0x130>
mov    -0x38(%rbp),%rcx
mov    %rcx,%r12
imul   -0x90(%rbp),%r12
ff
mov    -0x98(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm5
mulsd  -0x30(%rbp),%xmm5
xorpd  %xmm4,%xmm4
mov    -0x40(%rbp),%rax
mov    %eax,%edi
xor    %r15d,%r15d
mov    %r14,-0xd8(%rbp)
movsd  %xmm5,-0xd0(%rbp)
ff
mov    %r12,-0xc8(%rbp)
jmp    1304 <calculateNumericalDiffusionResGrad+0x1f4>
xchg   %ax,%ax
mov    0x10(%rbp),%rcx
movsd  %xmm2,(%rcx,%rax,8)
movsd  (%r8,%rax,8),%xmm1
andpd  %xmm6,%xmm1
movapd %xmm4,%xmm0
cmpunordsd %xmm4,%xmm0
movapd %xmm0,%xmm2
andpd  %xmm1,%xmm2
maxsd  %xmm4,%xmm1
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
add    $0x1,%r15
add    %r13d,%edi
movapd %xmm0,%xmm4
cmp    %r9,%r15
je     1490 <calculateNumericalDiffusionResGrad+0x380>
xorpd  %xmm0,%xmm0
test   %r13d,%r13d
jle    13c6 <calculateNumericalDiffusionResGrad+0x2b6>
movslq %edi,%rax
cmpq   $0x3,-0xe0(%rbp)
03
jae    1330 <calculateNumericalDiffusionResGrad+0x220>
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
jmp    1390 <calculateNumericalDiffusionResGrad+0x280>
cs nopw 0x0(%rax,%rax,1)
mov    -0xb0(%rbp),%rcx
lea    (%rcx,%rax,8),%rsi
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  -0x18(%rsi,%rcx,8),%xmm1
movsd  -0x10(%rsi,%rcx,8),%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x8(%rsi,%rcx,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  (%rsi,%rcx,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
add    $0x4,%rcx
cmp    %rcx,%r10
jne    1350 <calculateNumericalDiffusionResGrad+0x240>
test   %rbx,%rbx
je     13c6 <calculateNumericalDiffusionResGrad+0x2b6>
add    %rax,%rcx
mov    -0x60(%rbp),%rax
lea    (%rax,%rcx,8),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rcx
cmp    %rcx,%rbx
jne    13b0 <calculateNumericalDiffusionResGrad+0x2a0>
ucomisd %xmm8,%xmm0
jb     13e0 <calculateNumericalDiffusionResGrad+0x2d0>
sqrtsd %xmm0,%xmm0
jmp    1446 <calculateNumericalDiffusionResGrad+0x336>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r8,%r12
mov    %edi,-0x4c(%rbp)
mov    %r9,%r14
mov    %r11,%rbx
movsd  %xmm4,-0xe8(%rbp)
ff
call   1030 <sqrt@plt>
movsd  -0xe8(%rbp),%xmm4
movsd  -0xd0(%rbp),%xmm5
ff
movsd  0xbf7(%rip),%xmm7
movapd 0xbf7(%rip),%xmm6
xorpd  %xmm8,%xmm8
mov    -0xc0(%rbp),%r10
mov    %rbx,%r11
mov    -0xb8(%rbp),%rbx
mov    %r14,%r9
mov    -0xd8(%rbp),%r14
mov    -0x4c(%rbp),%edi
mov    %r12,%r8
mov    -0xc8(%rbp),%r12
movsd  %xmm0,(%r11,%r15,8)
lea    (%r15,%r12,1),%rax
movsd  (%r8,%rax,8),%xmm1
andpd  %xmm6,%xmm1
mulsd  %xmm5,%xmm1
movapd %xmm1,%xmm3
mulsd  %xmm7,%xmm3
xorpd  %xmm2,%xmm2
ucomisd %xmm3,%xmm0
jbe    12c0 <calculateNumericalDiffusionResGrad+0x1b0>
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm2
jmp    12c0 <calculateNumericalDiffusionResGrad+0x1b0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x44(%rbp),%esi
test   %esi,%esi
mov    -0x88(%rbp),%r15
jle    1240 <calculateNumericalDiffusionResGrad+0x130>
mulsd  %xmm0,%xmm5
movapd %xmm5,%xmm1
mulsd  %xmm7,%xmm1
xorpd  %xmm0,%xmm0
xor    %eax,%eax
jmp    14f0 <calculateNumericalDiffusionResGrad+0x3e0>
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm2,(%r14,%rax,8)
movapd %xmm0,%xmm3
cmpunordsd %xmm0,%xmm3
movapd %xmm3,%xmm4
andpd  %xmm2,%xmm4
maxsd  %xmm0,%xmm2
andnpd %xmm2,%xmm3
orpd   %xmm4,%xmm3
movapd %xmm3,%xmm0
add    $0x1,%rax
cmp    %rax,%r9
je     1510 <calculateNumericalDiffusionResGrad+0x400>
movsd  (%r11,%rax,8),%xmm3
ucomisd %xmm1,%xmm3
xorpd  %xmm2,%xmm2
jbe    14c0 <calculateNumericalDiffusionResGrad+0x3b0>
movapd %xmm5,%xmm2
divsd  %xmm3,%xmm2
jmp    14c0 <calculateNumericalDiffusionResGrad+0x3b0>
nopw   0x0(%rax,%rax,1)
test   %esi,%esi
jle    1240 <calculateNumericalDiffusionResGrad+0x130>
cmp    $0x4,%esi
jae    1524 <calculateNumericalDiffusionResGrad+0x414>
xor    %eax,%eax
jmp    15d0 <calculateNumericalDiffusionResGrad+0x4c0>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0xc,-0x78(%rbp)
jae    1537 <calculateNumericalDiffusionResGrad+0x427>
xor    %eax,%eax
jmp    1581 <calculateNumericalDiffusionResGrad+0x471>
mov    -0x68(%rbp),%rcx
xor    %eax,%eax
nopl   (%rax)
movupd %xmm1,(%r14,%rax,8)
movupd %xmm1,0x10(%r14,%rax,8)
movupd %xmm1,0x20(%r14,%rax,8)
movupd %xmm1,0x30(%r14,%rax,8)
movupd %xmm1,0x40(%r14,%rax,8)
movupd %xmm1,0x50(%r14,%rax,8)
movupd %xmm1,0x60(%r14,%rax,8)
movupd %xmm1,0x70(%r14,%rax,8)
add    $0x10,%rax
add    $0xfffffffffffffffc,%rcx
jne    1540 <calculateNumericalDiffusionResGrad+0x430>
cmpq   $0x0,-0x70(%rbp)
je     15b4 <calculateNumericalDiffusionResGrad+0x4a4>
mov    -0x58(%rbp),%rcx
lea    (%rcx,%rax,8),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd %xmm1,-0x10(%rax,%rcx,1)
movupd %xmm1,(%rax,%rcx,1)
add    $0x20,%rcx
cmp    %rcx,%r15
jne    15a0 <calculateNumericalDiffusionResGrad+0x490>
mov    -0x80(%rbp),%rcx
mov    %rcx,%rax
cmp    %r9,%rcx
je     1240 <calculateNumericalDiffusionResGrad+0x130>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,(%r14,%rax,8)
add    $0x1,%rax
cmp    %rax,%r9
jne    15d0 <calculateNumericalDiffusionResGrad+0x4c0>
jmp    1240 <calculateNumericalDiffusionResGrad+0x130>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calculateNumericalDiffusionResGrad(i32 %0, i32 %1, i32 %2, double %3, double* %4, double* %5, double* %6, double* %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca i8*
%24 = alloca i64
%25 = alloca double
%26 = alloca double
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store double %3, double* %12
store double* %4, double** %13
store double* %5, double** %14
store double* %6, double** %15
store double* %7, double** %16
%27 = load i32, i32* %10
%28 = zext i32 %27 to i64
%29 = call i8* @llvm.stacksave()
store i8* %29, i8** %23
%30 = alloca double, i64 %28
store i64 %28, i64* %24
store i32 0, i32* %17
br label %31
31: ; preds = %236, %8
%32 = load i32, i32* %17
%33 = load i32, i32* %9
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %239
35: ; preds = %31
%36 = load double*, double** %13
%37 = load i32, i32* %17
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
store double %40, double* %20
store double 0.000000e+00, double* %25
store i32 0, i32* %18
br label %41
41: ; preds = %158, %35
%42 = load i32, i32* %18
%43 = load i32, i32* %10
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %161
45: ; preds = %41
%46 = load i32, i32* %18
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %30, i64 %47
store double 0.000000e+00, double* %48
store i32 0, i32* %19
br label %49
49: ; preds = %89, %45
%50 = load i32, i32* %19
%51 = load i32, i32* %11
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %92
53: ; preds = %49
%54 = load double*, double** %15
%55 = load i32, i32* %17
%56 = load i32, i32* %10
%57 = mul nsw i32 %55, %56
%58 = load i32, i32* %11
%59 = mul nsw i32 %57, %58
%60 = load i32, i32* %18
%61 = load i32, i32* %11
%62 = mul nsw i32 %60, %61
%63 = add nsw i32 %59, %62
%64 = load i32, i32* %19
%65 = add nsw i32 %63, %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %54, i64 %66
%68 = load double, double* %67
%69 = load double*, double** %15
%70 = load i32, i32* %17
%71 = load i32, i32* %10
%72 = mul nsw i32 %70, %71
%73 = load i32, i32* %11
%74 = mul nsw i32 %72, %73
%75 = load i32, i32* %18
%76 = load i32, i32* %11
%77 = mul nsw i32 %75, %76
%78 = add nsw i32 %74, %77
%79 = load i32, i32* %19
%80 = add nsw i32 %78, %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %69, i64 %81
%83 = load double, double* %82
%84 = load i32, i32* %18
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %30, i64 %85
%87 = load double, double* %86
%88 = call double @llvm.fmuladd.f64(double %68, double %83, double %87)
store double %88, double* %86
br label %89
89: ; preds = %53
%90 = load i32, i32* %19
%91 = add nsw i32 %90, 1
store i32 %91, i32* %19
br label %49
92: ; preds = %49
%93 = load i32, i32* %18
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %30, i64 %94
%96 = load double, double* %95
%97 = call double @sqrt(double %96)
%98 = load i32, i32* %18
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %30, i64 %99
store double %97, double* %100
%101 = load double, double* %12
%102 = fmul double %101, 5.000000e-01
%103 = load double, double* %20
%104 = fmul double %102, %103
%105 = load double*, double** %14
%106 = load i32, i32* %17
%107 = load i32, i32* %10
%108 = mul nsw i32 %106, %107
%109 = load i32, i32* %18
%110 = add nsw i32 %108, %109
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %105, i64 %111
%113 = load double, double* %112
%114 = call double @llvm.fabs.f64(double %113)
%115 = fmul double %104, %114
store double %115, double* %21
%116 = load i32, i32* %18
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %30, i64 %117
%119 = load double, double* %118
store double %119, double* %22
%120 = load double, double* %22
%121 = load double, double* %21
%122 = fmul double %121, 1.000000e-08
%123 = fcmp ogt double %120, %122
br i1 %123, label %124, label %136
124: ; preds = %92
%125 = load double, double* %21
%126 = load double, double* %22
%127 = fdiv double %125, %126
%128 = load double*, double** %16
%129 = load i32, i32* %17
%130 = load i32, i32* %10
%131 = mul nsw i32 %129, %130
%132 = load i32, i32* %18
%133 = add nsw i32 %131, %132
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double, double* %128, i64 %134
store double %127, double* %135
br label %145
136: ; preds = %92
%137 = load double*, double** %16
%138 = load i32, i32* %17
%139 = load i32, i32* %10
%140 = mul nsw i32 %138, %139
%141 = load i32, i32* %18
%142 = add nsw i32 %140, %141
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds double, double* %137, i64 %143
store double 0.000000e+00, double* %144
br label %145
145: ; preds = %136, %124
%146 = load double, double* %25
%147 = load double*, double** %14
%148 = load i32, i32* %17
%149 = load i32, i32* %10
%150 = mul nsw i32 %148, %149
%151 = load i32, i32* %18
%152 = add nsw i32 %150, %151
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds double, double* %147, i64 %153
%155 = load double, double* %154
%156 = call double @llvm.fabs.f64(double %155)
%157 = call double @llvm.maxnum.f64(double %146, double %156)
store double %157, double* %25
br label %158
158: ; preds = %145
%159 = load i32, i32* %18
%160 = add nsw i32 %159, 1
store i32 %160, i32* %18
br label %41
161: ; preds = %41
store double 0.000000e+00, double* %26
store i32 0, i32* %18
br label %162
162: ; preds = %214, %161
%163 = load i32, i32* %18
%164 = load i32, i32* %10
%165 = icmp slt i32 %163, %164
br i1 %165, label %166, label %217
166: ; preds = %162
%167 = load double, double* %12
%168 = fmul double %167, 5.000000e-01
%169 = load double, double* %20
%170 = fmul double %168, %169
%171 = load double, double* %25
%172 = fmul double %170, %171
store double %172, double* %21
%173 = load i32, i32* %18
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds double, double* %30, i64 %174
%176 = load double, double* %175
store double %176, double* %22
%177 = load double, double* %22
%178 = load double, double* %21
%179 = fmul double %178, 1.000000e-08
%180 = fcmp ogt double %177, %179
br i1 %180, label %181, label %193
181: ; preds = %166
%182 = load double, double* %21
%183 = load double, double* %22
%184 = fdiv double %182, %183
%185 = load double*, double** %16
%186 = load i32, i32* %17
%187 = load i32, i32* %10
%188 = mul nsw i32 %186, %187
%189 = load i32, i32* %18
%190 = add nsw i32 %188, %189
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds double, double* %185, i64 %191
store double %184, double* %192
br label %202
193: ; preds = %166
%194 = load double*, double** %16
%195 = load i32, i32* %17
%196 = load i32, i32* %10
%197 = mul nsw i32 %195, %196
%198 = load i32, i32* %18
%199 = add nsw i32 %197, %198
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds double, double* %194, i64 %200
store double 0.000000e+00, double* %201
br label %202
202: ; preds = %193, %181
%203 = load double, double* %26
%204 = load double*, double** %16
%205 = load i32, i32* %17
%206 = load i32, i32* %10
%207 = mul nsw i32 %205, %206
%208 = load i32, i32* %18
%209 = add nsw i32 %207, %208
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds double, double* %204, i64 %210
%212 = load double, double* %211
%213 = call double @llvm.maxnum.f64(double %203, double %212)
store double %213, double* %26
br label %214
214: ; preds = %202
%215 = load i32, i32* %18
%216 = add nsw i32 %215, 1
store i32 %216, i32* %18
br label %162
217: ; preds = %162
store i32 0, i32* %18
br label %218
218: ; preds = %232, %217
%219 = load i32, i32* %18
%220 = load i32, i32* %10
%221 = icmp slt i32 %219, %220
br i1 %221, label %222, label %235
222: ; preds = %218
%223 = load double, double* %26
%224 = load double*, double** %16
%225 = load i32, i32* %17
%226 = load i32, i32* %10
%227 = mul nsw i32 %225, %226
%228 = load i32, i32* %18
%229 = add nsw i32 %227, %228
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds double, double* %224, i64 %230
store double %223, double* %231
br label %232
232: ; preds = %222
%233 = load i32, i32* %18
%234 = add nsw i32 %233, 1
store i32 %234, i32* %18
br label %218
235: ; preds = %218
br label %236
236: ; preds = %235
%237 = load i32, i32* %17
%238 = add nsw i32 %237, 1
store i32 %238, i32* %17
br label %31
239: ; preds = %31
%240 = load i8*, i8** %23
ret void
}

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