; LLVM IR from sourceryinstitute/MORFEUS-Source :: src/FV/src/mesh_optimize/OptMS (SMfunc3d)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @vGradNormJacSquared(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca [3 x double], align 16
  %15 = alloca [3 x double], align 16
  %16 = alloca [3 x double], align 16
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #2
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds double, ptr %17, i64 0
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds double, ptr %20, i64 0
  %22 = load double, ptr %21, align 8, !tbaa !9
  %23 = fsub double %19, %22
  %24 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  store double %23, ptr %24, align 16, !tbaa !9
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i64 1
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds double, ptr %28, i64 1
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = fsub double %27, %30
  %32 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 1
  store double %31, ptr %32, align 8, !tbaa !9
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds double, ptr %33, i64 2
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds double, ptr %36, i64 2
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = fsub double %35, %38
  %40 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 2
  store double %39, ptr %40, align 16, !tbaa !9
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds double, ptr %41, i64 0
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds double, ptr %44, i64 0
  %46 = load double, ptr %45, align 8, !tbaa !9
  %47 = fsub double %43, %46
  %48 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 0
  store double %47, ptr %48, align 16, !tbaa !9
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds double, ptr %49, i64 1
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds double, ptr %52, i64 1
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = fsub double %51, %54
  %56 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 1
  store double %55, ptr %56, align 8, !tbaa !9
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds double, ptr %57, i64 2
  %59 = load double, ptr %58, align 8, !tbaa !9
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds double, ptr %60, i64 2
  %62 = load double, ptr %61, align 8, !tbaa !9
  %63 = fsub double %59, %62
  %64 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 2
  store double %63, ptr %64, align 16, !tbaa !9
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = getelementptr inbounds double, ptr %65, i64 0
  %67 = load double, ptr %66, align 8, !tbaa !9
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds double, ptr %68, i64 0
  %70 = load double, ptr %69, align 8, !tbaa !9
  %71 = fsub double %67, %70
  %72 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 0
  store double %71, ptr %72, align 16, !tbaa !9
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds double, ptr %73, i64 1
  %75 = load double, ptr %74, align 8, !tbaa !9
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = getelementptr inbounds double, ptr %76, i64 1
  %78 = load double, ptr %77, align 8, !tbaa !9
  %79 = fsub double %75, %78
  %80 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 1
  store double %79, ptr %80, align 8, !tbaa !9
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = getelementptr inbounds double, ptr %81, i64 2
  %83 = load double, ptr %82, align 8, !tbaa !9
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds double, ptr %84, i64 2
  %86 = load double, ptr %85, align 8, !tbaa !9
  %87 = fsub double %83, %86
  %88 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 2
  store double %87, ptr %88, align 16, !tbaa !9
  %89 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %90 = load double, ptr %89, align 16, !tbaa !9
  %91 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 0
  %92 = load double, ptr %91, align 16, !tbaa !9
  %93 = fadd double %90, %92
  %94 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 0
  %95 = load double, ptr %94, align 16, !tbaa !9
  %96 = fadd double %93, %95
  %97 = fmul double -2.000000e+00, %96
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  %99 = getelementptr inbounds ptr, ptr %98, i64 0
  %100 = load ptr, ptr %99, align 8, !tbaa !5
  %101 = getelementptr inbounds double, ptr %100, i64 0
  store double %97, ptr %101, align 8, !tbaa !9
  %102 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 1
  %103 = load double, ptr %102, align 8, !tbaa !9
  %104 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 1
  %105 = load double, ptr %104, align 8, !tbaa !9
  %106 = fadd double %103, %105
  %107 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 1
  %108 = load double, ptr %107, align 8, !tbaa !9
  %109 = fadd double %106, %108
  %110 = fmul double -2.000000e+00, %109
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = getelementptr inbounds ptr, ptr %111, i64 0
  %113 = load ptr, ptr %112, align 8, !tbaa !5
  %114 = getelementptr inbounds double, ptr %113, i64 1
  store double %110, ptr %114, align 8, !tbaa !9
  %115 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 2
  %116 = load double, ptr %115, align 16, !tbaa !9
  %117 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 2
  %118 = load double, ptr %117, align 16, !tbaa !9
  %119 = fadd double %116, %118
  %120 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 2
  %121 = load double, ptr %120, align 16, !tbaa !9
  %122 = fadd double %119, %121
  %123 = fmul double -2.000000e+00, %122
  %124 = load ptr, ptr %11, align 8, !tbaa !5
  %125 = getelementptr inbounds ptr, ptr %124, i64 0
  %126 = load ptr, ptr %125, align 8, !tbaa !5
  %127 = getelementptr inbounds double, ptr %126, i64 2
  store double %123, ptr %127, align 8, !tbaa !9
  %128 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 1, ptr %128, align 4, !tbaa !11
  store i32 0, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @vGradNormJacSquared(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fsub double %8, %10
  %12 = getelementptr inbounds i8, ptr %2, i64 16
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fsub double %13, %10
  %15 = getelementptr inbounds i8, ptr %3, i64 16
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fsub double %16, %10
  %18 = load ptr, ptr %4, align 8, !tbaa !9
  %19 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %20 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %21 = fsub <2 x double> %19, %20
  %22 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %23 = fsub <2 x double> %22, %20
  %24 = load <2 x double>, ptr %3, align 8, !tbaa !5
  %25 = fsub <2 x double> %24, %20
  %26 = fadd <2 x double> %21, %23
  %27 = fadd <2 x double> %26, %25
  %28 = fmul <2 x double> %27, <double -2.000000e+00, double -2.000000e+00>
  store <2 x double> %28, ptr %18, align 8, !tbaa !5
  %29 = fadd double %11, %14
  %30 = fadd double %29, %17
  %31 = fmul double %30, -2.000000e+00
  %32 = getelementptr inbounds i8, ptr %18, i64 16
  store double %31, ptr %32, align 8, !tbaa !5
  store i32 1, ptr %5, align 4, !tbaa !11
  ret i32 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass