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

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

declare ptr @liquid_error_config_fl(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: 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_crcf_create(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @iirfilt_crcf_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) #3 {
  %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) #4
  %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) #4
  %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) #4
  %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) #4
  %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.87, i32 noundef 242, ptr noundef @.str.91, ptr noundef @.str.2)
  store ptr %76, ptr %9, align 8
  store i32 1, ptr %25, align 4
  br label %120

77:                                               ; preds = %56
  %78 = load i32, ptr %21, align 4, !tbaa !5
  %79 = zext i32 %78 to i64
  %80 = alloca 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, i64 %82, align 16
  store i64 %82, ptr %27, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #4
  store i32 0, ptr %28, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %103, %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 %106

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, ptr %80, i64 %94
  store float %92, ptr %95, align 4, !tbaa !9
  %96 = load i32, ptr %28, align 4, !tbaa !5
  %97 = zext i32 %96 to i64
  %98 = getelementptr inbounds float, ptr %64, i64 %97
  %99 = load float, ptr %98, align 4, !tbaa !9
  %100 = load i32, ptr %28, align 4, !tbaa !5
  %101 = zext i32 %100 to i64
  %102 = getelementptr inbounds float, ptr %83, i64 %101
  store float %99, ptr %102, align 4, !tbaa !9
  br label %103

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

106:                                              ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #4
  store ptr null, ptr %29, align 8, !tbaa !13
  %107 = load i32, ptr %12, align 4, !tbaa !5
  %108 = icmp eq i32 %107, 0
  br i1 %108, label %109, label %114

109:                                              ; preds = %106
  %110 = load i32, ptr %20, align 4, !tbaa !5
  %111 = load i32, ptr %19, align 4, !tbaa !5
  %112 = add i32 %110, %111
  %113 = call ptr @iirfilt_crcf_create_sos(ptr noundef %80, ptr noundef %83, i32 noundef %112)
  store ptr %113, ptr %29, align 8, !tbaa !13
  br label %118

114:                                              ; preds = %106
  %115 = load i32, ptr %21, align 4, !tbaa !5
  %116 = load i32, ptr %21, align 4, !tbaa !5
  %117 = call ptr @iirfilt_crcf_create(ptr noundef %80, i32 noundef %115, ptr noundef %83, i32 noundef %116)
  store ptr %117, ptr %29, align 8, !tbaa !13
  br label %118

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @iirfilt_crcf_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) #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 = { 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 = !{!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.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.91 = 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_crcf_create(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @iirfilt_crcf_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 #1 {
  %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.87, i32 noundef 242, ptr noundef nonnull @.str.91, ptr noundef nonnull @.str.2) #3
  br label %31

23:                                               ; preds = %8
  %24 = alloca float, i64 %17, align 16
  %25 = alloca 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
  %26 = shl nuw nsw i64 %17, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %24, ptr nonnull align 16 %18, i64 %26, i1 false), !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %25, ptr nonnull align 16 %19, i64 %26, i1 false), !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %23
  br i1 %12, label %27, label %29

27:                                               ; preds = %._crit_edge
  %28 = call ptr @iirfilt_crcf_create_sos(ptr noundef nonnull %24, ptr noundef nonnull %25, i32 noundef %13)
  br label %31

29:                                               ; preds = %._crit_edge
  %30 = call ptr @iirfilt_crcf_create(ptr noundef nonnull %24, i32 noundef %15, ptr noundef nonnull %25, i32 noundef %15)
  br label %31

31:                                               ; preds = %27, %29, %21
  %.039 = phi ptr [ %22, %21 ], [ %28, %27 ], [ %30, %29 ]
  ret ptr %.039
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @iirfilt_crcf_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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 nounwind willreturn memory(argmem: readwrite) }
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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass