; 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"

@.str.31 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [64 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, 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: nounwind uwtable
declare dso_local float @kaiser_beta_As(float noundef) #2

declare float @sincf(float noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_firdes_kaiser(i32 noundef %0, float noundef %1, float noundef %2, float noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca ptr, align 8
  %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 %7, align 4, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !9
  store float %2, ptr %9, align 4, !tbaa !9
  store float %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !11
  %17 = load float, ptr %10, align 4, !tbaa !9
  %18 = fcmp olt float %17, -5.000000e-01
  br i1 %18, label %22, label %19

19:                                               ; preds = %5
  %20 = load float, ptr %10, align 4, !tbaa !9
  %21 = fcmp ogt float %20, 5.000000e-01
  br i1 %21, label %22, label %26

22:                                               ; preds = %19, %5
  %23 = load float, ptr %10, align 4, !tbaa !9
  %24 = fpext float %23 to double
  %25 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.31, i32 noundef 313, ptr noundef @.str.38, double noundef %24)
  store i32 %25, ptr %6, align 4
  br label %78

26:                                               ; preds = %19
  %27 = load float, ptr %8, align 4, !tbaa !9
  %28 = fcmp ole float %27, 0.000000e+00
  br i1 %28, label %32, label %29

29:                                               ; preds = %26
  %30 = load float, ptr %8, align 4, !tbaa !9
  %31 = fcmp ogt float %30, 5.000000e-01
  br i1 %31, label %32, label %36

32:                                               ; preds = %29, %26
  %33 = load float, ptr %8, align 4, !tbaa !9
  %34 = fpext float %33 to double
  %35 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.31, i32 noundef 315, ptr noundef @.str.39, double noundef %34)
  store i32 %35, ptr %6, align 4
  br label %78

36:                                               ; preds = %29
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %36
  %40 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.31, i32 noundef 317, ptr noundef @.str.40)
  store i32 %40, ptr %6, align 4
  br label %78

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %42 = load float, ptr %9, align 4, !tbaa !9
  %43 = call float @kaiser_beta_As(float noundef %42)
  store float %43, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %74, %41
  %45 = load i32, ptr %16, align 4, !tbaa !5
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = icmp ult i32 %45, %46
  br i1 %47, label %48, label %77

48:                                               ; preds = %44
  %49 = load i32, ptr %16, align 4, !tbaa !5
  %50 = uitofp i32 %49 to float
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = sub i32 %51, 1
  %53 = uitofp i32 %52 to float
  %54 = fdiv float %53, 2.000000e+00
  %55 = fsub float %50, %54
  %56 = load float, ptr %10, align 4, !tbaa !9
  %57 = fadd float %55, %56
  store float %57, ptr %13, align 4, !tbaa !9
  %58 = load float, ptr %8, align 4, !tbaa !9
  %59 = fmul float 2.000000e+00, %58
  %60 = load float, ptr %13, align 4, !tbaa !9
  %61 = fmul float %59, %60
  %62 = call float @sincf(float noundef %61)
  store float %62, ptr %14, align 4, !tbaa !9
  %63 = load i32, ptr %16, align 4, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = load float, ptr %12, align 4, !tbaa !9
  %66 = call float @liquid_kaiser(i32 noundef %63, i32 noundef %64, float noundef %65)
  store float %66, ptr %15, align 4, !tbaa !9
  %67 = load float, ptr %14, align 4, !tbaa !9
  %68 = load float, ptr %15, align 4, !tbaa !9
  %69 = fmul float %67, %68
  %70 = load ptr, ptr %11, align 8, !tbaa !11
  %71 = load i32, ptr %16, align 4, !tbaa !5
  %72 = zext i32 %71 to i64
  %73 = getelementptr inbounds float, ptr %70, i64 %72
  store float %69, ptr %73, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %48
  %75 = load i32, ptr %16, align 4, !tbaa !5
  %76 = add i32 %75, 1
  store i32 %76, ptr %16, align 4, !tbaa !5
  br label %44, !llvm.loop !13

77:                                               ; preds = %44
  store i32 0, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %78

78:                                               ; preds = %77, %39, %32, %22
  %79 = load i32, ptr %6, align 4
  ret i32 %79
}

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

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 = { 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 #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 = !{!"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"

@.str.31 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [64 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local float @kaiser_beta_As(float noundef) local_unnamed_addr #1

declare float @sincf(float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_firdes_kaiser(i32 noundef %0, float noundef %1, float noundef %2, float noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = tail call float @llvm.fabs.f32(float %3)
  %or.cond = fcmp ogt float %6, 5.000000e-01
  br i1 %or.cond, label %7, label %10

7:                                                ; preds = %5
  %8 = fpext float %3 to double
  %9 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.31, i32 noundef 313, ptr noundef nonnull @.str.38, double noundef %8) #3
  br label %.loopexit

10:                                               ; preds = %5
  %11 = fcmp ole float %1, 0.000000e+00
  %12 = fcmp ogt float %1, 5.000000e-01
  %or.cond3 = or i1 %11, %12
  br i1 %or.cond3, label %13, label %16

13:                                               ; preds = %10
  %14 = fpext float %1 to double
  %15 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.31, i32 noundef 315, ptr noundef nonnull @.str.39, double noundef %14) #3
  br label %.loopexit

16:                                               ; preds = %10
  %17 = icmp eq i32 %0, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %16
  %19 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.31, i32 noundef 317, ptr noundef nonnull @.str.40) #3
  br label %.loopexit

20:                                               ; preds = %16
  %21 = tail call float @kaiser_beta_As(float noundef %2)
  %22 = add i32 %0, -1
  %23 = uitofp i32 %22 to float
  %24 = fmul float %23, 5.000000e-01
  %25 = fmul float %1, 2.000000e+00
  %wide.trip.count = zext i32 %0 to i64
  br label %26

26:                                               ; preds = %20, %26
  %indvars.iv = phi i64 [ 0, %20 ], [ %indvars.iv.next, %26 ]
  %27 = trunc nuw i64 %indvars.iv to i32
  %28 = uitofp i32 %27 to float
  %29 = fsub float %28, %24
  %30 = fadd float %29, %3
  %31 = fmul float %25, %30
  %32 = tail call float @sincf(float noundef %31) #3
  %33 = tail call float @liquid_kaiser(i32 noundef %27, i32 noundef %0, float noundef %21) #3
  %34 = fmul float %32, %33
  %35 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  store float %34, ptr %35, 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 %.loopexit, label %26, !llvm.loop !9

.loopexit:                                        ; preds = %26, %18, %13, %7
  %.026 = phi i32 [ %9, %7 ], [ %15, %13 ], [ %19, %18 ], [ 0, %26 ]
  ret i32 %.026
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #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 nosync nounwind speculatable willreturn memory(none) }
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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass