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

; 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.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [42 x i8], align 1

declare ptr @liquid_error_config_fl(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 willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @firfilt_crcf_create(ptr noundef, i32 noundef) #3

declare i32 @liquid_firdes_notch(i32 noundef, float noundef, float noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @firfilt_crcf_create_notch(i32 noundef %0, float noundef %1, float noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = mul i32 2, %14
  %16 = add i32 %15, 1
  store i32 %16, ptr %9, align 4, !tbaa !5
  %17 = load i32, ptr %9, align 4, !tbaa !5
  %18 = zext i32 %17 to i64
  %19 = call ptr @llvm.stacksave.p0()
  store ptr %19, ptr %10, align 8
  %20 = alloca float, i64 %18, align 16
  store i64 %18, ptr %11, align 8
  %21 = load i32, ptr %9, align 4, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = alloca float, i64 %22, align 16
  store i64 %22, ptr %12, align 8
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = load float, ptr %7, align 4, !tbaa !9
  %26 = load float, ptr %6, align 4, !tbaa !9
  %27 = call i32 @liquid_firdes_notch(i32 noundef %24, float noundef %25, float noundef %26, ptr noundef %20)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %3
  %30 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.38, i32 noundef 242, ptr noundef @.str.45, ptr noundef @.str.2)
  store ptr %30, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %50

31:                                               ; preds = %3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %44, %31
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %36, label %47

36:                                               ; preds = %32
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %20, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !9
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %23, i64 %42
  store float %40, ptr %43, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %36
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = add i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !5
  br label %32, !llvm.loop !11

47:                                               ; preds = %32
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = call ptr @firfilt_crcf_create(ptr noundef %23, i32 noundef %48)
  store ptr %49, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %50

50:                                               ; preds = %47, %29
  %51 = load ptr, ptr %10, align 8
  call void @llvm.stackrestore.p0(ptr %51)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %52 = load ptr, ptr %4, align 8
  ret ptr %52
}

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 willreturn }
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 }

!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 = distinct !{!11, !12}
!12 = !{!"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"

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [42 x i8], align 1

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

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

declare i32 @liquid_firdes_notch(i32 noundef, float noundef, float noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @firfilt_crcf_create_notch(i32 noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #1 {
  %4 = shl i32 %0, 1
  %5 = or disjoint i32 %4, 1
  %6 = zext i32 %5 to i64
  %7 = alloca float, i64 %6, align 16
  %8 = alloca float, i64 %6, align 16
  %9 = call i32 @liquid_firdes_notch(i32 noundef %0, float noundef %2, float noundef %1, ptr noundef nonnull %7) #3
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %.preheader.preheader, label %14

.preheader.preheader:                             ; preds = %3
  %10 = zext i32 %4 to i64
  %11 = shl nuw nsw i64 %10, 2
  %12 = or disjoint i64 %11, 4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %8, ptr noundef nonnull align 16 dereferenceable(1) %7, i64 %12, i1 false), !tbaa !5
  %13 = call ptr @firfilt_crcf_create(ptr noundef nonnull %8, i32 noundef %5)
  br label %16

14:                                               ; preds = %3
  %15 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.38, i32 noundef 242, ptr noundef nonnull @.str.45, ptr noundef nonnull @.str.2) #3
  br label %16

16:                                               ; preds = %.preheader.preheader, %14
  %.0 = phi ptr [ %15, %14 ], [ %13, %.preheader.preheader ]
  ret ptr %.0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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 = { 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 nounwind willreturn memory(argmem: readwrite) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass