; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (detector_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.detector_cccf_s = type { ptr, i32, float, float, ptr, ptr, i32, float, float, ptr, ptr, ptr, ptr, i32, i32, ptr, float, float, i32, i32 }

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @detector_cccf_update_sumsq(ptr noundef %0, <2 x float> noundef %1) #1 {
  %3 = alloca { float, float }, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca { float, float }, align 4
  %7 = alloca float, align 4
  store <2 x float> %1, ptr %3, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %8 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %9 = load float, ptr %8, align 4
  %10 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %11 = load float, ptr %10, align 4
  %12 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %13 = load float, ptr %12, align 4
  %14 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %15 = load float, ptr %14, align 4
  %16 = fneg float %15
  %17 = fmul float %9, %13
  %18 = fmul float %11, %16
  %19 = fmul float %9, %16
  %20 = fmul float %11, %13
  %21 = fsub float %17, %18
  %22 = fadd float %19, %20
  %23 = fcmp uno float %21, %21
  br i1 %23, label %24, label %32, !prof !9

24:                                               ; preds = %2
  %25 = fcmp uno float %22, %22
  br i1 %25, label %26, label %32, !prof !9

26:                                               ; preds = %24
  %27 = call <2 x float> @__mulsc3(float noundef %9, float noundef %11, float noundef %13, float noundef %16) #3
  store <2 x float> %27, ptr %6, align 4
  %28 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  br label %32

32:                                               ; preds = %26, %24, %2
  %33 = phi float [ %21, %2 ], [ %21, %24 ], [ %29, %26 ]
  %34 = phi float [ %22, %2 ], [ %22, %24 ], [ %31, %26 ]
  store float %33, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.detector_cccf_s, ptr %35, i32 0, i32 15
  %37 = load ptr, ptr %36, align 8, !tbaa !12
  %38 = load float, ptr %5, align 4, !tbaa !10
  %39 = call i32 @wdelayf_push(ptr noundef %37, float noundef %38)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.detector_cccf_s, ptr %40, i32 0, i32 15
  %42 = load ptr, ptr %41, align 8, !tbaa !12
  %43 = call i32 @wdelayf_read(ptr noundef %42, ptr noundef %7)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.detector_cccf_s, ptr %44, i32 0, i32 16
  %46 = load float, ptr %45, align 8, !tbaa !15
  %47 = load float, ptr %5, align 4, !tbaa !10
  %48 = fadd float %46, %47
  %49 = load float, ptr %7, align 4, !tbaa !10
  %50 = fsub float %48, %49
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.detector_cccf_s, ptr %51, i32 0, i32 16
  store float %50, ptr %52, align 8, !tbaa !15
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.detector_cccf_s, ptr %53, i32 0, i32 16
  %55 = load float, ptr %54, align 8, !tbaa !15
  %56 = fcmp olt float %55, 0x3E80000000000000
  br i1 %56, label %57, label %60

57:                                               ; preds = %32
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.detector_cccf_s, ptr %58, i32 0, i32 16
  store float 0x3E80000000000000, ptr %59, align 8, !tbaa !15
  br label %60

60:                                               ; preds = %57, %32
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.detector_cccf_s, ptr %61, i32 0, i32 16
  %63 = load float, ptr %62, align 8, !tbaa !15
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.detector_cccf_s, ptr %64, i32 0, i32 3
  %66 = load float, ptr %65, align 8, !tbaa !16
  %67 = fmul float %63, %66
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.detector_cccf_s, ptr %68, i32 0, i32 17
  store float %67, ptr %69, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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

declare i32 @wdelayf_read(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"branch_weights", i32 1, i32 1048575}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !6, i64 96}
!13 = !{!"detector_cccf_s", !6, i64 0, !14, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !11, i64 44, !11, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !14, i64 88, !14, i64 92, !6, i64 96, !11, i64 104, !11, i64 108, !14, i64 112, !14, i64 116}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !11, i64 104}
!16 = !{!13, !11, i64 16}
!17 = !{!13, !11, i64 108}


; 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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @detector_cccf_update_sumsq(ptr nocapture noundef %0, <2 x float> noundef %1) local_unnamed_addr #1 {
  %3 = extractelement <2 x float> %1, i64 1
  %4 = extractelement <2 x float> %1, i64 0
  %5 = alloca float, align 4
  %6 = fneg float %3
  %7 = fmul <2 x float> %1, %1
  %shift = shufflevector <2 x float> %7, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %8 = fadd <2 x float> %7, %shift
  %9 = extractelement <2 x float> %8, i64 0
  %10 = fcmp uno float %9, 0.000000e+00
  br i1 %10, label %11, label %17, !prof !5

11:                                               ; preds = %2
  %12 = fmul float %3, %4
  %13 = fsub float %12, %12
  %14 = fcmp uno float %13, 0.000000e+00
  br i1 %14, label %15, label %17, !prof !5

15:                                               ; preds = %11
  %16 = tail call <2 x float> @__mulsc3(float noundef %4, float noundef %3, float noundef %4, float noundef %6) #3
  %.sroa.0.0.vec.extract = extractelement <2 x float> %16, i64 0
  br label %17

17:                                               ; preds = %15, %11, %2
  %18 = phi float [ %9, %2 ], [ %9, %11 ], [ %.sroa.0.0.vec.extract, %15 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 96
  %20 = load ptr, ptr %19, align 8, !tbaa !6
  %21 = tail call i32 @wdelayf_push(ptr noundef %20, float noundef %18) #3
  %22 = load ptr, ptr %19, align 8, !tbaa !6
  %23 = call i32 @wdelayf_read(ptr noundef %22, ptr noundef nonnull %5) #3
  %24 = getelementptr inbounds i8, ptr %0, i64 104
  %25 = load float, ptr %24, align 8, !tbaa !13
  %26 = fadd float %18, %25
  %27 = load float, ptr %5, align 4, !tbaa !14
  %28 = fsub float %26, %27
  %29 = fcmp olt float %28, 0x3E80000000000000
  %storemerge = select i1 %29, float 0x3E80000000000000, float %28
  store float %storemerge, ptr %24, align 8, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  %31 = load float, ptr %30, align 8, !tbaa !15
  %32 = fmul float %31, %storemerge
  %33 = getelementptr inbounds i8, ptr %0, i64 108
  store float %32, ptr %33, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  ret void
}

declare i32 @wdelayf_push(ptr noundef, float noundef) local_unnamed_addr #2

declare i32 @wdelayf_read(ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !8, i64 96}
!7 = !{!"detector_cccf_s", !8, i64 0, !11, i64 8, !12, i64 12, !12, i64 16, !8, i64 24, !8, i64 32, !11, i64 40, !12, i64 44, !12, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !11, i64 88, !11, i64 92, !8, i64 96, !12, i64 104, !12, i64 108, !11, i64 112, !11, i64 116}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"float", !9, i64 0}
!13 = !{!7, !12, i64 104}
!14 = !{!12, !12, i64 0}
!15 = !{!7, !12, i64 16}
!16 = !{!7, !12, i64 108}


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