; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libSimuTilts/digital_tilt.ll (Z14ConvBufferFastPfS_ii)

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

14:                                               ; preds = %48, %4
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %18, label %51

18:                                               ; preds = %14
  store float 0.000000e+00, ptr %13, align 4, !tbaa !11
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds float, ptr %19, i64 %21
  store ptr %22, ptr %10, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds float, ptr %23, i64 0
  store ptr %24, ptr %11, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %25, i64 %27
  store ptr %28, ptr %12, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %33, %18
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = icmp ult ptr %30, %31
  br i1 %32, label %33, label %42

33:                                               ; preds = %29
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds float, ptr %34, i32 1
  store ptr %35, ptr %10, align 8, !tbaa !5
  %36 = load float, ptr %34, align 4, !tbaa !11
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds float, ptr %37, i32 1
  store ptr %38, ptr %11, align 8, !tbaa !5
  %39 = load float, ptr %37, align 4, !tbaa !11
  %40 = load float, ptr %13, align 4, !tbaa !11
  %41 = call float @llvm.fmuladd.f32(float %36, float %39, float %40)
  store float %41, ptr %13, align 4, !tbaa !11
  br label %29, !llvm.loop !13

42:                                               ; preds = %29
  %43 = load float, ptr %13, align 4, !tbaa !11
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %44, i64 %46
  store float %43, ptr %47, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %42
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %9, align 4, !tbaa !9
  br label %14, !llvm.loop !15

51:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #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 = { 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 #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++ 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"}
!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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_Z14ConvBufferFastPfS_ii(ptr nocapture noundef %0, ptr noundef readonly %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp sgt i32 %2, 0
  br i1 %5, label %.lr.ph23, label %._crit_edge24

.lr.ph23:                                         ; preds = %4
  %6 = sext i32 %3 to i64
  %7 = getelementptr inbounds float, ptr %1, i64 %6
  %8 = icmp sgt i32 %3, 0
  %wide.trip.count = zext nneg i32 %2 to i64
  br i1 %8, label %.lr.ph.us.preheader, label %.lr.ph23.split.preheader

.lr.ph.us.preheader:                              ; preds = %.lr.ph23
  %xtraiter = and i64 %wide.trip.count, 1
  %9 = icmp eq i32 %2, 1
  br i1 %9, label %._crit_edge24.loopexit.unr-lcssa, label %.lr.ph.us.preheader.new

.lr.ph.us.preheader.new:                          ; preds = %.lr.ph.us.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph.us

.lr.ph23.split.preheader:                         ; preds = %.lr.ph23
  %10 = shl nuw nsw i64 %wide.trip.count, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %0, i8 0, i64 %10, i1 false), !tbaa !5
  br label %._crit_edge24

.lr.ph.us:                                        ; preds = %._crit_edge.us.1, %.lr.ph.us.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.us.preheader.new ], [ %indvars.iv.next.1, %._crit_edge.us.1 ]
  %niter = phi i64 [ 0, %.lr.ph.us.preheader.new ], [ %niter.next.1, %._crit_edge.us.1 ]
  %11 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  br label %12

12:                                               ; preds = %.lr.ph.us, %12
  %.020.us = phi float [ 0.000000e+00, %.lr.ph.us ], [ %17, %12 ]
  %.01619.us = phi ptr [ %1, %.lr.ph.us ], [ %15, %12 ]
  %.01718.us = phi ptr [ %11, %.lr.ph.us ], [ %13, %12 ]
  %13 = getelementptr inbounds i8, ptr %.01718.us, i64 4
  %14 = load float, ptr %.01718.us, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.01619.us, i64 4
  %16 = load float, ptr %.01619.us, align 4, !tbaa !5
  %17 = tail call float @llvm.fmuladd.f32(float %14, float %16, float %.020.us)
  %18 = icmp ult ptr %15, %7
  br i1 %18, label %12, label %._crit_edge.us, !llvm.loop !9

._crit_edge.us:                                   ; preds = %12
  store float %17, ptr %11, align 4, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %19 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  br label %20

20:                                               ; preds = %20, %._crit_edge.us
  %.020.us.1 = phi float [ 0.000000e+00, %._crit_edge.us ], [ %25, %20 ]
  %.01619.us.1 = phi ptr [ %1, %._crit_edge.us ], [ %23, %20 ]
  %.01718.us.1 = phi ptr [ %19, %._crit_edge.us ], [ %21, %20 ]
  %21 = getelementptr inbounds i8, ptr %.01718.us.1, i64 4
  %22 = load float, ptr %.01718.us.1, align 4, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %.01619.us.1, i64 4
  %24 = load float, ptr %.01619.us.1, align 4, !tbaa !5
  %25 = tail call float @llvm.fmuladd.f32(float %22, float %24, float %.020.us.1)
  %26 = icmp ult ptr %23, %7
  br i1 %26, label %20, label %._crit_edge.us.1, !llvm.loop !9

._crit_edge.us.1:                                 ; preds = %20
  store float %25, ptr %19, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge24.loopexit.unr-lcssa, label %.lr.ph.us, !llvm.loop !11

._crit_edge24.loopexit.unr-lcssa:                 ; preds = %._crit_edge.us.1, %.lr.ph.us.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next.1, %._crit_edge.us.1 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge24, label %.lr.ph.us.epil

.lr.ph.us.epil:                                   ; preds = %._crit_edge24.loopexit.unr-lcssa
  %27 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.unr
  br label %28

28:                                               ; preds = %28, %.lr.ph.us.epil
  %.020.us.epil = phi float [ 0.000000e+00, %.lr.ph.us.epil ], [ %33, %28 ]
  %.01619.us.epil = phi ptr [ %1, %.lr.ph.us.epil ], [ %31, %28 ]
  %.01718.us.epil = phi ptr [ %27, %.lr.ph.us.epil ], [ %29, %28 ]
  %29 = getelementptr inbounds i8, ptr %.01718.us.epil, i64 4
  %30 = load float, ptr %.01718.us.epil, align 4, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %.01619.us.epil, i64 4
  %32 = load float, ptr %.01619.us.epil, align 4, !tbaa !5
  %33 = tail call float @llvm.fmuladd.f32(float %30, float %32, float %.020.us.epil)
  %34 = icmp ult ptr %31, %7
  br i1 %34, label %28, label %._crit_edge.us.epil, !llvm.loop !9

._crit_edge.us.epil:                              ; preds = %28
  store float %33, ptr %27, align 4, !tbaa !5
  br label %._crit_edge24

._crit_edge24:                                    ; preds = %._crit_edge.us.epil, %._crit_edge24.loopexit.unr-lcssa, %.lr.ph23.split.preheader, %4
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress 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) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass