; LLVM IR from yinqiwen/ardb :: src/common/channel (channel_pipeline)

; 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::ChannelPipeline" = type { ptr, ptr, ptr, %"class.btree::btree_map" }
%"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<std::__cxx11::basic_string<char>, ardb::ChannelHandlerContext *, std::less<std::__cxx11::basic_string<char>>, std::allocator<std::pair<const std::__cxx11::basic_string<char>, ardb::ChannelHandlerContext *>>, 256>>::empty_base_handle" }
%"struct.btree::btree<btree::btree_map_params<std::__cxx11::basic_string<char>, ardb::ChannelHandlerContext *, std::less<std::__cxx11::basic_string<char>>, std::allocator<std::pair<const std::__cxx11::basic_string<char>, ardb::ChannelHandlerContext *>>, 256>>::empty_base_handle" = type { 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4ardb21ChannelHandlerContext7GetNextEv(ptr noundef nonnull align 8 dereferenceable(66)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4ardb21ChannelHandlerContext10GetHandlerEv(ptr noundef nonnull align 8 dereferenceable(66)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb15ChannelPipeline6GetAllESt6vectorIPNS_14ChannelHandlerESaIS3_EE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %8 = getelementptr inbounds %"class.ardb::ChannelPipeline", ptr %7, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %9, ptr %5, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %13, %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr null, %11
  br i1 %12, label %13, label %18

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noundef ptr @_ZN4ardb21ChannelHandlerContext10GetHandlerEv(ptr noundef nonnull align 8 dereferenceable(66) %14)
  store ptr %15, ptr %6, align 8, !tbaa !5
  call void @_ZNSt6vectorIPN4ardb14ChannelHandlerESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN4ardb21ChannelHandlerContext7GetNextEv(ptr noundef nonnull align 8 dereferenceable(66) %16)
  store ptr %17, ptr %5, align 8, !tbaa !5
  br label %10, !llvm.loop !17

18:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN4ardb14ChannelHandlerESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { 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" }
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, !6, i64 8}
!10 = !{!"_ZTSN4ardb15ChannelPipelineE", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"_ZTSN5btree9btree_mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS6_ESaISt4pairIKS6_S9_EELi256EEE", !12, i64 0}
!12 = !{!"_ZTSN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !13, i64 0}
!13 = !{!"_ZTSN5btree22btree_unique_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !14, i64 0}
!14 = !{!"_ZTSN5btree15btree_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !15, i64 0}
!15 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS7_ESaISt4pairIKS7_SA_EELi256EEEEE", !16, i64 0}
!16 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS7_ESaISt4pairIKS7_SA_EELi256EEEE17empty_base_handleIS6_PNS_10btree_nodeISH_EEEE", !6, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4ardb21ChannelHandlerContext7GetNextEv(ptr noundef nonnull align 8 dereferenceable(66)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4ardb21ChannelHandlerContext10GetHandlerEv(ptr noundef nonnull align 8 dereferenceable(66)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb15ChannelPipeline6GetAllESt6vectorIPNS_14ChannelHandlerESaIS3_EE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not4 = icmp eq ptr %5, null
  br i1 %.not4, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.05 = phi ptr [ %7, %.lr.ph ], [ %5, %2 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %6 = call noundef ptr @_ZN4ardb21ChannelHandlerContext10GetHandlerEv(ptr noundef nonnull align 8 dereferenceable(66) %.05)
  store ptr %6, ptr %3, align 8, !tbaa !16
  call void @_ZNSt6vectorIPN4ardb14ChannelHandlerESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  %7 = call noundef ptr @_ZN4ardb21ChannelHandlerContext7GetNextEv(ptr noundef nonnull align 8 dereferenceable(66) %.05)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN4ardb14ChannelHandlerESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { 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" }
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, !7, i64 8}
!6 = !{!"_ZTSN4ardb15ChannelPipelineE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN5btree9btree_mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS6_ESaISt4pairIKS6_S9_EELi256EEE", !11, i64 0}
!11 = !{!"_ZTSN5btree19btree_map_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !12, i64 0}
!12 = !{!"_ZTSN5btree22btree_unique_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !13, i64 0}
!13 = !{!"_ZTSN5btree15btree_containerINS_5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS8_ESaISt4pairIKS8_SB_EELi256EEEEEEE", !14, i64 0}
!14 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS7_ESaISt4pairIKS7_SA_EELi256EEEEE", !15, i64 0}
!15 = !{!"_ZTSN5btree5btreeINS_16btree_map_paramsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPN4ardb21ChannelHandlerContextESt4lessIS7_ESaISt4pairIKS7_SA_EELi256EEEE17empty_base_handleIS6_PNS_10btree_nodeISH_EEEE", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass