; 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
define dso_local i32 @dsssframesync_step(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #1 {
  %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 i32, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.dsssframesync_s, ptr %11, i32 0, i32 12
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %15 = load float, ptr %14, align 4
  %16 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %17 = load float, ptr %16, align 4
  %18 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %19 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %15, ptr %18, align 4
  store float %17, ptr %19, align 4
  %20 = load <2 x float>, ptr %8, align 4
  %21 = call i32 @nco_crcf_mix_down(ptr noundef %13, <2 x float> noundef %20, ptr noundef %7)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.dsssframesync_s, ptr %22, i32 0, i32 12
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = call i32 @nco_crcf_step(ptr noundef %24)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.dsssframesync_s, ptr %26, i32 0, i32 14
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %30 = load float, ptr %29, align 4
  %31 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %32 = load float, ptr %31, align 4
  %33 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %34 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %30, ptr %33, align 4
  store float %32, ptr %34, align 4
  %35 = load <2 x float>, ptr %9, align 4
  %36 = call i32 @firpfb_crcf_push(ptr noundef %28, <2 x float> noundef %35)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.dsssframesync_s, ptr %37, i32 0, i32 14
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.dsssframesync_s, ptr %40, i32 0, i32 17
  %42 = load i32, ptr %41, align 8, !tbaa !18
  %43 = call i32 @firpfb_crcf_execute(ptr noundef %39, i32 noundef %42, ptr noundef %7)
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.dsssframesync_s, ptr %44, i32 0, i32 16
  %46 = load i32, ptr %45, align 4, !tbaa !19
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %45, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.dsssframesync_s, ptr %48, i32 0, i32 16
  %50 = load i32, ptr %49, align 4, !tbaa !19
  %51 = icmp sge i32 %50, 1
  %52 = zext i1 %51 to i64
  %53 = select i1 %51, i32 1, i32 0
  store i32 %53, ptr %10, align 4, !tbaa !20
  %54 = load i32, ptr %10, align 4, !tbaa !20
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %71

56:                                               ; preds = %3
  %57 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %58 = load float, ptr %57, align 4
  %59 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %60 = load float, ptr %59, align 4
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds { float, float }, ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds { float, float }, ptr %61, i32 0, i32 1
  store float %58, ptr %62, align 4
  store float %60, ptr %63, align 4
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.dsssframesync_s, ptr %64, i32 0, i32 4
  %66 = load i32, ptr %65, align 8, !tbaa !21
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.dsssframesync_s, ptr %67, i32 0, i32 16
  %69 = load i32, ptr %68, align 4, !tbaa !19
  %70 = sub i32 %69, %66
  store i32 %70, ptr %68, align 4, !tbaa !19
  br label %71

71:                                               ; preds = %56, %3
  %72 = load i32, ptr %10, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 %72
}

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

declare i32 @nco_crcf_step(ptr noundef) #2

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

declare i32 @firpfb_crcf_execute(ptr noundef, i32 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 = !{!10, !6, i64 128}
!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, !6, i64 144}
!18 = !{!10, !13, i64 160}
!19 = !{!10, !13, i64 156}
!20 = !{!13, !13, i64 0}
!21 = !{!10, !13, i64 88}


; 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 range(i32 0, 2) i32 @dsssframesync_step(ptr nocapture noundef %0, <2 x float> noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca { float, float }, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 128
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = call i32 @nco_crcf_mix_down(ptr noundef %6, <2 x float> noundef %1, ptr noundef nonnull %4) #3
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = call i32 @nco_crcf_step(ptr noundef %8) #3
  %10 = getelementptr inbounds i8, ptr %0, i64 144
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %12 = load <2 x float>, ptr %4, align 8
  %13 = call i32 @firpfb_crcf_push(ptr noundef %11, <2 x float> noundef %12) #3
  %14 = load ptr, ptr %10, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %0, i64 160
  %16 = load i32, ptr %15, align 8, !tbaa !17
  %17 = call i32 @firpfb_crcf_execute(ptr noundef %14, i32 noundef %16, ptr noundef nonnull %4) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 156
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %18, align 4, !tbaa !18
  %21 = icmp sgt i32 %19, -1
  br i1 %21, label %22, label %28

22:                                               ; preds = %3
  %23 = load <2 x float>, ptr %4, align 8
  store <2 x float> %23, ptr %2, align 4
  %24 = getelementptr inbounds i8, ptr %0, i64 88
  %25 = load i32, ptr %24, align 8, !tbaa !19
  %26 = load i32, ptr %18, align 4, !tbaa !18
  %27 = sub i32 %26, %25
  store i32 %27, ptr %18, align 4, !tbaa !18
  br label %28

28:                                               ; preds = %22, %3
  %29 = zext i1 %21 to i32
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 %29
}

declare i32 @nco_crcf_mix_down(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #2

declare i32 @nco_crcf_step(ptr noundef) local_unnamed_addr #2

declare i32 @firpfb_crcf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #2

declare i32 @firpfb_crcf_execute(ptr noundef, i32 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 = !{!6, !7, i64 128}
!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, !7, i64 144}
!17 = !{!6, !12, i64 160}
!18 = !{!6, !12, i64 156}
!19 = !{!6, !12, i64 88}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass