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

; 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.flexframegen_s = type { i32, i32, float, ptr, [2 x { float, float }], %struct.flexframegenprops_s, %struct.flexframegenprops_s, ptr, ptr, i32, i32, ptr, i32, ptr, ptr, i32, ptr, i32, ptr, i32, ptr, i32, i32, i32, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [80 x i8], align 1
@flexframegenprops_header_default = external hidden global %struct.flexframegenprops_s, align 4
@.str.7 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [72 x i8], align 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) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @flexframegen_set_header_props(ptr noundef %0, ptr noundef %1) #1 {
  %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 %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.flexframegen_s, ptr %6, i32 0, i32 23
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %12

10:                                               ; preds = %2
  %11 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.1, i32 noundef 303, ptr noundef @.str.6)
  store i32 %11, ptr %3, align 4
  br label %56

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  store ptr @flexframegenprops_header_default, ptr %5, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %15, %12
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.flexframegenprops_s, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %26, label %21

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.flexframegenprops_s, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !14
  %25 = icmp uge i32 %24, 7
  br i1 %25, label %26, label %28

26:                                               ; preds = %21, %16
  %27 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef @.str.1, i32 noundef 310, ptr noundef @.str.7)
  store i32 %27, ptr %3, align 4
  br label %56

28:                                               ; preds = %21
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.flexframegenprops_s, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !15
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %38, label %33

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

38:                                               ; preds = %33, %28
  %39 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef @.str.1, i32 noundef 312, ptr noundef @.str.8)
  store i32 %39, ptr %3, align 4
  br label %56

40:                                               ; preds = %33
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.flexframegenprops_s, ptr %41, i32 0, i32 3
  %43 = load i32, ptr %42, align 4, !tbaa !17
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %47

45:                                               ; preds = %40
  %46 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef @.str.1, i32 noundef 314, ptr noundef @.str.9)
  store i32 %46, ptr %3, align 4
  br label %56

47:                                               ; preds = %40
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.flexframegen_s, ptr %48, i32 0, i32 6
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memmove.p0.p0.i64(ptr align 8 %49, ptr align 4 %50, i64 16, i1 false)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.flexframegen_s, ptr %52, i32 0, i32 9
  %54 = load i32, ptr %53, align 8, !tbaa !18
  %55 = call i32 @flexframegen_set_header_len(ptr noundef %51, i32 noundef %54)
  store i32 %55, ptr %3, align 4
  br label %56

56:                                               ; preds = %47, %45, %38, %26, %10
  %57 = load i32, ptr %3, align 4
  ret i32 %57
}

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

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

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

!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 184}
!10 = !{!"flexframegen_s", !11, i64 0, !11, i64 4, !12, i64 8, !6, i64 16, !7, i64 24, !13, i64 40, !13, i64 56, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !6, i64 96, !11, i64 104, !6, i64 112, !6, i64 120, !11, i64 128, !6, i64 136, !11, i64 144, !6, i64 152, !11, i64 160, !6, i64 168, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!14 = !{!13, !11, i64 0}
!15 = !{!13, !11, i64 4}
!16 = !{!13, !11, i64 8}
!17 = !{!13, !11, i64 12}
!18 = !{!10, !11, 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"

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

@.str.1 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [80 x i8], align 1
@flexframegenprops_header_default = external hidden local_unnamed_addr global %struct.flexframegenprops_s, align 4
@.str.7 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [72 x i8], align 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) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @flexframegen_set_header_props(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 184
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %7, label %5

5:                                                ; preds = %2
  %6 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.1, i32 noundef 303, ptr noundef nonnull @.str.6) #3
  br label %34

7:                                                ; preds = %2
  %8 = icmp eq ptr %1, null
  %spec.store.select = select i1 %8, ptr @flexframegenprops_header_default, ptr %1
  %9 = load i32, ptr %spec.store.select, align 4, !tbaa !13
  %10 = add i32 %9, -7
  %or.cond = icmp ult i32 %10, -6
  br i1 %or.cond, label %11, label %13

11:                                               ; preds = %7
  %12 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef nonnull @.str.1, i32 noundef 310, ptr noundef nonnull @.str.7) #3
  br label %34

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

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %spec.store.select, i64 8
  %19 = load i32, ptr %18, align 4, !tbaa !15
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %17, %13
  %22 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef nonnull @.str.1, i32 noundef 312, ptr noundef nonnull @.str.8) #3
  br label %34

23:                                               ; preds = %17
  %24 = getelementptr inbounds i8, ptr %spec.store.select, i64 12
  %25 = load i32, ptr %24, align 4, !tbaa !16
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef nonnull @.str.1, i32 noundef 314, ptr noundef nonnull @.str.9) #3
  br label %34

29:                                               ; preds = %23
  %30 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @llvm.memmove.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 4 dereferenceable(16) %spec.store.select, i64 16, i1 false)
  %31 = getelementptr inbounds i8, ptr %0, i64 88
  %32 = load i32, ptr %31, align 8, !tbaa !17
  %33 = tail call i32 @flexframegen_set_header_len(ptr noundef nonnull %0, i32 noundef %32)
  br label %34

34:                                               ; preds = %29, %27, %21, %11, %5
  %.0 = phi i32 [ %6, %5 ], [ %12, %11 ], [ %22, %21 ], [ %28, %27 ], [ %33, %29 ]
  ret i32 %.0
}

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

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

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 184}
!6 = !{!"flexframegen_s", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !8, i64 24, !12, i64 40, !12, i64 56, !11, i64 72, !11, i64 80, !7, i64 88, !7, i64 92, !11, i64 96, !7, i64 104, !11, i64 112, !11, i64 120, !7, i64 128, !11, i64 136, !7, i64 144, !11, i64 152, !7, i64 160, !11, i64 168, !7, i64 176, !7, i64 180, !7, i64 184, !7, i64 188, !7, i64 192}
!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 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!13 = !{!12, !7, i64 0}
!14 = !{!12, !7, i64 4}
!15 = !{!12, !7, i64 8}
!16 = !{!12, !7, i64 12}
!17 = !{!6, !7, i64 88}


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