; LLVM IR from codee-com/open-catalog :: Checks/PWR028 (example)

; 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: nounwind uwtable
define dso_local void @example(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %13, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %37, %5
  %15 = load i32, ptr %12, align 4, !tbaa !9
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = icmp ult i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %40

19:                                               ; preds = %14
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds float, ptr %20, i64 %22
  %24 = load float, ptr %23, align 4, !tbaa !11
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds float, ptr %25, i64 0
  %27 = load float, ptr %26, align 4, !tbaa !11
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds float, ptr %28, i64 0
  %30 = load float, ptr %29, align 4, !tbaa !11
  %31 = call float @llvm.fmuladd.f32(float %24, float %27, float %30)
  store float %31, ptr %29, align 4, !tbaa !11
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = zext i32 %32 to i64
  %35 = sub i64 0, %34
  %36 = getelementptr inbounds float, ptr %33, i64 %35
  store ptr %36, ptr %11, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %19
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = add i32 %38, 1
  store i32 %39, ptr %12, align 4, !tbaa !9
  br label %14, !llvm.loop !13

40:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @example(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %6 = zext i32 %4 to i64
  %7 = sub nsw i64 0, %6
  %.promoted = load float, ptr %2, align 4, !tbaa !5
  %wide.trip.count = zext i32 %3 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %8 = icmp ult i32 %3, 4
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %15

._crit_edge.loopexit.unr-lcssa:                   ; preds = %15, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.3, %15 ]
  %.unr = phi float [ %.promoted, %.lr.ph ], [ %35, %15 ]
  %.0910.unr = phi ptr [ %1, %.lr.ph ], [ %36, %15 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %9 = phi float [ %13, %.epil.preheader ], [ %.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.0910.epil = phi ptr [ %14, %.epil.preheader ], [ %.0910.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %10 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.epil
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = load float, ptr %.0910.epil, align 4, !tbaa !5
  %13 = tail call float @llvm.fmuladd.f32(float %11, float %12, float %9)
  store float %13, ptr %2, align 4, !tbaa !5
  %14 = getelementptr inbounds float, ptr %.0910.epil, i64 %7
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %5
  ret void

15:                                               ; preds = %15, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.3, %15 ]
  %16 = phi float [ %.promoted, %.lr.ph.new ], [ %35, %15 ]
  %.0910 = phi ptr [ %1, %.lr.ph.new ], [ %36, %15 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %15 ]
  %17 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = load float, ptr %.0910, align 4, !tbaa !5
  %20 = tail call float @llvm.fmuladd.f32(float %18, float %19, float %16)
  store float %20, ptr %2, align 4, !tbaa !5
  %21 = getelementptr inbounds float, ptr %.0910, i64 %7
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %22 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = load float, ptr %21, align 4, !tbaa !5
  %25 = tail call float @llvm.fmuladd.f32(float %23, float %24, float %20)
  store float %25, ptr %2, align 4, !tbaa !5
  %26 = getelementptr inbounds float, ptr %21, i64 %7
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %27 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next.1
  %28 = load float, ptr %27, align 4, !tbaa !5
  %29 = load float, ptr %26, align 4, !tbaa !5
  %30 = tail call float @llvm.fmuladd.f32(float %28, float %29, float %25)
  store float %30, ptr %2, align 4, !tbaa !5
  %31 = getelementptr inbounds float, ptr %26, i64 %7
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %32 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next.2
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = load float, ptr %31, align 4, !tbaa !5
  %35 = tail call float @llvm.fmuladd.f32(float %33, float %34, float %30)
  store float %35, ptr %2, align 4, !tbaa !5
  %36 = getelementptr inbounds float, ptr %31, i64 %7
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %15, !llvm.loop !11
}

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

attributes #0 = { nofree norecurse nosync nounwind memory(read, 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass