; 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.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 }

; Function Attrs: nounwind uwtable
define dso_local i32 @dsssframesync_set_header_len(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.dsssframesync_s, ptr %6, i32 0, i32 27
  store i32 %5, ptr %7, align 8, !tbaa !11
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.dsssframesync_s, ptr %8, i32 0, i32 27
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = add i32 5, %10
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.dsssframesync_s, ptr %12, i32 0, i32 28
  store i32 %11, ptr %13, align 4, !tbaa !18
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.dsssframesync_s, ptr %14, i32 0, i32 29
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.dsssframesync_s, ptr %17, i32 0, i32 28
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = zext i32 %19 to i64
  %21 = mul i64 %20, 1
  %22 = call ptr @realloc(ptr noundef %16, i64 noundef %21) #3
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.dsssframesync_s, ptr %23, i32 0, i32 29
  store ptr %22, ptr %24, align 8, !tbaa !19
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.dsssframesync_s, ptr %25, i32 0, i32 26
  %27 = load ptr, ptr %26, align 8, !tbaa !20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.dsssframesync_s, ptr %28, i32 0, i32 28
  %30 = load i32, ptr %29, align 4, !tbaa !18
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.dsssframesync_s, ptr %31, i32 0, i32 23
  %33 = getelementptr inbounds %struct.flexframegenprops_s, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 4, !tbaa !21
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.dsssframesync_s, ptr %35, i32 0, i32 23
  %37 = getelementptr inbounds %struct.flexframegenprops_s, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !22
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.dsssframesync_s, ptr %39, i32 0, i32 23
  %41 = getelementptr inbounds %struct.flexframegenprops_s, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !23
  %43 = call i32 @qpacketmodem_configure(ptr noundef %27, i32 noundef %30, i32 noundef %34, i32 noundef %38, i32 noundef %42, i32 noundef 39)
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.dsssframesync_s, ptr %44, i32 0, i32 20
  %46 = load ptr, ptr %45, align 8, !tbaa !24
  %47 = call i32 @synth_crcf_get_length(ptr noundef %46)
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.dsssframesync_s, ptr %48, i32 0, i32 25
  store i32 %47, ptr %49, align 8, !tbaa !25
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.dsssframesync_s, ptr %50, i32 0, i32 24
  %52 = load ptr, ptr %51, align 8, !tbaa !26
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.dsssframesync_s, ptr %53, i32 0, i32 25
  %55 = load i32, ptr %54, align 8, !tbaa !25
  %56 = zext i32 %55 to i64
  %57 = mul i64 %56, 8
  %58 = call ptr @realloc(ptr noundef %52, i64 noundef %57) #3
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.dsssframesync_s, ptr %59, i32 0, i32 24
  store ptr %58, ptr %60, align 8, !tbaa !26
  ret i32 0
}

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

declare i32 @qpacketmodem_configure(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

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


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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @dsssframesync_set_header_len(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 248
  store i32 %1, ptr %3, align 8, !tbaa !5
  %4 = add i32 %1, 5
  %5 = getelementptr inbounds i8, ptr %0, i64 252
  store i32 %4, ptr %5, align 4, !tbaa !16
  %6 = getelementptr inbounds i8, ptr %0, i64 256
  %7 = load ptr, ptr %6, align 8, !tbaa !17
  %8 = zext i32 %4 to i64
  %9 = tail call ptr @realloc(ptr noundef %7, i64 noundef %8) #3
  store ptr %9, ptr %6, align 8, !tbaa !17
  %10 = getelementptr inbounds i8, ptr %0, i64 240
  %11 = load ptr, ptr %10, align 8, !tbaa !18
  %12 = load i32, ptr %5, align 4, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %0, i64 204
  %14 = load i32, ptr %13, align 4, !tbaa !19
  %15 = getelementptr inbounds i8, ptr %0, i64 208
  %16 = load i32, ptr %15, align 4, !tbaa !20
  %17 = getelementptr inbounds i8, ptr %0, i64 212
  %18 = load i32, ptr %17, align 4, !tbaa !21
  %19 = tail call i32 @qpacketmodem_configure(ptr noundef %11, i32 noundef %12, i32 noundef %14, i32 noundef %16, i32 noundef %18, i32 noundef 39) #4
  %20 = getelementptr inbounds i8, ptr %0, i64 184
  %21 = load ptr, ptr %20, align 8, !tbaa !22
  %22 = tail call i32 @synth_crcf_get_length(ptr noundef %21) #4
  %23 = getelementptr inbounds i8, ptr %0, i64 232
  store i32 %22, ptr %23, align 8, !tbaa !23
  %24 = getelementptr inbounds i8, ptr %0, i64 224
  %25 = load ptr, ptr %24, align 8, !tbaa !24
  %26 = zext i32 %22 to i64
  %27 = shl nuw nsw i64 %26, 3
  %28 = tail call ptr @realloc(ptr noundef %25, i64 noundef %27) #3
  store ptr %28, ptr %24, align 8, !tbaa !24
  ret i32 0
}

; 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 #1

declare i32 @qpacketmodem_configure(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @synth_crcf_get_length(ptr noundef) local_unnamed_addr #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 = { 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 #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 allocsize(1) }
attributes #4 = { 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, !12, i64 248}
!6 = !{!"dsssframesync_s", !7, i64 0, !7, i64 8, !10, i64 16, !13, i64 64, !12, i64 88, !12, i64 92, !11, i64 96, !7, i64 104, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !7, i64 128, !7, i64 136, !7, i64 144, !12, i64 152, !12, i64 156, !12, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !12, i64 200, !15, i64 204, !7, i64 224, !12, i64 232, !7, i64 240, !12, i64 248, !12, i64 252, !7, i64 256, !12, i64 264, !12, i64 268, !7, i64 272, !12, i64 280, !7, i64 288, !12, i64 296, !7, i64 304, !12, i64 312, !12, i64 316, !12, i64 320, !12, i64 324}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44}
!11 = !{!"float", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !14, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!16 = !{!6, !12, i64 252}
!17 = !{!6, !7, i64 256}
!18 = !{!6, !7, i64 240}
!19 = !{!6, !12, i64 204}
!20 = !{!6, !12, i64 208}
!21 = !{!6, !12, i64 212}
!22 = !{!6, !7, i64 184}
!23 = !{!6, !12, i64 232}
!24 = !{!6, !7, i64 224}


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