; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (firdes)

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind uwtable
define dso_local float @liquid_filter_autocorr(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %10 = load i32, ptr %7, align 4, !tbaa !9
  %11 = call i32 @llvm.abs.i32(i32 %10, i1 true)
  store i32 %11, ptr %7, align 4, !tbaa !9
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = icmp uge i32 %12, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  store float 0.000000e+00, ptr %4, align 4
  br label %42

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store float 0.000000e+00, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %17 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %17, ptr %9, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %37, %16
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp ult i32 %19, %20
  br i1 %21, label %22, label %40

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

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

40:                                               ; preds = %18
  %41 = load float, ptr %8, align 4, !tbaa !11
  store float %41, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %42

42:                                               ; preds = %40, %15
  %43 = load float, ptr %4, align 4
  ret float %43
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local float @liquid_filter_autocorr(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = tail call i32 @llvm.abs.i32(i32 %2, i1 true)
  %.not = icmp ult i32 %4, %1
  br i1 %.not, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %3
  %5 = zext nneg i32 %4 to i64
  %wide.trip.count = zext i32 %1 to i64
  %6 = sub nsw i64 %wide.trip.count, %5
  %xtraiter = and i64 %6, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader.prol.loopexit, label %.preheader.prol

.preheader.prol:                                  ; preds = %.preheader.preheader, %.preheader.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %.preheader.prol ], [ %5, %.preheader.preheader ]
  %.01418.prol = phi float [ %12, %.preheader.prol ], [ 0.000000e+00, %.preheader.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.preheader.prol ], [ 0, %.preheader.preheader ]
  %7 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.prol
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = sub nuw nsw i64 %indvars.iv.prol, %5
  %10 = getelementptr inbounds float, ptr %0, i64 %9
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = tail call float @llvm.fmuladd.f32(float %8, float %11, float %.01418.prol)
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.preheader.prol.loopexit, label %.preheader.prol, !llvm.loop !9

.preheader.prol.loopexit:                         ; preds = %.preheader.prol, %.preheader.preheader
  %.lcssa.unr = phi float [ poison, %.preheader.preheader ], [ %12, %.preheader.prol ]
  %indvars.iv.unr = phi i64 [ %5, %.preheader.preheader ], [ %indvars.iv.next.prol, %.preheader.prol ]
  %.01418.unr = phi float [ 0.000000e+00, %.preheader.preheader ], [ %12, %.preheader.prol ]
  %13 = sub nsw i64 %5, %wide.trip.count
  %14 = icmp ugt i64 %13, -4
  br i1 %14, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.preheader.prol.loopexit, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.preheader ], [ %indvars.iv.unr, %.preheader.prol.loopexit ]
  %.01418 = phi float [ %38, %.preheader ], [ %.01418.unr, %.preheader.prol.loopexit ]
  %15 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = sub nuw nsw i64 %indvars.iv, %5
  %18 = getelementptr inbounds float, ptr %0, i64 %17
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = tail call float @llvm.fmuladd.f32(float %16, float %19, float %.01418)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = sub nuw nsw i64 %indvars.iv.next, %5
  %24 = getelementptr inbounds float, ptr %0, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !5
  %26 = tail call float @llvm.fmuladd.f32(float %22, float %25, float %20)
  %indvars.iv.next.1 = add nuw nsw 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 = sub nuw nsw i64 %indvars.iv.next.1, %5
  %30 = getelementptr inbounds float, ptr %0, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = tail call float @llvm.fmuladd.f32(float %28, float %31, float %26)
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %33 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next.2
  %34 = load float, ptr %33, align 4, !tbaa !5
  %35 = sub nuw nsw i64 %indvars.iv.next.2, %5
  %36 = getelementptr inbounds float, ptr %0, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !5
  %38 = tail call float @llvm.fmuladd.f32(float %34, float %37, float %32)
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %.loopexit, label %.preheader, !llvm.loop !11

.loopexit:                                        ; preds = %.preheader.prol.loopexit, %.preheader, %3
  %.015 = phi float [ 0.000000e+00, %3 ], [ %.lcssa.unr, %.preheader.prol.loopexit ], [ %38, %.preheader ]
  ret float %.015
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #0

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

!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: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass