; 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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_freqrespcf(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
  %13 = 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
  %14 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %15 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float 0.000000e+00, ptr %14, align 4
  store float 0.000000e+00, ptr %15, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %16

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

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

54:                                               ; preds = %20
  %55 = fcmp uno float %52, %52
  br i1 %55, label %56, label %62, !prof !13

56:                                               ; preds = %54
  %57 = call <2 x float> @__mulsc3(float noundef %26, float noundef %28, float noundef %44, float noundef %46) #3
  store <2 x float> %57, ptr %13, align 4
  %58 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %59 = load float, ptr %58, align 4
  %60 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  %61 = load float, ptr %60, align 4
  br label %62

62:                                               ; preds = %56, %54, %20
  %63 = phi float [ %51, %20 ], [ %51, %54 ], [ %59, %56 ]
  %64 = phi float [ %52, %20 ], [ %52, %54 ], [ %61, %56 ]
  %65 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %66 = load float, ptr %65, align 4
  %67 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %68 = load float, ptr %67, align 4
  %69 = fadd float %66, %63
  %70 = fadd float %68, %64
  %71 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %72 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %69, ptr %71, align 4
  store float %70, ptr %72, align 4
  br label %73

73:                                               ; preds = %62
  %74 = load i32, ptr %10, align 4, !tbaa !9
  %75 = add i32 %74, 1
  store i32 %75, ptr %10, align 4, !tbaa !9
  br label %16, !llvm.loop !14

76:                                               ; preds = %16
  %77 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %78 = load float, ptr %77, align 4
  %79 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %80 = load float, ptr %79, align 4
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds { float, float }, ptr %81, i32 0, i32 0
  %83 = getelementptr inbounds { float, float }, ptr %81, i32 0, i32 1
  store float %78, ptr %82, align 4
  store float %80, ptr %83, 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 = !{!"branch_weights", i32 1, i32 1048575}
!14 = distinct !{!14, !15}
!15 = !{!"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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @liquid_freqrespcf(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, %41
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %41 ]
  %10 = phi <2 x float> [ zeroinitializer, %.lr.ph ], [ %43, %41 ]
  %11 = getelementptr inbounds { float, float }, ptr %0, i64 %indvars.iv
  %12 = load float, ptr %11, align 4
  %13 = getelementptr inbounds i8, ptr %11, i64 4
  %14 = load float, ptr %13, align 4
  %15 = trunc nuw i64 %indvars.iv to i32
  %16 = uitofp i32 %15 to double
  %17 = insertelement <2 x double> poison, double %16, i64 0
  %18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
  %19 = fmul <2 x double> %8, %18
  %20 = fptrunc <2 x double> %19 to <2 x float>
  %21 = tail call <2 x float> @cexpf(<2 x float> noundef %20) #2
  %22 = insertelement <2 x float> poison, float %12, i64 0
  %23 = shufflevector <2 x float> %22, <2 x float> poison, <2 x i32> zeroinitializer
  %24 = fmul <2 x float> %23, %21
  %25 = insertelement <2 x float> poison, float %14, i64 0
  %26 = shufflevector <2 x float> %25, <2 x float> poison, <2 x i32> zeroinitializer
  %27 = fmul <2 x float> %26, %21
  %28 = shufflevector <2 x float> %27, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %29 = fsub <2 x float> %24, %28
  %30 = fadd <2 x float> %24, %28
  %31 = shufflevector <2 x float> %29, <2 x float> %30, <2 x i32> <i32 0, i32 3>
  %32 = extractelement <2 x float> %29, i64 0
  %33 = fcmp uno float %32, 0.000000e+00
  br i1 %33, label %34, label %41, !prof !5

34:                                               ; preds = %9
  %35 = extractelement <2 x float> %30, i64 1
  %36 = fcmp uno float %35, 0.000000e+00
  br i1 %36, label %37, label %41, !prof !5

37:                                               ; preds = %34
  %38 = extractelement <2 x float> %21, i64 0
  %39 = extractelement <2 x float> %21, i64 1
  %40 = tail call <2 x float> @__mulsc3(float noundef %12, float noundef %14, float noundef %38, float noundef %39) #2
  br label %41

41:                                               ; preds = %37, %34, %9
  %42 = phi <2 x float> [ %31, %9 ], [ %31, %34 ], [ %40, %37 ]
  %43 = fadd <2 x float> %10, %42
  %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 !6

._crit_edge:                                      ; preds = %41, %4
  %44 = phi <2 x float> [ zeroinitializer, %4 ], [ %43, %41 ]
  store <2 x float> %44, 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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = distinct !{!6, !7}
!7 = !{!"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