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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @dsssframegen_assemble(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call i32 @dsssframegen_reset(ptr noundef %10)
  %12 = load i32, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.dsssframegen_s, ptr %13, i32 0, i32 16
  store i32 %12, ptr %14, align 8, !tbaa !11
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %26

17:                                               ; preds = %4
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.dsssframegen_s, ptr %18, i32 0, i32 10
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.dsssframegen_s, ptr %21, i32 0, i32 11
  %23 = load i32, ptr %22, align 8, !tbaa !16
  %24 = zext i32 %23 to i64
  %25 = mul i64 %24, 1
  call void @llvm.memset.p0.i64(ptr align 1 %20, i8 0, i64 %25, i1 false)
  br label %36

26:                                               ; preds = %4
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.dsssframegen_s, ptr %27, i32 0, i32 10
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.dsssframegen_s, ptr %31, i32 0, i32 11
  %33 = load i32, ptr %32, align 8, !tbaa !16
  %34 = zext i32 %33 to i64
  %35 = mul i64 %34, 1
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %29, ptr align 1 %30, i64 %35, i1 false)
  br label %36

36:                                               ; preds = %26, %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.dsssframegen_s, ptr %37, i32 0, i32 11
  %39 = load i32, ptr %38, align 8, !tbaa !16
  store i32 %39, ptr %9, align 4, !tbaa !9
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.dsssframegen_s, ptr %40, i32 0, i32 10
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = add i32 %43, 0
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %42, i64 %45
  store i8 102, ptr %46, align 1, !tbaa !17
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.dsssframegen_s, ptr %47, i32 0, i32 16
  %49 = load i32, ptr %48, align 8, !tbaa !11
  %50 = lshr i32 %49, 8
  %51 = and i32 %50, 255
  %52 = trunc i32 %51 to i8
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.dsssframegen_s, ptr %53, i32 0, i32 10
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = add i32 %56, 1
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %55, i64 %58
  store i8 %52, ptr %59, align 1, !tbaa !17
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.dsssframegen_s, ptr %60, i32 0, i32 16
  %62 = load i32, ptr %61, align 8, !tbaa !11
  %63 = and i32 %62, 255
  %64 = trunc i32 %63 to i8
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.dsssframegen_s, ptr %65, i32 0, i32 10
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = add i32 %68, 2
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds i8, ptr %67, i64 %70
  store i8 %64, ptr %71, align 1, !tbaa !17
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.dsssframegen_s, ptr %72, i32 0, i32 5
  %74 = getelementptr inbounds %struct.dsssframegenprops_s, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %74, align 8, !tbaa !18
  %76 = and i32 %75, 7
  %77 = shl i32 %76, 5
  %78 = trunc i32 %77 to i8
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.dsssframegen_s, ptr %79, i32 0, i32 10
  %81 = load ptr, ptr %80, align 8, !tbaa !15
  %82 = load i32, ptr %9, align 4, !tbaa !9
  %83 = add i32 %82, 3
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds i8, ptr %81, i64 %84
  store i8 %78, ptr %85, align 1, !tbaa !17
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.dsssframegen_s, ptr %86, i32 0, i32 5
  %88 = getelementptr inbounds %struct.dsssframegenprops_s, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !19
  %90 = and i32 %89, 31
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.dsssframegen_s, ptr %91, i32 0, i32 10
  %93 = load ptr, ptr %92, align 8, !tbaa !15
  %94 = load i32, ptr %9, align 4, !tbaa !9
  %95 = add i32 %94, 3
  %96 = zext i32 %95 to i64
  %97 = getelementptr inbounds i8, ptr %93, i64 %96
  %98 = load i8, ptr %97, align 1, !tbaa !17
  %99 = zext i8 %98 to i32
  %100 = or i32 %99, %90
  %101 = trunc i32 %100 to i8
  store i8 %101, ptr %97, align 1, !tbaa !17
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.dsssframegen_s, ptr %102, i32 0, i32 5
  %104 = getelementptr inbounds %struct.dsssframegenprops_s, ptr %103, i32 0, i32 2
  %105 = load i32, ptr %104, align 8, !tbaa !20
  %106 = and i32 %105, 31
  %107 = trunc i32 %106 to i8
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.dsssframegen_s, ptr %108, i32 0, i32 10
  %110 = load ptr, ptr %109, align 8, !tbaa !15
  %111 = load i32, ptr %9, align 4, !tbaa !9
  %112 = add i32 %111, 4
  %113 = zext i32 %112 to i64
  %114 = getelementptr inbounds i8, ptr %110, i64 %113
  store i8 %107, ptr %114, align 1, !tbaa !17
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.dsssframegen_s, ptr %115, i32 0, i32 13
  %117 = load ptr, ptr %116, align 8, !tbaa !21
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.dsssframegen_s, ptr %118, i32 0, i32 10
  %120 = load ptr, ptr %119, align 8, !tbaa !15
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.dsssframegen_s, ptr %121, i32 0, i32 15
  %123 = load ptr, ptr %122, align 8, !tbaa !22
  %124 = call i32 @qpacketmodem_encode(ptr noundef %117, ptr noundef %120, ptr noundef %123)
  %125 = load i32, ptr %8, align 4, !tbaa !9
  %126 = load ptr, ptr %5, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.dsssframegen_s, ptr %126, i32 0, i32 16
  store i32 %125, ptr %127, align 8, !tbaa !11
  %128 = load ptr, ptr %5, align 8, !tbaa !5
  %129 = call i32 @dsssframegen_reconfigure(ptr noundef %128)
  %130 = load ptr, ptr %5, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.dsssframegen_s, ptr %130, i32 0, i32 17
  %132 = load ptr, ptr %131, align 8, !tbaa !23
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.dsssframegen_s, ptr %134, i32 0, i32 19
  %136 = load ptr, ptr %135, align 8, !tbaa !24
  %137 = call i32 @qpacketmodem_encode(ptr noundef %132, ptr noundef %133, ptr noundef %136)
  %138 = load ptr, ptr %5, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.dsssframegen_s, ptr %138, i32 0, i32 25
  store i32 1, ptr %139, align 8, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare i32 @qpacketmodem_encode(ptr noundef, ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 #5 = { 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, !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 128}
!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, !6, i64 88}
!16 = !{!12, !10, i64 96}
!17 = !{!7, !7, i64 0}
!18 = !{!12, !10, i64 40}
!19 = !{!12, !10, i64 44}
!20 = !{!12, !10, i64 48}
!21 = !{!12, !6, i64 104}
!22 = !{!12, !6, i64 120}
!23 = !{!12, !6, i64 136}
!24 = !{!12, !6, i64 152}
!25 = !{!12, !10, i64 184}


; 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
declare dso_local i32 @dsssframegen_reset(ptr 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) #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @dsssframegen_assemble(ptr noundef %0, ptr noundef readonly %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call i32 @dsssframegen_reset(ptr noundef %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 128
  store i32 %3, ptr %6, align 8, !tbaa !5
  %7 = icmp eq ptr %1, null
  %8 = getelementptr inbounds i8, ptr %0, i64 88
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 96
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = zext i32 %11 to i64
  br i1 %7, label %13, label %14

13:                                               ; preds = %4
  tail call void @llvm.memset.p0.i64(ptr align 1 %9, i8 0, i64 %12, i1 false)
  br label %15

14:                                               ; preds = %4
  tail call void @llvm.memmove.p0.p0.i64(ptr align 1 %9, ptr nonnull align 1 %1, i64 %12, i1 false)
  br label %15

15:                                               ; preds = %14, %13
  %16 = getelementptr inbounds i8, ptr %0, i64 96
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %0, i64 88
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = zext i32 %17 to i64
  %21 = getelementptr inbounds i8, ptr %19, i64 %20
  store i8 102, ptr %21, align 1, !tbaa !15
  %22 = load i32, ptr %6, align 8, !tbaa !5
  %23 = lshr i32 %22, 8
  %24 = trunc i32 %23 to i8
  %25 = load ptr, ptr %18, align 8, !tbaa !13
  %26 = add i32 %17, 1
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %25, i64 %27
  store i8 %24, ptr %28, align 1, !tbaa !15
  %29 = load i32, ptr %6, align 8, !tbaa !5
  %30 = trunc i32 %29 to i8
  %31 = load ptr, ptr %18, align 8, !tbaa !13
  %32 = add i32 %17, 2
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %31, i64 %33
  store i8 %30, ptr %34, align 1, !tbaa !15
  %35 = getelementptr inbounds i8, ptr %0, i64 40
  %36 = load i32, ptr %35, align 8, !tbaa !16
  %.tr = trunc i32 %36 to i8
  %37 = shl i8 %.tr, 5
  %38 = load ptr, ptr %18, align 8, !tbaa !13
  %39 = add i32 %17, 3
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %38, i64 %40
  store i8 %37, ptr %41, align 1, !tbaa !15
  %42 = getelementptr inbounds i8, ptr %0, i64 44
  %43 = load i32, ptr %42, align 4, !tbaa !17
  %44 = load ptr, ptr %18, align 8, !tbaa !13
  %45 = getelementptr inbounds i8, ptr %44, i64 %40
  %46 = load i8, ptr %45, align 1, !tbaa !15
  %47 = trunc i32 %43 to i8
  %48 = and i8 %47, 31
  %49 = or i8 %48, %46
  store i8 %49, ptr %45, align 1, !tbaa !15
  %50 = getelementptr inbounds i8, ptr %0, i64 48
  %51 = load i32, ptr %50, align 8, !tbaa !18
  %52 = trunc i32 %51 to i8
  %53 = and i8 %52, 31
  %54 = load ptr, ptr %18, align 8, !tbaa !13
  %55 = add i32 %17, 4
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  store i8 %53, ptr %57, align 1, !tbaa !15
  %58 = getelementptr inbounds i8, ptr %0, i64 104
  %59 = load ptr, ptr %58, align 8, !tbaa !19
  %60 = load ptr, ptr %18, align 8, !tbaa !13
  %61 = getelementptr inbounds i8, ptr %0, i64 120
  %62 = load ptr, ptr %61, align 8, !tbaa !20
  %63 = tail call i32 @qpacketmodem_encode(ptr noundef %59, ptr noundef %60, ptr noundef %62) #4
  store i32 %3, ptr %6, align 8, !tbaa !5
  %64 = tail call i32 @dsssframegen_reconfigure(ptr noundef nonnull %0)
  %65 = getelementptr inbounds i8, ptr %0, i64 136
  %66 = load ptr, ptr %65, align 8, !tbaa !21
  %67 = getelementptr inbounds i8, ptr %0, i64 152
  %68 = load ptr, ptr %67, align 8, !tbaa !22
  %69 = tail call i32 @qpacketmodem_encode(ptr noundef %66, ptr noundef %2, ptr noundef %68) #4
  %70 = getelementptr inbounds i8, ptr %0, i64 184
  store i32 1, ptr %70, align 8, !tbaa !23
  ret i32 0
}

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

declare i32 @qpacketmodem_encode(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 #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, !7, i64 128}
!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, !11, i64 88}
!14 = !{!6, !7, i64 96}
!15 = !{!8, !8, i64 0}
!16 = !{!6, !7, i64 40}
!17 = !{!6, !7, i64 44}
!18 = !{!6, !7, i64 48}
!19 = !{!6, !11, i64 104}
!20 = !{!6, !11, i64 120}
!21 = !{!6, !11, i64 136}
!22 = !{!6, !11, i64 152}
!23 = !{!6, !7, i64 184}


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