; 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.81 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [55 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 @iirfilt_cccf_create(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @iirfilt_cccf_create_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4, float noundef %5, float noundef %6, float noundef %7) #4 {
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca i32, align 4
  %26 = alloca i64, align 8
  %27 = alloca i64, align 8
  %28 = alloca i32, align 4
  %29 = alloca ptr, align 8
  store i32 %0, ptr %10, align 4, !tbaa !5
  store i32 %1, ptr %11, align 4, !tbaa !5
  store i32 %2, ptr %12, align 4, !tbaa !5
  store i32 %3, ptr %13, align 4, !tbaa !5
  store float %4, ptr %14, align 4, !tbaa !9
  store float %5, ptr %15, align 4, !tbaa !9
  store float %6, ptr %16, align 4, !tbaa !9
  store float %7, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %30 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %30, ptr %18, align 4, !tbaa !5
  %31 = load i32, ptr %11, align 4, !tbaa !5
  %32 = icmp eq i32 %31, 2
  br i1 %32, label %36, label %33

33:                                               ; preds = %8
  %34 = load i32, ptr %11, align 4, !tbaa !5
  %35 = icmp eq i32 %34, 3
  br i1 %35, label %36, label %39

36:                                               ; preds = %33, %8
  %37 = load i32, ptr %18, align 4, !tbaa !5
  %38 = mul i32 %37, 2
  store i32 %38, ptr %18, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %36, %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %40 = load i32, ptr %18, align 4, !tbaa !5
  %41 = urem i32 %40, 2
  store i32 %41, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %42 = load i32, ptr %18, align 4, !tbaa !5
  %43 = load i32, ptr %19, align 4, !tbaa !5
  %44 = sub i32 %42, %43
  %45 = udiv i32 %44, 2
  store i32 %45, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  %46 = load i32, ptr %12, align 4, !tbaa !5
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %53

48:                                               ; preds = %39
  %49 = load i32, ptr %20, align 4, !tbaa !5
  %50 = load i32, ptr %19, align 4, !tbaa !5
  %51 = add i32 %49, %50
  %52 = mul i32 3, %51
  br label %56

53:                                               ; preds = %39
  %54 = load i32, ptr %18, align 4, !tbaa !5
  %55 = add i32 %54, 1
  br label %56

56:                                               ; preds = %53, %48
  %57 = phi i32 [ %52, %48 ], [ %55, %53 ]
  store i32 %57, ptr %21, align 4, !tbaa !5
  %58 = load i32, ptr %21, align 4, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = call ptr @llvm.stacksave.p0()
  store ptr %60, ptr %22, align 8
  %61 = alloca float, i64 %59, align 16
  store i64 %59, ptr %23, align 8
  %62 = load i32, ptr %21, align 4, !tbaa !5
  %63 = zext i32 %62 to i64
  %64 = alloca float, i64 %63, align 16
  store i64 %63, ptr %24, align 8
  %65 = load i32, ptr %10, align 4, !tbaa !5
  %66 = load i32, ptr %11, align 4, !tbaa !5
  %67 = load i32, ptr %12, align 4, !tbaa !5
  %68 = load i32, ptr %13, align 4, !tbaa !5
  %69 = load float, ptr %14, align 4, !tbaa !9
  %70 = load float, ptr %15, align 4, !tbaa !9
  %71 = load float, ptr %16, align 4, !tbaa !9
  %72 = load float, ptr %17, align 4, !tbaa !9
  %73 = call i32 @liquid_iirdes(i32 noundef %65, i32 noundef %66, i32 noundef %67, i32 noundef %68, float noundef %69, float noundef %70, float noundef %71, float noundef %72, ptr noundef %61, ptr noundef %64)
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %56
  %76 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.81, i32 noundef 242, ptr noundef @.str.85, ptr noundef @.str.3)
  store ptr %76, ptr %9, align 8
  store i32 1, ptr %25, align 4
  br label %124

77:                                               ; preds = %56
  %78 = load i32, ptr %21, align 4, !tbaa !5
  %79 = zext i32 %78 to i64
  %80 = alloca { float, float }, i64 %79, align 16
  store i64 %79, ptr %26, align 8
  %81 = load i32, ptr %21, align 4, !tbaa !5
  %82 = zext i32 %81 to i64
  %83 = alloca { float, float }, i64 %82, align 16
  store i64 %82, ptr %27, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #5
  store i32 0, ptr %28, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %107, %77
  %85 = load i32, ptr %28, align 4, !tbaa !5
  %86 = load i32, ptr %21, align 4, !tbaa !5
  %87 = icmp ult i32 %85, %86
  br i1 %87, label %88, label %110

88:                                               ; preds = %84
  %89 = load i32, ptr %28, align 4, !tbaa !5
  %90 = zext i32 %89 to i64
  %91 = getelementptr inbounds float, ptr %61, i64 %90
  %92 = load float, ptr %91, align 4, !tbaa !9
  %93 = load i32, ptr %28, align 4, !tbaa !5
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds { float, float }, ptr %80, i64 %94
  %96 = getelementptr inbounds { float, float }, ptr %95, i32 0, i32 0
  %97 = getelementptr inbounds { float, float }, ptr %95, i32 0, i32 1
  store float %92, ptr %96, align 8
  store float 0.000000e+00, ptr %97, align 4
  %98 = load i32, ptr %28, align 4, !tbaa !5
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds float, ptr %64, i64 %99
  %101 = load float, ptr %100, align 4, !tbaa !9
  %102 = load i32, ptr %28, align 4, !tbaa !5
  %103 = zext i32 %102 to i64
  %104 = getelementptr inbounds { float, float }, ptr %83, i64 %103
  %105 = getelementptr inbounds { float, float }, ptr %104, i32 0, i32 0
  %106 = getelementptr inbounds { float, float }, ptr %104, i32 0, i32 1
  store float %101, ptr %105, align 8
  store float 0.000000e+00, ptr %106, align 4
  br label %107

107:                                              ; preds = %88
  %108 = load i32, ptr %28, align 4, !tbaa !5
  %109 = add i32 %108, 1
  store i32 %109, ptr %28, align 4, !tbaa !5
  br label %84, !llvm.loop !11

110:                                              ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #5
  store ptr null, ptr %29, align 8, !tbaa !13
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = icmp eq i32 %111, 0
  br i1 %112, label %113, label %118

113:                                              ; preds = %110
  %114 = load i32, ptr %20, align 4, !tbaa !5
  %115 = load i32, ptr %19, align 4, !tbaa !5
  %116 = add i32 %114, %115
  %117 = call ptr @iirfilt_cccf_create_sos(ptr noundef %80, ptr noundef %83, i32 noundef %116)
  store ptr %117, ptr %29, align 8, !tbaa !13
  br label %122

118:                                              ; preds = %110
  %119 = load i32, ptr %21, align 4, !tbaa !5
  %120 = load i32, ptr %21, align 4, !tbaa !5
  %121 = call ptr @iirfilt_cccf_create(ptr noundef %80, i32 noundef %119, ptr noundef %83, i32 noundef %120)
  store ptr %121, ptr %29, align 8, !tbaa !13
  br label %122

122:                                              ; preds = %118, %113
  %123 = load ptr, ptr %29, align 8, !tbaa !13
  store ptr %123, ptr %9, align 8
  store i32 1, ptr %25, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #5
  br label %124

124:                                              ; preds = %122, %75
  %125 = load ptr, ptr %22, align 8
  call void @llvm.stackrestore.p0(ptr %125)
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  %126 = load ptr, ptr %9, align 8
  ret ptr %126
}

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

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

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"="64" "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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}


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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @iirfilt_cccf_create_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4, float noundef %5, float noundef %6, float noundef %7) local_unnamed_addr #2 {
  %9 = and i32 %1, -2
  %or.cond = icmp eq i32 %9, 2
  %10 = zext i1 %or.cond to i32
  %spec.select = shl i32 %3, %10
  %11 = lshr i32 %spec.select, 1
  %12 = icmp eq i32 %2, 0
  %13 = sub i32 %spec.select, %11
  %14 = mul i32 %13, 3
  %15 = add i32 %spec.select, 1
  %16 = select i1 %12, i32 %14, i32 %15
  %17 = zext i32 %16 to i64
  %18 = alloca float, i64 %17, align 16
  %19 = alloca float, i64 %17, align 16
  %20 = call i32 @liquid_iirdes(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4, float noundef %5, float noundef %6, float noundef %7, ptr noundef nonnull %18, ptr noundef nonnull %19) #3
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %23, label %21

21:                                               ; preds = %8
  %22 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.81, i32 noundef 242, ptr noundef nonnull @.str.85, ptr noundef nonnull @.str.3) #3
  br label %48

23:                                               ; preds = %8
  %24 = alloca { float, float }, i64 %17, align 16
  %25 = alloca { float, float }, i64 %17, align 16
  %.not43 = icmp eq i32 %16, 0
  br i1 %.not43, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %23
  %min.iters.check = icmp ult i32 %16, 4
  br i1 %min.iters.check, label %.lr.ph.preheader51, label %vector.ph

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

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %26 = or disjoint i64 %index, 2
  %27 = getelementptr inbounds float, ptr %18, i64 %index
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %wide.load = load <2 x float>, ptr %27, align 16, !tbaa !5
  %wide.load45 = load <2 x float>, ptr %28, align 8, !tbaa !5
  %29 = getelementptr inbounds { float, float }, ptr %24, i64 %index
  %30 = getelementptr inbounds { float, float }, ptr %24, i64 %26
  %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 %29, align 16
  %interleaved.vec46 = shufflevector <2 x float> %wide.load45, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec46, ptr %30, align 16
  %31 = getelementptr inbounds float, ptr %19, i64 %index
  %32 = getelementptr inbounds i8, ptr %31, i64 8
  %wide.load47 = load <2 x float>, ptr %31, align 16, !tbaa !5
  %wide.load48 = load <2 x float>, ptr %32, align 8, !tbaa !5
  %33 = getelementptr inbounds { float, float }, ptr %25, i64 %index
  %34 = getelementptr inbounds { float, float }, ptr %25, i64 %26
  %interleaved.vec49 = shufflevector <2 x float> %wide.load47, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec49, ptr %33, align 16
  %interleaved.vec50 = shufflevector <2 x float> %wide.load48, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec50, ptr %34, align 16
  %index.next = add nuw i64 %index, 4
  %35 = icmp eq i64 %index.next, %n.vec
  br i1 %35, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %17
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader51

.lr.ph.preheader51:                               ; 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.preheader51, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader51 ]
  %36 = getelementptr inbounds float, ptr %18, i64 %indvars.iv
  %37 = load float, ptr %36, align 4, !tbaa !5
  %38 = getelementptr inbounds { float, float }, ptr %24, i64 %indvars.iv
  %39 = getelementptr inbounds i8, ptr %38, i64 4
  store float %37, ptr %38, align 8
  store float 0.000000e+00, ptr %39, align 4
  %40 = getelementptr inbounds float, ptr %19, i64 %indvars.iv
  %41 = load float, ptr %40, align 4, !tbaa !5
  %42 = getelementptr inbounds { float, float }, ptr %25, i64 %indvars.iv
  %43 = getelementptr inbounds i8, ptr %42, i64 4
  store float %41, ptr %42, align 8
  store float 0.000000e+00, ptr %43, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %17
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %23
  br i1 %12, label %44, label %46

44:                                               ; preds = %._crit_edge
  %45 = call ptr @iirfilt_cccf_create_sos(ptr noundef nonnull %24, ptr noundef nonnull %25, i32 noundef %13)
  br label %48

46:                                               ; preds = %._crit_edge
  %47 = call ptr @iirfilt_cccf_create(ptr noundef nonnull %24, i32 noundef %15, ptr noundef nonnull %25, i32 noundef %15)
  br label %48

48:                                               ; preds = %44, %46, %21
  %.039 = phi ptr [ %22, %21 ], [ %45, %44 ], [ %47, %46 ]
  ret ptr %.039
}

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

declare i32 @liquid_iirdes(i32 noundef, i32 noundef, i32 noundef, i32 noundef, float noundef, float noundef, float noundef, float noundef, ptr noundef, ptr 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"="64" "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 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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass