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

; Function Attrs: nounwind uwtable
declare dso_local float @liquid_filter_autocorr(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @liquid_filter_isi(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = mul i32 2, %17
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = mul i32 %18, %19
  %21 = add i32 %20, 1
  store i32 %21, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = call float @liquid_filter_autocorr(ptr noundef %22, i32 noundef %23, i32 noundef 0)
  store float %24, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store float 0.000000e+00, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store float 0.000000e+00, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %54, %5
  %26 = load i32, ptr %13, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = mul i32 2, %27
  %29 = icmp ule i32 %26, %28
  br i1 %29, label %30, label %57

30:                                               ; preds = %25
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = load i32, ptr %13, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = mul i32 %33, %34
  %36 = call float @liquid_filter_autocorr(ptr noundef %31, i32 noundef %32, i32 noundef %35)
  %37 = load float, ptr %12, align 4, !tbaa !11
  %38 = fdiv float %36, %37
  store float %38, ptr %16, align 4, !tbaa !11
  %39 = load float, ptr %16, align 4, !tbaa !11
  %40 = call float @llvm.fabs.f32(float %39)
  store float %40, ptr %16, align 4, !tbaa !11
  %41 = load float, ptr %16, align 4, !tbaa !11
  %42 = load float, ptr %16, align 4, !tbaa !11
  %43 = load float, ptr %14, align 4, !tbaa !11
  %44 = call float @llvm.fmuladd.f32(float %41, float %42, float %43)
  store float %44, ptr %14, align 4, !tbaa !11
  %45 = load i32, ptr %13, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 1
  br i1 %46, label %51, label %47

47:                                               ; preds = %30
  %48 = load float, ptr %16, align 4, !tbaa !11
  %49 = load float, ptr %15, align 4, !tbaa !11
  %50 = fcmp ogt float %48, %49
  br i1 %50, label %51, label %53

51:                                               ; preds = %47, %30
  %52 = load float, ptr %16, align 4, !tbaa !11
  store float %52, ptr %15, align 4, !tbaa !11
  br label %53

53:                                               ; preds = %51, %47
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = add i32 %55, 1
  store i32 %56, ptr %13, align 4, !tbaa !9
  br label %25, !llvm.loop !13

57:                                               ; preds = %25
  %58 = load float, ptr %14, align 4, !tbaa !11
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = mul i32 2, %59
  %61 = uitofp i32 %60 to float
  %62 = fdiv float %58, %61
  %63 = call float @sqrtf(float noundef %62) #4
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  store float %63, ptr %64, align 4, !tbaa !11
  %65 = load float, ptr %15, align 4, !tbaa !11
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  store float %65, ptr %66, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #3

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 "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 #4 = { 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

; Function Attrs: nounwind uwtable
declare dso_local float @liquid_filter_autocorr(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @liquid_filter_isi(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = shl i32 %1, 1
  %7 = mul i32 %6, %2
  %8 = or disjoint i32 %7, 1
  %9 = tail call float @liquid_filter_autocorr(ptr noundef %0, i32 noundef %8, i32 noundef 0)
  %10 = shl i32 %2, 1
  %.not27 = icmp eq i32 %10, 0
  br i1 %.not27, label %._crit_edge, label %.lr.ph.peel.next

.lr.ph.peel.next:                                 ; preds = %5
  %11 = tail call float @liquid_filter_autocorr(ptr noundef %0, i32 noundef %8, i32 noundef %1)
  %12 = fdiv float %11, %9
  %13 = tail call float @llvm.fmuladd.f32(float %12, float %12, float 0.000000e+00)
  %14 = tail call float @llvm.fabs.f32(float %12)
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.peel.next, %.lr.ph
  %.030 = phi float [ %.1, %.lr.ph ], [ %14, %.lr.ph.peel.next ]
  %.02429 = phi float [ %19, %.lr.ph ], [ %13, %.lr.ph.peel.next ]
  %.02528 = phi i32 [ %21, %.lr.ph ], [ 2, %.lr.ph.peel.next ]
  %15 = mul i32 %.02528, %1
  %16 = tail call float @liquid_filter_autocorr(ptr noundef %0, i32 noundef %8, i32 noundef %15)
  %17 = fdiv float %16, %9
  %18 = tail call float @llvm.fabs.f32(float %17)
  %19 = tail call float @llvm.fmuladd.f32(float %17, float %17, float %.02429)
  %20 = fcmp ogt float %18, %.030
  %.1 = select i1 %20, float %18, float %.030
  %21 = add nuw i32 %.02528, 1
  %exitcond.not = icmp eq i32 %.02528, %10
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %5
  %.024.lcssa = phi float [ 0.000000e+00, %5 ], [ %19, %.lr.ph ]
  %.0.lcssa = phi float [ 0.000000e+00, %5 ], [ %.1, %.lr.ph ]
  %22 = uitofp i32 %10 to float
  %23 = fdiv float %.024.lcssa, %22
  %24 = tail call float @sqrtf(float noundef %23) #3
  store float %24, ptr %3, align 4, !tbaa !8
  store float %.0.lcssa, ptr %4, align 4, !tbaa !8
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 = { mustprogress nofree nounwind willreturn memory(write) "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 = distinct !{!5, !6, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.peeled.count", i32 1}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass