; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (dsssframesync)

; 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.dsssframesync_s = type { ptr, ptr, %struct.framesyncstats_s, %struct.framedatastats_s, i32, i32, float, ptr, float, float, float, float, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, i32, %struct.flexframegenprops_s, ptr, i32, ptr, i32, i32, ptr, i32, i32, ptr, i32, ptr, i32, ptr, i32, i32, i32, i32 }
%struct.framesyncstats_s = type { float, float, float, ptr, i32, i32, i32, i32, i32, i32 }
%struct.framedatastats_s = type { i32, i32, i32, i64 }
%struct.flexframegenprops_s = type { i32, i32, 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
declare dso_local i32 @dsssframesync_execute(ptr noundef, ptr noundef, i32 noundef) #1

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

23:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %123

24:                                               ; preds = %2
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.dsssframesync_s, ptr %25, i32 0, i32 7
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = call float @qdetector_cccf_get_tau(ptr noundef %27)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.dsssframesync_s, ptr %29, i32 0, i32 8
  store float %28, ptr %30, align 8, !tbaa !17
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.dsssframesync_s, ptr %31, i32 0, i32 7
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call float @qdetector_cccf_get_gamma(ptr noundef %33)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.dsssframesync_s, ptr %35, i32 0, i32 11
  store float %34, ptr %36, align 4, !tbaa !18
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.dsssframesync_s, ptr %37, i32 0, i32 7
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = call float @qdetector_cccf_get_dphi(ptr noundef %39)
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.dsssframesync_s, ptr %41, i32 0, i32 9
  store float %40, ptr %42, align 4, !tbaa !19
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.dsssframesync_s, ptr %43, i32 0, i32 7
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = call float @qdetector_cccf_get_phi(ptr noundef %45)
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.dsssframesync_s, ptr %47, i32 0, i32 10
  store float %46, ptr %48, align 8, !tbaa !20
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.dsssframesync_s, ptr %49, i32 0, i32 8
  %51 = load float, ptr %50, align 8, !tbaa !17
  %52 = fcmp ogt float %51, 0.000000e+00
  br i1 %52, label %53, label %71

53:                                               ; preds = %24
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.dsssframesync_s, ptr %54, i32 0, i32 8
  %56 = load float, ptr %55, align 8, !tbaa !17
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.dsssframesync_s, ptr %57, i32 0, i32 15
  %59 = load i32, ptr %58, align 8, !tbaa !21
  %60 = uitofp i32 %59 to float
  %61 = fmul float %56, %60
  %62 = fptoui float %61 to i32
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.dsssframesync_s, ptr %63, i32 0, i32 15
  %65 = load i32, ptr %64, align 8, !tbaa !21
  %66 = urem i32 %62, %65
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.dsssframesync_s, ptr %67, i32 0, i32 17
  store i32 %66, ptr %68, align 8, !tbaa !22
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.dsssframesync_s, ptr %69, i32 0, i32 16
  store i32 0, ptr %70, align 4, !tbaa !23
  br label %90

71:                                               ; preds = %24
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.dsssframesync_s, ptr %72, i32 0, i32 8
  %74 = load float, ptr %73, align 8, !tbaa !17
  %75 = fadd float 1.000000e+00, %74
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.dsssframesync_s, ptr %76, i32 0, i32 15
  %78 = load i32, ptr %77, align 8, !tbaa !21
  %79 = uitofp i32 %78 to float
  %80 = fmul float %75, %79
  %81 = fptoui float %80 to i32
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.dsssframesync_s, ptr %82, i32 0, i32 15
  %84 = load i32, ptr %83, align 8, !tbaa !21
  %85 = urem i32 %81, %84
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.dsssframesync_s, ptr %86, i32 0, i32 17
  store i32 %85, ptr %87, align 8, !tbaa !22
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.dsssframesync_s, ptr %88, i32 0, i32 16
  store i32 1, ptr %89, align 4, !tbaa !23
  br label %90

90:                                               ; preds = %71, %53
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.dsssframesync_s, ptr %91, i32 0, i32 14
  %93 = load ptr, ptr %92, align 8, !tbaa !24
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.dsssframesync_s, ptr %94, i32 0, i32 11
  %96 = load float, ptr %95, align 4, !tbaa !18
  %97 = fdiv float 5.000000e-01, %96
  %98 = call i32 @firpfb_crcf_set_scale(ptr noundef %93, float noundef %97)
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.dsssframesync_s, ptr %99, i32 0, i32 12
  %101 = load ptr, ptr %100, align 8, !tbaa !25
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.dsssframesync_s, ptr %102, i32 0, i32 9
  %104 = load float, ptr %103, align 4, !tbaa !19
  %105 = call i32 @nco_crcf_set_frequency(ptr noundef %101, float noundef %104)
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.dsssframesync_s, ptr %106, i32 0, i32 12
  %108 = load ptr, ptr %107, align 8, !tbaa !25
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.dsssframesync_s, ptr %109, i32 0, i32 10
  %111 = load float, ptr %110, align 8, !tbaa !20
  %112 = call i32 @nco_crcf_set_phase(ptr noundef %108, float noundef %111)
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.dsssframesync_s, ptr %113, i32 0, i32 40
  store i32 1, ptr %114, align 4, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.dsssframesync_s, ptr %115, i32 0, i32 7
  %117 = load ptr, ptr %116, align 8, !tbaa !9
  %118 = call i32 @qdetector_cccf_get_buf_len(ptr noundef %117)
  store i32 %118, ptr %9, align 4, !tbaa !27
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = load ptr, ptr %6, align 8, !tbaa !5
  %121 = load i32, ptr %9, align 4, !tbaa !27
  %122 = call i32 @dsssframesync_execute(ptr noundef %119, ptr noundef %120, i32 noundef %121)
  store i32 %122, ptr %3, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %123

123:                                              ; preds = %90, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %124 = load i32, ptr %3, align 4
  ret i32 %124
}

declare ptr @qdetector_cccf_execute(ptr noundef, <2 x float> noundef) #2

declare float @qdetector_cccf_get_tau(ptr noundef) #2

declare float @qdetector_cccf_get_gamma(ptr noundef) #2

declare float @qdetector_cccf_get_dphi(ptr noundef) #2

declare float @qdetector_cccf_get_phi(ptr noundef) #2

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

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

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

declare i32 @qdetector_cccf_get_buf_len(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 = !{!10, !6, i64 104}
!10 = !{!"dsssframesync_s", !6, i64 0, !6, i64 8, !11, i64 16, !14, i64 64, !13, i64 88, !13, i64 92, !12, i64 96, !6, i64 104, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !6, i64 128, !6, i64 136, !6, i64 144, !13, i64 152, !13, i64 156, !13, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !13, i64 200, !16, i64 204, !6, i64 224, !13, i64 232, !6, i64 240, !13, i64 248, !13, i64 252, !6, i64 256, !13, i64 264, !13, i64 268, !6, i64 272, !13, i64 280, !6, i64 288, !13, i64 296, !6, i64 304, !13, i64 312, !13, i64 316, !13, i64 320, !13, i64 324}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !6, i64 16, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44}
!12 = !{!"float", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !15, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!17 = !{!10, !12, i64 112}
!18 = !{!10, !12, i64 124}
!19 = !{!10, !12, i64 116}
!20 = !{!10, !12, i64 120}
!21 = !{!10, !13, i64 152}
!22 = !{!10, !13, i64 160}
!23 = !{!10, !13, i64 156}
!24 = !{!10, !6, i64 144}
!25 = !{!10, !6, i64 128}
!26 = !{!10, !13, i64 324}
!27 = !{!13, !13, i64 0}


; 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: nounwind uwtable
declare dso_local i32 @dsssframesync_execute(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @dsssframesync_execute_seekpn(ptr noundef %0, <2 x float> noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 104
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call ptr @qdetector_cccf_execute(ptr noundef %4, <2 x float> noundef %1) #2
  %6 = icmp eq ptr %5, null
  br i1 %6, label %47, label %7

7:                                                ; preds = %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = tail call float @qdetector_cccf_get_tau(ptr noundef %8) #2
  %10 = getelementptr inbounds i8, ptr %0, i64 112
  store float %9, ptr %10, align 8, !tbaa !16
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = tail call float @qdetector_cccf_get_gamma(ptr noundef %11) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 124
  store float %12, ptr %13, align 4, !tbaa !17
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = tail call float @qdetector_cccf_get_dphi(ptr noundef %14) #2
  %16 = getelementptr inbounds i8, ptr %0, i64 116
  store float %15, ptr %16, align 4, !tbaa !18
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = tail call float @qdetector_cccf_get_phi(ptr noundef %17) #2
  %19 = getelementptr inbounds i8, ptr %0, i64 120
  store float %18, ptr %19, align 8, !tbaa !19
  %20 = load float, ptr %10, align 8, !tbaa !16
  %21 = fcmp ule float %20, 0.000000e+00
  %22 = fadd float %20, 1.000000e+00
  %.sink40 = select i1 %21, float %22, float %20
  %.sink = zext i1 %21 to i32
  %23 = getelementptr inbounds i8, ptr %0, i64 152
  %24 = load i32, ptr %23, align 8, !tbaa !20
  %25 = uitofp i32 %24 to float
  %26 = fmul float %.sink40, %25
  %27 = fptoui float %26 to i32
  %28 = urem i32 %27, %24
  %29 = getelementptr inbounds i8, ptr %0, i64 160
  store i32 %28, ptr %29, align 8
  %30 = getelementptr inbounds i8, ptr %0, i64 156
  store i32 %.sink, ptr %30, align 4
  %31 = getelementptr inbounds i8, ptr %0, i64 144
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  %33 = load float, ptr %13, align 4, !tbaa !17
  %34 = fdiv float 5.000000e-01, %33
  %35 = tail call i32 @firpfb_crcf_set_scale(ptr noundef %32, float noundef %34) #2
  %36 = getelementptr inbounds i8, ptr %0, i64 128
  %37 = load ptr, ptr %36, align 8, !tbaa !22
  %38 = load float, ptr %16, align 4, !tbaa !18
  %39 = tail call i32 @nco_crcf_set_frequency(ptr noundef %37, float noundef %38) #2
  %40 = load ptr, ptr %36, align 8, !tbaa !22
  %41 = load float, ptr %19, align 8, !tbaa !19
  %42 = tail call i32 @nco_crcf_set_phase(ptr noundef %40, float noundef %41) #2
  %43 = getelementptr inbounds i8, ptr %0, i64 324
  store i32 1, ptr %43, align 4, !tbaa !23
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = tail call i32 @qdetector_cccf_get_buf_len(ptr noundef %44) #2
  %46 = tail call i32 @dsssframesync_execute(ptr noundef nonnull %0, ptr noundef nonnull %5, i32 noundef %45)
  br label %47

47:                                               ; preds = %2, %7
  %.0 = phi i32 [ %46, %7 ], [ 0, %2 ]
  ret i32 %.0
}

declare ptr @qdetector_cccf_execute(ptr noundef, <2 x float> noundef) local_unnamed_addr #1

declare float @qdetector_cccf_get_tau(ptr noundef) local_unnamed_addr #1

declare float @qdetector_cccf_get_gamma(ptr noundef) local_unnamed_addr #1

declare float @qdetector_cccf_get_dphi(ptr noundef) local_unnamed_addr #1

declare float @qdetector_cccf_get_phi(ptr noundef) local_unnamed_addr #1

declare i32 @firpfb_crcf_set_scale(ptr noundef, float noundef) local_unnamed_addr #1

declare i32 @nco_crcf_set_frequency(ptr noundef, float noundef) local_unnamed_addr #1

declare i32 @nco_crcf_set_phase(ptr noundef, float noundef) local_unnamed_addr #1

declare i32 @qdetector_cccf_get_buf_len(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 }

!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 104}
!6 = !{!"dsssframesync_s", !7, i64 0, !7, i64 8, !10, i64 16, !13, i64 64, !12, i64 88, !12, i64 92, !11, i64 96, !7, i64 104, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !7, i64 128, !7, i64 136, !7, i64 144, !12, i64 152, !12, i64 156, !12, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !12, i64 200, !15, i64 204, !7, i64 224, !12, i64 232, !7, i64 240, !12, i64 248, !12, i64 252, !7, i64 256, !12, i64 264, !12, i64 268, !7, i64 272, !12, i64 280, !7, i64 288, !12, i64 296, !7, i64 304, !12, i64 312, !12, i64 316, !12, i64 320, !12, i64 324}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44}
!11 = !{!"float", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !14, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!16 = !{!6, !11, i64 112}
!17 = !{!6, !11, i64 124}
!18 = !{!6, !11, i64 116}
!19 = !{!6, !11, i64 120}
!20 = !{!6, !12, i64 152}
!21 = !{!6, !7, i64 144}
!22 = !{!6, !7, i64 128}
!23 = !{!6, !12, i64 324}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass