; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_firdes_doppler(i32 noundef %0, float noundef %1, float noundef %2, float noundef %3, ptr noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, 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 float %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store float 4.000000e+00, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %17

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

21:                                               ; preds = %17
  %22 = load i32, ptr %16, align 4, !tbaa !5
  %23 = uitofp i32 %22 to float
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = sub i32 %24, 1
  %26 = uitofp i32 %25 to float
  %27 = fdiv float %26, 2.000000e+00
  %28 = fsub float %23, %27
  store float %28, ptr %11, align 4, !tbaa !9
  %29 = load float, ptr %7, align 4, !tbaa !9
  %30 = fpext float %29 to double
  %31 = fmul double 0x401921FB54442D18, %30
  %32 = load float, ptr %11, align 4, !tbaa !9
  %33 = fpext float %32 to double
  %34 = fmul double %31, %33
  %35 = fptrunc double %34 to float
  %36 = call float @llvm.fabs.f32(float %35)
  %37 = call float @liquid_besselj0f(float noundef %36)
  %38 = fpext float %37 to double
  %39 = fmul double 1.500000e+00, %38
  %40 = fptrunc double %39 to float
  store float %40, ptr %12, align 4, !tbaa !9
  %41 = load float, ptr %8, align 4, !tbaa !9
  %42 = fpext float %41 to double
  %43 = fmul double 1.500000e+00, %42
  %44 = load float, ptr %8, align 4, !tbaa !9
  %45 = fadd float %44, 1.000000e+00
  %46 = fpext float %45 to double
  %47 = fdiv double %43, %46
  %48 = load float, ptr %7, align 4, !tbaa !9
  %49 = fpext float %48 to double
  %50 = fmul double 0x401921FB54442D18, %49
  %51 = load float, ptr %11, align 4, !tbaa !9
  %52 = fpext float %51 to double
  %53 = fmul double %50, %52
  %54 = load float, ptr %9, align 4, !tbaa !9
  %55 = call float @cosf(float noundef %54) #5
  %56 = fpext float %55 to double
  %57 = fmul double %53, %56
  %58 = fptrunc double %57 to float
  %59 = call float @cosf(float noundef %58) #5
  %60 = fpext float %59 to double
  %61 = fmul double %47, %60
  %62 = fptrunc double %61 to float
  store float %62, ptr %13, align 4, !tbaa !9
  %63 = load i32, ptr %16, align 4, !tbaa !5
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = load float, ptr %15, align 4, !tbaa !9
  %66 = call float @liquid_kaiser(i32 noundef %63, i32 noundef %64, float noundef %65)
  store float %66, ptr %14, align 4, !tbaa !9
  %67 = load float, ptr %12, align 4, !tbaa !9
  %68 = load float, ptr %13, align 4, !tbaa !9
  %69 = fadd float %67, %68
  %70 = load float, ptr %14, align 4, !tbaa !9
  %71 = fmul float %69, %70
  %72 = load ptr, ptr %10, align 8, !tbaa !11
  %73 = load i32, ptr %16, 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
  br label %76

76:                                               ; preds = %21
  %77 = load i32, ptr %16, align 4, !tbaa !5
  %78 = add i32 %77, 1
  store i32 %78, ptr %16, align 4, !tbaa !5
  br label %17, !llvm.loop !13

79:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  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
  ret i32 0
}

declare float @liquid_besselj0f(float noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "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 "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 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 #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"}


; 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 speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

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

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

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

.lr.ph:                                           ; preds = %5
  %6 = add i32 %0, -1
  %7 = uitofp i32 %6 to float
  %8 = fmul float %7, 5.000000e-01
  %9 = fpext float %1 to double
  %10 = fmul double %9, 0x401921FB54442D18
  %11 = fpext float %2 to double
  %12 = fmul double %11, 1.500000e+00
  %13 = fadd float %2, 1.000000e+00
  %14 = fpext float %13 to double
  %15 = fdiv double %12, %14
  %wide.trip.count = zext i32 %0 to i64
  br label %16

16:                                               ; preds = %.lr.ph, %16
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %16 ]
  %17 = trunc nuw i64 %indvars.iv to i32
  %18 = uitofp i32 %17 to float
  %19 = fsub float %18, %8
  %20 = fpext float %19 to double
  %21 = fmul double %10, %20
  %22 = fptrunc double %21 to float
  %23 = tail call float @llvm.fabs.f32(float %22)
  %24 = tail call float @liquid_besselj0f(float noundef %23) #4
  %25 = fmul float %24, 1.500000e+00
  %26 = tail call float @cosf(float noundef %3) #4
  %27 = fpext float %26 to double
  %28 = fmul double %21, %27
  %29 = fptrunc double %28 to float
  %30 = tail call float @cosf(float noundef %29) #4
  %31 = fpext float %30 to double
  %32 = fmul double %15, %31
  %33 = fptrunc double %32 to float
  %34 = tail call float @liquid_kaiser(i32 noundef %17, i32 noundef %0, float noundef 4.000000e+00) #4
  %35 = fadd float %25, %33
  %36 = fmul float %34, %35
  %37 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  store float %36, ptr %37, align 4, !tbaa !5
  %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 %16, !llvm.loop !9

._crit_edge:                                      ; preds = %16, %5
  ret i32 0
}

declare float @liquid_besselj0f(float noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "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 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 = !{!"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,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass