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

; 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.modulation_type_s = type { ptr, ptr, i32, i32 }
%struct.ofdmflexframegen_s = type { i32, i32, i32, ptr, i32, i32, i32, i32, i32, i32, ptr, ptr, i32, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, ptr, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, %struct.ofdmflexframegenprops_s, %struct.ofdmflexframegenprops_s }
%struct.ofdmflexframegenprops_s = type { i32, i32, i32, i32 }

@modulation_types = external constant [53 x %struct.modulation_type_s], align 16

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ofdmflexframegen_reset(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ofdmflexframegen_reconfigure(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @ofdmflexframegen_assemble(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #2 {
  %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
  %10 = 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
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call i32 @ofdmflexframegen_reset(ptr noundef %11)
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %14, i32 0, i32 26
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp ne i32 %13, %16
  br i1 %17, label %18, label %24

18:                                               ; preds = %4
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %20, i32 0, i32 26
  store i32 %19, ptr %21, align 8, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call i32 @ofdmflexframegen_reconfigure(ptr noundef %22)
  br label %24

24:                                               ; preds = %18, %4
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %25, i32 0, i32 34
  store i32 1, ptr %26, align 8, !tbaa !14
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %38

29:                                               ; preds = %24
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %30, i32 0, i32 18
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %33, i32 0, i32 21
  %35 = load i32, ptr %34, align 8, !tbaa !16
  %36 = zext i32 %35 to i64
  %37 = mul i64 %36, 1
  call void @llvm.memset.p0.i64(ptr align 1 %32, i8 0, i64 %37, i1 false)
  br label %48

38:                                               ; preds = %24
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %39, i32 0, i32 18
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %43, i32 0, i32 21
  %45 = load i32, ptr %44, align 8, !tbaa !16
  %46 = zext i32 %45 to i64
  %47 = mul i64 %46, 1
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %41, ptr align 1 %42, i64 %47, i1 false)
  br label %48

48:                                               ; preds = %38, %29
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = call i32 @ofdmflexframegen_encode_header(ptr noundef %49)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call i32 @ofdmflexframegen_modulate_header(ptr noundef %51)
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %53, i32 0, i32 25
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %57, i32 0, i32 28
  %59 = load ptr, ptr %58, align 8, !tbaa !18
  %60 = call i32 @packetizer_encode(ptr noundef %55, ptr noundef %56, ptr noundef %59)
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %61, i32 0, i32 29
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %64, i32 0, i32 31
  %66 = load i32, ptr %65, align 4, !tbaa !20
  %67 = zext i32 %66 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %63, i8 0, i64 %67, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %68, i32 0, i32 38
  %70 = getelementptr inbounds %struct.ofdmflexframegenprops_s, ptr %69, i32 0, i32 3
  %71 = load i32, ptr %70, align 4, !tbaa !21
  %72 = zext i32 %71 to i64
  %73 = getelementptr inbounds [53 x %struct.modulation_type_s], ptr @modulation_types, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.modulation_type_s, ptr %73, i32 0, i32 3
  %75 = load i32, ptr %74, align 4, !tbaa !22
  store i32 %75, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %76, i32 0, i32 28
  %78 = load ptr, ptr %77, align 8, !tbaa !18
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %79, i32 0, i32 30
  %81 = load i32, ptr %80, align 8, !tbaa !24
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %82, i32 0, i32 29
  %84 = load ptr, ptr %83, align 8, !tbaa !19
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.ofdmflexframegen_s, ptr %86, i32 0, i32 31
  %88 = load i32, ptr %87, align 4, !tbaa !20
  %89 = call i32 @liquid_repack_bytes(ptr noundef %78, i32 noundef 8, i32 noundef %81, ptr noundef %84, i32 noundef %85, i32 noundef %88, ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ofdmflexframegen_encode_header(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @ofdmflexframegen_modulate_header(ptr noundef) #2

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

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 152}
!12 = !{!"ofdmflexframegen_s", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !6, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !10, i64 184, !10, i64 188, !10, i64 192, !10, i64 196, !10, i64 200, !10, i64 204, !10, i64 208, !10, i64 212, !13, i64 216, !13, i64 232}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!14 = !{!12, !10, i64 200}
!15 = !{!12, !6, i64 104}
!16 = !{!12, !10, i64 128}
!17 = !{!12, !6, i64 144}
!18 = !{!12, !6, i64 168}
!19 = !{!12, !6, i64 176}
!20 = !{!12, !10, i64 188}
!21 = !{!12, !10, i64 228}
!22 = !{!23, !10, i64 20}
!23 = !{!"modulation_type_s", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20}
!24 = !{!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"

%struct.modulation_type_s = type { ptr, ptr, i32, i32 }

@modulation_types = external local_unnamed_addr constant [53 x %struct.modulation_type_s], align 16

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @ofdmflexframegen_assemble(ptr noundef %0, ptr noundef readonly %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = alloca i32, align 4
  %6 = tail call i32 @ofdmflexframegen_reset(ptr noundef %0)
  %7 = getelementptr inbounds i8, ptr %0, i64 152
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %.not = icmp eq i32 %8, %3
  br i1 %.not, label %11, label %9

9:                                                ; preds = %4
  store i32 %3, ptr %7, align 8, !tbaa !5
  %10 = tail call i32 @ofdmflexframegen_reconfigure(ptr noundef nonnull %0)
  br label %11

11:                                               ; preds = %9, %4
  %12 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 1, ptr %12, align 8, !tbaa !12
  %13 = icmp eq ptr %1, null
  %14 = getelementptr inbounds i8, ptr %0, i64 104
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %0, i64 128
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %18 = zext i32 %17 to i64
  br i1 %13, label %19, label %20

19:                                               ; preds = %11
  tail call void @llvm.memset.p0.i64(ptr align 1 %15, i8 0, i64 %18, i1 false)
  br label %21

20:                                               ; preds = %11
  tail call void @llvm.memmove.p0.p0.i64(ptr align 1 %15, ptr nonnull align 1 %1, i64 %18, i1 false)
  br label %21

21:                                               ; preds = %20, %19
  %22 = tail call i32 @ofdmflexframegen_encode_header(ptr noundef nonnull %0)
  %23 = tail call i32 @ofdmflexframegen_modulate_header(ptr noundef nonnull %0)
  %24 = getelementptr inbounds i8, ptr %0, i64 144
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %0, i64 168
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = tail call i32 @packetizer_encode(ptr noundef %25, ptr noundef %2, ptr noundef %27) #5
  %29 = getelementptr inbounds i8, ptr %0, i64 176
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %0, i64 188
  %32 = load i32, ptr %31, align 4, !tbaa !18
  %33 = zext i32 %32 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %30, i8 0, i64 %33, i1 false)
  %34 = getelementptr inbounds i8, ptr %0, i64 228
  %35 = load i32, ptr %34, align 4, !tbaa !19
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds [53 x %struct.modulation_type_s], ptr @modulation_types, i64 0, i64 %36, i32 3
  %38 = load i32, ptr %37, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %39 = load ptr, ptr %26, align 8, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %0, i64 184
  %41 = load i32, ptr %40, align 8, !tbaa !22
  %42 = load ptr, ptr %29, align 8, !tbaa !17
  %43 = load i32, ptr %31, align 4, !tbaa !18
  %44 = call i32 @liquid_repack_bytes(ptr noundef %39, i32 noundef 8, i32 noundef %41, ptr noundef %42, i32 noundef %38, i32 noundef %43, ptr noundef nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  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) #3

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

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

declare i32 @packetizer_encode(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @liquid_repack_bytes(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress 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, !7, i64 152}
!6 = !{!"ofdmflexframegen_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !10, i64 48, !10, i64 56, !7, i64 64, !10, i64 72, !7, i64 80, !7, i64 84, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !7, i64 128, !7, i64 132, !7, i64 136, !7, i64 140, !10, i64 144, !7, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !7, i64 184, !7, i64 188, !7, i64 192, !7, i64 196, !7, i64 200, !7, i64 204, !7, i64 208, !7, i64 212, !11, i64 216, !11, i64 232}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!12 = !{!6, !7, i64 200}
!13 = !{!6, !10, i64 104}
!14 = !{!6, !7, i64 128}
!15 = !{!6, !10, i64 144}
!16 = !{!6, !10, i64 168}
!17 = !{!6, !10, i64 176}
!18 = !{!6, !7, i64 188}
!19 = !{!6, !7, i64 228}
!20 = !{!21, !7, i64 20}
!21 = !{!"modulation_type_s", !10, i64 0, !10, i64 8, !7, i64 16, !7, i64 20}
!22 = !{!6, !7, i64 184}


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