; LLVM IR from intel/qpl :: sources/middle-layer/compression/huffman_table (huffman_table)

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

%"class.qpl::ml::compression::huffman_table_t" = type { %"struct.qpl::ml::compression::huffman_table_meta_t", i8, ptr, ptr, %"class.std::unique_ptr", %struct.allocator_t }
%"struct.qpl::ml::compression::huffman_table_meta_t" = type { [4 x i8], i32, i8, i8, i8, i8, i32 }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.1" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { ptr }
%"struct.std::_Head_base.1" = type { ptr }
%struct.allocator_t = type { ptr, ptr }

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

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

; Function Attrs: nounwind
declare noundef i32 @_ZN3qpl2ml11compression21huffman_table_convertI29qpl_compression_huffman_table31qpl_decompression_huffman_tableEEjRKT_RT0_j(ptr noundef nonnull align 64 dereferenceable(3904), ptr noundef nonnull align 64 dereferenceable(27584), i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN3qpl2ml11compression15huffman_table_tILNS1_23compression_algorithm_eE0EE4initERKS4_(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(72) %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %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 %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = getelementptr inbounds %"class.qpl::ml::compression::huffman_table_t", ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %"struct.qpl::ml::compression::huffman_table_meta_t", ptr %11, i32 0, i32 4
  %13 = load i8, ptr %12, align 2, !tbaa !9
  %14 = icmp eq i8 %13, 2
  br i1 %14, label %15, label %35

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.qpl::ml::compression::huffman_table_t", ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !27
  store ptr %18, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %19 = getelementptr inbounds %"class.qpl::ml::compression::huffman_table_t", ptr %10, i32 0, i32 3
  %20 = load ptr, ptr %19, align 8, !tbaa !28
  store ptr %20, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.qpl::ml::compression::huffman_table_t", ptr %10, i32 0, i32 0
  %24 = getelementptr inbounds %"struct.qpl::ml::compression::huffman_table_meta_t", ptr %23, i32 0, i32 6
  %25 = load i32, ptr %24, align 4, !tbaa !29
  %26 = call noundef i32 @_ZN3qpl2ml11compression21huffman_table_convertI29qpl_compression_huffman_table31qpl_decompression_huffman_tableEEjRKT_RT0_j(ptr noundef nonnull align 64 dereferenceable(3904) %21, ptr noundef nonnull align 64 dereferenceable(27584) %22, i32 noundef %25) #3
  store i32 %26, ptr %8, align 4, !tbaa !30
  %27 = load i32, ptr %8, align 4, !tbaa !30
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %15
  %30 = load i32, ptr %8, align 4, !tbaa !30
  store i32 %30, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %32

31:                                               ; preds = %15
  store i32 0, ptr %9, align 4
  br label %32

32:                                               ; preds = %31, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %33 = load i32, ptr %9, align 4
  switch i32 %33, label %40 [
    i32 0, label %34
    i32 1, label %38
  ]

34:                                               ; preds = %32
  br label %36

35:                                               ; preds = %2
  store i32 52, ptr %3, align 4
  br label %38

36:                                               ; preds = %34
  %37 = getelementptr inbounds %"class.qpl::ml::compression::huffman_table_t", ptr %10, i32 0, i32 1
  store i8 1, ptr %37, align 8, !tbaa !31
  store i32 0, ptr %3, align 4
  br label %38

38:                                               ; preds = %36, %35, %32
  %39 = load i32, ptr %3, align 4
  ret i32 %39

40:                                               ; preds = %32
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !15, i64 10}
!10 = !{!"_ZTSN3qpl2ml11compression15huffman_table_tILNS1_23compression_algorithm_eE0EEE", !11, i64 0, !17, i64 16, !6, i64 24, !6, i64 32, !18, i64 40, !26, i64 56}
!11 = !{!"_ZTSN3qpl2ml11compression20huffman_table_meta_tE", !7, i64 0, !12, i64 4, !13, i64 8, !14, i64 9, !15, i64 10, !16, i64 11, !12, i64 12}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN3qpl2ml11compression23compression_algorithm_eE", !7, i64 0}
!14 = !{!"_ZTSN3qpl2ml11compression15table_version_eE", !7, i64 0}
!15 = !{!"_ZTSN3qpl2ml11compression20huffman_table_type_eE", !7, i64 0}
!16 = !{!"_ZTSN3qpl2ml16execution_path_tE", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSSt10unique_ptrIA_hPFvPvEE", !19, i64 0}
!19 = !{!"_ZTSSt15__uniq_ptr_dataIhPFvPvELb1ELb1EE", !20, i64 0}
!20 = !{!"_ZTSSt15__uniq_ptr_implIhPFvPvEE", !21, i64 0}
!21 = !{!"_ZTSSt5tupleIJPhPFvPvEEE", !22, i64 0}
!22 = !{!"_ZTSSt11_Tuple_implILm0EJPhPFvPvEEE", !23, i64 0, !25, i64 8}
!23 = !{!"_ZTSSt11_Tuple_implILm1EJPFvPvEEE", !24, i64 0}
!24 = !{!"_ZTSSt10_Head_baseILm1EPFvPvELb0EE", !6, i64 0}
!25 = !{!"_ZTSSt10_Head_baseILm0EPhLb0EE", !6, i64 0}
!26 = !{!"_ZTS11allocator_t", !6, i64 0, !6, i64 8}
!27 = !{!10, !6, i64 24}
!28 = !{!10, !6, i64 32}
!29 = !{!10, !12, i64 12}
!30 = !{!12, !12, i64 0}
!31 = !{!10, !17, i64 16}


; 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
declare noundef i32 @_ZN3qpl2ml11compression21huffman_table_convertI29qpl_compression_huffman_table31qpl_decompression_huffman_tableEEjRKT_RT0_j(ptr noundef nonnull align 64 dereferenceable(3904), ptr noundef nonnull align 64 dereferenceable(27584), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN3qpl2ml11compression15huffman_table_tILNS1_23compression_algorithm_eE0EE4initERKS4_(ptr nocapture noundef nonnull align 8 dereferenceable(72) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(72) %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 10
  %4 = load i8, ptr %3, align 2, !tbaa !5
  %5 = icmp eq i8 %4, 2
  br i1 %5, label %6, label %16

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !26
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !27
  %11 = getelementptr inbounds i8, ptr %0, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !28
  %13 = tail call noundef i32 @_ZN3qpl2ml11compression21huffman_table_convertI29qpl_compression_huffman_table31qpl_decompression_huffman_tableEEjRKT_RT0_j(ptr noundef nonnull align 64 dereferenceable(3904) %8, ptr noundef nonnull align 64 dereferenceable(27584) %10, i32 noundef %12) #2
  %.not.not = icmp eq i32 %13, 0
  br i1 %.not.not, label %14, label %16

14:                                               ; preds = %6
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 1, ptr %15, align 8, !tbaa !29
  br label %16

16:                                               ; preds = %6, %2, %14
  %.1 = phi i32 [ %13, %6 ], [ 0, %14 ], [ 52, %2 ]
  ret i32 %.1
}

attributes #0 = { 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 #1 = { mustprogress 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 = { 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, !13, i64 10}
!6 = !{!"_ZTSN3qpl2ml11compression15huffman_table_tILNS1_23compression_algorithm_eE0EEE", !7, i64 0, !15, i64 16, !16, i64 24, !16, i64 32, !17, i64 40, !25, i64 56}
!7 = !{!"_ZTSN3qpl2ml11compression20huffman_table_meta_tE", !8, i64 0, !10, i64 4, !11, i64 8, !12, i64 9, !13, i64 10, !14, i64 11, !10, i64 12}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSN3qpl2ml11compression23compression_algorithm_eE", !8, i64 0}
!12 = !{!"_ZTSN3qpl2ml11compression15table_version_eE", !8, i64 0}
!13 = !{!"_ZTSN3qpl2ml11compression20huffman_table_type_eE", !8, i64 0}
!14 = !{!"_ZTSN3qpl2ml16execution_path_tE", !8, i64 0}
!15 = !{!"bool", !8, i64 0}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"_ZTSSt10unique_ptrIA_hPFvPvEE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_dataIhPFvPvELb1ELb1EE", !19, i64 0}
!19 = !{!"_ZTSSt15__uniq_ptr_implIhPFvPvEE", !20, i64 0}
!20 = !{!"_ZTSSt5tupleIJPhPFvPvEEE", !21, i64 0}
!21 = !{!"_ZTSSt11_Tuple_implILm0EJPhPFvPvEEE", !22, i64 0, !24, i64 8}
!22 = !{!"_ZTSSt11_Tuple_implILm1EJPFvPvEEE", !23, i64 0}
!23 = !{!"_ZTSSt10_Head_baseILm1EPFvPvELb0EE", !16, i64 0}
!24 = !{!"_ZTSSt10_Head_baseILm0EPhLb0EE", !16, i64 0}
!25 = !{!"_ZTS11allocator_t", !16, i64 0, !16, i64 8}
!26 = !{!6, !16, i64 24}
!27 = !{!6, !16, i64 32}
!28 = !{!6, !10, i64 12}
!29 = !{!6, !15, i64 16}


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