#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 sqrt(double);
void calculateNumericalDiffusionHJV2(
    int nElements_global, int nQuadraturePoints_element, char shockCapturing,
    double shockCapturingDiffusion, double *elementDiameter,
    double *strong_residual, double *mt, double *H, double *numDiff) {
  int eN, k;
  double h, num, den = 0.0, enorm_h;
  for (eN = 0; eN < nElements_global; eN++) {
    h = elementDiameter[eN];
    for (k = 0; k < nQuadraturePoints_element; k++) {
      num = shockCapturingDiffusion * h *
            fabs(strong_residual[eN * nQuadraturePoints_element + k]);
      enorm_h = fabs(H[eN * nQuadraturePoints_element + k]);
      if (shockCapturing == '1') {
        den = (fabs(mt[eN * nQuadraturePoints_element + k]) + enorm_h) +
              num * 1.0e-8;
      } else if (shockCapturing == '2') {
        den = sqrt(mt[eN * nQuadraturePoints_element + k] *
                       mt[eN * nQuadraturePoints_element + k] +
                   enorm_h * enorm_h) +
              num * 1.0e-8;
      }
      numDiff[eN * nQuadraturePoints_element + k] = num / den;
    }
  }
}


x86 assembly (clang, -O0):
<calculateNumericalDiffusionHJV2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %dl,%al
mov    0x18(%rbp),%rdx
mov    0x10(%rbp),%rdx
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12db <calculateNumericalDiffusionHJV2+0x1cb>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c8 <calculateNumericalDiffusionHJV2+0x1b8>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xe5d(%rip),%xmm2
pand   %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe33(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x31,%eax
jne    1228 <calculateNumericalDiffusionHJV2+0x118>
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xe00(%rip),%xmm0
pand   %xmm0,%xmm1
addsd  -0x58(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xdfa(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    129a <calculateNumericalDiffusionHJV2+0x18a>
movsbl -0x9(%rbp),%eax
cmp    $0x32,%eax
jne    1295 <calculateNumericalDiffusionHJV2+0x185>
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xd88(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    129a <calculateNumericalDiffusionHJV2+0x18a>
movsd  -0x48(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
mov    0x18(%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    1170 <calculateNumericalDiffusionHJV2+0x60>
jmp    12cd <calculateNumericalDiffusionHJV2+0x1bd>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114b <calculateNumericalDiffusionHJV2+0x3b>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculateNumericalDiffusionHJV2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %esi,0x4(%rsp)
test   %edi,%edi
jle    1293 <calculateNumericalDiffusionHJV2+0x183>
mov    %r9,%r12
mov    %edx,%ebx
mov    0x98(%rsp),%r15
mov    0x90(%rsp),%rbp
movslq 0x4(%rsp),%rax
mov    %edi,%ecx
mov    %rcx,0x18(%rsp)
mov    %eax,%r13d
shl    $0x3,%rax
mov    %rax,0x20(%rsp)
xorpd  %xmm8,%xmm8
xor    %edi,%edi
movapd 0xe8f(%rip),%xmm4
movsd  0xe97(%rip),%xmm5
movapd 0xe7f(%rip),%xmm6
xorpd  %xmm3,%xmm3
jmp    11b5 <calculateNumericalDiffusionHJV2+0xa5>
nopw   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rdi
add    $0x1,%rdi
mov    0x20(%rsp),%rax
add    %rax,%r8
add    %rax,%rbp
add    %rax,%r12
add    %rax,%r15
cmp    0x18(%rsp),%rdi
je     1293 <calculateNumericalDiffusionHJV2+0x183>
cmpl   $0x0,0x4(%rsp)
mov    %rdi,0x28(%rsp)
jle    1190 <calculateNumericalDiffusionHJV2+0x80>
mov    0x10(%rsp),%rax
movsd  (%rax,%rdi,8),%xmm7
mulsd  0x8(%rsp),%xmm7
xor    %r14d,%r14d
mov    %r8,0x38(%rsp)
movsd  %xmm7,0x30(%rsp)
jmp    123d <calculateNumericalDiffusionHJV2+0x12d>
movapd %xmm1,0x40(%rsp)
call   1030 <sqrt@plt>
movapd 0x40(%rsp),%xmm1
movsd  0x30(%rsp),%xmm7
movapd 0xe00(%rip),%xmm6
movsd  0xe08(%rip),%xmm5
movapd 0xdf0(%rip),%xmm4
xorpd  %xmm8,%xmm8
mov    0x38(%rsp),%r8
movapd %xmm1,%xmm3
mulsd  %xmm5,%xmm3
addsd  %xmm0,%xmm3
divsd  %xmm3,%xmm1
movsd  %xmm1,(%r15,%r14,8)
add    $0x1,%r14
cmp    %r14,%r13
je     1190 <calculateNumericalDiffusionHJV2+0x80>
movsd  (%r8,%r14,8),%xmm1
andpd  %xmm4,%xmm1
mulsd  %xmm7,%xmm1
movsd  0x0(%rbp,%r14,8),%xmm2
cmp    $0x32,%bl
je     1270 <calculateNumericalDiffusionHJV2+0x160>
cmp    $0x31,%bl
jne    1226 <calculateNumericalDiffusionHJV2+0x116>
andpd  %xmm6,%xmm2
movsd  (%r12,%r14,8),%xmm0
andpd  %xmm6,%xmm0
addsd  %xmm2,%xmm0
jmp    121a <calculateNumericalDiffusionHJV2+0x10a>
movsd  (%r12,%r14,8),%xmm0
mulsd  %xmm2,%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm8,%xmm0
jb     11e1 <calculateNumericalDiffusionHJV2+0xd1>
sqrtsd %xmm0,%xmm0
jmp    121a <calculateNumericalDiffusionHJV2+0x10a>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calculateNumericalDiffusionHJV2(i32 %0, i32 %1, i8 signext %2, double %3, double* %4, double* %5, double* %6, double* %7, double* %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca double
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
store i32 %0, i32* %10
store i32 %1, i32* %11
store i8 %2, i8* %12
store double %3, double* %13
store double* %4, double** %14
store double* %5, double** %15
store double* %6, double** %16
store double* %7, double** %17
store double* %8, double** %18
store double 0.000000e+00, double* %23
store i32 0, i32* %19
br label %25
25: ; preds = %129, %9
%26 = load i32, i32* %19
%27 = load i32, i32* %10
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %132
29: ; preds = %25
%30 = load double*, double** %14
%31 = load i32, i32* %19
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
store double %34, double* %21
store i32 0, i32* %20
br label %35
35: ; preds = %125, %29
%36 = load i32, i32* %20
%37 = load i32, i32* %11
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %128
39: ; preds = %35
%40 = load double, double* %13
%41 = load double, double* %21
%42 = fmul double %40, %41
%43 = load double*, double** %15
%44 = load i32, i32* %19
%45 = load i32, i32* %11
%46 = mul nsw i32 %44, %45
%47 = load i32, i32* %20
%48 = add nsw i32 %46, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %43, i64 %49
%51 = load double, double* %50
%52 = call double @llvm.fabs.f64(double %51)
%53 = fmul double %42, %52
store double %53, double* %22
%54 = load double*, double** %17
%55 = load i32, i32* %19
%56 = load i32, i32* %11
%57 = mul nsw i32 %55, %56
%58 = load i32, i32* %20
%59 = add nsw i32 %57, %58
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %54, i64 %60
%62 = load double, double* %61
%63 = call double @llvm.fabs.f64(double %62)
store double %63, double* %24
%64 = load i8, i8* %12
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 49
br i1 %66, label %67, label %82
67: ; preds = %39
%68 = load double*, double** %16
%69 = load i32, i32* %19
%70 = load i32, i32* %11
%71 = mul nsw i32 %69, %70
%72 = load i32, i32* %20
%73 = add nsw i32 %71, %72
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %68, i64 %74
%76 = load double, double* %75
%77 = call double @llvm.fabs.f64(double %76)
%78 = load double, double* %24
%79 = fadd double %77, %78
%80 = load double, double* %22
%81 = call double @llvm.fmuladd.f64(double %80, double 1.000000e-08, double %79)
store double %81, double* %23
br label %113
82: ; preds = %39
%83 = load i8, i8* %12
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 50
br i1 %85, label %86, label %112
86: ; preds = %82
%87 = load double*, double** %16
%88 = load i32, i32* %19
%89 = load i32, i32* %11
%90 = mul nsw i32 %88, %89
%91 = load i32, i32* %20
%92 = add nsw i32 %90, %91
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %87, i64 %93
%95 = load double, double* %94
%96 = load double*, double** %16
%97 = load i32, i32* %19
%98 = load i32, i32* %11
%99 = mul nsw i32 %97, %98
%100 = load i32, i32* %20
%101 = add nsw i32 %99, %100
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %96, i64 %102
%104 = load double, double* %103
%105 = load double, double* %24
%106 = load double, double* %24
%107 = fmul double %105, %106
%108 = call double @llvm.fmuladd.f64(double %95, double %104, double %107)
%109 = call double @sqrt(double %108)
%110 = load double, double* %22
%111 = call double @llvm.fmuladd.f64(double %110, double 1.000000e-08, double %109)
store double %111, double* %23
br label %112
112: ; preds = %86, %82
br label %113
113: ; preds = %112, %67
%114 = load double, double* %22
%115 = load double, double* %23
%116 = fdiv double %114, %115
%117 = load double*, double** %18
%118 = load i32, i32* %19
%119 = load i32, i32* %11
%120 = mul nsw i32 %118, %119
%121 = load i32, i32* %20
%122 = add nsw i32 %120, %121
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds double, double* %117, i64 %123
store double %116, double* %124
br label %125
125: ; preds = %113
%126 = load i32, i32* %20
%127 = add nsw i32 %126, 1
store i32 %127, i32* %20
br label %35
128: ; preds = %35
br label %129
129: ; preds = %128
%130 = load i32, i32* %19
%131 = add nsw i32 %130, 1
store i32 %131, i32* %19
br label %25
132: ; preds = %25
ret void
}

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