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

@prsred_.ii = external hidden global i64, align 8
@prsred_.jj = external hidden global i64, align 8
@prsred_.sum = external hidden global double, align 8
@prsred_.jajj = external hidden global i64, align 8
@prsred_.ibgn = external hidden global i64, align 8
@prsred_.iend = external hidden global i64, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @prsred_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %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 ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 0, ptr @prsred_.ii, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %75, %7
  %17 = load i64, ptr @prsred_.ii, align 8, !tbaa !9
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = icmp slt i64 %17, %19
  br i1 %20, label %21, label %78

21:                                               ; preds = %16
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = load i64, ptr @prsred_.ii, align 8, !tbaa !9
  %24 = getelementptr inbounds i64, ptr %22, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = sub nsw i64 %25, 1
  store i64 %26, ptr @prsred_.ibgn, align 8, !tbaa !9
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = load i64, ptr @prsred_.ii, align 8, !tbaa !9
  %29 = add nsw i64 %28, 1
  %30 = getelementptr inbounds i64, ptr %27, i64 %29
  %31 = load i64, ptr %30, align 8, !tbaa !9
  %32 = sub nsw i64 %31, 1
  store i64 %32, ptr @prsred_.iend, align 8, !tbaa !9
  %33 = load i64, ptr @prsred_.ibgn, align 8, !tbaa !9
  %34 = load i64, ptr @prsred_.iend, align 8, !tbaa !9
  %35 = icmp sge i64 %33, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %21
  br label %75

37:                                               ; preds = %21
  %38 = load ptr, ptr %14, align 8, !tbaa !5
  %39 = load i64, ptr @prsred_.ii, align 8, !tbaa !9
  %40 = getelementptr inbounds double, ptr %38, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !11
  store double %41, ptr @prsred_.sum, align 8, !tbaa !11
  %42 = load i64, ptr @prsred_.ibgn, align 8, !tbaa !9
  store i64 %42, ptr @prsred_.jj, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %67, %37
  %44 = load i64, ptr @prsred_.jj, align 8, !tbaa !9
  %45 = load i64, ptr @prsred_.iend, align 8, !tbaa !9
  %46 = icmp slt i64 %44, %45
  br i1 %46, label %47, label %70

47:                                               ; preds = %43
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = load i64, ptr @prsred_.jj, align 8, !tbaa !9
  %50 = getelementptr inbounds i64, ptr %48, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load i64, ptr %52, align 8, !tbaa !9
  %54 = sub nsw i64 %51, %53
  %55 = sub nsw i64 %54, 1
  store i64 %55, ptr @prsred_.jajj, align 8, !tbaa !9
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = load i64, ptr @prsred_.jj, align 8, !tbaa !9
  %58 = getelementptr inbounds double, ptr %56, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !11
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = load i64, ptr @prsred_.jajj, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %60, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = load double, ptr @prsred_.sum, align 8, !tbaa !11
  %65 = fneg double %59
  %66 = call double @llvm.fmuladd.f64(double %65, double %63, double %64)
  store double %66, ptr @prsred_.sum, align 8, !tbaa !11
  br label %67

67:                                               ; preds = %47
  %68 = load i64, ptr @prsred_.jj, align 8, !tbaa !9
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr @prsred_.jj, align 8, !tbaa !9
  br label %43, !llvm.loop !13

70:                                               ; preds = %43
  %71 = load double, ptr @prsred_.sum, align 8, !tbaa !11
  %72 = load ptr, ptr %14, align 8, !tbaa !5
  %73 = load i64, ptr @prsred_.ii, align 8, !tbaa !9
  %74 = getelementptr inbounds double, ptr %72, i64 %73
  store double %71, ptr %74, align 8, !tbaa !11
  br label %75

75:                                               ; preds = %70, %36
  %76 = load i64, ptr @prsred_.ii, align 8, !tbaa !9
  %77 = add nsw i64 %76, 1
  store i64 %77, ptr @prsred_.ii, align 8, !tbaa !9
  br label %16, !llvm.loop !15

78:                                               ; preds = %16
  ret i32 0
}

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

@prsred_.ii = external hidden local_unnamed_addr global i64, align 8
@prsred_.jj = external hidden local_unnamed_addr global i64, align 8
@prsred_.sum = external hidden local_unnamed_addr global double, align 8
@prsred_.jajj = external hidden local_unnamed_addr global i64, align 8
@prsred_.ibgn = external hidden local_unnamed_addr global i64, align 8
@prsred_.iend = 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 @prsred_(ptr nocapture noundef readnone %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 {
  store i64 0, ptr @prsred_.ii, align 8, !tbaa !5
  %8 = load i64, ptr %1, align 8, !tbaa !5
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %7, %57
  %storemerge13 = phi i64 [ %58, %57 ], [ 0, %7 ]
  %10 = getelementptr inbounds i64, ptr %2, i64 %storemerge13
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = add nsw i64 %11, -1
  store i64 %12, ptr @prsred_.ibgn, align 8, !tbaa !5
  %13 = getelementptr i8, ptr %10, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = add i64 %14, -1
  store i64 %15, ptr @prsred_.iend, align 8, !tbaa !5
  %.not = icmp slt i64 %11, %14
  br i1 %.not, label %16, label %57

16:                                               ; preds = %.lr.ph
  %17 = getelementptr inbounds double, ptr %6, i64 %storemerge13
  %18 = load double, ptr %17, align 8, !tbaa !9
  store double %18, ptr @prsred_.sum, align 8, !tbaa !9
  store i64 %12, ptr @prsred_.jj, align 8, !tbaa !5
  %19 = sub i64 %14, %11
  %.neg = add i64 %11, 1
  %xtraiter = and i64 %19, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.loopexit.unr-lcssa

.prol.loopexit.unr-lcssa:                         ; preds = %16
  %20 = getelementptr inbounds i64, ptr %3, i64 %12
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = load i64, ptr %1, align 8, !tbaa !5
  %23 = xor i64 %22, -1
  %24 = add i64 %21, %23
  store i64 %24, ptr @prsred_.jajj, align 8, !tbaa !5
  %25 = getelementptr inbounds double, ptr %4, i64 %12
  %26 = load double, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds double, ptr %5, i64 %24
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = fneg double %26
  %30 = tail call double @llvm.fmuladd.f64(double %29, double %28, double %18)
  store double %30, ptr @prsred_.sum, align 8, !tbaa !9
  store i64 %11, ptr @prsred_.jj, align 8, !tbaa !5
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %16
  %.lcssa.unr = phi double [ poison, %16 ], [ %30, %.prol.loopexit.unr-lcssa ]
  %storemerge1112.unr = phi i64 [ %12, %16 ], [ %11, %.prol.loopexit.unr-lcssa ]
  %.unr = phi double [ %18, %16 ], [ %30, %.prol.loopexit.unr-lcssa ]
  %31 = icmp eq i64 %14, %.neg
  br i1 %31, label %.unr-lcssa, label %.new

.new:                                             ; preds = %.prol.loopexit, %.new
  %storemerge1112 = phi i64 [ %56, %.new ], [ %storemerge1112.unr, %.prol.loopexit ]
  %32 = phi double [ %55, %.new ], [ %.unr, %.prol.loopexit ]
  %33 = getelementptr inbounds i64, ptr %3, i64 %storemerge1112
  %34 = load i64, ptr %33, align 8, !tbaa !5
  %35 = load i64, ptr %1, align 8, !tbaa !5
  %36 = xor i64 %35, -1
  %37 = add i64 %34, %36
  store i64 %37, ptr @prsred_.jajj, align 8, !tbaa !5
  %38 = getelementptr inbounds double, ptr %4, i64 %storemerge1112
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds double, ptr %5, i64 %37
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = fneg double %39
  %43 = tail call double @llvm.fmuladd.f64(double %42, double %41, double %32)
  store double %43, ptr @prsred_.sum, align 8, !tbaa !9
  %44 = add nsw i64 %storemerge1112, 1
  store i64 %44, ptr @prsred_.jj, align 8, !tbaa !5
  %45 = getelementptr inbounds i64, ptr %3, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !5
  %47 = load i64, ptr %1, align 8, !tbaa !5
  %48 = xor i64 %47, -1
  %49 = add i64 %46, %48
  store i64 %49, ptr @prsred_.jajj, align 8, !tbaa !5
  %50 = getelementptr inbounds double, ptr %4, i64 %44
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = getelementptr inbounds double, ptr %5, i64 %49
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = fneg double %51
  %55 = tail call double @llvm.fmuladd.f64(double %54, double %53, double %43)
  store double %55, ptr @prsred_.sum, align 8, !tbaa !9
  %56 = add nsw i64 %storemerge1112, 2
  store i64 %56, ptr @prsred_.jj, align 8, !tbaa !5
  %exitcond.not.1 = icmp eq i64 %56, %15
  br i1 %exitcond.not.1, label %.unr-lcssa, label %.new, !llvm.loop !11

.unr-lcssa:                                       ; preds = %.new, %.prol.loopexit
  %.lcssa = phi double [ %.lcssa.unr, %.prol.loopexit ], [ %55, %.new ]
  store double %.lcssa, ptr %17, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %.lr.ph, %.unr-lcssa
  %58 = add nuw nsw i64 %storemerge13, 1
  store i64 %58, ptr @prsred_.ii, align 8, !tbaa !5
  %59 = load i64, ptr %1, align 8, !tbaa !5
  %60 = icmp slt i64 %58, %59
  br i1 %60, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %57, %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,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass