; 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.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 }
%"struct.BT::Tree::Subtree" = type { %"class.std::vector.250", %"class.std::shared_ptr.140", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string" }
%"class.std::vector.250" = type { %"struct.std::_Vector_base.251" }
%"struct.std::_Vector_base.251" = type { %"struct.std::_Vector_base<std::shared_ptr<BT::TreeNode>, std::allocator<std::shared_ptr<BT::TreeNode>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<BT::TreeNode>, std::allocator<std::shared_ptr<BT::TreeNode>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<BT::TreeNode>, std::allocator<std::shared_ptr<BT::TreeNode>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<BT::TreeNode>, std::allocator<std::shared_ptr<BT::TreeNode>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::shared_ptr.140" = type { %"class.std::__shared_ptr.141" }
%"class.std::__shared_ptr.141" = type { ptr, %"class.std::__shared_count" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str.78 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [82 x i8], align 1
@__PRETTY_FUNCTION__._ZN2BT17BlackboardRestoreERKSt6vectorISt10shared_ptrINS_10BlackboardEESaIS3_EERNS_4TreeE = external hidden unnamed_addr constant [73 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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2BT17BlackboardRestoreERKSt6vectorISt10shared_ptrINS_10BlackboardEESaIS3_EERNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(98) %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2BT10BlackboardEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %"class.BT::Tree", ptr %8, i32 0, i32 0
  %10 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #5
  %11 = icmp eq i64 %7, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %15

13:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.78, ptr noundef @.str.79, i32 noundef 609, ptr noundef @__PRETTY_FUNCTION__._ZN2BT17BlackboardRestoreERKSt6vectorISt10shared_ptrINS_10BlackboardEESaIS3_EERNS_4TreeE) #6
  unreachable

14:                                               ; No predecessors!
  br label %15

15:                                               ; preds = %14, %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %35, %15
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.BT::Tree", ptr %18, i32 0, i32 0
  %20 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #5
  %21 = icmp ult i64 %17, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %38

23:                                               ; preds = %16
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i64, ptr %5, align 8, !tbaa !9
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN2BT10BlackboardEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %25) #5
  %27 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN2BT10BlackboardELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %26) #5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.BT::Tree", ptr %28, i32 0, i32 0
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %30) #5
  %32 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN2BT4Tree7SubtreeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %31) #5
  %33 = getelementptr inbounds %"struct.BT::Tree::Subtree", ptr %32, i32 0, i32 1
  %34 = call noundef nonnull align 8 dereferenceable(217) ptr @_ZNKSt19__shared_ptr_accessIN2BT10BlackboardELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEdeEv(ptr noundef nonnull align 1 dereferenceable(1) %33) #5
  call void @_ZNK2BT10Blackboard9cloneIntoERS0_(ptr noundef nonnull align 8 dereferenceable(217) %27, ptr noundef nonnull align 8 dereferenceable(217) %34)
  br label %35

35:                                               ; preds = %23
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = add i64 %36, 1
  store i64 %37, ptr %5, align 8, !tbaa !9
  br label %16, !llvm.loop !11

38:                                               ; preds = %22
  ret void
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN2BT10BlackboardEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

declare void @_ZNK2BT10Blackboard9cloneIntoERS0_(ptr noundef nonnull align 8 dereferenceable(217), ptr noundef nonnull align 8 dereferenceable(217)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { noreturn nounwind "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 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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str.78 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [82 x i8], align 1
@__PRETTY_FUNCTION__._ZN2BT17BlackboardRestoreERKSt6vectorISt10shared_ptrINS_10BlackboardEESaIS3_EERNS_4TreeE = external hidden unnamed_addr constant [73 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2BT17BlackboardRestoreERKSt6vectorISt10shared_ptrINS_10BlackboardEESaIS3_EERNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(98) %1) local_unnamed_addr #1 {
  %3 = tail call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2BT10BlackboardEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %4 = tail call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %5 = icmp eq i64 %3, %4
  br i1 %5, label %.preheader, label %7

.preheader:                                       ; preds = %2
  %6 = tail call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

7:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.78, ptr noundef nonnull @.str.79, i32 noundef 609, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2BT17BlackboardRestoreERKSt6vectorISt10shared_ptrINS_10BlackboardEESaIS3_EERNS_4TreeE) #5
  unreachable

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

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.08 = phi i64 [ %14, %.lr.ph ], [ 0, %.preheader ]
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN2BT10BlackboardEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.08) #4
  %9 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN2BT10BlackboardELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %8) #4
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.08) #4
  %11 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN2BT4Tree7SubtreeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %10) #4
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  %13 = tail call noundef nonnull align 8 dereferenceable(217) ptr @_ZNKSt19__shared_ptr_accessIN2BT10BlackboardELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEdeEv(ptr noundef nonnull align 1 dereferenceable(1) %12) #4
  tail call void @_ZNK2BT10Blackboard9cloneIntoERS0_(ptr noundef nonnull align 8 dereferenceable(217) %9, ptr noundef nonnull align 8 dereferenceable(217) %13)
  %14 = add nuw i64 %.08, 1
  %15 = tail call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !5
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN2BT10BlackboardEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

declare void @_ZNK2BT10Blackboard9cloneIntoERS0_(ptr noundef nonnull align 8 dereferenceable(217), ptr noundef nonnull align 8 dereferenceable(217)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt10shared_ptrIN2BT4Tree7SubtreeEESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

attributes #0 = { 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 #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 = { noreturn nounwind "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 }
attributes #5 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass