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

; 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.bpacketgen_s = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, [6 x i8], [12 x i8], ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [57 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__.bpacketgen_create = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @bpacketgen_create(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %12 = call noalias ptr @malloc(i64 noundef 96) #6
  store ptr %12, ptr %11, align 8, !tbaa !9
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = load ptr, ptr %11, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.bpacketgen_s, ptr %14, i32 0, i32 2
  store i32 %13, ptr %15, align 8, !tbaa !11
  %16 = load i32, ptr %8, align 4, !tbaa !5
  %17 = load ptr, ptr %11, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.bpacketgen_s, ptr %17, i32 0, i32 3
  store i32 %16, ptr %18, align 4, !tbaa !13
  %19 = load i32, ptr %9, align 4, !tbaa !5
  %20 = load ptr, ptr %11, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.bpacketgen_s, ptr %20, i32 0, i32 4
  store i32 %19, ptr %21, align 8, !tbaa !14
  %22 = load i32, ptr %10, align 4, !tbaa !5
  %23 = load ptr, ptr %11, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.bpacketgen_s, ptr %23, i32 0, i32 5
  store i32 %22, ptr %24, align 4, !tbaa !15
  %25 = load ptr, ptr %11, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.bpacketgen_s, ptr %25, i32 0, i32 0
  store i32 0, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %11, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.bpacketgen_s, ptr %27, i32 0, i32 1
  store i32 8, ptr %28, align 4, !tbaa !17
  %29 = load ptr, ptr %11, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.bpacketgen_s, ptr %29, i32 0, i32 2
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = load ptr, ptr %11, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.bpacketgen_s, ptr %32, i32 0, i32 3
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = load ptr, ptr %11, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.bpacketgen_s, ptr %35, i32 0, i32 4
  %37 = load i32, ptr %36, align 8, !tbaa !14
  %38 = load ptr, ptr %11, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.bpacketgen_s, ptr %38, i32 0, i32 5
  %40 = load i32, ptr %39, align 4, !tbaa !15
  %41 = call i32 @packetizer_compute_enc_msg_len(i32 noundef %31, i32 noundef %34, i32 noundef %37, i32 noundef %40)
  %42 = load ptr, ptr %11, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.bpacketgen_s, ptr %42, i32 0, i32 6
  store i32 %41, ptr %43, align 8, !tbaa !18
  %44 = call i32 @packetizer_compute_enc_msg_len(i32 noundef 6, i32 noundef 4, i32 noundef 1, i32 noundef 6)
  %45 = load ptr, ptr %11, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.bpacketgen_s, ptr %45, i32 0, i32 7
  store i32 %44, ptr %46, align 4, !tbaa !19
  %47 = load ptr, ptr %11, align 8, !tbaa !9
  call void @bpacketgen_compute_packet_len(ptr noundef %47)
  %48 = load ptr, ptr %11, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.bpacketgen_s, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !17
  %51 = zext i32 %50 to i64
  %52 = mul i64 %51, 1
  %53 = call noalias ptr @malloc(i64 noundef %52) #6
  %54 = load ptr, ptr %11, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.bpacketgen_s, ptr %54, i32 0, i32 9
  store ptr %53, ptr %55, align 8, !tbaa !20
  %56 = call ptr @msequence_create_default(i32 noundef 6)
  %57 = load ptr, ptr %11, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.bpacketgen_s, ptr %57, i32 0, i32 12
  store ptr %56, ptr %58, align 8, !tbaa !21
  %59 = call ptr @packetizer_create(i32 noundef 6, i32 noundef 4, i32 noundef 1, i32 noundef 6)
  %60 = load ptr, ptr %11, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.bpacketgen_s, ptr %60, i32 0, i32 13
  store ptr %59, ptr %61, align 8, !tbaa !22
  %62 = load ptr, ptr %11, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.bpacketgen_s, ptr %62, i32 0, i32 7
  %64 = load i32, ptr %63, align 4, !tbaa !19
  %65 = load ptr, ptr %11, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.bpacketgen_s, ptr %65, i32 0, i32 13
  %67 = load ptr, ptr %66, align 8, !tbaa !22
  %68 = call i32 @packetizer_get_enc_msg_len(ptr noundef %67)
  %69 = icmp eq i32 %64, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %5
  br label %72

71:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 112, ptr noundef @__PRETTY_FUNCTION__.bpacketgen_create) #7
  unreachable

72:                                               ; preds = %70
  %73 = load ptr, ptr %11, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.bpacketgen_s, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !11
  %76 = load ptr, ptr %11, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.bpacketgen_s, ptr %76, i32 0, i32 3
  %78 = load i32, ptr %77, align 4, !tbaa !13
  %79 = load ptr, ptr %11, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct.bpacketgen_s, ptr %79, i32 0, i32 4
  %81 = load i32, ptr %80, align 8, !tbaa !14
  %82 = load ptr, ptr %11, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.bpacketgen_s, ptr %82, i32 0, i32 5
  %84 = load i32, ptr %83, align 4, !tbaa !15
  %85 = call ptr @packetizer_create(i32 noundef %75, i32 noundef %78, i32 noundef %81, i32 noundef %84)
  %86 = load ptr, ptr %11, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.bpacketgen_s, ptr %86, i32 0, i32 14
  store ptr %85, ptr %87, align 8, !tbaa !23
  %88 = load ptr, ptr %11, align 8, !tbaa !9
  call void @bpacketgen_assemble_header(ptr noundef %88)
  %89 = load ptr, ptr %11, align 8, !tbaa !9
  call void @bpacketgen_assemble_pnsequence(ptr noundef %89)
  %90 = load ptr, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  ret ptr %90
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

declare i32 @packetizer_compute_enc_msg_len(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @bpacketgen_compute_packet_len(ptr noundef) #0

declare ptr @msequence_create_default(i32 noundef) #3

declare ptr @packetizer_create(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare i32 @packetizer_get_enc_msg_len(ptr noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @bpacketgen_assemble_header(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @bpacketgen_assemble_pnsequence(ptr noundef) #0

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(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 = { "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 = { noreturn nounwind "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 }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"bpacketgen_s", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !10, i64 40, !7, i64 48, !7, i64 54, !10, i64 72, !10, i64 80, !10, i64 88}
!13 = !{!12, !6, i64 12}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 20}
!16 = !{!12, !6, i64 0}
!17 = !{!12, !6, i64 4}
!18 = !{!12, !6, i64 24}
!19 = !{!12, !6, i64 28}
!20 = !{!12, !10, i64 40}
!21 = !{!12, !10, i64 72}
!22 = !{!12, !10, i64 80}
!23 = !{!12, !10, 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 [57 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__.bpacketgen_create = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @bpacketgen_create(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call noalias dereferenceable_or_null(96) ptr @malloc(i64 noundef 96) #4
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %1, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %6, i64 12
  store i32 %2, ptr %8, align 4, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %6, i64 16
  store i32 %3, ptr %9, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %6, i64 20
  store i32 %4, ptr %10, align 4, !tbaa !13
  store i32 0, ptr %6, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 8, ptr %11, align 4, !tbaa !15
  %12 = tail call i32 @packetizer_compute_enc_msg_len(i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #5
  %13 = getelementptr inbounds i8, ptr %6, i64 24
  store i32 %12, ptr %13, align 8, !tbaa !16
  %14 = tail call i32 @packetizer_compute_enc_msg_len(i32 noundef 6, i32 noundef 4, i32 noundef 1, i32 noundef 6) #5
  %15 = getelementptr inbounds i8, ptr %6, i64 28
  store i32 %14, ptr %15, align 4, !tbaa !17
  tail call void @bpacketgen_compute_packet_len(ptr noundef nonnull %6)
  %16 = load i32, ptr %11, align 4, !tbaa !15
  %17 = zext i32 %16 to i64
  %18 = tail call noalias ptr @malloc(i64 noundef %17) #4
  %19 = getelementptr inbounds i8, ptr %6, i64 40
  store ptr %18, ptr %19, align 8, !tbaa !18
  %20 = tail call ptr @msequence_create_default(i32 noundef 6) #5
  %21 = getelementptr inbounds i8, ptr %6, i64 72
  store ptr %20, ptr %21, align 8, !tbaa !19
  %22 = tail call ptr @packetizer_create(i32 noundef 6, i32 noundef 4, i32 noundef 1, i32 noundef 6) #5
  %23 = getelementptr inbounds i8, ptr %6, i64 80
  store ptr %22, ptr %23, align 8, !tbaa !20
  %24 = load i32, ptr %15, align 4, !tbaa !17
  %25 = tail call i32 @packetizer_get_enc_msg_len(ptr noundef %22) #5
  %26 = icmp eq i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 112, ptr noundef nonnull @__PRETTY_FUNCTION__.bpacketgen_create) #6
  unreachable

28:                                               ; preds = %5
  %29 = load i32, ptr %7, align 8, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !11
  %31 = load i32, ptr %9, align 8, !tbaa !12
  %32 = load i32, ptr %10, align 4, !tbaa !13
  %33 = tail call ptr @packetizer_create(i32 noundef %29, i32 noundef %30, i32 noundef %31, i32 noundef %32) #5
  %34 = getelementptr inbounds i8, ptr %6, i64 88
  store ptr %33, ptr %34, align 8, !tbaa !21
  tail call void @bpacketgen_assemble_header(ptr noundef nonnull %6)
  tail call void @bpacketgen_assemble_pnsequence(ptr noundef nonnull %6)
  ret ptr %6
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

declare i32 @packetizer_compute_enc_msg_len(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

declare ptr @msequence_create_default(i32 noundef) local_unnamed_addr #2

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

declare i32 @packetizer_get_enc_msg_len(ptr noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @bpacketgen_assemble_pnsequence(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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 = { noreturn nounwind "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 allocsize(0) }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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 8}
!6 = !{!"bpacketgen_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !10, i64 40, !8, i64 48, !8, i64 54, !10, i64 72, !10, i64 80, !10, i64 88}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 12}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 20}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !7, i64 4}
!16 = !{!6, !7, i64 24}
!17 = !{!6, !7, i64 28}
!18 = !{!6, !10, i64 40}
!19 = !{!6, !10, i64 72}
!20 = !{!6, !10, i64 80}
!21 = !{!6, !10, i64 88}


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