; 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.32 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [60 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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @firfilt_cccf_create_rect(i32 noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %13, label %10

10:                                               ; preds = %1
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp ugt i32 %11, 1024
  br i1 %12, label %13, label %15

13:                                               ; preds = %10, %1
  %14 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.32, i32 noundef 184, ptr noundef @.str.37, ptr noundef @.str.3)
  store ptr %14, ptr %2, align 8
  br label %56

15:                                               ; preds = %10
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = call ptr @llvm.stacksave.p0()
  store ptr %18, ptr %4, align 8
  %19 = alloca float, i64 %17, align 16
  store i64 %17, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %28, %15
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = icmp ult i32 %21, %22
  br i1 %23, label %24, label %31

24:                                               ; preds = %20
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds float, ptr %19, i64 %26
  store float 1.000000e+00, ptr %27, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %24
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = add i32 %29, 1
  store i32 %30, ptr %6, align 4, !tbaa !5
  br label %20, !llvm.loop !11

31:                                               ; preds = %20
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = alloca { float, float }, i64 %33, align 16
  store i64 %33, ptr %7, align 8
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %49, %31
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = icmp ult i32 %36, %37
  br i1 %38, label %39, label %52

39:                                               ; preds = %35
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds float, ptr %19, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds { float, float }, ptr %34, i64 %45
  %47 = getelementptr inbounds { float, float }, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds { float, float }, ptr %46, i32 0, i32 1
  store float %43, ptr %47, align 8
  store float 0.000000e+00, ptr %48, align 4
  br label %49

49:                                               ; preds = %39
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = add i32 %50, 1
  store i32 %51, ptr %6, align 4, !tbaa !5
  br label %35, !llvm.loop !13

52:                                               ; preds = %35
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = call ptr @firfilt_cccf_create(ptr noundef %34, i32 noundef %53)
  store ptr %54, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %55 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %55)
  br label %56

56:                                               ; preds = %52, %13
  %57 = load ptr, ptr %2, align 8
  ret ptr %57
}

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"}
!13 = distinct !{!13, !12}


; 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.32 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [60 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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @firfilt_cccf_create_rect(i32 noundef %0) local_unnamed_addr #2 {
  %2 = add i32 %0, -1025
  %or.cond = icmp ult i32 %2, -1024
  br i1 %or.cond, label %3, label %.lr.ph.preheader

3:                                                ; preds = %1
  %4 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.32, i32 noundef 184, ptr noundef nonnull @.str.37, ptr noundef nonnull @.str.3) #3
  br label %24

.lr.ph.preheader:                                 ; preds = %1
  %5 = zext nneg i32 %0 to i64
  %6 = tail call ptr @llvm.stacksave.p0()
  %7 = alloca float, i64 %5, align 16
  %min.iters.check = icmp ult i32 %0, 8
  br i1 %min.iters.check, label %.lr.ph.preheader44, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %5, 2040
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %8 = getelementptr inbounds float, ptr %7, i64 %index
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %8, align 16, !tbaa !5
  store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %9, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %10 = icmp eq i64 %index.next, %n.vec
  br i1 %10, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %5
  br i1 %cmp.n, label %.lr.ph21.preheader, label %.lr.ph.preheader44

.lr.ph.preheader44:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader44, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader44 ]
  %11 = getelementptr inbounds float, ptr %7, i64 %indvars.iv
  store float 1.000000e+00, ptr %11, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %5
  br i1 %exitcond.not, label %.lr.ph21.preheader, label %.lr.ph, !llvm.loop !13

.lr.ph21.preheader:                               ; preds = %.lr.ph, %middle.block
  %12 = alloca { float, float }, i64 %5, align 16
  %min.iters.check32 = icmp ult i32 %0, 4
  br i1 %min.iters.check32, label %.lr.ph21.preheader43, label %vector.ph33

vector.ph33:                                      ; preds = %.lr.ph21.preheader
  %n.vec35 = and i64 %5, 2044
  br label %vector.body37

vector.body37:                                    ; preds = %vector.body37, %vector.ph33
  %index38 = phi i64 [ 0, %vector.ph33 ], [ %index.next41, %vector.body37 ]
  %13 = or disjoint i64 %index38, 2
  %14 = getelementptr inbounds float, ptr %7, i64 %index38
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %wide.load = load <2 x float>, ptr %14, align 16, !tbaa !5
  %wide.load39 = load <2 x float>, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds { float, float }, ptr %12, i64 %index38
  %17 = getelementptr inbounds { float, float }, ptr %12, i64 %13
  %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 %16, align 16
  %interleaved.vec40 = shufflevector <2 x float> %wide.load39, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec40, ptr %17, align 16
  %index.next41 = add nuw i64 %index38, 4
  %18 = icmp eq i64 %index.next41, %n.vec35
  br i1 %18, label %middle.block30, label %vector.body37, !llvm.loop !14

middle.block30:                                   ; preds = %vector.body37
  %cmp.n42 = icmp eq i64 %n.vec35, %5
  br i1 %cmp.n42, label %._crit_edge22, label %.lr.ph21.preheader43

.lr.ph21.preheader43:                             ; preds = %middle.block30, %.lr.ph21.preheader
  %indvars.iv25.ph = phi i64 [ 0, %.lr.ph21.preheader ], [ %n.vec35, %middle.block30 ]
  br label %.lr.ph21

.lr.ph21:                                         ; preds = %.lr.ph21.preheader43, %.lr.ph21
  %indvars.iv25 = phi i64 [ %indvars.iv.next26, %.lr.ph21 ], [ %indvars.iv25.ph, %.lr.ph21.preheader43 ]
  %19 = getelementptr inbounds float, ptr %7, i64 %indvars.iv25
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds { float, float }, ptr %12, i64 %indvars.iv25
  %22 = getelementptr inbounds i8, ptr %21, i64 4
  store float %20, ptr %21, align 8
  store float 0.000000e+00, ptr %22, align 4
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next26, %5
  br i1 %exitcond29.not, label %._crit_edge22, label %.lr.ph21, !llvm.loop !15

._crit_edge22:                                    ; preds = %.lr.ph21, %middle.block30
  %23 = call ptr @firfilt_cccf_create(ptr noundef nonnull %12, i32 noundef %0)
  call void @llvm.stackrestore.p0(ptr %6)
  br label %24

24:                                               ; preds = %._crit_edge22, %3
  %.0 = phi ptr [ %4, %3 ], [ %23, %._crit_edge22 ]
  ret ptr %.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 = { 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}
!14 = distinct !{!14, !10, !11, !12}
!15 = distinct !{!15, !10, !12, !11}


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