; 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: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_freqrespf(ptr noundef %0, i32 noundef %1, float noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca ptr, align 8
  %9 = alloca { float, float }, align 4
  %10 = alloca i32, align 4
  %11 = alloca { float, float }, align 4
  %12 = alloca { float, float }, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !11
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %13 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %14 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float 0.000000e+00, ptr %13, align 4
  store float 0.000000e+00, ptr %14, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %53, %4
  %16 = load i32, ptr %10, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp ult i32 %16, %17
  br i1 %18, label %19, label %56

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds float, ptr %20, i64 %22
  %24 = load float, ptr %23, align 4, !tbaa !11
  %25 = load float, ptr %7, align 4, !tbaa !11
  %26 = fpext float %25 to double
  %27 = fmul double -0.000000e+00, %26
  %28 = fmul double 0xC01921FB54442D18, %26
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = uitofp i32 %29 to double
  %31 = fmul double %27, %30
  %32 = fmul double %28, %30
  %33 = fptrunc double %31 to float
  %34 = fptrunc double %32 to float
  %35 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %36 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %33, ptr %35, align 4
  store float %34, ptr %36, align 4
  %37 = load <2 x float>, ptr %11, align 4
  %38 = call <2 x float> @cexpf(<2 x float> noundef %37) #3
  store <2 x float> %38, ptr %12, align 4
  %39 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 0
  %40 = load float, ptr %39, align 4
  %41 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 1
  %42 = load float, ptr %41, align 4
  %43 = fmul float %24, %40
  %44 = fmul float %24, %42
  %45 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %46 = load float, ptr %45, align 4
  %47 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %48 = load float, ptr %47, align 4
  %49 = fadd float %46, %43
  %50 = fadd float %48, %44
  %51 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %52 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %49, ptr %51, align 4
  store float %50, ptr %52, align 4
  br label %53

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

56:                                               ; preds = %15
  %57 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %58 = load float, ptr %57, align 4
  %59 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %60 = load float, ptr %59, align 4
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds { float, float }, ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds { float, float }, ptr %61, i32 0, i32 1
  store float %58, ptr %62, align 4
  store float %60, ptr %63, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @liquid_freqrespf(ptr nocapture noundef readonly %0, i32 noundef %1, float noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #1 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %5 = fpext float %2 to double
  %6 = insertelement <2 x double> poison, double %5, i64 0
  %7 = shufflevector <2 x double> %6, <2 x double> poison, <2 x i32> zeroinitializer
  %8 = fmul <2 x double> %7, <double -0.000000e+00, double 0xC01921FB54442D18>
  %wide.trip.count = zext i32 %1 to i64
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %9 ]
  %10 = phi <2 x float> [ zeroinitializer, %.lr.ph ], [ %23, %9 ]
  %11 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = trunc nuw i64 %indvars.iv to i32
  %14 = uitofp i32 %13 to double
  %15 = insertelement <2 x double> poison, double %14, i64 0
  %16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
  %17 = fmul <2 x double> %8, %16
  %18 = fptrunc <2 x double> %17 to <2 x float>
  %19 = tail call <2 x float> @cexpf(<2 x float> noundef %18) #2
  %20 = insertelement <2 x float> poison, float %12, i64 0
  %21 = shufflevector <2 x float> %20, <2 x float> poison, <2 x i32> zeroinitializer
  %22 = fmul <2 x float> %21, %19
  %23 = fadd <2 x float> %10, %22
  %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 %._crit_edge, label %9, !llvm.loop !9

._crit_edge:                                      ; preds = %9, %4
  %24 = phi <2 x float> [ zeroinitializer, %4 ], [ %23, %9 ]
  store <2 x float> %24, ptr %3, align 4
  ret i32 0
}

attributes #0 = { 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 #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 }

!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.mustprogress"}


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