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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @bsync_cccf_correlate(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #2 {
  %4 = alloca { float, float }, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca { float, float }, align 4
  %8 = alloca { float, float }, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca { float, float }, align 4
  %11 = alloca { float, float }, align 4
  store <2 x float> %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.bsync_cccf_s, ptr %12, i32 0, i32 2
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %16 = load float, ptr %15, align 4
  %17 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %18 = load float, ptr %17, align 4
  %19 = fpext float %16 to double
  %20 = fcmp ogt double %19, 0.000000e+00
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 1, i32 0
  %23 = call i32 @bsequence_push(ptr noundef %14, i32 noundef %22)
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.bsync_cccf_s, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !12
  %27 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %28 = load float, ptr %27, align 4
  %29 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %30 = load float, ptr %29, align 4
  %31 = fpext float %30 to double
  %32 = fcmp ogt double %31, 0.000000e+00
  %33 = zext i1 %32 to i64
  %34 = select i1 %32, i32 1, i32 0
  %35 = call i32 @bsequence_push(ptr noundef %26, i32 noundef %34)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.bsync_cccf_s, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.bsync_cccf_s, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = call i32 @bsequence_correlate(ptr noundef %38, ptr noundef %41)
  %43 = sitofp i32 %42 to double
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.bsync_cccf_s, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !14
  %47 = uitofp i32 %46 to float
  %48 = fpext float %47 to double
  %49 = fneg double %48
  %50 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %43, double %49)
  %51 = fptrunc double %50 to float
  %52 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %53 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %51, ptr %52, align 4
  store float 0.000000e+00, ptr %53, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.bsync_cccf_s, ptr %54, i32 0, i32 3
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.bsync_cccf_s, ptr %57, i32 0, i32 4
  %59 = load ptr, ptr %58, align 8, !tbaa !12
  %60 = call i32 @bsequence_correlate(ptr noundef %56, ptr noundef %59)
  %61 = sitofp i32 %60 to double
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.bsync_cccf_s, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !14
  %65 = uitofp i32 %64 to float
  %66 = fpext float %65 to double
  %67 = fneg double %66
  %68 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %61, double %67)
  %69 = fptrunc double %68 to float
  %70 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %71 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %69, ptr %70, align 4
  store float 0.000000e+00, ptr %71, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.bsync_cccf_s, ptr %72, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !13
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.bsync_cccf_s, ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !12
  %78 = call i32 @bsequence_correlate(ptr noundef %74, ptr noundef %77)
  %79 = sitofp i32 %78 to double
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.bsync_cccf_s, ptr %80, i32 0, i32 0
  %82 = load i32, ptr %81, align 8, !tbaa !14
  %83 = uitofp i32 %82 to float
  %84 = fpext float %83 to double
  %85 = fneg double %84
  %86 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %79, double %85)
  %87 = fptrunc double %86 to float
  %88 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %89 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %87, ptr %88, align 4
  store float 0.000000e+00, ptr %89, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.bsync_cccf_s, ptr %90, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !15
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.bsync_cccf_s, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !9
  %96 = call i32 @bsequence_correlate(ptr noundef %92, ptr noundef %95)
  %97 = sitofp i32 %96 to double
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.bsync_cccf_s, ptr %98, i32 0, i32 0
  %100 = load i32, ptr %99, align 8, !tbaa !14
  %101 = uitofp i32 %100 to float
  %102 = fpext float %101 to double
  %103 = fneg double %102
  %104 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %97, double %103)
  %105 = fptrunc double %104 to float
  %106 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %107 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %105, ptr %106, align 4
  store float 0.000000e+00, ptr %107, align 4
  %108 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %109 = load float, ptr %108, align 4
  %110 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %111 = load float, ptr %110, align 4
  %112 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %113 = load float, ptr %112, align 4
  %114 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %115 = load float, ptr %114, align 4
  %116 = fsub float %109, %113
  %117 = fsub float %111, %115
  %118 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %119 = load float, ptr %118, align 4
  %120 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %121 = load float, ptr %120, align 4
  %122 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %123 = load float, ptr %122, align 4
  %124 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %125 = load float, ptr %124, align 4
  %126 = fadd float %119, %123
  %127 = fadd float %121, %125
  %128 = fmul float 0.000000e+00, %126
  %129 = fmul float 1.000000e+00, %127
  %130 = fmul float 0.000000e+00, %127
  %131 = fmul float 1.000000e+00, %126
  %132 = fsub float %128, %129
  %133 = fadd float %130, %131
  %134 = fcmp uno float %132, %132
  br i1 %134, label %135, label %143, !prof !16

135:                                              ; preds = %3
  %136 = fcmp uno float %133, %133
  br i1 %136, label %137, label %143, !prof !16

137:                                              ; preds = %135
  %138 = call <2 x float> @__mulsc3(float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef %126, float noundef %127) #4
  store <2 x float> %138, ptr %11, align 4
  %139 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %140 = load float, ptr %139, align 4
  %141 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  %142 = load float, ptr %141, align 4
  br label %143

143:                                              ; preds = %137, %135, %3
  %144 = phi float [ %132, %3 ], [ %132, %135 ], [ %140, %137 ]
  %145 = phi float [ %133, %3 ], [ %133, %135 ], [ %142, %137 ]
  %146 = fadd float %116, %144
  %147 = fadd float %117, %145
  %148 = load ptr, ptr %5, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.bsync_cccf_s, ptr %148, i32 0, i32 5
  %150 = getelementptr inbounds { float, float }, ptr %149, i32 0, i32 0
  %151 = getelementptr inbounds { float, float }, ptr %149, i32 0, i32 1
  store float %146, ptr %150, align 8
  store float %147, ptr %151, align 4
  %152 = load ptr, ptr %5, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.bsync_cccf_s, ptr %152, i32 0, i32 5
  %154 = getelementptr inbounds { float, float }, ptr %153, i32 0, i32 0
  %155 = load float, ptr %154, align 8
  %156 = getelementptr inbounds { float, float }, ptr %153, i32 0, i32 1
  %157 = load float, ptr %156, align 4
  %158 = load ptr, ptr %5, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.bsync_cccf_s, ptr %158, i32 0, i32 0
  %160 = load i32, ptr %159, align 8, !tbaa !14
  %161 = uitofp i32 %160 to float
  %162 = fdiv float %155, %161
  %163 = fdiv float %157, %161
  %164 = load ptr, ptr %6, align 8, !tbaa !5
  %165 = getelementptr inbounds { float, float }, ptr %164, i32 0, i32 0
  %166 = getelementptr inbounds { float, float }, ptr %164, i32 0, i32 1
  store float %162, ptr %165, align 4
  store float %163, ptr %166, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 16}
!10 = !{!"bsync_cccf_s", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !7, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 32}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !6, i64 24}
!16 = !{!"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"

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

declare i32 @bsequence_push(ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @bsequence_correlate(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @bsync_cccf_correlate(ptr nocapture noundef %0, <2 x float> noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.sroa.025.0.vec.extract = extractelement <2 x float> %1, i64 0
  %6 = fcmp ogt float %.sroa.025.0.vec.extract, 0.000000e+00
  %7 = zext i1 %6 to i32
  %8 = tail call i32 @bsequence_push(ptr noundef %5, i32 noundef %7) #4
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %.sroa.025.4.vec.extract29 = extractelement <2 x float> %1, i64 1
  %11 = fcmp ogt float %.sroa.025.4.vec.extract29, 0.000000e+00
  %12 = zext i1 %11 to i32
  %13 = tail call i32 @bsequence_push(ptr noundef %10, i32 noundef %12) #4
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = tail call i32 @bsequence_correlate(ptr noundef %15, ptr noundef %16) #4
  %18 = load i32, ptr %0, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %9, align 8, !tbaa !11
  %22 = tail call i32 @bsequence_correlate(ptr noundef %20, ptr noundef %21) #4
  %23 = load i32, ptr %0, align 8, !tbaa !13
  %24 = load ptr, ptr %14, align 8, !tbaa !12
  %25 = load ptr, ptr %9, align 8, !tbaa !11
  %26 = tail call i32 @bsequence_correlate(ptr noundef %24, ptr noundef %25) #4
  %27 = sitofp i32 %26 to double
  %28 = load i32, ptr %0, align 8, !tbaa !13
  %29 = uitofp i32 %28 to float
  %30 = fpext float %29 to double
  %31 = fneg double %30
  %32 = tail call double @llvm.fmuladd.f64(double %27, double 2.000000e+00, double %31)
  %33 = fptrunc double %32 to float
  %34 = load ptr, ptr %19, align 8, !tbaa !14
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = tail call i32 @bsequence_correlate(ptr noundef %34, ptr noundef %35) #4
  %37 = sitofp i32 %36 to double
  %38 = load i32, ptr %0, align 8, !tbaa !13
  %39 = uitofp i32 %38 to float
  %40 = fpext float %39 to double
  %41 = fneg double %40
  %42 = tail call double @llvm.fmuladd.f64(double %37, double 2.000000e+00, double %41)
  %43 = fptrunc double %42 to float
  %44 = fadd float %33, %43
  %45 = fmul float %44, 0.000000e+00
  %46 = fcmp uno float %45, 0.000000e+00
  %47 = insertelement <2 x float> poison, float %45, i64 0
  %48 = insertelement <2 x float> %47, float %44, i64 1
  br i1 %46, label %49, label %53, !prof !15

49:                                               ; preds = %3
  %50 = fcmp uno float %44, 0.000000e+00
  br i1 %50, label %51, label %53, !prof !15

51:                                               ; preds = %49
  %52 = tail call <2 x float> @__mulsc3(float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef %44, float noundef 0.000000e+00) #4
  %.pre = load i32, ptr %0, align 8, !tbaa !13
  %.pre30 = uitofp i32 %.pre to float
  br label %53

53:                                               ; preds = %51, %49, %3
  %.pre-phi = phi float [ %.pre30, %51 ], [ %39, %49 ], [ %39, %3 ]
  %54 = phi <2 x float> [ %52, %51 ], [ %48, %49 ], [ %48, %3 ]
  %55 = insertelement <2 x i32> poison, i32 %17, i64 0
  %56 = insertelement <2 x i32> %55, i32 %22, i64 1
  %57 = sitofp <2 x i32> %56 to <2 x double>
  %58 = insertelement <2 x i32> poison, i32 %18, i64 0
  %59 = insertelement <2 x i32> %58, i32 %23, i64 1
  %60 = uitofp <2 x i32> %59 to <2 x float>
  %61 = fpext <2 x float> %60 to <2 x double>
  %62 = fneg <2 x double> %61
  %63 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %57, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %62)
  %64 = fptrunc <2 x double> %63 to <2 x float>
  %shift = shufflevector <2 x float> %64, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %65 = fsub <2 x float> %64, %shift
  %66 = getelementptr inbounds i8, ptr %0, i64 40
  %67 = insertelement <2 x float> %65, float 0.000000e+00, i64 1
  %68 = fadd <2 x float> %67, %54
  store <2 x float> %68, ptr %66, align 8
  %69 = insertelement <2 x float> poison, float %.pre-phi, i64 0
  %70 = shufflevector <2 x float> %69, <2 x float> poison, <2 x i32> zeroinitializer
  %71 = fdiv <2 x float> %68, %70
  store <2 x float> %71, ptr %2, align 4
  ret i32 0
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

attributes #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 = { 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 16}
!6 = !{!"bsync_cccf_s", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !8, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 32}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 24}
!15 = !{!"branch_weights", i32 1, i32 1048575}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass