; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/Numerics/FEM/src (dsrc2c)

; 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"

@sum3_.i = external hidden global i64, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @sum3_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = icmp sle i64 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %7
  store i32 0, ptr %8, align 4
  br label %87

20:                                               ; preds = %7
  %21 = load ptr, ptr %14, align 8, !tbaa !5
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = fcmp une double %22, 0.000000e+00
  br i1 %23, label %24, label %59

24:                                               ; preds = %20
  store i64 0, ptr @sum3_.i, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %55, %24
  %26 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = icmp slt i64 %26, %28
  br i1 %29, label %30, label %58

30:                                               ; preds = %25
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load double, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %35 = getelementptr inbounds double, ptr %33, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = load double, ptr %37, align 8, !tbaa !11
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %41 = getelementptr inbounds double, ptr %39, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = fmul double %38, %42
  %44 = call double @llvm.fmuladd.f64(double %32, double %36, double %43)
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = load ptr, ptr %15, align 8, !tbaa !5
  %48 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %49 = getelementptr inbounds double, ptr %47, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = call double @llvm.fmuladd.f64(double %46, double %50, double %44)
  %52 = load ptr, ptr %15, align 8, !tbaa !5
  %53 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %54 = getelementptr inbounds double, ptr %52, i64 %53
  store double %51, ptr %54, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %30
  %56 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr @sum3_.i, align 8, !tbaa !9
  br label %25, !llvm.loop !13

58:                                               ; preds = %25
  store i32 0, ptr %8, align 4
  br label %87

59:                                               ; preds = %20
  store i64 0, ptr @sum3_.i, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %83, %59
  %61 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = icmp slt i64 %61, %63
  br i1 %64, label %65, label %86

65:                                               ; preds = %60
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = load double, ptr %66, align 8, !tbaa !11
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %70 = getelementptr inbounds double, ptr %68, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !11
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = load double, ptr %72, align 8, !tbaa !11
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  %75 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %76 = getelementptr inbounds double, ptr %74, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !11
  %78 = fmul double %73, %77
  %79 = call double @llvm.fmuladd.f64(double %67, double %71, double %78)
  %80 = load ptr, ptr %15, align 8, !tbaa !5
  %81 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %82 = getelementptr inbounds double, ptr %80, i64 %81
  store double %79, ptr %82, align 8, !tbaa !11
  br label %83

83:                                               ; preds = %65
  %84 = load i64, ptr @sum3_.i, align 8, !tbaa !9
  %85 = add nsw i64 %84, 1
  store i64 %85, ptr @sum3_.i, align 8, !tbaa !9
  br label %60, !llvm.loop !15

86:                                               ; preds = %60
  store i32 0, ptr %8, align 4
  br label %87

87:                                               ; preds = %86, %58, %19
  %88 = load i32, ptr %8, align 4
  ret i32 %88
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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"

@sum3_.i = external hidden local_unnamed_addr global i64, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @sum3_(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 readonly %5, ptr nocapture noundef %6) local_unnamed_addr #0 {
  %8 = load i64, ptr %0, align 8, !tbaa !5
  %9 = icmp slt i64 %8, 1
  br i1 %9, label %.loopexit, label %10

10:                                               ; preds = %7
  %11 = load double, ptr %5, align 8, !tbaa !9
  %12 = fcmp une double %11, 0.000000e+00
  store i64 0, ptr @sum3_.i, align 8, !tbaa !5
  %13 = load i64, ptr %0, align 8, !tbaa !5
  %14 = icmp sgt i64 %13, 0
  br i1 %12, label %.preheader, label %.preheader18

.preheader18:                                     ; preds = %10
  br i1 %14, label %.lr.ph, label %.loopexit

.preheader:                                       ; preds = %10
  br i1 %14, label %.lr.ph22, label %.loopexit

.lr.ph22:                                         ; preds = %.preheader, %.lr.ph22
  %storemerge1721 = phi i64 [ %27, %.lr.ph22 ], [ 0, %.preheader ]
  %15 = load double, ptr %1, align 8, !tbaa !9
  %16 = getelementptr inbounds double, ptr %2, i64 %storemerge1721
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = load double, ptr %3, align 8, !tbaa !9
  %19 = getelementptr inbounds double, ptr %4, i64 %storemerge1721
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = fmul double %18, %20
  %22 = tail call double @llvm.fmuladd.f64(double %15, double %17, double %21)
  %23 = load double, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds double, ptr %6, i64 %storemerge1721
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = tail call double @llvm.fmuladd.f64(double %23, double %25, double %22)
  store double %26, ptr %24, align 8, !tbaa !9
  %27 = add nuw nsw i64 %storemerge1721, 1
  store i64 %27, ptr @sum3_.i, align 8, !tbaa !5
  %28 = load i64, ptr %0, align 8, !tbaa !5
  %29 = icmp slt i64 %27, %28
  br i1 %29, label %.lr.ph22, label %.loopexit, !llvm.loop !11

.lr.ph:                                           ; preds = %.preheader18, %.lr.ph
  %storemerge20 = phi i64 [ %39, %.lr.ph ], [ 0, %.preheader18 ]
  %30 = load double, ptr %1, align 8, !tbaa !9
  %31 = getelementptr inbounds double, ptr %2, i64 %storemerge20
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = load double, ptr %3, align 8, !tbaa !9
  %34 = getelementptr inbounds double, ptr %4, i64 %storemerge20
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = fmul double %33, %35
  %37 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %36)
  %38 = getelementptr inbounds double, ptr %6, i64 %storemerge20
  store double %37, ptr %38, align 8, !tbaa !9
  %39 = add nuw nsw i64 %storemerge20, 1
  store i64 %39, ptr @sum3_.i, align 8, !tbaa !5
  %40 = load i64, ptr %0, align 8, !tbaa !5
  %41 = icmp slt i64 %39, %40
  br i1 %41, label %.lr.ph, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph22, %.preheader18, %.preheader, %7
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { nofree norecurse nosync nounwind 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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"long", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass