; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libSimuTilts/library.ll (Z7combinePffS_fS_i)

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

14:                                               ; preds = %38, %6
  %15 = load i32, ptr %13, align 4, !tbaa !11
  %16 = load i32, ptr %12, align 4, !tbaa !11
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

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

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

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

41:                                               ; preds = %18
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_Z7combinePffS_fS_i(ptr nocapture noundef readonly %0, float noundef %1, ptr nocapture noundef readonly %2, float noundef %3, ptr nocapture noundef writeonly %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = ptrtoint ptr %2 to i64
  %8 = ptrtoint ptr %0 to i64
  %9 = ptrtoint ptr %4 to i64
  %10 = icmp sgt i32 %5, 0
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %6
  %wide.trip.count = zext nneg i32 %5 to i64
  %min.iters.check = icmp ult i32 %5, 8
  br i1 %min.iters.check, label %.lr.ph.preheader18, label %vector.memcheck

.lr.ph.preheader18:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader18
  %11 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.ph
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.ph
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = fmul float %14, %3
  %16 = tail call float @llvm.fmuladd.f32(float %1, float %12, float %15)
  %17 = getelementptr inbounds float, ptr %4, i64 %indvars.iv.ph
  store float %16, ptr %17, align 4, !tbaa !5
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader18
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.preheader18 ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %18 = add nsw i64 %wide.trip.count, -1
  %19 = icmp eq i64 %indvars.iv.ph, %18
  br i1 %19, label %._crit_edge, label %.lr.ph

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %20 = sub i64 %9, %8
  %diff.check = icmp ult i64 %20, 32
  %21 = sub i64 %9, %7
  %diff.check12 = icmp ult i64 %21, 32
  %conflict.rdx = or i1 %diff.check, %diff.check12
  br i1 %conflict.rdx, label %.lr.ph.preheader18, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483640
  %broadcast.splatinsert = insertelement <4 x float> poison, float %3, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert16 = insertelement <4 x float> poison, float %1, i64 0
  %broadcast.splat17 = shufflevector <4 x float> %broadcast.splatinsert16, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %22 = getelementptr inbounds float, ptr %0, i64 %index
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %wide.load = load <4 x float>, ptr %22, align 4, !tbaa !5
  %wide.load13 = load <4 x float>, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds float, ptr %2, i64 %index
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load14 = load <4 x float>, ptr %24, align 4, !tbaa !5
  %wide.load15 = load <4 x float>, ptr %25, align 4, !tbaa !5
  %26 = fmul <4 x float> %wide.load14, %broadcast.splat
  %27 = fmul <4 x float> %wide.load15, %broadcast.splat
  %28 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %broadcast.splat17, <4 x float> %wide.load, <4 x float> %26)
  %29 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %broadcast.splat17, <4 x float> %wide.load13, <4 x float> %27)
  %30 = getelementptr inbounds float, ptr %4, i64 %index
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  store <4 x float> %28, ptr %30, align 4, !tbaa !5
  store <4 x float> %29, ptr %31, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader18

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %6
  ret void

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %33 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %34 = load float, ptr %33, align 4, !tbaa !5
  %35 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %36 = load float, ptr %35, align 4, !tbaa !5
  %37 = fmul float %36, %3
  %38 = tail call float @llvm.fmuladd.f32(float %1, float %34, float %37)
  %39 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  store float %38, ptr %39, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %40 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  %41 = load float, ptr %40, align 4, !tbaa !5
  %42 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.next
  %43 = load float, ptr %42, align 4, !tbaa !5
  %44 = fmul float %43, %3
  %45 = tail call float @llvm.fmuladd.f32(float %1, float %41, float %44)
  %46 = getelementptr inbounds float, ptr %4, i64 %indvars.iv.next
  store float %45, ptr %46, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !13
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #2

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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) }
attributes #2 = { 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++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}


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