; 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.48 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.51 = external hidden unnamed_addr constant [82 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

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

; 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_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, float noundef %4) #3 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store float %3, ptr %10, align 4, !tbaa !9
  store float %4, ptr %11, align 4, !tbaa !9
  %17 = load i32, ptr %8, align 4, !tbaa !5
  %18 = icmp ult i32 %17, 2
  br i1 %18, label %19, label %21

19:                                               ; preds = %5
  %20 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.42, i32 noundef 123, ptr noundef @.str.48, ptr noundef @.str.3)
  store ptr %20, ptr %6, align 8
  br label %83

21:                                               ; preds = %5
  %22 = load i32, ptr %9, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.42, i32 noundef 125, ptr noundef @.str.49, ptr noundef @.str.3)
  store ptr %25, ptr %6, align 8
  br label %83

26:                                               ; preds = %21
  %27 = load float, ptr %10, align 4, !tbaa !9
  %28 = fcmp olt float %27, 0.000000e+00
  br i1 %28, label %32, label %29

29:                                               ; preds = %26
  %30 = load float, ptr %10, align 4, !tbaa !9
  %31 = fcmp ogt float %30, 1.000000e+00
  br i1 %31, label %32, label %34

32:                                               ; preds = %29, %26
  %33 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.42, i32 noundef 127, ptr noundef @.str.50, ptr noundef @.str.3)
  store ptr %33, ptr %6, align 8
  br label %83

34:                                               ; preds = %29
  %35 = load float, ptr %11, align 4, !tbaa !9
  %36 = fcmp olt float %35, -1.000000e+00
  br i1 %36, label %40, label %37

37:                                               ; preds = %34
  %38 = load float, ptr %11, align 4, !tbaa !9
  %39 = fcmp ogt float %38, 1.000000e+00
  br i1 %39, label %40, label %42

40:                                               ; preds = %37, %34
  %41 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.42, i32 noundef 129, ptr noundef @.str.51, ptr noundef @.str.3)
  store ptr %41, ptr %6, align 8
  br label %83

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = mul i32 2, %43
  %45 = load i32, ptr %9, align 4, !tbaa !5
  %46 = mul i32 %44, %45
  %47 = add i32 %46, 1
  store i32 %47, ptr %12, align 4, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !5
  %49 = zext i32 %48 to i64
  %50 = call ptr @llvm.stacksave.p0()
  store ptr %50, ptr %13, align 8
  %51 = alloca float, i64 %49, align 16
  store i64 %49, ptr %14, align 8
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = load i32, ptr %9, align 4, !tbaa !5
  %55 = load float, ptr %10, align 4, !tbaa !9
  %56 = load float, ptr %11, align 4, !tbaa !9
  %57 = call i32 @liquid_firdes_prototype(i32 noundef %52, i32 noundef %53, i32 noundef %54, float noundef %55, float noundef %56, ptr noundef %51)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %58 = load i32, ptr %12, align 4, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = alloca { float, float }, i64 %59, align 16
  store i64 %59, ptr %16, align 8
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %75, %42
  %62 = load i32, ptr %15, align 4, !tbaa !5
  %63 = load i32, ptr %12, align 4, !tbaa !5
  %64 = icmp ult i32 %62, %63
  br i1 %64, label %65, label %78

65:                                               ; preds = %61
  %66 = load i32, ptr %15, align 4, !tbaa !5
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %51, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !9
  %70 = load i32, ptr %15, align 4, !tbaa !5
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds { float, float }, ptr %60, i64 %71
  %73 = getelementptr inbounds { float, float }, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds { float, float }, ptr %72, i32 0, i32 1
  store float %69, ptr %73, align 8
  store float 0.000000e+00, ptr %74, align 4
  br label %75

75:                                               ; preds = %65
  %76 = load i32, ptr %15, align 4, !tbaa !5
  %77 = add i32 %76, 1
  store i32 %77, ptr %15, align 4, !tbaa !5
  br label %61, !llvm.loop !11

78:                                               ; preds = %61
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = load i32, ptr %12, align 4, !tbaa !5
  %81 = call ptr @firinterp_cccf_create(i32 noundef %79, ptr noundef %60, i32 noundef %80)
  store ptr %81, ptr %6, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  %82 = load ptr, ptr %13, align 8
  call void @llvm.stackrestore.p0(ptr %82)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %83

83:                                               ; preds = %78, %40, %32, %24, %19
  %84 = load ptr, ptr %6, align 8
  ret ptr %84
}

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.48 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.51 = external hidden unnamed_addr constant [82 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

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

; 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_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #2 {
  %6 = icmp ult i32 %1, 2
  br i1 %6, label %7, label %9

7:                                                ; preds = %5
  %8 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.42, i32 noundef 123, ptr noundef nonnull @.str.48, ptr noundef nonnull @.str.3) #4
  br label %43

9:                                                ; preds = %5
  %10 = icmp eq i32 %2, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %9
  %12 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.42, i32 noundef 125, ptr noundef nonnull @.str.49, ptr noundef nonnull @.str.3) #4
  br label %43

13:                                               ; preds = %9
  %14 = fcmp olt float %3, 0.000000e+00
  %15 = fcmp ogt float %3, 1.000000e+00
  %or.cond = or i1 %14, %15
  br i1 %or.cond, label %16, label %18

16:                                               ; preds = %13
  %17 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.42, i32 noundef 127, ptr noundef nonnull @.str.50, ptr noundef nonnull @.str.3) #4
  br label %43

18:                                               ; preds = %13
  %19 = tail call float @llvm.fabs.f32(float %4)
  %or.cond3 = fcmp ogt float %19, 1.000000e+00
  br i1 %or.cond3, label %20, label %22

20:                                               ; preds = %18
  %21 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.42, i32 noundef 129, ptr noundef nonnull @.str.51, ptr noundef nonnull @.str.3) #4
  br label %43

22:                                               ; preds = %18
  %23 = shl i32 %1, 1
  %24 = mul i32 %23, %2
  %25 = or disjoint i32 %24, 1
  %26 = zext i32 %25 to i64
  %27 = tail call ptr @llvm.stacksave.p0()
  %28 = alloca float, i64 %26, align 16
  %29 = call i32 @liquid_firdes_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, float noundef %4, ptr noundef nonnull %28) #4
  %30 = alloca { float, float }, i64 %26, align 16
  %31 = or disjoint i32 %24, 1
  %wide.trip.count = zext i32 %31 to i64
  %min.iters.check = icmp ult i32 %24, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %22
  %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 ]
  %32 = or disjoint i64 %index, 2
  %33 = getelementptr inbounds float, ptr %28, i64 %index
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %wide.load = load <2 x float>, ptr %33, align 16, !tbaa !5
  %wide.load34 = load <2 x float>, ptr %34, align 8, !tbaa !5
  %35 = getelementptr inbounds { float, float }, ptr %30, i64 %index
  %36 = getelementptr inbounds { float, float }, ptr %30, i64 %32
  %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 %35, align 16
  %interleaved.vec35 = shufflevector <2 x float> %wide.load34, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec35, ptr %36, align 16
  %index.next = add nuw i64 %index, 4
  %37 = icmp eq i64 %index.next, %n.vec
  br i1 %37, label %scalar.ph.preheader, label %vector.body, !llvm.loop !9

scalar.ph.preheader:                              ; preds = %vector.body, %22
  %indvars.iv.ph = phi i64 [ 0, %22 ], [ %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 ]
  %38 = getelementptr inbounds float, ptr %28, i64 %indvars.iv
  %39 = load float, ptr %38, align 4, !tbaa !5
  %40 = getelementptr inbounds { float, float }, ptr %30, i64 %indvars.iv
  %41 = getelementptr inbounds i8, ptr %40, i64 4
  store float %39, ptr %40, align 8
  store float 0.000000e+00, ptr %41, 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
  %42 = call ptr @firinterp_cccf_create(i32 noundef %1, ptr noundef nonnull %30, i32 noundef %25)
  call void @llvm.stackrestore.p0(ptr %27)
  br label %43

43:                                               ; preds = %.loopexit, %20, %16, %11, %7
  %.0 = phi ptr [ %8, %7 ], [ %12, %11 ], [ %17, %16 ], [ %21, %20 ], [ %42, %.loopexit ]
  ret ptr %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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