; LLVM IR from jgaeddert/liquid-dsp :: src/equalization/src (equalizer_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 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [61 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @eqlms_cccf_create(ptr noundef, i32 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

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

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

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

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

12:                                               ; preds = %2
  %13 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str, i32 noundef 136, ptr noundef @.str.6, ptr noundef @.str.2)
  store ptr %13, ptr %3, align 8
  br label %57

14:                                               ; preds = %2
  %15 = load float, ptr %5, align 4, !tbaa !9
  %16 = fcmp ole float %15, 0.000000e+00
  br i1 %16, label %20, label %17

17:                                               ; preds = %14
  %18 = load float, ptr %5, align 4, !tbaa !9
  %19 = fcmp ogt float %18, 5.000000e-01
  br i1 %19, label %20, label %22

20:                                               ; preds = %17, %14
  %21 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str, i32 noundef 138, ptr noundef @.str.7, ptr noundef @.str.2)
  store ptr %21, ptr %3, align 8
  br label %57

22:                                               ; preds = %17
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = zext i32 %23 to i64
  %25 = call ptr @llvm.stacksave.p0()
  store ptr %25, ptr %6, align 8
  %26 = alloca float, i64 %24, align 16
  store i64 %24, ptr %7, align 8
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = load float, ptr %5, align 4, !tbaa !9
  %29 = call i32 @liquid_firdes_kaiser(i32 noundef %27, float noundef %28, float noundef 4.000000e+01, float noundef 0.000000e+00, ptr noundef %26)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = alloca { float, float }, i64 %31, align 16
  store i64 %31, ptr %9, align 8
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %50, %22
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = icmp ult i32 %34, %35
  br i1 %36, label %37, label %53

37:                                               ; preds = %33
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %26, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !9
  %42 = fmul float %41, 2.000000e+00
  %43 = load float, ptr %5, align 4, !tbaa !9
  %44 = fmul float %42, %43
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds { float, float }, ptr %32, i64 %46
  %48 = getelementptr inbounds { float, float }, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds { float, float }, ptr %47, i32 0, i32 1
  store float %44, ptr %48, align 8
  store float 0.000000e+00, ptr %49, align 4
  br label %50

50:                                               ; preds = %37
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = add i32 %51, 1
  store i32 %52, ptr %8, align 4, !tbaa !5
  br label %33, !llvm.loop !11

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

57:                                               ; preds = %53, %20, %12
  %58 = load ptr, ptr %3, align 8
  ret ptr %58
}

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 willreturn }
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 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [61 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @eqlms_cccf_create_lowpass(i32 noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq i32 %0, 0
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str, i32 noundef 136, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2) #3
  br label %34

6:                                                ; preds = %2
  %7 = fcmp ole float %1, 0.000000e+00
  %8 = fcmp ogt float %1, 5.000000e-01
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %9, label %11

9:                                                ; preds = %6
  %10 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str, i32 noundef 138, ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.2) #3
  br label %34

11:                                               ; preds = %6
  %12 = zext i32 %0 to i64
  %13 = tail call ptr @llvm.stacksave.p0()
  %14 = alloca float, i64 %12, align 16
  %15 = call i32 @liquid_firdes_kaiser(i32 noundef %0, float noundef %1, float noundef 4.000000e+01, float noundef 0.000000e+00, ptr noundef nonnull %14) #3
  %16 = alloca { float, float }, i64 %12, align 16
  %min.iters.check = icmp ult i32 %0, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %11
  %n.vec = and i64 %12, 4294967292
  %broadcast.splatinsert = insertelement <2 x float> poison, float %1, i64 0
  %broadcast.splat = shufflevector <2 x float> %broadcast.splatinsert, <2 x float> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %17 = or disjoint i64 %index, 2
  %18 = getelementptr inbounds float, ptr %14, i64 %index
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %wide.load = load <2 x float>, ptr %18, align 16, !tbaa !5
  %wide.load21 = load <2 x float>, ptr %19, align 8, !tbaa !5
  %20 = fmul <2 x float> %wide.load, <float 2.000000e+00, float 2.000000e+00>
  %21 = fmul <2 x float> %wide.load21, <float 2.000000e+00, float 2.000000e+00>
  %22 = fmul <2 x float> %20, %broadcast.splat
  %23 = fmul <2 x float> %21, %broadcast.splat
  %24 = getelementptr inbounds { float, float }, ptr %16, i64 %index
  %25 = getelementptr inbounds { float, float }, ptr %16, i64 %17
  %interleaved.vec = shufflevector <2 x float> %22, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec, ptr %24, align 16
  %interleaved.vec22 = shufflevector <2 x float> %23, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec22, ptr %25, align 16
  %index.next = add nuw i64 %index, 4
  %26 = icmp eq i64 %index.next, %n.vec
  br i1 %26, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %12
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %11
  %indvars.iv.ph = phi i64 [ 0, %11 ], [ %n.vec, %middle.block ]
  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 ]
  %27 = getelementptr inbounds float, ptr %14, i64 %indvars.iv
  %28 = load float, ptr %27, align 4, !tbaa !5
  %29 = fmul float %28, 2.000000e+00
  %30 = fmul float %29, %1
  %31 = getelementptr inbounds { float, float }, ptr %16, i64 %indvars.iv
  %32 = getelementptr inbounds i8, ptr %31, i64 4
  store float %30, ptr %31, align 8
  store float 0.000000e+00, ptr %32, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %12
  br i1 %exitcond.not, label %.loopexit, label %scalar.ph, !llvm.loop !13

.loopexit:                                        ; preds = %scalar.ph, %middle.block
  %33 = call ptr @eqlms_cccf_create(ptr noundef nonnull %16, i32 noundef %0)
  call void @llvm.stackrestore.p0(ptr %13)
  br label %34

34:                                               ; preds = %.loopexit, %9, %4
  %.0 = phi ptr [ %5, %4 ], [ %10, %9 ], [ %33, %.loopexit ]
  ret ptr %.0
}

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

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn }
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,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass