; 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_execute_rxpreamble(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 { float, float }, align 4
  %7 = alloca i32, align 4
  %8 = alloca { float, float }, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = 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) #2
  %12 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %13 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float 0.000000e+00, ptr %12, align 4
  store float 0.000000e+00, ptr %13, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %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 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %20 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %16, ptr %19, align 4
  store float %18, ptr %20, align 4
  %21 = load <2 x float>, ptr %8, align 4
  %22 = call i32 @dsssframesync_step(ptr noundef %14, <2 x float> noundef %21, ptr noundef %6)
  store i32 %22, ptr %7, align 4, !tbaa !9
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %72

26:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.dsssframesync_s, ptr %27, i32 0, i32 4
  %29 = load i32, ptr %28, align 8, !tbaa !11
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.dsssframesync_s, ptr %30, i32 0, i32 5
  %32 = load i32, ptr %31, align 4, !tbaa !18
  %33 = mul i32 %29, %32
  store i32 %33, ptr %10, align 4, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.dsssframesync_s, ptr %34, i32 0, i32 38
  %36 = load i32, ptr %35, align 4, !tbaa !19
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = icmp uge i32 %36, %37
  br i1 %38, label %39, label %57

39:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.dsssframesync_s, ptr %40, i32 0, i32 38
  %42 = load i32, ptr %41, align 4, !tbaa !19
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = sub i32 %42, %43
  store i32 %44, ptr %11, align 4, !tbaa !9
  %45 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %46 = load float, ptr %45, align 4
  %47 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  %48 = load float, ptr %47, align 4
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.dsssframesync_s, ptr %49, i32 0, i32 19
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds { float, float }, ptr %51, i64 %53
  %55 = getelementptr inbounds { float, float }, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds { float, float }, ptr %54, i32 0, i32 1
  store float %46, ptr %55, align 4
  store float %48, ptr %56, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %57

57:                                               ; preds = %39, %26
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.dsssframesync_s, ptr %58, i32 0, i32 38
  %60 = load i32, ptr %59, align 4, !tbaa !19
  %61 = add i32 %60, 1
  store i32 %61, ptr %59, align 4, !tbaa !19
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.dsssframesync_s, ptr %62, i32 0, i32 38
  %64 = load i32, ptr %63, align 4, !tbaa !19
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = add i32 64, %65
  %67 = icmp eq i32 %64, %66
  br i1 %67, label %68, label %71

68:                                               ; preds = %57
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.dsssframesync_s, ptr %69, i32 0, i32 40
  store i32 2, ptr %70, align 4, !tbaa !21
  br label %71

71:                                               ; preds = %68, %57
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %72

72:                                               ; preds = %71, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %73 = load i32, ptr %3, align 4
  ret i32 %73
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @dsssframesync_step(ptr noundef, <2 x float> noundef, ptr noundef) #1

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 }

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


; 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 noundef i32 @dsssframesync_execute_rxpreamble(ptr noundef %0, <2 x float> noundef %1) local_unnamed_addr #1 {
  %3 = alloca { float, float }, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  store <2 x float> zeroinitializer, ptr %3, align 8
  %4 = call i32 @dsssframesync_step(ptr noundef %0, <2 x float> noundef %1, ptr noundef nonnull %3)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %27, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 92
  %9 = load i32, ptr %8, align 4, !tbaa !16
  %10 = mul i32 %9, %7
  %11 = getelementptr inbounds i8, ptr %0, i64 316
  %12 = load i32, ptr %11, align 4, !tbaa !17
  %.not17 = icmp ult i32 %12, %10
  br i1 %.not17, label %20, label %13

13:                                               ; preds = %5
  %14 = sub i32 %12, %10
  %15 = getelementptr inbounds i8, ptr %0, i64 176
  %16 = load ptr, ptr %15, align 8, !tbaa !18
  %17 = zext i32 %14 to i64
  %18 = getelementptr inbounds { float, float }, ptr %16, i64 %17
  %19 = load <2 x float>, ptr %3, align 8
  store <2 x float> %19, ptr %18, align 4
  %.pre = load i32, ptr %11, align 4, !tbaa !17
  br label %20

20:                                               ; preds = %13, %5
  %21 = phi i32 [ %.pre, %13 ], [ %12, %5 ]
  %22 = add i32 %21, 1
  store i32 %22, ptr %11, align 4, !tbaa !17
  %23 = add i32 %10, 63
  %24 = icmp eq i32 %21, %23
  br i1 %24, label %25, label %27

25:                                               ; preds = %20
  %26 = getelementptr inbounds i8, ptr %0, i64 324
  store i32 2, ptr %26, align 4, !tbaa !19
  br label %27

27:                                               ; preds = %20, %25, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @dsssframesync_step(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #1

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 = { 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, !12, i64 88}
!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, !12, i64 92}
!17 = !{!6, !12, i64 316}
!18 = !{!6, !7, i64 176}
!19 = !{!6, !12, i64 324}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass