; 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.dsssframegenprops_s = type { i32, i32, i32 }
%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 }

@.str = external hidden unnamed_addr constant [86 x i8], align 1
@dsssframesyncprops_header_default = external hidden global %struct.dsssframegenprops_s, align 4
@.str.3 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [65 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @dsssframesync_set_header_props(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  store ptr @dsssframesyncprops_header_default, ptr %5, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %8, %2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.dsssframegenprops_s, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %19, label %14

14:                                               ; preds = %9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.dsssframegenprops_s, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = icmp uge i32 %17, 7
  br i1 %18, label %19, label %21

19:                                               ; preds = %14, %9
  %20 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef @.str, i32 noundef 256, ptr noundef @.str.3)
  store i32 %20, ptr %3, align 4
  br label %42

21:                                               ; preds = %14
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.dsssframegenprops_s, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !12
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %31, label %26

26:                                               ; preds = %21
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.dsssframegenprops_s, ptr %27, i32 0, i32 2
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %26, %21
  %32 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef @.str, i32 noundef 258, ptr noundef @.str.4)
  store i32 %32, ptr %3, align 4
  br label %42

33:                                               ; preds = %26
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.dsssframesync_s, ptr %34, i32 0, i32 23
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %35, ptr align 4 %36, i64 12, i1 false)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.dsssframesync_s, ptr %38, i32 0, i32 27
  %40 = load i32, ptr %39, align 8, !tbaa !14
  %41 = call i32 @dsssframesync_set_header_len(ptr noundef %37, i32 noundef %40)
  store i32 %41, ptr %3, align 4
  br label %42

42:                                               ; preds = %33, %31, %19
  %43 = load i32, ptr %3, align 4
  ret i32 %43
}

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @dsssframesync_set_header_len(ptr noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }

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


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

%struct.dsssframegenprops_s = type { i32, i32, i32 }

@.str = external hidden unnamed_addr constant [86 x i8], align 1
@dsssframesyncprops_header_default = external hidden local_unnamed_addr global %struct.dsssframegenprops_s, align 4
@.str.3 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [65 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @dsssframesync_set_header_props(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %1, null
  %spec.store.select = select i1 %3, ptr @dsssframesyncprops_header_default, ptr %1
  %4 = load i32, ptr %spec.store.select, align 4, !tbaa !5
  %5 = add i32 %4, -7
  %or.cond = icmp ult i32 %5, -6
  br i1 %or.cond, label %6, label %8

6:                                                ; preds = %2
  %7 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef nonnull @.str, i32 noundef 256, ptr noundef nonnull @.str.3) #3
  br label %23

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %spec.store.select, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !10
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %16, label %12

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %spec.store.select, i64 8
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %12, %8
  %17 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef nonnull @.str, i32 noundef 258, ptr noundef nonnull @.str.4) #3
  br label %23

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 204
  tail call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %19, ptr noundef nonnull align 4 dereferenceable(12) %spec.store.select, i64 12, i1 false)
  %20 = getelementptr inbounds i8, ptr %0, i64 248
  %21 = load i32, ptr %20, align 8, !tbaa !12
  %22 = tail call i32 @dsssframesync_set_header_len(ptr noundef %0, i32 noundef %21)
  br label %23

23:                                               ; preds = %18, %16, %6
  %.0 = phi i32 [ %7, %6 ], [ %17, %16 ], [ %22, %18 ]
  ret i32 %.0
}

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @dsssframesync_set_header_len(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

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


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