; 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

; 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_compute_dotprods(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca { float, float }, align 4
  %6 = alloca float, align 4
  %7 = alloca { float, float }, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.detector_cccf_s, ptr %8, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = call i32 @windowcf_read(ptr noundef %10, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store float 0.000000e+00, ptr %6, align 4, !tbaa !13
  store i32 0, ptr %4, align 4, !tbaa !14
  br label %12

12:                                               ; preds = %72, %1
  %13 = load i32, ptr %4, align 4, !tbaa !14
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.detector_cccf_s, ptr %14, i32 0, i32 6
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = icmp ult i32 %13, %16
  br i1 %17, label %18, label %75

18:                                               ; preds = %12
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.detector_cccf_s, ptr %19, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !16
  %22 = load i32, ptr %4, align 4, !tbaa !14
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds ptr, ptr %21, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call i32 @dotprod_cccf_execute(ptr noundef %25, ptr noundef %26, ptr noundef %5)
  %28 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  %32 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %33 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %29, ptr %32, align 4
  store float %31, ptr %33, align 4
  %34 = load <2 x float>, ptr %7, align 4
  %35 = call float @cabsf(<2 x float> noundef %34) #4
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.detector_cccf_s, ptr %36, i32 0, i32 3
  %38 = load float, ptr %37, align 8, !tbaa !17
  %39 = fmul float %35, %38
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.detector_cccf_s, ptr %40, i32 0, i32 17
  %42 = load float, ptr %41, align 4, !tbaa !18
  %43 = call float @sqrtf(float noundef %42) #4
  %44 = fdiv float %39, %43
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.detector_cccf_s, ptr %45, i32 0, i32 10
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  %48 = load i32, ptr %4, align 4, !tbaa !14
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %47, i64 %49
  store float %44, ptr %50, align 4, !tbaa !13
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.detector_cccf_s, ptr %51, i32 0, i32 10
  %53 = load ptr, ptr %52, align 8, !tbaa !19
  %54 = load i32, ptr %4, align 4, !tbaa !14
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds float, ptr %53, i64 %55
  %57 = load float, ptr %56, align 4, !tbaa !13
  %58 = load float, ptr %6, align 4, !tbaa !13
  %59 = fcmp ogt float %57, %58
  br i1 %59, label %60, label %71

60:                                               ; preds = %18
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.detector_cccf_s, ptr %61, i32 0, i32 10
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  %64 = load i32, ptr %4, align 4, !tbaa !14
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds float, ptr %63, i64 %65
  %67 = load float, ptr %66, align 4, !tbaa !13
  store float %67, ptr %6, align 4, !tbaa !13
  %68 = load i32, ptr %4, align 4, !tbaa !14
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.detector_cccf_s, ptr %69, i32 0, i32 13
  store i32 %68, ptr %70, align 8, !tbaa !20
  br label %71

71:                                               ; preds = %60, %18
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %4, align 4, !tbaa !14
  %74 = add i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !14
  br label %12, !llvm.loop !21

75:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #2

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

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

; Function Attrs: nounwind
declare float @cabsf(<2 x float> 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 = { nounwind "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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 24}
!10 = !{!"detector_cccf_s", !6, i64 0, !11, i64 8, !12, i64 12, !12, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !12, i64 44, !12, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !6, i64 96, !12, i64 104, !12, i64 108, !11, i64 112, !11, i64 116}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 40}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !12, i64 16}
!18 = !{!10, !12, i64 108}
!19 = !{!10, !6, i64 64}
!20 = !{!10, !11, i64 88}
!21 = distinct !{!21, !22}
!22 = !{!"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

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

.lr.ph:                                           ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = getelementptr inbounds i8, ptr %0, i64 108
  %12 = getelementptr inbounds i8, ptr %0, i64 64
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  br label %14

14:                                               ; preds = %.lr.ph, %32
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %32 ]
  %.020 = phi float [ 0.000000e+00, %.lr.ph ], [ %.1, %32 ]
  %15 = load ptr, ptr %9, align 8, !tbaa !13
  %16 = getelementptr inbounds ptr, ptr %15, i64 %indvars.iv
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = load ptr, ptr %2, align 8, !tbaa !14
  %19 = call i32 @dotprod_cccf_execute(ptr noundef %17, ptr noundef %18, ptr noundef nonnull %3) #5
  %20 = load <2 x float>, ptr %3, align 8
  %21 = call float @cabsf(<2 x float> noundef %20) #5
  %22 = load float, ptr %10, align 8, !tbaa !15
  %23 = fmul float %21, %22
  %24 = load float, ptr %11, align 4, !tbaa !16
  %25 = call float @sqrtf(float noundef %24) #5
  %26 = fdiv float %23, %25
  %27 = load ptr, ptr %12, align 8, !tbaa !17
  %28 = getelementptr inbounds float, ptr %27, i64 %indvars.iv
  store float %26, ptr %28, align 4, !tbaa !18
  %29 = fcmp ogt float %26, %.020
  br i1 %29, label %30, label %32

30:                                               ; preds = %14
  %31 = trunc nuw i64 %indvars.iv to i32
  store i32 %31, ptr %13, align 8, !tbaa !19
  br label %32

32:                                               ; preds = %14, %30
  %.1 = phi float [ %26, %30 ], [ %.020, %14 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %33 = load i32, ptr %7, align 8, !tbaa !12
  %34 = zext i32 %33 to i64
  %35 = icmp ult i64 %indvars.iv.next, %34
  br i1 %35, label %14, label %._crit_edge, !llvm.loop !20

._crit_edge:                                      ; preds = %32, %1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind
declare float @cabsf(<2 x float> noundef) local_unnamed_addr #4

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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { "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 "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 #5 = { 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 24}
!6 = !{!"detector_cccf_s", !7, i64 0, !10, i64 8, !11, i64 12, !11, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !11, i64 44, !11, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !10, i64 88, !10, i64 92, !7, i64 96, !11, i64 104, !11, i64 108, !10, i64 112, !10, i64 116}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 40}
!13 = !{!6, !7, i64 32}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !11, i64 16}
!16 = !{!6, !11, i64 108}
!17 = !{!6, !7, i64 64}
!18 = !{!11, !11, i64 0}
!19 = !{!6, !10, i64 88}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass