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

; 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.btree::btree_iterator" = type <{ ptr, i32, [4 x i8] }>
%"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 }
%"struct.btree::btree_iterator.38" = type <{ ptr, i32, [4 x i8] }>
%"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.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 }
%"struct.std::pair" = type { i32, ptr }

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

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EneERKNS0_IKSD_RKSA_PSI_EE(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE3endEv(ptr dead_on_unwind noalias writable sret(%"struct.btree::btree_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5btree14btree_iteratorIKNS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERKSA_PSF_EC2ERKNS0_ISD_RSA_PSA_EE(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE5beginEv(ptr dead_on_unwind noalias writable sret(%"struct.btree::btree_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EptEv(ptr noundef nonnull align 8 dereferenceable(12)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EppEi(ptr dead_on_unwind noalias writable sret(%"struct.btree::btree_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb14ChannelService16CloseAllChannelsEb(ptr noundef nonnull align 8 dereferenceable(288) %0, i1 noundef zeroext %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca %"class.btree::btree_map", align 8
  %6 = alloca %"struct.btree::btree_iterator", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.btree::btree_iterator.38", align 8
  %10 = alloca %"struct.btree::btree_iterator", align 8
  %11 = alloca ptr, align 8
  %12 = alloca %"struct.btree::btree_iterator", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %13 = zext i1 %1 to i8
  store i8 %13, ptr %4, align 1, !tbaa !9
  %14 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %15 = getelementptr inbounds %"class.ardb::ChannelService", ptr %14, i32 0, i32 2
  call void @_ZN5btree9btree_mapIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS3_EELi256EEC2ERKSA_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %15)
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  invoke void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE5beginEv(ptr dead_on_unwind writable sret(%"struct.btree::btree_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %16 unwind label %33

16:                                               ; preds = %2
  br label %17

17:                                               ; preds = %48, %16
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #5
  invoke void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE3endEv(ptr dead_on_unwind writable sret(%"struct.btree::btree_iterator") align 8 %10, ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %18 unwind label %37

18:                                               ; preds = %17
  invoke void @_ZN5btree14btree_iteratorIKNS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERKSA_PSF_EC2ERKNS0_ISD_RSA_PSA_EE(ptr noundef nonnull align 8 dereferenceable(12) %9, ptr noundef nonnull align 8 dereferenceable(12) %10)
          to label %19 unwind label %37

19:                                               ; preds = %18
  %20 = invoke noundef zeroext i1 @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EneERKNS0_IKSD_RKSA_PSI_EE(ptr noundef nonnull align 8 dereferenceable(12) %6, ptr noundef nonnull align 8 dereferenceable(12) %9)
          to label %21 unwind label %37

21:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  br i1 %20, label %22, label %54

22:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %23 = invoke noundef ptr @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EptEv(ptr noundef nonnull align 8 dereferenceable(12) %6)
          to label %24 unwind label %41

24:                                               ; preds = %22
  %25 = getelementptr inbounds %"struct.std::pair", ptr %23, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  store ptr %26, ptr %11, align 8, !tbaa !5
  %27 = load i8, ptr %4, align 1, !tbaa !9, !range !14, !noundef !15
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %45

29:                                               ; preds = %24
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = invoke noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256) %30)
          to label %32 unwind label %41

32:                                               ; preds = %29
  br label %45

33:                                               ; preds = %54, %2
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %7, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %8, align 4
  br label %57

37:                                               ; preds = %19, %18, %17
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %7, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  br label %57

41:                                               ; preds = %45, %29, %22
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %7, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %8, align 4
  br label %53

45:                                               ; preds = %32, %24
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  invoke void @_ZN4ardb14ChannelService13DeleteChannelEPNS_7ChannelE(ptr noundef nonnull align 8 dereferenceable(288) %14, ptr noundef %46)
          to label %47 unwind label %41

47:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  invoke void @_ZN5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EppEi(ptr dead_on_unwind writable sret(%"struct.btree::btree_iterator") align 8 %12, ptr noundef nonnull align 8 dereferenceable(12) %6, i32 noundef 0)
          to label %48 unwind label %49

48:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %17, !llvm.loop !16

49:                                               ; preds = %47
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %7, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  br label %53

53:                                               ; preds = %49, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %57

54:                                               ; preds = %21
  %55 = getelementptr inbounds %"class.ardb::ChannelService", ptr %14, i32 0, i32 2
  invoke void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(8) %55)
          to label %56 unwind label %33

56:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void

57:                                               ; preds = %53, %37, %33
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %7, align 8
  %60 = load i32, ptr %8, align 4
  %61 = insertvalue { ptr, i32 } poison, ptr %59, 0
  %62 = insertvalue { ptr, i32 } %61, i32 %60, 1
  resume { ptr, i32 } %62
}

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

declare noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256)) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE5clearEv(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 = { 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 #4 = { "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 }

!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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSSt4pairIKjPN4ardb7ChannelEE", !13, i64 0, !6, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%"struct.btree::btree_iterator" = type <{ ptr, i32, [4 x i8] }>
%"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 }
%"struct.btree::btree_iterator.38" = type <{ ptr, i32, [4 x i8] }>

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

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EneERKNS0_IKSD_RKSA_PSI_EE(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE3endEv(ptr dead_on_unwind noalias writable sret(%"struct.btree::btree_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5btree14btree_iteratorIKNS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERKSA_PSF_EC2ERKNS0_ISD_RSA_PSA_EE(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE5beginEv(ptr dead_on_unwind noalias writable sret(%"struct.btree::btree_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EppEi(ptr dead_on_unwind noalias writable sret(%"struct.btree::btree_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb14ChannelService16CloseAllChannelsEb(ptr noundef nonnull align 8 dereferenceable(288) %0, i1 noundef zeroext %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.btree::btree_map", align 8
  %4 = alloca %"struct.btree::btree_iterator", align 8
  %5 = alloca %"struct.btree::btree_iterator.38", align 8
  %6 = alloca %"struct.btree::btree_iterator", align 8
  %7 = alloca %"struct.btree::btree_iterator", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  call void @_ZN5btree9btree_mapIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS3_EELi256EEC2ERKSA_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  invoke void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE5beginEv(ptr dead_on_unwind nonnull writable sret(%"struct.btree::btree_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %.preheader unwind label %30

.preheader:                                       ; preds = %2
  br i1 %1, label %.preheader.split.us, label %.preheader.split

.preheader.split.us:                              ; preds = %.preheader, %19
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  invoke void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE3endEv(ptr dead_on_unwind nonnull writable sret(%"struct.btree::btree_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %9 unwind label %.split.us

9:                                                ; preds = %.preheader.split.us
  call void @_ZN5btree14btree_iteratorIKNS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERKSA_PSF_EC2ERKNS0_ISD_RSA_PSA_EE(ptr noundef nonnull align 8 dereferenceable(12) %5, ptr noundef nonnull align 8 dereferenceable(12) %6)
  %10 = call noundef zeroext i1 @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EneERKNS0_IKSD_RKSA_PSI_EE(ptr noundef nonnull align 8 dereferenceable(12) %4, ptr noundef nonnull align 8 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  br i1 %10, label %11, label %.split10.us

11:                                               ; preds = %9
  %12 = invoke noundef ptr @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EptEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
          to label %13 unwind label %.split12.us

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %12, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = invoke noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256) %15)
          to label %17 unwind label %.split12.us

17:                                               ; preds = %13
  invoke void @_ZN4ardb14ChannelService13DeleteChannelEPNS_7ChannelE(ptr noundef nonnull align 8 dereferenceable(288) %0, ptr noundef nonnull %15)
          to label %18 unwind label %.split12.us

18:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #5
  invoke void @_ZN5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EppEi(ptr dead_on_unwind nonnull writable sret(%"struct.btree::btree_iterator") align 8 %7, ptr noundef nonnull align 8 dereferenceable(12) %4, i32 noundef 0)
          to label %19 unwind label %.split15.us

19:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #5
  br label %.preheader.split.us, !llvm.loop !11

.split.us:                                        ; preds = %.preheader.split.us
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %33

.split12.us:                                      ; preds = %17, %13, %11
  %21 = landingpad { ptr, i32 }
          cleanup
  br label %40

.split15.us:                                      ; preds = %18
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %38

.preheader.split:                                 ; preds = %.preheader, %36
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  invoke void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE3endEv(ptr dead_on_unwind nonnull writable sret(%"struct.btree::btree_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %23 unwind label %.split

23:                                               ; preds = %.preheader.split
  call void @_ZN5btree14btree_iteratorIKNS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERKSA_PSF_EC2ERKNS0_ISD_RSA_PSA_EE(ptr noundef nonnull align 8 dereferenceable(12) %5, ptr noundef nonnull align 8 dereferenceable(12) %6)
  %24 = call noundef zeroext i1 @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EneERKNS0_IKSD_RKSA_PSI_EE(ptr noundef nonnull align 8 dereferenceable(12) %4, ptr noundef nonnull align 8 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  br i1 %24, label %25, label %.split10.us

25:                                               ; preds = %23
  %26 = invoke noundef ptr @_ZNK5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EptEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
          to label %27 unwind label %.split12

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %26, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  invoke void @_ZN4ardb14ChannelService13DeleteChannelEPNS_7ChannelE(ptr noundef nonnull align 8 dereferenceable(288) %0, ptr noundef %29)
          to label %35 unwind label %.split12

30:                                               ; preds = %.split10.us, %2
  %31 = landingpad { ptr, i32 }
          cleanup
  br label %40

.split:                                           ; preds = %.preheader.split
  %32 = landingpad { ptr, i32 }
          cleanup
  br label %33

33:                                               ; preds = %.split.us, %.split
  %.us-phi = phi { ptr, i32 } [ %32, %.split ], [ %20, %.split.us ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  br label %40

.split12:                                         ; preds = %27, %25
  %34 = landingpad { ptr, i32 }
          cleanup
  br label %40

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #5
  invoke void @_ZN5btree14btree_iteratorINS_10btree_nodeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEERSA_PSA_EppEi(ptr dead_on_unwind nonnull writable sret(%"struct.btree::btree_iterator") align 8 %7, ptr noundef nonnull align 8 dereferenceable(12) %4, i32 noundef 0)
          to label %36 unwind label %.split15

36:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #5
  br label %.preheader.split, !llvm.loop !11

.split15:                                         ; preds = %35
  %37 = landingpad { ptr, i32 }
          cleanup
  br label %38

38:                                               ; preds = %.split15.us, %.split15
  %.us-phi16 = phi { ptr, i32 } [ %37, %.split15 ], [ %22, %.split15.us ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #5
  br label %40

.split10.us:                                      ; preds = %23, %9
  invoke void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %39 unwind label %30

39:                                               ; preds = %.split10.us
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  call void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret void

40:                                               ; preds = %.split12, %.split12.us, %38, %33, %30
  %.pn.pn = phi { ptr, i32 } [ %31, %30 ], [ %.us-phi, %33 ], [ %.us-phi16, %38 ], [ %34, %.split12 ], [ %21, %.split12.us ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  call void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  resume { ptr, i32 } %.pn.pn
}

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

declare noundef zeroext i1 @_ZN4ardb7Channel5CloseEv(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5btree15btree_containerINS_5btreeINS_16btree_map_paramsIjPN4ardb7ChannelESt4lessIjESaISt4pairIKjS5_EELi256EEEEEE5clearEv(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 = { 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 #4 = { "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 }

!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 8}
!6 = !{!"_ZTSSt4pairIKjPN4ardb7ChannelEE", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass