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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @dsssframegen_set_header_len(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.dsssframegen_s, ptr %6, i32 0, i32 25
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %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, i32 noundef 227, ptr noundef @.str.5)
  store i32 %11, ptr %3, align 4
  br label %35

12:                                               ; preds = %2
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.dsssframegen_s, ptr %14, i32 0, i32 11
  store i32 %13, ptr %15, align 8, !tbaa !15
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.dsssframegen_s, ptr %16, i32 0, i32 11
  %18 = load i32, ptr %17, align 8, !tbaa !15
  %19 = add i32 5, %18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.dsssframegen_s, ptr %20, i32 0, i32 12
  store i32 %19, ptr %21, align 4, !tbaa !16
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.dsssframegen_s, ptr %22, i32 0, i32 10
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.dsssframegen_s, ptr %25, i32 0, i32 12
  %27 = load i32, ptr %26, align 4, !tbaa !16
  %28 = zext i32 %27 to i64
  %29 = mul i64 %28, 1
  %30 = call ptr @realloc(ptr noundef %24, i64 noundef %29) #3
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.dsssframegen_s, ptr %31, i32 0, i32 10
  store ptr %30, ptr %32, align 8, !tbaa !17
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i32 @dsssframegen_reconfigure_header(ptr noundef %33)
  store i32 %34, ptr %3, align 4
  br label %35

35:                                               ; preds = %12, %10
  %36 = load i32, ptr %3, align 4
  ret i32 %36
}

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

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #2

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

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 = { nounwind allocsize(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 #3 = { nounwind allocsize(1) }

!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 184}
!12 = !{!"dsssframegen_s", !10, i64 0, !10, i64 4, !13, i64 8, !6, i64 16, !7, i64 24, !14, i64 40, !14, i64 52, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !6, i64 104, !10, i64 112, !6, i64 120, !10, i64 128, !6, i64 136, !10, i64 144, !6, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !7, i64 176, !10, i64 184, !10, i64 188, !10, i64 192}
!13 = !{!"float", !7, i64 0}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!12, !10, i64 96}
!16 = !{!12, !10, i64 100}
!17 = !{!12, !6, 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"

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

; Function Attrs: nounwind uwtable
define dso_local i32 @dsssframegen_set_header_len(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %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, i32 noundef 227, ptr noundef nonnull @.str.5) #3
  br label %16

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %1, ptr %8, align 8, !tbaa !13
  %9 = add i32 %1, 5
  %10 = getelementptr inbounds i8, ptr %0, i64 100
  store i32 %9, ptr %10, align 4, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 88
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = zext i32 %9 to i64
  %14 = tail call ptr @realloc(ptr noundef %12, i64 noundef %13) #4
  store ptr %14, ptr %11, align 8, !tbaa !15
  %15 = tail call i32 @dsssframegen_reconfigure_header(ptr noundef nonnull %0)
  br label %16

16:                                               ; preds = %7, %5
  %.0 = phi i32 [ %6, %5 ], [ %15, %7 ]
  ret i32 %.0
}

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

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #2

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

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 nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #4 = { nounwind allocsize(1) }

!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 = !{!"dsssframegen_s", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !8, i64 24, !12, i64 40, !12, i64 52, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !7, i64 96, !7, i64 100, !11, i64 104, !7, i64 112, !11, i64 120, !7, i64 128, !11, i64 136, !7, i64 144, !11, i64 152, !7, i64 160, !7, i64 164, !7, i64 168, !7, i64 172, !8, i64 176, !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}
!13 = !{!6, !7, i64 96}
!14 = !{!6, !7, i64 100}
!15 = !{!6, !11, i64 88}


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