; LLVM IR from yinqiwen/ardb :: src/common/channel/channel_service.ll (ZN4ardb14ChannelService16GetSignalChannelEv)

; 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.ardb::ChannelService" = type { %"class.ardb::Runnable", %"struct.ardb::SoftSignalHandler", %"class.btree::btree_map", i32, ptr, ptr, ptr, ptr, %"class.std::__cxx11::list", %"class.ardb::MPSCQueue", i8, i32, %"class.std::vector", %"class.std::vector.6", i64, %"class.ardb::SPSCQueue", ptr, i32, ptr }
%"class.ardb::Runnable" = type { ptr }
%"struct.ardb::SoftSignalHandler" = type { ptr }
%"class.btree::btree_map" = type { %"class.btree::btree_map_container" }
%"class.btree::btree_map_container" = type { %"class.btree::btree_unique_container" }
%"class.btree::btree_unique_container" = type { %"class.btree::btree_container" }
%"class.btree::btree_container" = type { %"class.btree::btree" }
%"class.btree::btree" = type { %"struct.btree::btree<btree::btree_map_params<unsigned int, ardb::Channel *, std::less<unsigned int>, std::allocator<std::pair<const unsigned int, ardb::Channel *>>, 256>>::empty_base_handle" }
%"struct.btree::btree<btree::btree_map_params<unsigned int, ardb::Channel *, std::less<unsigned int>, std::allocator<std::pair<const unsigned int, ardb::Channel *>>, 256>>::empty_base_handle" = type { ptr }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<unsigned int, std::allocator<unsigned int>>::_List_impl" }
%"struct.std::__cxx11::_List_base<unsigned int, std::allocator<unsigned int>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }
%"class.ardb::MPSCQueue" = type { ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<ardb::ChannelService *, std::allocator<ardb::ChannelService *>>::_Vector_impl" }
%"struct.std::_Vector_base<ardb::ChannelService *, std::allocator<ardb::ChannelService *>>::_Vector_impl" = type { %"struct.std::_Vector_base<ardb::ChannelService *, std::allocator<ardb::ChannelService *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ardb::ChannelService *, std::allocator<ardb::ChannelService *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.6" = type { %"struct.std::_Vector_base.7" }
%"struct.std::_Vector_base.7" = type { %"struct.std::_Vector_base<ardb::Thread *, std::allocator<ardb::Thread *>>::_Vector_impl" }
%"struct.std::_Vector_base<ardb::Thread *, std::allocator<ardb::Thread *>>::_Vector_impl" = type { %"struct.std::_Vector_base<ardb::Thread *, std::allocator<ardb::Thread *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ardb::Thread *, std::allocator<ardb::Thread *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.ardb::SPSCQueue" = type { ptr, [64 x i8], ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(276) ptr @_ZN4ardb14ChannelService16GetSignalChannelEv(ptr noundef nonnull align 8 dereferenceable(288) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.ardb::ChannelService", ptr %3, i32 0, i32 6
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = icmp eq ptr null, %5
  br i1 %6, label %7, label %10

7:                                                ; preds = %1
  %8 = call noundef ptr @_ZN4ardb14ChannelService16NewSignalChannelEv(ptr noundef nonnull align 8 dereferenceable(288) %3)
  %9 = getelementptr inbounds %"class.ardb::ChannelService", ptr %3, i32 0, i32 6
  store ptr %8, ptr %9, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %7, %1
  %11 = getelementptr inbounds %"class.ardb::ChannelService", ptr %3, i32 0, i32 6
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  ret ptr %12
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4ardb14ChannelService16NewSignalChannelEv(ptr noundef nonnull align 8 dereferenceable(288)) #0 align 2

attributes #0 = { mustprogress 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" }

!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, !6, i64 48}
!10 = !{!"_ZTSN4ardb14ChannelServiceE", !11, i64 0, !12, i64 8, !13, i64 16, !19, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !20, i64 64, !26, i64 88, !27, i64 104, !19, i64 108, !28, i64 112, !32, i64 136, !25, i64 160, !36, i64 168, !6, i64 264, !19, i64 272, !6, i64 280}
!11 = !{!"_ZTSN4ardb8RunnableE"}
!12 = !{!"_ZTSN4ardb17SoftSignalHandlerE"}
!13 = !{!"_ZTSN5btree9btree_mapIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS3_EELi256EEE", !14, i64 0}
!14 = !{!"_ZTSN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEEE", !15, i64 0}
!15 = !{!"_ZTSN5btree22btree_unique_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEEE", !16, i64 0}
!16 = !{!"_ZTSN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEEE", !17, i64 0}
!17 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS4_EELi256EEEEE", !18, i64 0}
!18 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS4_EELi256EEEE17empty_base_handleISaIcEPNS_10btree_nodeISB_EEEE", !6, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"_ZTSNSt7__cxx114listIjSaIjEEE", !21, i64 0}
!21 = !{!"_ZTSNSt7__cxx1110_List_baseIjSaIjEEE", !22, i64 0}
!22 = !{!"_ZTSNSt7__cxx1110_List_baseIjSaIjEE10_List_implE", !23, i64 0}
!23 = !{!"_ZTSNSt8__detail17_List_node_headerE", !24, i64 0, !25, i64 16}
!24 = !{!"_ZTSNSt8__detail15_List_node_baseE", !6, i64 0, !6, i64 8}
!25 = !{!"long", !7, i64 0}
!26 = !{!"_ZTSN4ardb9MPSCQueueINS_21ChannelAsyncIOContextEEE", !6, i64 0, !6, i64 8}
!27 = !{!"bool", !7, i64 0}
!28 = !{!"_ZTSSt6vectorIPN4ardb14ChannelServiceESaIS2_EE", !29, i64 0}
!29 = !{!"_ZTSSt12_Vector_baseIPN4ardb14ChannelServiceESaIS2_EE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIPN4ardb14ChannelServiceESaIS2_EE12_Vector_implE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIPN4ardb14ChannelServiceESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!32 = !{!"_ZTSSt6vectorIPN4ardb6ThreadESaIS2_EE", !33, i64 0}
!33 = !{!"_ZTSSt12_Vector_baseIPN4ardb6ThreadESaIS2_EE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIPN4ardb6ThreadESaIS2_EE12_Vector_implE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIPN4ardb6ThreadESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!36 = !{!"_ZTSN4ardb9SPSCQueueIPNS_8RunnableEEE", !6, i64 0, !7, i64 8, !6, i64 72, !6, i64 80, !6, 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"

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(276) ptr @_ZN4ardb14ChannelService16GetSignalChannelEv(ptr noundef nonnull align 8 dereferenceable(288) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %7

5:                                                ; preds = %1
  %6 = tail call noundef ptr @_ZN4ardb14ChannelService16NewSignalChannelEv(ptr noundef nonnull align 8 dereferenceable(288) %0)
  store ptr %6, ptr %2, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %5, %1
  %8 = phi ptr [ %6, %5 ], [ %3, %1 ]
  ret ptr %8
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4ardb14ChannelService16NewSignalChannelEv(ptr noundef nonnull align 8 dereferenceable(288)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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" }

!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, !15, i64 48}
!6 = !{!"_ZTSN4ardb14ChannelServiceE", !7, i64 0, !8, i64 8, !9, i64 16, !18, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !19, i64 64, !25, i64 88, !26, i64 104, !18, i64 108, !27, i64 112, !31, i64 136, !24, i64 160, !35, i64 168, !15, i64 264, !18, i64 272, !15, i64 280}
!7 = !{!"_ZTSN4ardb8RunnableE"}
!8 = !{!"_ZTSN4ardb17SoftSignalHandlerE"}
!9 = !{!"_ZTSN5btree9btree_mapIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS3_EELi256EEE", !10, i64 0}
!10 = !{!"_ZTSN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEEE", !11, i64 0}
!11 = !{!"_ZTSN5btree22btree_unique_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEEE", !12, i64 0}
!12 = !{!"_ZTSN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEEE", !13, i64 0}
!13 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS4_EELi256EEEEE", !14, i64 0}
!14 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS4_EELi256EEEE17empty_base_handleISaIcEPNS_10btree_nodeISB_EEEE", !15, i64 0}
!15 = !{!"any pointer", !16, i64 0}
!16 = !{!"omnipotent char", !17, i64 0}
!17 = !{!"Simple C++ TBAA"}
!18 = !{!"int", !16, i64 0}
!19 = !{!"_ZTSNSt7__cxx114listIjSaIjEEE", !20, i64 0}
!20 = !{!"_ZTSNSt7__cxx1110_List_baseIjSaIjEEE", !21, i64 0}
!21 = !{!"_ZTSNSt7__cxx1110_List_baseIjSaIjEE10_List_implE", !22, i64 0}
!22 = !{!"_ZTSNSt8__detail17_List_node_headerE", !23, i64 0, !24, i64 16}
!23 = !{!"_ZTSNSt8__detail15_List_node_baseE", !15, i64 0, !15, i64 8}
!24 = !{!"long", !16, i64 0}
!25 = !{!"_ZTSN4ardb9MPSCQueueINS_21ChannelAsyncIOContextEEE", !15, i64 0, !15, i64 8}
!26 = !{!"bool", !16, i64 0}
!27 = !{!"_ZTSSt6vectorIPN4ardb14ChannelServiceESaIS2_EE", !28, i64 0}
!28 = !{!"_ZTSSt12_Vector_baseIPN4ardb14ChannelServiceESaIS2_EE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIPN4ardb14ChannelServiceESaIS2_EE12_Vector_implE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIPN4ardb14ChannelServiceESaIS2_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!31 = !{!"_ZTSSt6vectorIPN4ardb6ThreadESaIS2_EE", !32, i64 0}
!32 = !{!"_ZTSSt12_Vector_baseIPN4ardb6ThreadESaIS2_EE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseIPN4ardb6ThreadESaIS2_EE12_Vector_implE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIPN4ardb6ThreadESaIS2_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!35 = !{!"_ZTSN4ardb9SPSCQueueIPNS_8RunnableEEE", !15, i64 0, !16, i64 8, !15, i64 72, !15, i64 80, !15, i64 88}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass