; 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"

%struct.firdecim_cccf_s = type { ptr, i32, i32, ptr, ptr, { float, float } }

; 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 i32 @windowcf_push(ptr noundef, <2 x float> noundef) #1

declare i32 @windowcf_read(ptr noundef, ptr noundef) #1

declare <2 x float> @__mulsc3(float, float, float, float)

; Function Attrs: nounwind uwtable
define dso_local i32 @firdecim_cccf_execute(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca { float, float }, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %78, %3
  %12 = load i32, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.firdecim_cccf_s, ptr %13, i32 0, i32 2
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp ult i32 %12, %15
  br i1 %16, label %17, label %81

17:                                               ; preds = %11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.firdecim_cccf_s, ptr %18, i32 0, i32 3
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds { float, float }, ptr %21, i64 %23
  %25 = getelementptr inbounds { float, float }, ptr %24, i32 0, i32 0
  %26 = load float, ptr %25, align 4
  %27 = getelementptr inbounds { float, float }, ptr %24, i32 0, i32 1
  %28 = load float, ptr %27, align 4
  %29 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %30 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %26, ptr %29, align 4
  store float %28, ptr %30, align 4
  %31 = load <2 x float>, ptr %9, align 4
  %32 = call i32 @windowcf_push(ptr noundef %20, <2 x float> noundef %31)
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %77

35:                                               ; preds = %17
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.firdecim_cccf_s, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = call i32 @windowcf_read(ptr noundef %38, ptr noundef %7)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.firdecim_cccf_s, ptr %40, i32 0, i32 4
  %42 = load ptr, ptr %41, align 8, !tbaa !14
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = call i32 @dotprod_cccf_execute(ptr noundef %42, ptr noundef %43, ptr noundef %44)
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.firdecim_cccf_s, ptr %46, i32 0, i32 5
  %48 = getelementptr inbounds { float, float }, ptr %47, i32 0, i32 0
  %49 = load float, ptr %48, align 8
  %50 = getelementptr inbounds { float, float }, ptr %47, i32 0, i32 1
  %51 = load float, ptr %50, align 4
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds { float, float }, ptr %52, i32 0, i32 0
  %54 = load float, ptr %53, align 4
  %55 = getelementptr inbounds { float, float }, ptr %52, i32 0, i32 1
  %56 = load float, ptr %55, align 4
  %57 = fmul float %54, %49
  %58 = fmul float %56, %51
  %59 = fmul float %54, %51
  %60 = fmul float %56, %49
  %61 = fsub float %57, %58
  %62 = fadd float %59, %60
  %63 = fcmp uno float %61, %61
  br i1 %63, label %64, label %72, !prof !15

64:                                               ; preds = %35
  %65 = fcmp uno float %62, %62
  br i1 %65, label %66, label %72, !prof !15

66:                                               ; preds = %64
  %67 = call <2 x float> @__mulsc3(float noundef %54, float noundef %56, float noundef %49, float noundef %51) #3
  store <2 x float> %67, ptr %10, align 4
  %68 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %69 = load float, ptr %68, align 4
  %70 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %71 = load float, ptr %70, align 4
  br label %72

72:                                               ; preds = %66, %64, %35
  %73 = phi float [ %61, %35 ], [ %61, %64 ], [ %69, %66 ]
  %74 = phi float [ %62, %35 ], [ %62, %64 ], [ %71, %66 ]
  %75 = getelementptr inbounds { float, float }, ptr %52, i32 0, i32 0
  %76 = getelementptr inbounds { float, float }, ptr %52, i32 0, i32 1
  store float %73, ptr %75, align 4
  store float %74, ptr %76, align 4
  br label %77

77:                                               ; preds = %72, %17
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = add i32 %79, 1
  store i32 %80, ptr %8, align 4, !tbaa !9
  br label %11, !llvm.loop !16

81:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 0
}

declare i32 @dotprod_cccf_execute(ptr 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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"firdecim_cccf_s", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !7, i64 32}
!13 = !{!12, !6, i64 16}
!14 = !{!12, !6, i64 24}
!15 = !{!"branch_weights", i32 1, i32 1048575}
!16 = distinct !{!16, !17}
!17 = !{!"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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @windowcf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #1

declare i32 @windowcf_read(ptr noundef, ptr noundef) local_unnamed_addr #1

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @firdecim_cccf_execute(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = getelementptr inbounds i8, ptr %2, i64 4
  %10 = load ptr, ptr %8, align 8, !tbaa !11
  %11 = load <2 x float>, ptr %1, align 4
  %12 = tail call i32 @windowcf_push(ptr noundef %10, <2 x float> noundef %11) #3
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load ptr, ptr %8, align 8, !tbaa !11
  %16 = call i32 @windowcf_read(ptr noundef %15, ptr noundef nonnull %4) #3
  %17 = load ptr, ptr %14, align 8, !tbaa !12
  %18 = load ptr, ptr %4, align 8, !tbaa !13
  %19 = call i32 @dotprod_cccf_execute(ptr noundef %17, ptr noundef %18, ptr noundef %2) #3
  %20 = load <2 x float>, ptr %13, align 8
  %21 = load <2 x float>, ptr %2, align 4
  %22 = fmul <2 x float> %20, %21
  %23 = shufflevector <2 x float> %20, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %24 = fmul <2 x float> %23, %21
  %shift = shufflevector <2 x float> %22, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %25 = fsub <2 x float> %22, %shift
  %26 = extractelement <2 x float> %25, i64 0
  %shift17 = shufflevector <2 x float> %24, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %27 = fadd <2 x float> %24, %shift17
  %28 = extractelement <2 x float> %27, i64 0
  %29 = fcmp uno float %26, 0.000000e+00
  br i1 %29, label %30, label %38, !prof !14

30:                                               ; preds = %7
  %31 = fcmp uno float %28, 0.000000e+00
  br i1 %31, label %32, label %38, !prof !14

32:                                               ; preds = %30
  %33 = extractelement <2 x float> %20, i64 0
  %34 = extractelement <2 x float> %20, i64 1
  %35 = extractelement <2 x float> %21, i64 0
  %36 = extractelement <2 x float> %21, i64 1
  %37 = call <2 x float> @__mulsc3(float noundef %35, float noundef %36, float noundef %33, float noundef %34) #3
  %.sroa.0.0.vec.extract.peel = extractelement <2 x float> %37, i64 0
  %.sroa.0.4.vec.extract.peel = extractelement <2 x float> %37, i64 1
  br label %38

38:                                               ; preds = %7, %30, %32
  %39 = phi float [ %26, %7 ], [ %26, %30 ], [ %.sroa.0.0.vec.extract.peel, %32 ]
  %40 = phi float [ %28, %7 ], [ %28, %30 ], [ %.sroa.0.4.vec.extract.peel, %32 ]
  store float %39, ptr %2, align 4
  store float %40, ptr %9, align 4
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = icmp ugt i32 %41, 1
  br i1 %42, label %.peel.next, label %._crit_edge

.peel.next:                                       ; preds = %38, %.peel.next
  %indvars.iv = phi i64 [ %indvars.iv.next, %.peel.next ], [ 1, %38 ]
  %43 = load ptr, ptr %8, align 8, !tbaa !11
  %44 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %45 = load <2 x float>, ptr %44, align 4
  %46 = call i32 @windowcf_push(ptr noundef %43, <2 x float> noundef %45) #3
  %.pre = load i32, ptr %5, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %47 = zext i32 %.pre to i64
  %48 = icmp ult i64 %indvars.iv.next, %47
  br i1 %48, label %.peel.next, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.peel.next, %38, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 0
}

declare i32 @dotprod_cccf_execute(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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 #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, !10, i64 12}
!6 = !{!"firdecim_cccf_s", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !7, i64 24, !8, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!7, !7, i64 0}
!14 = !{!"branch_weights", i32 1, i32 1048575}
!15 = distinct !{!15, !16, !17}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass