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

; 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

declare <2 x float> @__mulsc3(float, float, float, float)

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

; Function Attrs: nounwind uwtable
define dso_local float @iirfilt_cccf_get_psd(ptr noundef %0, float noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca { float, float }, align 4
  %6 = alloca { float, float }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load float, ptr %4, align 4, !tbaa !9
  %9 = call i32 @iirfilt_cccf_freqresponse(ptr noundef %7, float noundef %8, ptr noundef %5)
  %10 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %11 = load float, ptr %10, align 4
  %12 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %13 = load float, ptr %12, align 4
  %14 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %15 = load float, ptr %14, align 4
  %16 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %17 = load float, ptr %16, align 4
  %18 = fneg float %17
  %19 = fmul float %11, %15
  %20 = fmul float %13, %18
  %21 = fmul float %11, %18
  %22 = fmul float %13, %15
  %23 = fsub float %19, %20
  %24 = fadd float %21, %22
  %25 = fcmp uno float %23, %23
  br i1 %25, label %26, label %34, !prof !11

26:                                               ; preds = %2
  %27 = fcmp uno float %24, %24
  br i1 %27, label %28, label %34, !prof !11

28:                                               ; preds = %26
  %29 = call <2 x float> @__mulsc3(float noundef %11, float noundef %13, float noundef %15, float noundef %18) #3
  store <2 x float> %29, ptr %6, align 4
  %30 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %31 = load float, ptr %30, align 4
  %32 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  %33 = load float, ptr %32, align 4
  br label %34

34:                                               ; preds = %28, %26, %2
  %35 = phi float [ %23, %2 ], [ %23, %26 ], [ %31, %28 ]
  %36 = phi float [ %24, %2 ], [ %24, %26 ], [ %33, %28 ]
  %37 = call float @log10f(float noundef %35) #3
  %38 = fmul float 1.000000e+01, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret float %38
}

; Function Attrs: nounwind
declare float @log10f(float noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { 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 #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 = !{!"float", !7, i64 0}
!11 = !{!"branch_weights", i32 1, i32 1048575}


; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

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

; Function Attrs: nounwind uwtable
define dso_local float @iirfilt_cccf_get_psd(ptr noundef %0, float noundef %1) local_unnamed_addr #1 {
  %3 = alloca { float, float }, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = call i32 @iirfilt_cccf_freqresponse(ptr noundef %0, float noundef %1, ptr noundef nonnull %3)
  %5 = load <2 x float>, ptr %3, align 8
  %6 = extractelement <2 x float> %5, i64 1
  %7 = fneg float %6
  %8 = fmul <2 x float> %5, %5
  %shift = shufflevector <2 x float> %8, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %9 = fadd <2 x float> %8, %shift
  %10 = extractelement <2 x float> %9, i64 0
  %11 = fcmp uno float %10, 0.000000e+00
  br i1 %11, label %12, label %19, !prof !5

12:                                               ; preds = %2
  %13 = extractelement <2 x float> %5, i64 0
  %14 = fmul float %13, %6
  %15 = fsub float %14, %14
  %16 = fcmp uno float %15, 0.000000e+00
  br i1 %16, label %17, label %19, !prof !5

17:                                               ; preds = %12
  %18 = call <2 x float> @__mulsc3(float noundef %13, float noundef %6, float noundef %13, float noundef %7) #3
  %.sroa.0.0.vec.extract = extractelement <2 x float> %18, i64 0
  br label %19

19:                                               ; preds = %17, %12, %2
  %20 = phi float [ %10, %2 ], [ %10, %12 ], [ %.sroa.0.0.vec.extract, %17 ]
  %21 = call float @log10f(float noundef %20) #3
  %22 = fmul float %21, 1.000000e+01
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret float %22
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 = !{!"branch_weights", i32 1, i32 1048575}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,VectorCombinePass