; LLVM IR from BehaviorTree/BehaviorTree.CPP :: src/loggers (bt_observer)

; 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.std::chrono::duration" = type { i64 }
%"class.BT::TreeObserver" = type { %"class.BT::StatusChangeLogger", %"class.std::unordered_map", %"class.std::unordered_map.11", %"class.std::map" }
%"class.BT::StatusChangeLogger" = type { ptr, i8, i8, %"class.std::vector", i32, %"class.std::chrono::time_point", %"class.std::mutex" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::shared_ptr<std::function<void (std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, const BT::TreeNode &, BT::NodeStatus, BT::NodeStatus)>>, std::allocator<std::shared_ptr<std::function<void (std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, const BT::TreeNode &, BT::NodeStatus, BT::NodeStatus)>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<std::function<void (std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, const BT::TreeNode &, BT::NodeStatus, BT::NodeStatus)>>, std::allocator<std::shared_ptr<std::function<void (std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, const BT::TreeNode &, BT::NodeStatus, BT::NodeStatus)>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<std::function<void (std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, const BT::TreeNode &, BT::NodeStatus, BT::NodeStatus)>>, std::allocator<std::shared_ptr<std::function<void (std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, const BT::TreeNode &, BT::NodeStatus, BT::NodeStatus)>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<std::function<void (std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, const BT::TreeNode &, BT::NodeStatus, BT::NodeStatus)>>, std::allocator<std::shared_ptr<std::function<void (std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>, const BT::TreeNode &, BT::NodeStatus, BT::NodeStatus)>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::unordered_map.11" = type { %"class.std::_Hashtable.12" }
%"class.std::_Hashtable.12" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned short, std::pair<const unsigned short, std::__cxx11::basic_string<char>>, std::_Select1st<std::pair<const unsigned short, std::__cxx11::basic_string<char>>>, std::less<unsigned short>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned short, std::pair<const unsigned short, std::__cxx11::basic_string<char>>, std::_Select1st<std::pair<const unsigned short, std::__cxx11::basic_string<char>>>, std::less<unsigned short>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.BT::TreeObserver::NodeStatistics" = type { i32, i32, i32, i32, i32, i32, %"class.std::chrono::duration" }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2BT12TreeObserver8callbackENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEERKNS_8TreeNodeENS_10NodeStatusES9_(ptr noundef nonnull align 8 dereferenceable(256) %0, i64 %1, ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %3, i32 noundef %4) unnamed_addr #2 align 2 {
  %6 = alloca %"class.std::chrono::duration", align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i16, align 2
  %13 = alloca i32, align 4
  %14 = getelementptr inbounds %"class.std::chrono::duration", ptr %6, i32 0, i32 0
  store i64 %1, ptr %14, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %15 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %16 = getelementptr inbounds %"class.BT::TreeObserver", ptr %15, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #4
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = call noundef zeroext i16 @_ZNK2BT8TreeNode3UIDEv(ptr noundef nonnull align 8 dereferenceable(16) %17)
  store i16 %18, ptr %12, align 2, !tbaa !11
  %19 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt13unordered_mapItN2BT12TreeObserver14NodeStatisticsESt4hashItESt8equal_toItESaISt4pairIKtS2_EEEixEOt(ptr noundef nonnull align 8 dereferenceable(56) %16, ptr noundef nonnull align 2 dereferenceable(2) %12)
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #4
  store ptr %19, ptr %11, align 8, !tbaa !5
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.BT::TreeObserver::NodeStatistics", ptr %21, i32 0, i32 1
  store i32 %20, ptr %22, align 4, !tbaa !13
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.BT::TreeObserver::NodeStatistics", ptr %23, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %24, ptr align 8 %6, i64 8, i1 false), !tbaa.struct !18
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %5
  store i32 1, ptr %13, align 4
  br label %65

28:                                               ; preds = %5
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.BT::TreeObserver::NodeStatistics", ptr %29, i32 0, i32 2
  %31 = load i32, ptr %30, align 8, !tbaa !20
  %32 = add i32 %31, 1
  store i32 %32, ptr %30, align 8, !tbaa !20
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 2
  br i1 %34, label %35, label %43

35:                                               ; preds = %28
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.BT::TreeObserver::NodeStatistics", ptr %37, i32 0, i32 0
  store i32 %36, ptr %38, align 8, !tbaa !21
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.BT::TreeObserver::NodeStatistics", ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 4, !tbaa !22
  %42 = add i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !22
  br label %64

43:                                               ; preds = %28
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = icmp eq i32 %44, 3
  br i1 %45, label %46, label %54

46:                                               ; preds = %43
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.BT::TreeObserver::NodeStatistics", ptr %48, i32 0, i32 0
  store i32 %47, ptr %49, align 8, !tbaa !21
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.BT::TreeObserver::NodeStatistics", ptr %50, i32 0, i32 4
  %52 = load i32, ptr %51, align 8, !tbaa !23
  %53 = add i32 %52, 1
  store i32 %53, ptr %51, align 8, !tbaa !23
  br label %63

54:                                               ; preds = %43
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = icmp eq i32 %55, 4
  br i1 %56, label %57, label %62

57:                                               ; preds = %54
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.BT::TreeObserver::NodeStatistics", ptr %58, i32 0, i32 5
  %60 = load i32, ptr %59, align 4, !tbaa !24
  %61 = add i32 %60, 1
  store i32 %61, ptr %59, align 4, !tbaa !24
  br label %62

62:                                               ; preds = %57, %54
  br label %63

63:                                               ; preds = %62, %46
  br label %64

64:                                               ; preds = %63, %35
  store i32 0, ptr %13, align 4
  br label %65

65:                                               ; preds = %64, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %66 = load i32, ptr %13, align 4
  switch i32 %66, label %68 [
    i32 0, label %67
    i32 1, label %67
  ]

67:                                               ; preds = %65, %65
  ret void

68:                                               ; preds = %65
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt13unordered_mapItN2BT12TreeObserver14NodeStatisticsESt4hashItESt8equal_toItESaISt4pairIKtS2_EEEixEOt(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 2 dereferenceable(2)) #2 align 2

declare noundef zeroext i16 @_ZNK2BT8TreeNode3UIDEv(ptr noundef nonnull align 8 dereferenceable(16)) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 = !{!"_ZTSN2BT10NodeStatusE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !10, i64 4}
!14 = !{!"_ZTSN2BT12TreeObserver14NodeStatisticsE", !10, i64 0, !10, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !16, i64 24}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE", !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{i64 0, i64 8, !19}
!19 = !{!17, !17, i64 0}
!20 = !{!14, !15, i64 8}
!21 = !{!14, !10, i64 0}
!22 = !{!14, !15, i64 12}
!23 = !{!14, !15, i64 16}
!24 = !{!14, !15, i64 20}


; 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: mustprogress uwtable
define dso_local void @_ZN2BT12TreeObserver8callbackENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEERKNS_8TreeNodeENS_10NodeStatusES9_(ptr noundef nonnull align 8 dereferenceable(256) %0, i64 %1, ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %3, i32 noundef %4) unnamed_addr #1 align 2 {
  %6 = alloca i16, align 2
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %6) #3
  %8 = tail call noundef zeroext i16 @_ZNK2BT8TreeNode3UIDEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  store i16 %8, ptr %6, align 2, !tbaa !5
  %9 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt13unordered_mapItN2BT12TreeObserver14NodeStatisticsESt4hashItESt8equal_toItESaISt4pairIKtS2_EEEixEOt(ptr noundef nonnull align 8 dereferenceable(56) %7, ptr noundef nonnull align 2 dereferenceable(2) %6)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %6) #3
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  store i32 %4, ptr %10, align 4, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %9, i64 24
  store i64 %1, ptr %11, align 8, !tbaa !15
  %12 = icmp eq i32 %4, 0
  br i1 %12, label %29, label %13

13:                                               ; preds = %5
  %14 = getelementptr inbounds i8, ptr %9, i64 8
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = add i32 %15, 1
  store i32 %16, ptr %14, align 8, !tbaa !16
  switch i32 %4, label %29 [
    i32 2, label %17
    i32 3, label %21
    i32 4, label %25
  ]

17:                                               ; preds = %13
  store i32 2, ptr %9, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %9, i64 12
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = add i32 %19, 1
  store i32 %20, ptr %18, align 4, !tbaa !18
  br label %29

21:                                               ; preds = %13
  store i32 3, ptr %9, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %9, i64 16
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %24 = add i32 %23, 1
  store i32 %24, ptr %22, align 8, !tbaa !19
  br label %29

25:                                               ; preds = %13
  %26 = getelementptr inbounds i8, ptr %9, i64 20
  %27 = load i32, ptr %26, align 4, !tbaa !20
  %28 = add i32 %27, 1
  store i32 %28, ptr %26, align 4, !tbaa !20
  br label %29

29:                                               ; preds = %17, %25, %21, %13, %5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt13unordered_mapItN2BT12TreeObserver14NodeStatisticsESt4hashItESt8equal_toItESaISt4pairIKtS2_EEEixEOt(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 2 dereferenceable(2)) local_unnamed_addr #1 align 2

declare noundef zeroext i16 @_ZNK2BT8TreeNode3UIDEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"_ZTSN2BT12TreeObserver14NodeStatisticsE", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !13, i64 24}
!11 = !{!"_ZTSN2BT10NodeStatusE", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE", !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!10, !12, i64 8}
!17 = !{!10, !11, i64 0}
!18 = !{!10, !12, i64 12}
!19 = !{!10, !12, i64 16}
!20 = !{!10, !12, i64 20}


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