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

; 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.gmskframegen_s = type { ptr, i32, i32, float, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, i32, i32, i32, i32, ptr, i32 }

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

declare i32 @packetizer_get_enc_msg_len(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @gmskframegen_assemble(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = call i32 @gmskframegen_reset(ptr noundef %15)
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.gmskframegen_s, ptr %17, i32 0, i32 18
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = icmp ne i32 %19, %20
  br i1 %21, label %40, label %22

22:                                               ; preds = %7
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.gmskframegen_s, ptr %23, i32 0, i32 15
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = load i32, ptr %12, align 4, !tbaa !9
  %27 = icmp ne i32 %25, %26
  br i1 %27, label %40, label %28

28:                                               ; preds = %22
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.gmskframegen_s, ptr %29, i32 0, i32 16
  %31 = load i32, ptr %30, align 4, !tbaa !15
  %32 = load i32, ptr %13, align 4, !tbaa !9
  %33 = icmp ne i32 %31, %32
  br i1 %33, label %40, label %34

34:                                               ; preds = %28
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.gmskframegen_s, ptr %35, i32 0, i32 17
  %37 = load i32, ptr %36, align 8, !tbaa !16
  %38 = load i32, ptr %14, align 4, !tbaa !9
  %39 = icmp ne i32 %37, %38
  br i1 %39, label %40, label %94

40:                                               ; preds = %34, %28, %22, %7
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.gmskframegen_s, ptr %42, i32 0, i32 18
  store i32 %41, ptr %43, align 4, !tbaa !11
  %44 = load i32, ptr %12, align 4, !tbaa !9
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.gmskframegen_s, ptr %45, i32 0, i32 15
  store i32 %44, ptr %46, align 8, !tbaa !14
  %47 = load i32, ptr %13, align 4, !tbaa !9
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.gmskframegen_s, ptr %48, i32 0, i32 16
  store i32 %47, ptr %49, align 4, !tbaa !15
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.gmskframegen_s, ptr %51, i32 0, i32 17
  store i32 %50, ptr %52, align 8, !tbaa !16
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.gmskframegen_s, ptr %53, i32 0, i32 14
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.gmskframegen_s, ptr %56, i32 0, i32 18
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.gmskframegen_s, ptr %59, i32 0, i32 15
  %61 = load i32, ptr %60, align 8, !tbaa !14
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.gmskframegen_s, ptr %62, i32 0, i32 16
  %64 = load i32, ptr %63, align 4, !tbaa !15
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.gmskframegen_s, ptr %65, i32 0, i32 17
  %67 = load i32, ptr %66, align 8, !tbaa !16
  %68 = call ptr @packetizer_recreate(ptr noundef %55, i32 noundef %58, i32 noundef %61, i32 noundef %64, i32 noundef %67)
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.gmskframegen_s, ptr %69, i32 0, i32 14
  store ptr %68, ptr %70, align 8, !tbaa !17
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.gmskframegen_s, ptr %71, i32 0, i32 14
  %73 = load ptr, ptr %72, align 8, !tbaa !17
  %74 = call i32 @packetizer_get_enc_msg_len(ptr noundef %73)
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.gmskframegen_s, ptr %75, i32 0, i32 19
  store i32 %74, ptr %76, align 8, !tbaa !18
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.gmskframegen_s, ptr %77, i32 0, i32 19
  %79 = load i32, ptr %78, align 8, !tbaa !18
  %80 = mul i32 8, %79
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.gmskframegen_s, ptr %81, i32 0, i32 6
  store i32 %80, ptr %82, align 4, !tbaa !19
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.gmskframegen_s, ptr %83, i32 0, i32 20
  %85 = load ptr, ptr %84, align 8, !tbaa !20
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.gmskframegen_s, ptr %86, i32 0, i32 19
  %88 = load i32, ptr %87, align 8, !tbaa !18
  %89 = zext i32 %88 to i64
  %90 = mul i64 %89, 1
  %91 = call ptr @realloc(ptr noundef %85, i64 noundef %90) #3
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.gmskframegen_s, ptr %92, i32 0, i32 20
  store ptr %91, ptr %93, align 8, !tbaa !20
  br label %94

94:                                               ; preds = %40, %34
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.gmskframegen_s, ptr %95, i32 0, i32 22
  store i32 1, ptr %96, align 4, !tbaa !21
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = call i32 @gmskframegen_encode_header(ptr noundef %97, ptr noundef %98)
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.gmskframegen_s, ptr %100, i32 0, i32 14
  %102 = load ptr, ptr %101, align 8, !tbaa !17
  %103 = load ptr, ptr %10, align 8, !tbaa !5
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.gmskframegen_s, ptr %104, i32 0, i32 20
  %106 = load ptr, ptr %105, align 8, !tbaa !20
  %107 = call i32 @packetizer_encode(ptr noundef %102, ptr noundef %103, ptr noundef %106)
  %108 = load ptr, ptr %8, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.gmskframegen_s, ptr %108, i32 0, i32 21
  store i32 1, ptr %109, align 8, !tbaa !22
  ret i32 0
}

declare ptr @packetizer_recreate(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

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

declare i32 @packetizer_encode(ptr noundef, ptr noundef, ptr noundef) #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 = { "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 100}
!12 = !{!"gmskframegen_s", !6, i64 0, !10, i64 8, !10, i64 12, !13, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !6, i64 112, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !6, i64 136, !10, i64 144}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !10, i64 88}
!15 = !{!12, !10, i64 92}
!16 = !{!12, !10, i64 96}
!17 = !{!12, !6, i64 80}
!18 = !{!12, !10, i64 104}
!19 = !{!12, !10, i64 28}
!20 = !{!12, !6, i64 112}
!21 = !{!12, !10, i64 124}
!22 = !{!12, !10, i64 120}


; 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 @gmskframegen_reset(ptr noundef) local_unnamed_addr #0

declare i32 @packetizer_get_enc_msg_len(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
define dso_local noundef i32 @gmskframegen_assemble(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = tail call i32 @gmskframegen_reset(ptr noundef %0)
  %9 = getelementptr inbounds i8, ptr %0, i64 100
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %.not = icmp eq i32 %10, %3
  br i1 %.not, label %11, label %20

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 88
  %13 = load i32, ptr %12, align 8, !tbaa !12
  %.not36 = icmp eq i32 %13, %4
  br i1 %.not36, label %14, label %20

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 92
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %.not37 = icmp eq i32 %16, %5
  br i1 %.not37, label %17, label %20

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 96
  %19 = load i32, ptr %18, align 8, !tbaa !14
  %.not38 = icmp eq i32 %19, %6
  br i1 %.not38, label %35, label %20

20:                                               ; preds = %17, %14, %11, %7
  store i32 %3, ptr %9, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 %4, ptr %21, align 8, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 %5, ptr %22, align 4, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %6, ptr %23, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %0, i64 80
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = tail call ptr @packetizer_recreate(ptr noundef %25, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #3
  store ptr %26, ptr %24, align 8, !tbaa !15
  %27 = tail call i32 @packetizer_get_enc_msg_len(ptr noundef %26) #3
  %28 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 %27, ptr %28, align 8, !tbaa !16
  %29 = shl i32 %27, 3
  %30 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %29, ptr %30, align 4, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %0, i64 112
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  %33 = zext i32 %27 to i64
  %34 = tail call ptr @realloc(ptr noundef %32, i64 noundef %33) #4
  store ptr %34, ptr %31, align 8, !tbaa !18
  br label %35

35:                                               ; preds = %20, %17
  %36 = getelementptr inbounds i8, ptr %0, i64 124
  store i32 1, ptr %36, align 4, !tbaa !19
  %37 = tail call i32 @gmskframegen_encode_header(ptr noundef nonnull %0, ptr noundef %1)
  %38 = getelementptr inbounds i8, ptr %0, i64 80
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = getelementptr inbounds i8, ptr %0, i64 112
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  %42 = tail call i32 @packetizer_encode(ptr noundef %39, ptr noundef %2, ptr noundef %41) #3
  %43 = getelementptr inbounds i8, ptr %0, i64 120
  store i32 1, ptr %43, align 8, !tbaa !20
  ret i32 0
}

declare ptr @packetizer_recreate(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

declare i32 @packetizer_encode(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { "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, !10, i64 100}
!6 = !{!"gmskframegen_s", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !7, i64 40, !10, i64 48, !10, i64 52, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !7, i64 112, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !7, i64 136, !10, i64 144}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 88}
!13 = !{!6, !10, i64 92}
!14 = !{!6, !10, i64 96}
!15 = !{!6, !7, i64 80}
!16 = !{!6, !10, i64 104}
!17 = !{!6, !10, i64 28}
!18 = !{!6, !7, i64 112}
!19 = !{!6, !10, i64 124}
!20 = !{!6, !10, i64 120}


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