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

; 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.fskframesync_s = type { i32, i32, float, i32, ptr, ptr, ptr, ptr, ptr, %struct.framesyncstats_s, ptr, i32, i32, ptr, ptr, ptr, ptr, [3 x float], i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%struct.framesyncstats_s = type { float, float, float, ptr, i32, i32, i32, i32, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @fskframesync_execute(ptr noundef %0, <2 x float> noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca { float, float }, align 4
  %5 = alloca ptr, align 8
  %6 = alloca { float, float }, align 4
  %7 = alloca { float, float }, align 4
  %8 = alloca { float, float }, align 4
  %9 = alloca { float, float }, align 4
  store <2 x float> %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.fskframesync_s, ptr %10, i32 0, i32 37
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %26

14:                                               ; preds = %2
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.fskframesync_s, ptr %15, i32 0, i32 39
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %19 = load float, ptr %18, align 4
  %20 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %21 = load float, ptr %20, align 4
  %22 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %23 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float %19, ptr %22, align 4
  store float %21, ptr %23, align 4
  %24 = load <2 x float>, ptr %6, align 4
  %25 = call i32 @windowcf_push(ptr noundef %17, <2 x float> noundef %24)
  br label %26

26:                                               ; preds = %14, %2
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.fskframesync_s, ptr %27, i32 0, i32 31
  %29 = load i32, ptr %28, align 8, !tbaa !15
  switch i32 %29, label %60 [
    i32 0, label %30
    i32 1, label %40
    i32 2, label %50
  ]

30:                                               ; preds = %26
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %33 = load float, ptr %32, align 4
  %34 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %35 = load float, ptr %34, align 4
  %36 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %37 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %33, ptr %36, align 4
  store float %35, ptr %37, align 4
  %38 = load <2 x float>, ptr %7, align 4
  %39 = call i32 @fskframesync_execute_detectframe(ptr noundef %31, <2 x float> noundef %38)
  store i32 %39, ptr %3, align 4
  br label %63

40:                                               ; preds = %26
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %43 = load float, ptr %42, align 4
  %44 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %45 = load float, ptr %44, align 4
  %46 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %47 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %43, ptr %46, align 4
  store float %45, ptr %47, align 4
  %48 = load <2 x float>, ptr %8, align 4
  %49 = call i32 @fskframesync_execute_rxheader(ptr noundef %41, <2 x float> noundef %48)
  store i32 %49, ptr %3, align 4
  br label %63

50:                                               ; preds = %26
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %53 = load float, ptr %52, align 4
  %54 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %55 = load float, ptr %54, align 4
  %56 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %57 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %53, ptr %56, align 4
  store float %55, ptr %57, align 4
  %58 = load <2 x float>, ptr %9, align 4
  %59 = call i32 @fskframesync_execute_rxpayload(ptr noundef %51, <2 x float> noundef %58)
  store i32 %59, ptr %3, align 4
  br label %63

60:                                               ; preds = %26
  br label %61

61:                                               ; preds = %60
  %62 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str.1, i32 noundef 376, ptr noundef @.str.2)
  store i32 %62, ptr %3, align 4
  br label %63

63:                                               ; preds = %61, %50, %40, %30
  %64 = load i32, ptr %3, align 4
  ret i32 %64
}

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

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

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

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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #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" }

!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 272}
!10 = !{!"fskframesync_s", !11, i64 0, !11, i64 4, !12, i64 8, !11, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !6, i64 104, !11, i64 112, !11, i64 116, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !7, i64 152, !11, i64 164, !11, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !11, i64 200, !11, i64 204, !11, i64 208, !11, i64 212, !11, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !11, i64 248, !11, i64 252, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !6, i64 280}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!14 = !{!10, !6, i64 280}
!15 = !{!10, !11, i64 248}


; 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"

@.str.1 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @fskframesync_execute(ptr noundef %0, <2 x float> noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 272
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %9, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 280
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  %8 = tail call i32 @windowcf_push(ptr noundef %7, <2 x float> noundef %1) #2
  br label %9

9:                                                ; preds = %5, %2
  %10 = getelementptr inbounds i8, ptr %0, i64 248
  %11 = load i32, ptr %10, align 8, !tbaa !14
  switch i32 %11, label %18 [
    i32 0, label %12
    i32 1, label %14
    i32 2, label %16
  ]

12:                                               ; preds = %9
  %13 = tail call i32 @fskframesync_execute_detectframe(ptr noundef nonnull %0, <2 x float> noundef %1)
  br label %20

14:                                               ; preds = %9
  %15 = tail call i32 @fskframesync_execute_rxheader(ptr noundef nonnull %0, <2 x float> noundef %1)
  br label %20

16:                                               ; preds = %9
  %17 = tail call i32 @fskframesync_execute_rxpayload(ptr noundef nonnull %0, <2 x float> noundef %1)
  br label %20

18:                                               ; preds = %9
  %19 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef nonnull @.str.1, i32 noundef 376, ptr noundef nonnull @.str.2) #2
  br label %20

20:                                               ; preds = %18, %16, %14, %12
  %.0 = phi i32 [ %19, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ]
  ret i32 %.0
}

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

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

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

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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, 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 272}
!6 = !{!"fskframesync_s", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !12, i64 56, !11, i64 104, !7, i64 112, !7, i64 116, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !8, i64 152, !7, i64 164, !7, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !7, i64 200, !7, i64 204, !7, i64 208, !7, i64 212, !7, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !7, i64 248, !7, i64 252, !7, i64 256, !7, i64 260, !7, i64 264, !7, i64 268, !7, i64 272, !7, i64 276, !11, i64 280}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !11, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44}
!13 = !{!6, !11, i64 280}
!14 = !{!6, !7, i64 248}


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