; 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.36 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.37 = 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
define dso_local i32 @liquid_firdes_windowf(i32 noundef %0, i32 noundef %1, float noundef %2, float noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, 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 i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  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
  %16 = load float, ptr %9, align 4, !tbaa !9
  %17 = fcmp ole float %16, 0.000000e+00
  br i1 %17, label %21, label %18

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

21:                                               ; preds = %18, %5
  %22 = load float, ptr %9, align 4, !tbaa !9
  %23 = fpext float %22 to double
  %24 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.31, i32 noundef 276, ptr noundef @.str.36, double noundef %23)
  store i32 %24, ptr %6, align 4
  br label %65

25:                                               ; preds = %18
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %25
  %29 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.31, i32 noundef 278, ptr noundef @.str.37)
  store i32 %29, ptr %6, align 4
  br label %65

30:                                               ; preds = %25
  br label %31

31:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  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
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %61, %31
  %33 = load i32, ptr %15, align 4, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %36, label %64

36:                                               ; preds = %32
  %37 = load i32, ptr %15, align 4, !tbaa !5
  %38 = uitofp i32 %37 to float
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = sub i32 %39, 1
  %41 = uitofp i32 %40 to float
  %42 = fdiv float %41, 2.000000e+00
  %43 = fsub float %38, %42
  store float %43, ptr %12, align 4, !tbaa !9
  %44 = load float, ptr %9, align 4, !tbaa !9
  %45 = fmul float 2.000000e+00, %44
  %46 = load float, ptr %12, align 4, !tbaa !9
  %47 = fmul float %45, %46
  %48 = call float @sincf(float noundef %47)
  store float %48, ptr %13, align 4, !tbaa !9
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = load i32, ptr %15, align 4, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = load float, ptr %10, align 4, !tbaa !9
  %53 = call float @liquid_windowf(i32 noundef %49, i32 noundef %50, i32 noundef %51, float noundef %52)
  store float %53, ptr %14, align 4, !tbaa !9
  %54 = load float, ptr %13, align 4, !tbaa !9
  %55 = load float, ptr %14, align 4, !tbaa !9
  %56 = fmul float %54, %55
  %57 = load ptr, ptr %11, align 8, !tbaa !11
  %58 = load i32, ptr %15, align 4, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds float, ptr %57, i64 %59
  store float %56, ptr %60, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %36
  %62 = load i32, ptr %15, align 4, !tbaa !5
  %63 = add i32 %62, 1
  store i32 %63, ptr %15, align 4, !tbaa !5
  br label %32, !llvm.loop !13

64:                                               ; preds = %32
  store i32 0, ptr %6, align 4
  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 %65

65:                                               ; preds = %64, %28, %21
  %66 = load i32, ptr %6, align 4
  ret i32 %66
}

declare float @sincf(float noundef) #0

declare float @liquid_windowf(i32 noundef, 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.36 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.37 = 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
define dso_local i32 @liquid_firdes_windowf(i32 noundef %0, i32 noundef %1, float noundef %2, float noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = fcmp ole float %2, 0.000000e+00
  %7 = fcmp ogt float %2, 5.000000e-01
  %or.cond = or i1 %6, %7
  br i1 %or.cond, label %8, label %11

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

11:                                               ; preds = %5
  %12 = icmp eq i32 %1, 0
  br i1 %12, label %17, label %.preheader

.preheader:                                       ; preds = %11
  %13 = add i32 %1, -1
  %14 = uitofp i32 %13 to float
  %15 = fmul float %14, 5.000000e-01
  %16 = fmul float %2, 2.000000e+00
  %wide.trip.count = zext i32 %1 to i64
  br label %19

17:                                               ; preds = %11
  %18 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.31, i32 noundef 278, ptr noundef nonnull @.str.37) #2
  br label %.loopexit

19:                                               ; preds = %.preheader, %19
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %19 ]
  %20 = trunc nuw i64 %indvars.iv to i32
  %21 = uitofp i32 %20 to float
  %22 = fsub float %21, %15
  %23 = fmul float %16, %22
  %24 = tail call float @sincf(float noundef %23) #2
  %25 = tail call float @liquid_windowf(i32 noundef %0, i32 noundef %20, i32 noundef %1, float noundef %3) #2
  %26 = fmul float %24, %25
  %27 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  store float %26, ptr %27, 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 %19, !llvm.loop !9

.loopexit:                                        ; preds = %19, %17, %8
  %.020 = phi i32 [ %10, %8 ], [ %18, %17 ], [ 0, %19 ]
  ret i32 %.020
}

declare float @sincf(float noundef) local_unnamed_addr #0

declare float @liquid_windowf(i32 noundef, i32 noundef, i32 noundef, float noundef) local_unnamed_addr #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 = { 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 = { 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,SROAPass,SimplifyCFGPass,TailCallElimPass