; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (filter_cccf)

; 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.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [69 x i8], align 1

; 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

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

declare i32 @liquid_firdes_kaiser(i32 noundef, float noundef, float noundef, float noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @firinterp_cccf_create(i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @firinterp_cccf_create_kaiser(i32 noundef %0, i32 noundef %1, float noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca float, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !9
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = icmp ult i32 %14, 2
  br i1 %15, label %16, label %18

16:                                               ; preds = %3
  %17 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.42, i32 noundef 87, ptr noundef @.str.45, ptr noundef @.str.3)
  store ptr %17, ptr %4, align 8
  br label %71

18:                                               ; preds = %3
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.42, i32 noundef 89, ptr noundef @.str.46, ptr noundef @.str.3)
  store ptr %22, ptr %4, align 8
  br label %71

23:                                               ; preds = %18
  %24 = load float, ptr %7, align 4, !tbaa !9
  %25 = fcmp olt float %24, 0.000000e+00
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.42, i32 noundef 91, ptr noundef @.str.47, ptr noundef @.str.3)
  store ptr %27, ptr %4, align 8
  br label %71

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = mul i32 2, %29
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = mul i32 %30, %31
  %33 = add i32 %32, 1
  store i32 %33, ptr %8, align 4, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = zext i32 %34 to i64
  %36 = call ptr @llvm.stacksave.p0()
  store ptr %36, ptr %9, align 8
  %37 = alloca float, i64 %35, align 16
  store i64 %35, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = uitofp i32 %38 to float
  %40 = fdiv float 5.000000e-01, %39
  store float %40, ptr %11, align 4, !tbaa !9
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = load float, ptr %11, align 4, !tbaa !9
  %43 = load float, ptr %7, align 4, !tbaa !9
  %44 = call i32 @liquid_firdes_kaiser(i32 noundef %41, float noundef %42, float noundef %43, float noundef 0.000000e+00, ptr noundef %37)
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = zext i32 %45 to i64
  %47 = alloca { float, float }, i64 %46, align 16
  store i64 %46, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %62, %28
  %49 = load i32, ptr %13, align 4, !tbaa !5
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = icmp ult i32 %49, %50
  br i1 %51, label %52, label %65

52:                                               ; preds = %48
  %53 = load i32, ptr %13, align 4, !tbaa !5
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds float, ptr %37, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !9
  %57 = load i32, ptr %13, align 4, !tbaa !5
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds { float, float }, ptr %47, i64 %58
  %60 = getelementptr inbounds { float, float }, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds { float, float }, ptr %59, i32 0, i32 1
  store float %56, ptr %60, align 8
  store float 0.000000e+00, ptr %61, align 4
  br label %62

62:                                               ; preds = %52
  %63 = load i32, ptr %13, align 4, !tbaa !5
  %64 = add i32 %63, 1
  store i32 %64, ptr %13, align 4, !tbaa !5
  br label %48, !llvm.loop !11

65:                                               ; preds = %48
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = sub i32 %67, 1
  %69 = call ptr @firinterp_cccf_create(i32 noundef %66, ptr noundef %47, i32 noundef %68)
  store ptr %69, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  %70 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %70)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %71

71:                                               ; preds = %65, %26, %21, %16
  %72 = load ptr, ptr %4, align 8
  ret ptr %72
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn }
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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"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.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [69 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

declare i32 @liquid_firdes_kaiser(i32 noundef, float noundef, float noundef, float noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @firinterp_cccf_create(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @firinterp_cccf_create_kaiser(i32 noundef %0, i32 noundef %1, float noundef %2) local_unnamed_addr #2 {
  %4 = icmp ult i32 %0, 2
  br i1 %4, label %5, label %7

5:                                                ; preds = %3
  %6 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.42, i32 noundef 87, ptr noundef nonnull @.str.45, ptr noundef nonnull @.str.3) #3
  br label %38

7:                                                ; preds = %3
  %8 = icmp eq i32 %1, 0
  br i1 %8, label %9, label %11

9:                                                ; preds = %7
  %10 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.42, i32 noundef 89, ptr noundef nonnull @.str.46, ptr noundef nonnull @.str.3) #3
  br label %38

11:                                               ; preds = %7
  %12 = fcmp olt float %2, 0.000000e+00
  br i1 %12, label %13, label %15

13:                                               ; preds = %11
  %14 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.42, i32 noundef 91, ptr noundef nonnull @.str.47, ptr noundef nonnull @.str.3) #3
  br label %38

15:                                               ; preds = %11
  %16 = shl i32 %0, 1
  %17 = mul i32 %16, %1
  %18 = or disjoint i32 %17, 1
  %19 = zext i32 %18 to i64
  %20 = tail call ptr @llvm.stacksave.p0()
  %21 = alloca float, i64 %19, align 16
  %22 = uitofp i32 %0 to float
  %23 = fdiv float 5.000000e-01, %22
  %24 = call i32 @liquid_firdes_kaiser(i32 noundef %18, float noundef %23, float noundef %2, float noundef 0.000000e+00, ptr noundef nonnull %21) #3
  %25 = alloca { float, float }, i64 %19, align 16
  %26 = or disjoint i32 %17, 1
  %wide.trip.count = zext i32 %26 to i64
  %min.iters.check = icmp ult i32 %17, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %15
  %n.vec = and i64 %wide.trip.count, 4294967292
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %27 = or disjoint i64 %index, 2
  %28 = getelementptr inbounds float, ptr %21, i64 %index
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %wide.load = load <2 x float>, ptr %28, align 16, !tbaa !5
  %wide.load25 = load <2 x float>, ptr %29, align 8, !tbaa !5
  %30 = getelementptr inbounds { float, float }, ptr %25, i64 %index
  %31 = getelementptr inbounds { float, float }, ptr %25, i64 %27
  %interleaved.vec = shufflevector <2 x float> %wide.load, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec, ptr %30, align 16
  %interleaved.vec26 = shufflevector <2 x float> %wide.load25, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec26, ptr %31, align 16
  %index.next = add nuw i64 %index, 4
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %scalar.ph.preheader, label %vector.body, !llvm.loop !9

scalar.ph.preheader:                              ; preds = %vector.body, %15
  %indvars.iv.ph = phi i64 [ 0, %15 ], [ %n.vec, %vector.body ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %33 = getelementptr inbounds float, ptr %21, i64 %indvars.iv
  %34 = load float, ptr %33, align 4, !tbaa !5
  %35 = getelementptr inbounds { float, float }, ptr %25, i64 %indvars.iv
  %36 = getelementptr inbounds i8, ptr %35, i64 4
  store float %34, ptr %35, align 8
  store float 0.000000e+00, ptr %36, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond, label %.loopexit, label %scalar.ph, !llvm.loop !13

.loopexit:                                        ; preds = %scalar.ph
  %37 = call ptr @firinterp_cccf_create(i32 noundef %0, ptr noundef nonnull %25, i32 noundef %17)
  call void @llvm.stackrestore.p0(ptr %20)
  br label %38

38:                                               ; preds = %.loopexit, %13, %9, %5
  %.019 = phi ptr [ %6, %5 ], [ %10, %9 ], [ %14, %13 ], [ %37, %.loopexit ]
  ret ptr %.019
}

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 = { mustprogress nocallback nofree nosync nounwind willreturn }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass