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

; 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.std::chrono::duration.265" = type { i64 }
%"class.std::chrono::duration.264" = type { i64 }
%"class.BT::Tree" = type <{ %"class.std::vector.186", %"class.std::unordered_map.16", %"class.std::shared_ptr.191", i16, [6 x i8] }>
%"class.std::vector.186" = type { %"struct.std::_Vector_base.187" }
%"struct.std::_Vector_base.187" = type { %"struct.std::_Vector_base<std::shared_ptr<BT::Tree::Subtree>, std::allocator<std::shared_ptr<BT::Tree::Subtree>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<BT::Tree::Subtree>, std::allocator<std::shared_ptr<BT::Tree::Subtree>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<BT::Tree::Subtree>, std::allocator<std::shared_ptr<BT::Tree::Subtree>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<BT::Tree::Subtree>, std::allocator<std::shared_ptr<BT::Tree::Subtree>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::unordered_map.16" = type { %"class.std::_Hashtable.17" }
%"class.std::_Hashtable.17" = 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::shared_ptr.191" = type { %"class.std::__shared_ptr.192" }
%"class.std::__shared_ptr.192" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZTIN2BT12RuntimeErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.77 = external hidden unnamed_addr constant [11 x i8], align 1

; 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 noundef zeroext i1 @_ZN2BT17isStatusCompletedERKNS_10NodeStatusE(ptr noundef nonnull align 4 dereferenceable(4)) #1

declare ptr @__cxa_allocate_exception(i64)

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN2BT21BehaviorTreeExceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

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

; 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) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2BT4Tree10initializeEv(ptr noundef nonnull align 8 dereferenceable(98)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98)) #2 align 2

declare void @_ZN2BT8TreeNode11resetStatusEv(ptr noundef nonnull align 8 dereferenceable(16)) #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2BT4Tree5sleepENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 8 dereferenceable(98), i64) #4 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2BT12WakeUpSignal7waitForENSt6chrono8durationIlSt5ratioILl1ELl1000000EEEE(ptr noundef nonnull align 8 dereferenceable(89), i64) #4 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2BT4Tree8tickRootENS0_10TickOptionENSt6chrono8durationIlSt5ratioILl1ELl1000EEEE(ptr noundef nonnull align 8 dereferenceable(98) %0, i32 noundef %1, i64 %2) #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::chrono::duration", align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::chrono::duration.265", align 8
  %11 = alloca %"class.std::chrono::duration", align 8
  %12 = alloca i32, align 4
  %13 = alloca %"class.std::chrono::duration.264", align 8
  %14 = alloca %"class.std::chrono::duration", align 8
  %15 = getelementptr inbounds %"class.std::chrono::duration", ptr %4, i32 0, i32 0
  store i64 %2, ptr %15, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  %16 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !11
  %17 = getelementptr inbounds %"class.BT::Tree", ptr %16, i32 0, i32 2
  %18 = call noundef zeroext i1 @_ZNKSt12__shared_ptrIN2BT12WakeUpSignalELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %17) #6
  br i1 %18, label %20, label %19

19:                                               ; preds = %3
  call void @_ZN2BT4Tree10initializeEv(ptr noundef nonnull align 8 dereferenceable(98) %16)
  br label %20

20:                                               ; preds = %19, %3
  %21 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %16)
  %22 = icmp ne ptr %21, null
  br i1 %22, label %30, label %23

23:                                               ; preds = %20
  %24 = call ptr @__cxa_allocate_exception(i64 40) #6
  invoke void @_ZN2BT12RuntimeErrorC2IJA11_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %24, ptr noundef nonnull align 1 dereferenceable(11) @.str.77)
          to label %25 unwind label %26

25:                                               ; preds = %23
  call void @__cxa_throw(ptr %24, ptr @_ZTIN2BT12RuntimeErrorE, ptr @_ZN2BT21BehaviorTreeExceptionD2Ev) #7
  unreachable

26:                                               ; preds = %23
  %27 = landingpad { ptr, i32 }
          cleanup
  %28 = extractvalue { ptr, i32 } %27, 0
  store ptr %28, ptr %8, align 8
  %29 = extractvalue { ptr, i32 } %27, 1
  store i32 %29, ptr %9, align 4
  call void @__cxa_free_exception(ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %87

30:                                               ; preds = %20
  br label %31

31:                                               ; preds = %84, %30
  %32 = load i32, ptr %7, align 4, !tbaa !11
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %42, label %34

34:                                               ; preds = %31
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = icmp eq i32 %35, 2
  br i1 %36, label %37, label %40

37:                                               ; preds = %34
  %38 = load i32, ptr %7, align 4, !tbaa !11
  %39 = icmp eq i32 %38, 1
  br label %40

40:                                               ; preds = %37, %34
  %41 = phi i1 [ false, %34 ], [ %39, %37 ]
  br label %42

42:                                               ; preds = %40, %31
  %43 = phi i1 [ true, %31 ], [ %41, %40 ]
  br i1 %43, label %44, label %85

44:                                               ; preds = %42
  %45 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %16)
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = getelementptr inbounds ptr, ptr %46, i64 2
  %48 = load ptr, ptr %47, align 8
  %49 = call noundef i32 %48(ptr noundef nonnull align 8 dereferenceable(16) %45)
  store i32 %49, ptr %7, align 4, !tbaa !11
  br label %50

50:                                               ; preds = %64, %44
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = icmp ne i32 %51, 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  br i1 %52, label %53, label %62

53:                                               ; preds = %50
  %54 = load i32, ptr %7, align 4, !tbaa !11
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %62

56:                                               ; preds = %53
  %57 = getelementptr inbounds %"class.BT::Tree", ptr %16, i32 0, i32 2
  %58 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN2BT12WakeUpSignalELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %57) #6
  store i32 0, ptr %12, align 4, !tbaa !15
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000EEEC2IivEERKT_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 4 dereferenceable(4) %12)
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000EEEC2IlS1_ILl1ELl1000EEvEERKNS0_IT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %59 = getelementptr inbounds %"class.std::chrono::duration.265", ptr %10, i32 0, i32 0
  %60 = load i64, ptr %59, align 8
  %61 = call noundef zeroext i1 @_ZN2BT12WakeUpSignal7waitForENSt6chrono8durationIlSt5ratioILl1ELl1000000EEEE(ptr noundef nonnull align 8 dereferenceable(89) %58, i64 %60)
  br label %62

62:                                               ; preds = %56, %53, %50
  %63 = phi i1 [ false, %53 ], [ false, %50 ], [ %61, %56 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br i1 %63, label %64, label %70

64:                                               ; preds = %62
  %65 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %16)
  %66 = load ptr, ptr %65, align 8, !tbaa !13
  %67 = getelementptr inbounds ptr, ptr %66, i64 2
  %68 = load ptr, ptr %67, align 8
  %69 = call noundef i32 %68(ptr noundef nonnull align 8 dereferenceable(16) %65)
  store i32 %69, ptr %7, align 4, !tbaa !11
  br label %50, !llvm.loop !17

70:                                               ; preds = %62
  %71 = call noundef zeroext i1 @_ZN2BT17isStatusCompletedERKNS_10NodeStatusE(ptr noundef nonnull align 4 dereferenceable(4) %7)
  br i1 %71, label %72, label %74

72:                                               ; preds = %70
  %73 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %16)
  call void @_ZN2BT8TreeNode11resetStatusEv(ptr noundef nonnull align 8 dereferenceable(16) %73)
  br label %74

74:                                               ; preds = %72, %70
  %75 = load i32, ptr %7, align 4, !tbaa !11
  %76 = icmp eq i32 %75, 1
  br i1 %76, label %77, label %84

77:                                               ; preds = %74
  %78 = call noundef i64 @_ZNKSt6chrono8durationIlSt5ratioILl1ELl1000EEE5countEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %79 = icmp sgt i64 %78, 0
  br i1 %79, label %80, label %84

80:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %4, i64 8, i1 false), !tbaa.struct !19
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEC2IlS1_ILl1ELl1000EEvEERKNS0_IT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %81 = getelementptr inbounds %"class.std::chrono::duration.264", ptr %13, i32 0, i32 0
  %82 = load i64, ptr %81, align 8
  %83 = call noundef zeroext i1 @_ZN2BT4Tree5sleepENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 8 dereferenceable(98) %16, i64 %82)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %84

84:                                               ; preds = %80, %77, %74
  br label %31, !llvm.loop !22

85:                                               ; preds = %42
  %86 = load i32, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  ret i32 %86

87:                                               ; preds = %26
  %88 = load ptr, ptr %8, align 8
  %89 = load i32, ptr %9, align 4
  %90 = insertvalue { ptr, i32 } poison, ptr %88, 0
  %91 = insertvalue { ptr, i32 } %90, i32 %89, 1
  resume { ptr, i32 } %91
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt12__shared_ptrIN2BT12WakeUpSignalELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2BT12RuntimeErrorC2IJA11_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 1 dereferenceable(11)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6chrono8durationIlSt5ratioILl1ELl1000EEE5countEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEC2IlS1_ILl1ELl1000EEvEERKNS0_IT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { "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 #6 = { nounwind }
attributes #7 = { noreturn }

!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 = !{!"_ZTSN2BT4Tree10TickOptionE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN2BT10NodeStatusE", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{i64 0, i64 8, !20}
!20 = !{!21, !21, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = distinct !{!22, !18}


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

%"class.std::chrono::duration" = type { i64 }
%"class.std::chrono::duration.265" = type { i64 }
%"class.std::chrono::duration.264" = type { i64 }

@_ZTIN2BT12RuntimeErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.77 = external hidden unnamed_addr constant [11 x i8], align 1

; 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 noundef zeroext i1 @_ZN2BT17isStatusCompletedERKNS_10NodeStatusE(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_free_exception(ptr) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN2BT21BehaviorTreeExceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2BT4Tree10initializeEv(ptr noundef nonnull align 8 dereferenceable(98)) local_unnamed_addr #3 align 2

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

declare void @_ZN2BT8TreeNode11resetStatusEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 1, 0) i32 @_ZN2BT4Tree8tickRootENS0_10TickOptionENSt6chrono8durationIlSt5ratioILl1ELl1000EEEE(ptr noundef nonnull align 8 dereferenceable(98) %0, i32 noundef %1, i64 %2) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::chrono::duration", align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.std::chrono::duration.265", align 8
  %7 = alloca %"class.std::chrono::duration", align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.std::chrono::duration.264", align 8
  %10 = alloca %"class.std::chrono::duration", align 8
  store i64 %2, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = tail call noundef zeroext i1 @_ZNKSt12__shared_ptrIN2BT12WakeUpSignalELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %11) #5
  br i1 %12, label %14, label %13

13:                                               ; preds = %3
  tail call void @_ZN2BT4Tree10initializeEv(ptr noundef nonnull align 8 dereferenceable(98) %0)
  br label %14

14:                                               ; preds = %13, %3
  %15 = tail call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %0)
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %38, label %.preheader

.preheader:                                       ; preds = %14
  %16 = icmp eq i32 %1, 2
  %.not11 = icmp eq i32 %1, 0
  br i1 %.not11, label %.critedge.us.us, label %.critedge

.critedge.us.us:                                  ; preds = %.preheader, %35
  %17 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %0)
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load ptr, ptr %19, align 8
  %21 = call noundef i32 %20(ptr noundef nonnull align 8 dereferenceable(16) %17)
  store i32 %21, ptr %5, align 4, !tbaa !5
  %22 = call noundef zeroext i1 @_ZN2BT17isStatusCompletedERKNS_10NodeStatusE(ptr noundef nonnull align 4 dereferenceable(4) %5)
  br i1 %22, label %23, label %25

23:                                               ; preds = %.critedge.us.us
  %24 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %0)
  call void @_ZN2BT8TreeNode11resetStatusEv(ptr noundef nonnull align 8 dereferenceable(16) %24)
  br label %25

25:                                               ; preds = %23, %.critedge.us.us
  %26 = load i32, ptr %5, align 4
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %28, label %35

28:                                               ; preds = %25
  %29 = call noundef i64 @_ZNKSt6chrono8durationIlSt5ratioILl1ELl1000EEE5countEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %30 = icmp sgt i64 %29, 0
  br i1 %30, label %31, label %thread-pre-split

31:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  %32 = load i64, ptr %4, align 8, !tbaa !11
  store i64 %32, ptr %10, align 8, !tbaa !11
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEC2IlS1_ILl1ELl1000EEvEERKNS0_IT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %33 = load i64, ptr %9, align 8
  %34 = call noundef zeroext i1 @_ZN2BT4Tree5sleepENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 8 dereferenceable(98) %0, i64 %33)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %28, %31
  %.pr = load i32, ptr %5, align 4
  br label %35

35:                                               ; preds = %thread-pre-split, %25
  %36 = phi i32 [ %.pr, %thread-pre-split ], [ %26, %25 ]
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %.critedge.us.us, label %.split.us, !llvm.loop !13

38:                                               ; preds = %14
  %39 = tail call ptr @__cxa_allocate_exception(i64 40) #5
  invoke void @_ZN2BT12RuntimeErrorC2IJA11_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %39, ptr noundef nonnull align 1 dereferenceable(11) @.str.77)
          to label %40 unwind label %41

40:                                               ; preds = %38
  tail call void @__cxa_throw(ptr nonnull %39, ptr nonnull @_ZTIN2BT12RuntimeErrorE, ptr nonnull @_ZN2BT21BehaviorTreeExceptionD2Ev) #6
  unreachable

41:                                               ; preds = %38
  %42 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %39) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  resume { ptr, i32 } %42

.critedge:                                        ; preds = %.preheader, %.preheader.split
  %43 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %0)
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  %46 = load ptr, ptr %45, align 8
  %47 = call noundef i32 %46(ptr noundef nonnull align 8 dereferenceable(16) %43)
  store i32 %47, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  %48 = icmp eq i32 %47, 1
  br i1 %48, label %.lr.ph, label %.critedge3

.lr.ph:                                           ; preds = %.critedge, %52
  %49 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN2BT12WakeUpSignalELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %11) #5
  store i32 0, ptr %8, align 4, !tbaa !15
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000EEEC2IivEERKT_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000EEEC2IlS1_ILl1ELl1000EEvEERKNS0_IT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %50 = load i64, ptr %6, align 8
  %51 = call noundef zeroext i1 @_ZN2BT12WakeUpSignal7waitForENSt6chrono8durationIlSt5ratioILl1ELl1000000EEEE(ptr noundef nonnull align 8 dereferenceable(89) %49, i64 %50)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br i1 %51, label %52, label %.loopexit.split

52:                                               ; preds = %.lr.ph
  %53 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %0)
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds i8, ptr %54, i64 16
  %56 = load ptr, ptr %55, align 8
  %57 = call noundef i32 %56(ptr noundef nonnull align 8 dereferenceable(16) %53)
  store i32 %57, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  %58 = icmp eq i32 %57, 1
  br i1 %58, label %.lr.ph, label %.critedge3, !llvm.loop !17

.critedge3:                                       ; preds = %52, %.critedge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %.loopexit.split

.loopexit.split:                                  ; preds = %.lr.ph, %.critedge3
  %59 = call noundef zeroext i1 @_ZN2BT17isStatusCompletedERKNS_10NodeStatusE(ptr noundef nonnull align 4 dereferenceable(4) %5)
  br i1 %59, label %60, label %62

60:                                               ; preds = %.loopexit.split
  %61 = call noundef ptr @_ZNK2BT4Tree8rootNodeEv(ptr noundef nonnull align 8 dereferenceable(98) %0)
  call void @_ZN2BT8TreeNode11resetStatusEv(ptr noundef nonnull align 8 dereferenceable(16) %61)
  br label %62

62:                                               ; preds = %60, %.loopexit.split
  %63 = load i32, ptr %5, align 4
  %64 = icmp eq i32 %63, 1
  br i1 %64, label %65, label %.preheader.split

65:                                               ; preds = %62
  %66 = call noundef i64 @_ZNKSt6chrono8durationIlSt5ratioILl1ELl1000EEE5countEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %67 = icmp sgt i64 %66, 0
  br i1 %67, label %68, label %.preheader.split

68:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  %69 = load i64, ptr %4, align 8, !tbaa !11
  store i64 %69, ptr %10, align 8, !tbaa !11
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEC2IlS1_ILl1ELl1000EEvEERKNS0_IT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %70 = load i64, ptr %9, align 8
  %71 = call noundef zeroext i1 @_ZN2BT4Tree5sleepENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE(ptr noundef nonnull align 8 dereferenceable(98) %0, i64 %70)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  br label %.preheader.split

.preheader.split:                                 ; preds = %68, %65, %62
  %.pre = load i32, ptr %5, align 4
  %72 = icmp eq i32 %.pre, 0
  %73 = icmp eq i32 %.pre, 1
  %74 = and i1 %16, %73
  %or.cond = or i1 %72, %74
  br i1 %or.cond, label %.critedge, label %.split.us, !llvm.loop !13

.split.us:                                        ; preds = %.preheader.split, %35
  %.us-phi = phi i32 [ %36, %35 ], [ %.pre, %.preheader.split ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  ret i32 %.us-phi
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt12__shared_ptrIN2BT12WakeUpSignalELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2BT12RuntimeErrorC2IJA11_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 1 dereferenceable(11)) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEC2IlS1_ILl1ELl1000EEvEERKNS0_IT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 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 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 = { 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 #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 }
attributes #6 = { noreturn }

!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 = !{!"_ZTSN2BT10NodeStatusE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !14}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass