; 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_estimate_offsets(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca 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
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.detector_cccf_s, ptr %13, i32 0, i32 6
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %20

17:                                               ; preds = %3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  store float 0.000000e+00, ptr %18, align 4, !tbaa !13
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  store float 0.000000e+00, ptr %19, align 4, !tbaa !13
  br label %157

20:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.detector_cccf_s, ptr %21, i32 0, i32 11
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.detector_cccf_s, ptr %24, i32 0, i32 14
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %23, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !13
  store float %29, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.detector_cccf_s, ptr %30, i32 0, i32 14
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %45

34:                                               ; preds = %20
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.detector_cccf_s, ptr %35, i32 0, i32 12
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.detector_cccf_s, ptr %38, i32 0, i32 14
  %40 = load i32, ptr %39, align 4, !tbaa !15
  %41 = add i32 %40, 1
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %37, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !13
  br label %56

45:                                               ; preds = %20
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.detector_cccf_s, ptr %46, i32 0, i32 12
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.detector_cccf_s, ptr %49, i32 0, i32 14
  %51 = load i32, ptr %50, align 4, !tbaa !15
  %52 = sub i32 %51, 1
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %48, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !13
  br label %56

56:                                               ; preds = %45, %34
  %57 = phi float [ %44, %34 ], [ %55, %45 ]
  store float %57, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.detector_cccf_s, ptr %58, i32 0, i32 12
  %60 = load ptr, ptr %59, align 8, !tbaa !16
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.detector_cccf_s, ptr %61, i32 0, i32 14
  %63 = load i32, ptr %62, align 4, !tbaa !15
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds float, ptr %60, i64 %64
  %66 = load float, ptr %65, align 4, !tbaa !13
  store float %66, ptr %9, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.detector_cccf_s, ptr %67, i32 0, i32 14
  %69 = load i32, ptr %68, align 4, !tbaa !15
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.detector_cccf_s, ptr %70, i32 0, i32 6
  %72 = load i32, ptr %71, align 8, !tbaa !9
  %73 = sub i32 %72, 1
  %74 = icmp eq i32 %69, %73
  br i1 %74, label %75, label %86

75:                                               ; preds = %56
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.detector_cccf_s, ptr %76, i32 0, i32 12
  %78 = load ptr, ptr %77, align 8, !tbaa !16
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.detector_cccf_s, ptr %79, i32 0, i32 14
  %81 = load i32, ptr %80, align 4, !tbaa !15
  %82 = sub i32 %81, 1
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds float, ptr %78, i64 %83
  %85 = load float, ptr %84, align 4, !tbaa !13
  br label %97

86:                                               ; preds = %56
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.detector_cccf_s, ptr %87, i32 0, i32 12
  %89 = load ptr, ptr %88, align 8, !tbaa !16
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.detector_cccf_s, ptr %90, i32 0, i32 14
  %92 = load i32, ptr %91, align 4, !tbaa !15
  %93 = add i32 %92, 1
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds float, ptr %89, i64 %94
  %96 = load float, ptr %95, align 4, !tbaa !13
  br label %97

97:                                               ; preds = %86, %75
  %98 = phi float [ %85, %75 ], [ %96, %86 ]
  store float %98, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.detector_cccf_s, ptr %99, i32 0, i32 10
  %101 = load ptr, ptr %100, align 8, !tbaa !17
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.detector_cccf_s, ptr %102, i32 0, i32 14
  %104 = load i32, ptr %103, align 4, !tbaa !15
  %105 = zext i32 %104 to i64
  %106 = getelementptr inbounds float, ptr %101, i64 %105
  %107 = load float, ptr %106, align 4, !tbaa !13
  store float %107, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.detector_cccf_s, ptr %108, i32 0, i32 9
  %110 = load ptr, ptr %109, align 8, !tbaa !18
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.detector_cccf_s, ptr %111, i32 0, i32 14
  %113 = load i32, ptr %112, align 4, !tbaa !15
  %114 = zext i32 %113 to i64
  %115 = getelementptr inbounds float, ptr %110, i64 %114
  %116 = load float, ptr %115, align 4, !tbaa !13
  store float %116, ptr %12, align 4, !tbaa !13
  %117 = load float, ptr %12, align 4, !tbaa !13
  %118 = load ptr, ptr %4, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.detector_cccf_s, ptr %118, i32 0, i32 7
  %120 = load float, ptr %119, align 4, !tbaa !19
  %121 = fmul float %120, 5.000000e-01
  %122 = load float, ptr %10, align 4, !tbaa !13
  %123 = load float, ptr %8, align 4, !tbaa !13
  %124 = fsub float %122, %123
  %125 = fmul float %121, %124
  %126 = load float, ptr %10, align 4, !tbaa !13
  %127 = load float, ptr %8, align 4, !tbaa !13
  %128 = fadd float %126, %127
  %129 = load float, ptr %9, align 4, !tbaa !13
  %130 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %129, float %128)
  %131 = fdiv float %125, %130
  %132 = fsub float %117, %131
  %133 = load ptr, ptr %6, align 8, !tbaa !5
  store float %132, ptr %133, align 4, !tbaa !13
  %134 = load float, ptr %11, align 4, !tbaa !13
  %135 = load float, ptr %7, align 4, !tbaa !13
  %136 = fsub float %134, %135
  %137 = fmul float 5.000000e-01, %136
  %138 = load float, ptr %11, align 4, !tbaa !13
  %139 = load float, ptr %7, align 4, !tbaa !13
  %140 = fadd float %138, %139
  %141 = load float, ptr %9, align 4, !tbaa !13
  %142 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %141, float %140)
  %143 = fdiv float %137, %142
  %144 = load ptr, ptr %5, align 8, !tbaa !5
  store float %143, ptr %144, align 4, !tbaa !13
  %145 = load ptr, ptr %5, align 8, !tbaa !5
  %146 = load float, ptr %145, align 4, !tbaa !13
  %147 = fcmp olt float %146, 0xBFDFEF9DC0000000
  br i1 %147, label %148, label %150

148:                                              ; preds = %97
  %149 = load ptr, ptr %5, align 8, !tbaa !5
  store float 0xBFDFEF9DC0000000, ptr %149, align 4, !tbaa !13
  br label %150

150:                                              ; preds = %148, %97
  %151 = load ptr, ptr %5, align 8, !tbaa !5
  %152 = load float, ptr %151, align 4, !tbaa !13
  %153 = fcmp ogt float %152, 0x3FDFEF9DC0000000
  br i1 %153, label %154, label %156

154:                                              ; preds = %150
  %155 = load ptr, ptr %5, align 8, !tbaa !5
  store float 0x3FDFEF9DC0000000, ptr %155, align 4, !tbaa !13
  br label %156

156:                                              ; preds = %154, %150
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %157

157:                                              ; preds = %156, %17
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 40}
!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 = !{!10, !6, i64 72}
!15 = !{!10, !11, i64 92}
!16 = !{!10, !6, i64 80}
!17 = !{!10, !6, i64 64}
!18 = !{!10, !6, i64 56}
!19 = !{!10, !12, i64 44}


; 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 nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @detector_cccf_estimate_offsets(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 1
  br i1 %6, label %7, label %8

7:                                                ; preds = %3
  store float 0.000000e+00, ptr %2, align 4, !tbaa !12
  br label %53

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 72
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 92
  %12 = load i32, ptr %11, align 4, !tbaa !14
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds float, ptr %10, i64 %13
  %15 = load float, ptr %14, align 4, !tbaa !12
  %16 = icmp eq i32 %12, 0
  %17 = getelementptr inbounds i8, ptr %0, i64 80
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = add i32 %12, -1
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds float, ptr %18, i64 %21
  %.in = select i1 %16, ptr %19, ptr %22
  %23 = load float, ptr %.in, align 4, !tbaa !12
  %24 = getelementptr inbounds float, ptr %18, i64 %13
  %25 = load float, ptr %24, align 4, !tbaa !12
  %26 = add i32 %5, -1
  %27 = icmp eq i32 %12, %26
  %.pn.in.v = select i1 %27, i32 -1, i32 1
  %.pn.in = add i32 %.pn.in.v, %12
  %.pn = zext i32 %.pn.in to i64
  %.in42 = getelementptr inbounds float, ptr %18, i64 %.pn
  %28 = load float, ptr %.in42, align 4, !tbaa !12
  %29 = getelementptr inbounds i8, ptr %0, i64 64
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds float, ptr %30, i64 %13
  %32 = load float, ptr %31, align 4, !tbaa !12
  %33 = getelementptr inbounds i8, ptr %0, i64 56
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = getelementptr inbounds float, ptr %34, i64 %13
  %36 = load float, ptr %35, align 4, !tbaa !12
  %37 = getelementptr inbounds i8, ptr %0, i64 44
  %38 = load float, ptr %37, align 4, !tbaa !18
  %39 = fmul float %38, 5.000000e-01
  %40 = fsub float %28, %23
  %41 = fmul float %40, %39
  %42 = fadd float %23, %28
  %43 = tail call float @llvm.fmuladd.f32(float %25, float -2.000000e+00, float %42)
  %44 = fdiv float %41, %43
  %45 = fsub float %36, %44
  store float %45, ptr %2, align 4, !tbaa !12
  %46 = fsub float %32, %15
  %47 = fmul float %46, 5.000000e-01
  %48 = fadd float %15, %32
  %49 = tail call float @llvm.fmuladd.f32(float %25, float -2.000000e+00, float %48)
  %50 = fdiv float %47, %49
  %51 = fcmp olt float %50, 0xBFDFEF9DC0000000
  %storemerge = select i1 %51, float 0xBFDFEF9DC0000000, float %50
  %52 = fcmp ogt float %storemerge, 0x3FDFEF9DC0000000
  %storemerge43 = select i1 %52, float 0x3FDFEF9DC0000000, float %storemerge
  br label %53

53:                                               ; preds = %8, %7
  %storemerge44 = phi float [ %storemerge43, %8 ], [ 0.000000e+00, %7 ]
  store float %storemerge44, ptr %1, align 4, !tbaa !12
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 40}
!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 = !{!11, !11, i64 0}
!13 = !{!6, !7, i64 72}
!14 = !{!6, !10, i64 92}
!15 = !{!6, !7, i64 80}
!16 = !{!6, !7, i64 64}
!17 = !{!6, !7, i64 56}
!18 = !{!6, !11, i64 44}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass