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

; 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.flexframegenprops_s = type { i32, i32, i32, i32 }
%struct.flexframesync_s = type { ptr, ptr, %struct.framesyncstats_s, %struct.framedatastats_s, i32, float, ptr, float, float, float, float, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i32, ptr, i32, ptr, ptr, i32, ptr, i32, i32, ptr, i32, %struct.flexframegenprops_s, i32, ptr, ptr, i32, 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 }
%struct.framedatastats_s = type { i32, i32, i32, i64 }

@flexframesyncprops_header_default = external hidden global %struct.flexframegenprops_s, align 4
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @flexframesync_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 @flexframesyncprops_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.flexframegenprops_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.flexframegenprops_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 3, ptr noundef @.str.1, i32 noundef 367, ptr noundef @.str.2)
  store i32 %20, ptr %3, align 4
  br label %49

21:                                               ; preds = %14
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.flexframegenprops_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.flexframegenprops_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 3, ptr noundef @.str.1, i32 noundef 369, ptr noundef @.str.3)
  store i32 %32, ptr %3, align 4
  br label %49

33:                                               ; preds = %26
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.flexframegenprops_s, ptr %34, i32 0, i32 3
  %36 = load i32, ptr %35, align 4, !tbaa !14
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %33
  %39 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.1, i32 noundef 371, ptr noundef @.str.4)
  store i32 %39, ptr %3, align 4
  br label %49

40:                                               ; preds = %33
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.flexframesync_s, ptr %41, i32 0, i32 30
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %42, ptr align 4 %43, i64 16, i1 false)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.flexframesync_s, ptr %45, i32 0, i32 26
  %47 = load i32, ptr %46, align 8, !tbaa !15
  %48 = call i32 @flexframesync_set_header_len(ptr noundef %44, i32 noundef %47)
  store i32 %48, ptr %3, align 4
  br label %49

49:                                               ; preds = %40, %38, %31, %19
  %50 = load i32, ptr %3, align 4
  ret i32 %50
}

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

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

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

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

@flexframesyncprops_header_default = external hidden local_unnamed_addr global %struct.flexframegenprops_s, align 4
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @flexframesync_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 @flexframesyncprops_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 3, ptr noundef nonnull @.str.1, i32 noundef 367, ptr noundef nonnull @.str.2) #3
  br label %29

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 3, ptr noundef nonnull @.str.1, i32 noundef 369, ptr noundef nonnull @.str.3) #3
  br label %29

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %spec.store.select, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %18
  %23 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.1, i32 noundef 371, ptr noundef nonnull @.str.4) #3
  br label %29

24:                                               ; preds = %18
  %25 = getelementptr inbounds i8, ptr %0, i64 252
  tail call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %25, ptr noundef nonnull align 4 dereferenceable(16) %spec.store.select, i64 16, i1 false)
  %26 = getelementptr inbounds i8, ptr %0, i64 232
  %27 = load i32, ptr %26, align 8, !tbaa !13
  %28 = tail call i32 @flexframesync_set_header_len(ptr noundef %0, i32 noundef %27)
  br label %29

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

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

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

; 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, i64 12}
!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 = !{!6, !7, i64 12}
!13 = !{!14, !7, i64 232}
!14 = !{!"flexframesync_s", !15, i64 0, !15, i64 8, !16, i64 16, !18, i64 64, !7, i64 88, !17, i64 92, !15, i64 96, !17, i64 104, !17, i64 108, !17, i64 112, !17, i64 116, !15, i64 120, !15, i64 128, !15, i64 136, !7, i64 144, !7, i64 148, !7, i64 152, !15, i64 160, !15, i64 168, !7, i64 176, !15, i64 184, !7, i64 192, !15, i64 200, !15, i64 208, !7, i64 216, !15, i64 224, !7, i64 232, !7, i64 236, !15, i64 240, !7, i64 248, !6, i64 252, !7, i64 268, !15, i64 272, !15, i64 280, !7, i64 288, !15, i64 296, !15, i64 304, !7, i64 312, !7, i64 316, !7, i64 320, !7, i64 324, !7, i64 328, !7, i64 332, !7, i64 336, !7, i64 340, !15, i64 344}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"", !17, i64 0, !17, i64 4, !17, i64 8, !15, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44}
!17 = !{!"float", !8, i64 0}
!18 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !19, i64 16}
!19 = !{!"long", !8, i64 0}


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