; 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.firfilt_cccf_s = type { ptr, 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_read(ptr noundef, ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @firfilt_cccf_execute(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca { float, float }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %7, i32 0, i32 2
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = call i32 @windowcf_read(ptr noundef %9, ptr noundef %5)
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i32 @dotprod_cccf_execute(ptr noundef %13, ptr noundef %14, ptr noundef %15)
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %17, i32 0, i32 4
  %19 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 8
  %21 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 1
  %22 = load float, ptr %21, align 4
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 0
  %25 = load float, ptr %24, align 4
  %26 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 1
  %27 = load float, ptr %26, align 4
  %28 = fmul float %25, %20
  %29 = fmul float %27, %22
  %30 = fmul float %25, %22
  %31 = fmul float %27, %20
  %32 = fsub float %28, %29
  %33 = fadd float %30, %31
  %34 = fcmp uno float %32, %32
  br i1 %34, label %35, label %43, !prof !13

35:                                               ; preds = %2
  %36 = fcmp uno float %33, %33
  br i1 %36, label %37, label %43, !prof !13

37:                                               ; preds = %35
  %38 = call <2 x float> @__mulsc3(float noundef %25, float noundef %27, float noundef %20, float noundef %22) #3
  store <2 x float> %38, ptr %6, align 4
  %39 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %40 = load float, ptr %39, align 4
  %41 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  %42 = load float, ptr %41, align 4
  br label %43

43:                                               ; preds = %37, %35, %2
  %44 = phi float [ %32, %2 ], [ %32, %35 ], [ %40, %37 ]
  %45 = phi float [ %33, %2 ], [ %33, %35 ], [ %42, %37 ]
  %46 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 0
  %47 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 1
  store float %44, ptr %46, align 4
  store float %45, ptr %47, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i32 0
}

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, !6, i64 16}
!10 = !{!"firfilt_cccf_s", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !7, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!"branch_weights", i32 1, i32 1048575}


; 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_read(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @firfilt_cccf_execute(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = call i32 @windowcf_read(ptr noundef %5, ptr noundef nonnull %3) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = load ptr, ptr %3, align 8, !tbaa !12
  %10 = call i32 @dotprod_cccf_execute(ptr noundef %8, ptr noundef %9, ptr noundef %1) #3
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load <2 x float>, ptr %11, align 8
  %13 = load <2 x float>, ptr %1, align 4
  %14 = fmul <2 x float> %12, %13
  %15 = shufflevector <2 x float> %12, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %16 = fmul <2 x float> %15, %13
  %shift = shufflevector <2 x float> %14, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %17 = fsub <2 x float> %14, %shift
  %18 = extractelement <2 x float> %17, i64 0
  %shift5 = shufflevector <2 x float> %16, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %19 = fadd <2 x float> %16, %shift5
  %20 = extractelement <2 x float> %19, i64 0
  %21 = fcmp uno float %18, 0.000000e+00
  br i1 %21, label %22, label %30, !prof !13

22:                                               ; preds = %2
  %23 = fcmp uno float %20, 0.000000e+00
  br i1 %23, label %24, label %30, !prof !13

24:                                               ; preds = %22
  %25 = extractelement <2 x float> %12, i64 0
  %26 = extractelement <2 x float> %12, i64 1
  %27 = extractelement <2 x float> %13, i64 0
  %28 = extractelement <2 x float> %13, i64 1
  %29 = call <2 x float> @__mulsc3(float noundef %27, float noundef %28, float noundef %25, float noundef %26) #3
  %.sroa.0.0.vec.extract = extractelement <2 x float> %29, i64 0
  %.sroa.0.4.vec.extract = extractelement <2 x float> %29, i64 1
  br label %30

30:                                               ; preds = %24, %22, %2
  %31 = phi float [ %18, %2 ], [ %18, %22 ], [ %.sroa.0.0.vec.extract, %24 ]
  %32 = phi float [ %20, %2 ], [ %20, %22 ], [ %.sroa.0.4.vec.extract, %24 ]
  %33 = getelementptr inbounds i8, ptr %1, i64 4
  store float %31, ptr %1, align 4
  store float %32, ptr %33, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i32 0
}

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, !7, i64 16}
!6 = !{!"firfilt_cccf_s", !7, i64 0, !10, i64 8, !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 24}
!12 = !{!7, !7, i64 0}
!13 = !{!"branch_weights", i32 1, i32 1048575}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,VectorCombinePass