; 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"

@.str.31 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [80 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #0

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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: nounwind uwtable
declare dso_local float @kaiser_beta_As(float noundef) #3

declare float @liquid_kaiser(i32 noundef, i32 noundef, float noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_firdes_notch(i32 noundef %0, float noundef %1, float noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !11
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = icmp ult i32 %16, 1
  br i1 %17, label %21, label %18

18:                                               ; preds = %4
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = icmp ugt i32 %19, 1000
  br i1 %20, label %21, label %24

21:                                               ; preds = %18, %4
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.31, i32 noundef 354, ptr noundef @.str.41, i32 noundef %22)
  store i32 %23, ptr %5, align 4
  br label %110

24:                                               ; preds = %18
  %25 = load float, ptr %7, align 4, !tbaa !9
  %26 = fcmp olt float %25, -5.000000e-01
  br i1 %26, label %30, label %27

27:                                               ; preds = %24
  %28 = load float, ptr %7, align 4, !tbaa !9
  %29 = fcmp ogt float %28, 5.000000e-01
  br i1 %29, label %30, label %34

30:                                               ; preds = %27, %24
  %31 = load float, ptr %7, align 4, !tbaa !9
  %32 = fpext float %31 to double
  %33 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.31, i32 noundef 356, ptr noundef @.str.42, double noundef %32)
  store i32 %33, ptr %5, align 4
  br label %110

34:                                               ; preds = %27
  %35 = load float, ptr %8, align 4, !tbaa !9
  %36 = fcmp ole float %35, 0.000000e+00
  br i1 %36, label %37, label %41

37:                                               ; preds = %34
  %38 = load float, ptr %8, align 4, !tbaa !9
  %39 = fpext float %38 to double
  %40 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.31, i32 noundef 358, ptr noundef @.str.43, double noundef %39)
  store i32 %40, ptr %5, align 4
  br label %110

41:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %42 = load float, ptr %8, align 4, !tbaa !9
  %43 = call float @kaiser_beta_As(float noundef %42)
  store float %43, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = mul i32 2, %44
  %46 = add i32 %45, 1
  store i32 %46, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store float 0.000000e+00, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %84, %41
  %48 = load i32, ptr %12, align 4, !tbaa !5
  %49 = load i32, ptr %11, align 4, !tbaa !5
  %50 = icmp ult i32 %48, %49
  br i1 %50, label %51, label %87

51:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %52 = load float, ptr %7, align 4, !tbaa !9
  %53 = fpext float %52 to double
  %54 = fmul double 0x401921FB54442D18, %53
  %55 = load i32, ptr %12, align 4, !tbaa !5
  %56 = uitofp i32 %55 to float
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = uitofp i32 %57 to float
  %59 = fsub float %56, %58
  %60 = fpext float %59 to double
  %61 = fmul double %54, %60
  %62 = fptrunc double %61 to float
  %63 = call float @cosf(float noundef %62) #5
  %64 = fneg float %63
  store float %64, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %65 = load i32, ptr %12, align 4, !tbaa !5
  %66 = load i32, ptr %11, align 4, !tbaa !5
  %67 = load float, ptr %10, align 4, !tbaa !9
  %68 = call float @liquid_kaiser(i32 noundef %65, i32 noundef %66, float noundef %67)
  store float %68, ptr %15, align 4, !tbaa !9
  %69 = load float, ptr %14, align 4, !tbaa !9
  %70 = load float, ptr %15, align 4, !tbaa !9
  %71 = fmul float %69, %70
  %72 = load ptr, ptr %9, align 8, !tbaa !11
  %73 = load i32, ptr %12, align 4, !tbaa !5
  %74 = zext i32 %73 to i64
  %75 = getelementptr inbounds float, ptr %72, i64 %74
  store float %71, ptr %75, align 4, !tbaa !9
  %76 = load ptr, ptr %9, align 8, !tbaa !11
  %77 = load i32, ptr %12, align 4, !tbaa !5
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %76, i64 %78
  %80 = load float, ptr %79, align 4, !tbaa !9
  %81 = load float, ptr %14, align 4, !tbaa !9
  %82 = load float, ptr %13, align 4, !tbaa !9
  %83 = call float @llvm.fmuladd.f32(float %80, float %81, float %82)
  store float %83, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %84

84:                                               ; preds = %51
  %85 = load i32, ptr %12, align 4, !tbaa !5
  %86 = add i32 %85, 1
  store i32 %86, ptr %12, align 4, !tbaa !5
  br label %47, !llvm.loop !13

87:                                               ; preds = %47
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %100, %87
  %89 = load i32, ptr %12, align 4, !tbaa !5
  %90 = load i32, ptr %11, align 4, !tbaa !5
  %91 = icmp ult i32 %89, %90
  br i1 %91, label %92, label %103

92:                                               ; preds = %88
  %93 = load float, ptr %13, align 4, !tbaa !9
  %94 = load ptr, ptr %9, align 8, !tbaa !11
  %95 = load i32, ptr %12, align 4, !tbaa !5
  %96 = zext i32 %95 to i64
  %97 = getelementptr inbounds float, ptr %94, i64 %96
  %98 = load float, ptr %97, align 4, !tbaa !9
  %99 = fdiv float %98, %93
  store float %99, ptr %97, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %92
  %101 = load i32, ptr %12, align 4, !tbaa !5
  %102 = add i32 %101, 1
  store i32 %102, ptr %12, align 4, !tbaa !5
  br label %88, !llvm.loop !15

103:                                              ; preds = %88
  %104 = load ptr, ptr %9, align 8, !tbaa !11
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = zext i32 %105 to i64
  %107 = getelementptr inbounds float, ptr %104, i64 %106
  %108 = load float, ptr %107, align 4, !tbaa !9
  %109 = fadd float %108, 1.000000e+00
  store float %109, ptr %107, align 4, !tbaa !9
  store i32 0, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %110

110:                                              ; preds = %103, %37, %30, %21
  %111 = load i32, ptr %5, align 4
  ret i32 %111
}

; Function Attrs: nounwind
declare float @cosf(float noundef) #4

attributes #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 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 #4 = { 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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !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"

@.str.31 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [80 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local float @kaiser_beta_As(float noundef) local_unnamed_addr #2

declare float @liquid_kaiser(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_firdes_notch(i32 noundef %0, float noundef %1, float noundef %2, ptr nocapture noundef %3) local_unnamed_addr #2 {
  %5 = add i32 %0, -1001
  %or.cond = icmp ult i32 %5, -1000
  br i1 %or.cond, label %6, label %8

6:                                                ; preds = %4
  %7 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.31, i32 noundef 354, ptr noundef nonnull @.str.41, i32 noundef %0) #5
  br label %50

8:                                                ; preds = %4
  %9 = tail call float @llvm.fabs.f32(float %1)
  %or.cond3 = fcmp ogt float %9, 5.000000e-01
  br i1 %or.cond3, label %10, label %13

10:                                               ; preds = %8
  %11 = fpext float %1 to double
  %12 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.31, i32 noundef 356, ptr noundef nonnull @.str.42, double noundef %11) #5
  br label %50

13:                                               ; preds = %8
  %14 = fcmp ugt float %2, 0.000000e+00
  br i1 %14, label %18, label %15

15:                                               ; preds = %13
  %16 = fpext float %2 to double
  %17 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.31, i32 noundef 358, ptr noundef nonnull @.str.43, double noundef %16) #5
  br label %50

18:                                               ; preds = %13
  %19 = tail call float @kaiser_beta_As(float noundef %2)
  %20 = shl nuw nsw i32 %0, 1
  %21 = or disjoint i32 %20, 1
  %22 = fpext float %1 to double
  %23 = fmul double %22, 0x401921FB54442D18
  %24 = uitofp nneg i32 %0 to float
  %25 = or disjoint i32 %20, 1
  %wide.trip.count = zext nneg i32 %25 to i64
  br label %30

.preheader:                                       ; preds = %30
  %min.iters.check = icmp ult i32 %0, 2
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %vector.body, %.preheader
  %indvars.iv51.ph = phi i64 [ 0, %.preheader ], [ %n.vec, %vector.body ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.preheader
  %26 = and i32 %20, 2044
  %n.vec = zext nneg i32 %26 to i64
  %broadcast.splatinsert = insertelement <4 x float> poison, float %42, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <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 ]
  %27 = getelementptr inbounds float, ptr %3, i64 %index
  %wide.load = load <4 x float>, ptr %27, align 4, !tbaa !5
  %28 = fdiv <4 x float> %wide.load, %broadcast.splat
  store <4 x float> %28, ptr %27, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %29 = icmp eq i64 %index.next, %n.vec
  br i1 %29, label %scalar.ph.preheader, label %vector.body, !llvm.loop !9

30:                                               ; preds = %18, %30
  %indvars.iv = phi i64 [ 0, %18 ], [ %indvars.iv.next, %30 ]
  %.03947 = phi float [ 0.000000e+00, %18 ], [ %42, %30 ]
  %31 = trunc nuw nsw i64 %indvars.iv to i32
  %32 = uitofp nneg i32 %31 to float
  %33 = fsub float %32, %24
  %34 = fpext float %33 to double
  %35 = fmul double %23, %34
  %36 = fptrunc double %35 to float
  %37 = tail call float @cosf(float noundef %36) #5
  %38 = fneg float %37
  %39 = tail call float @liquid_kaiser(i32 noundef %31, i32 noundef %21, float noundef %19) #5
  %40 = fmul float %39, %38
  %41 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  store float %40, ptr %41, align 4, !tbaa !5
  %42 = tail call float @llvm.fmuladd.f32(float %40, float %38, float %.03947)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %30, !llvm.loop !13

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %scalar.ph ], [ %indvars.iv51.ph, %scalar.ph.preheader ]
  %43 = getelementptr inbounds float, ptr %3, i64 %indvars.iv51
  %44 = load float, ptr %43, align 4, !tbaa !5
  %45 = fdiv float %44, %42
  store float %45, ptr %43, align 4, !tbaa !5
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %exitcond55.not = icmp eq i64 %indvars.iv.next52, %wide.trip.count
  br i1 %exitcond55.not, label %.loopexit, label %scalar.ph, !llvm.loop !14

.loopexit:                                        ; preds = %scalar.ph
  %46 = zext nneg i32 %0 to i64
  %47 = getelementptr inbounds float, ptr %3, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !5
  %49 = fadd float %48, 1.000000e+00
  store float %49, ptr %47, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %.loopexit, %15, %10, %6
  %.0 = phi i32 [ %7, %6 ], [ %12, %10 ], [ %17, %15 ], [ 0, %.loopexit ]
  ret i32 %.0
}

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

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

attributes #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 = { 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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/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}
!14 = distinct !{!14, !10, !12, !11}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass