; LLVM IR from BehaviorTree/BehaviorTree.CPP :: src/controls/fallback_node.ll (ZN2BT12FallbackNode4tickEv)

; 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::ControlNode" = type { %"class.BT::TreeNode", %"class.std::vector" }
%"class.BT::TreeNode" = type { ptr, %"class.std::unique_ptr" }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<BT::TreeNode *, std::allocator<BT::TreeNode *>>::_Vector_impl" }
%"struct.std::_Vector_base<BT::TreeNode *, std::allocator<BT::TreeNode *>>::_Vector_impl" = type { %"struct.std::_Vector_base<BT::TreeNode *, std::allocator<BT::TreeNode *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<BT::TreeNode *, std::allocator<BT::TreeNode *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.BT::FallbackNode" = type <{ %"class.BT::ControlNode", i64, i64, i8, [7 x i8] }>

@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [37 x i8], align 1
@_ZTIN2BT10LogicErrorE = external dso_local constant { ptr, ptr, ptr }, align 8

; 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: mustprogress uwtable
define dso_local noundef i32 @_ZN2BT12FallbackNode4tickEv(ptr noundef nonnull align 8 dereferenceable(57) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %12 = getelementptr inbounds %"class.BT::ControlNode", ptr %11, i32 0, i32 1
  %13 = call noundef i64 @_ZNKSt6vectorIPN2BT8TreeNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #5
  store i64 %13, ptr %4, align 8, !tbaa !9
  %14 = call noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %1
  %17 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 2
  store i64 0, ptr %17, align 8, !tbaa !11
  br label %18

18:                                               ; preds = %16, %1
  call void @_ZN2BT8TreeNode9setStatusENS_10NodeStatusE(ptr noundef nonnull align 8 dereferenceable(16) %11, i32 noundef 1)
  br label %19

19:                                               ; preds = %81, %18
  %20 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !26
  %22 = load i64, ptr %4, align 8, !tbaa !9
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %24, label %82

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %25 = getelementptr inbounds %"class.BT::ControlNode", ptr %11, i32 0, i32 1
  %26 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 1
  %27 = load i64, ptr %26, align 8, !tbaa !26
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN2BT8TreeNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %27) #5
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  store ptr %29, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16) %30)
  store i32 %31, ptr %6, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %32, align 8, !tbaa !29
  %34 = getelementptr inbounds ptr, ptr %33, i64 2
  %35 = load ptr, ptr %34, align 8
  %36 = call noundef i32 %35(ptr noundef nonnull align 8 dereferenceable(16) %32)
  store i32 %36, ptr %7, align 4, !tbaa !27
  %37 = load i32, ptr %7, align 4, !tbaa !27
  switch i32 %37, label %78 [
    i32 1, label %38
    i32 2, label %40
    i32 3, label %43
    i32 4, label %62
    i32 0, label %69
  ]

38:                                               ; preds = %24
  %39 = load i32, ptr %7, align 4, !tbaa !27
  store i32 %39, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %79

40:                                               ; preds = %24
  call void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40) %11)
  %41 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 1
  store i64 0, ptr %41, align 8, !tbaa !26
  %42 = load i32, ptr %7, align 4, !tbaa !27
  store i32 %42, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %79

43:                                               ; preds = %24
  %44 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !26
  %46 = add i64 %45, 1
  store i64 %46, ptr %44, align 8, !tbaa !26
  %47 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 3
  %48 = load i8, ptr %47, align 8, !tbaa !31, !range !32, !noundef !33
  %49 = trunc i8 %48 to i1
  br i1 %49, label %50, label %61

50:                                               ; preds = %43
  %51 = call noundef zeroext i1 @_ZNK2BT8TreeNode14requiresWakeUpEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  br i1 %51, label %52, label %61

52:                                               ; preds = %50
  %53 = load i32, ptr %6, align 4, !tbaa !27
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %52
  %56 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !26
  %58 = load i64, ptr %4, align 8, !tbaa !9
  %59 = icmp ult i64 %57, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  call void @_ZN2BT8TreeNode16emitWakeUpSignalEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %79

61:                                               ; preds = %55, %52, %50, %43
  br label %78

62:                                               ; preds = %24
  %63 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !26
  %65 = add i64 %64, 1
  store i64 %65, ptr %63, align 8, !tbaa !26
  %66 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 2
  %67 = load i64, ptr %66, align 8, !tbaa !11
  %68 = add i64 %67, 1
  store i64 %68, ptr %66, align 8, !tbaa !11
  br label %78

69:                                               ; preds = %24
  %70 = call ptr @__cxa_allocate_exception(i64 40) #5
  %71 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK2BT8TreeNode4nameB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(16) %11)
          to label %72 unwind label %74

72:                                               ; preds = %69
  invoke void @_ZN2BT10LogicErrorC2IJA2_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEA37_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %70, ptr noundef nonnull align 1 dereferenceable(2) @.str.13, ptr noundef nonnull align 8 dereferenceable(32) %71, ptr noundef nonnull align 1 dereferenceable(37) @.str.14)
          to label %73 unwind label %74

73:                                               ; preds = %72
  call void @__cxa_throw(ptr %70, ptr @_ZTIN2BT10LogicErrorE, ptr @_ZN2BT21BehaviorTreeExceptionD2Ev) #6
  unreachable

74:                                               ; preds = %72, %69
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %9, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %10, align 4
  call void @__cxa_free_exception(ptr %70) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %98

78:                                               ; preds = %62, %61, %24
  store i32 0, ptr %8, align 4
  br label %79

79:                                               ; preds = %78, %60, %40, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %80 = load i32, ptr %8, align 4
  switch i32 %80, label %96 [
    i32 0, label %81
  ]

81:                                               ; preds = %79
  br label %19, !llvm.loop !34

82:                                               ; preds = %19
  %83 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 1
  %84 = load i64, ptr %83, align 8, !tbaa !26
  %85 = load i64, ptr %4, align 8, !tbaa !9
  %86 = icmp eq i64 %84, %85
  br i1 %86, label %87, label %89

87:                                               ; preds = %82
  call void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40) %11)
  %88 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 1
  store i64 0, ptr %88, align 8, !tbaa !26
  br label %89

89:                                               ; preds = %87, %82
  %90 = getelementptr inbounds %"class.BT::FallbackNode", ptr %11, i32 0, i32 2
  %91 = load i64, ptr %90, align 8, !tbaa !11
  %92 = load i64, ptr %4, align 8, !tbaa !9
  %93 = icmp eq i64 %91, %92
  %94 = zext i1 %93 to i64
  %95 = select i1 %93, i32 4, i32 3
  store i32 %95, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %96

96:                                               ; preds = %89, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %97 = load i32, ptr %2, align 4
  ret i32 %97

98:                                               ; preds = %74
  %99 = load ptr, ptr %9, align 8
  %100 = load i32, ptr %10, align 4
  %101 = insertvalue { ptr, i32 } poison, ptr %99, 0
  %102 = insertvalue { ptr, i32 } %101, i32 %100, 1
  resume { ptr, i32 } %102
}

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

declare noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16)) #3

declare void @_ZN2BT8TreeNode9setStatusENS_10NodeStatusE(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #3

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

declare void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40)) #3

declare noundef zeroext i1 @_ZNK2BT8TreeNode14requiresWakeUpEv(ptr noundef nonnull align 8 dereferenceable(16)) #3

declare void @_ZN2BT8TreeNode16emitWakeUpSignalEv(ptr noundef nonnull align 8 dereferenceable(16)) #3

declare ptr @__cxa_allocate_exception(i64)

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNK2BT8TreeNode4nameB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(16)) #3

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

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 #4 align 2

attributes #0 = { 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 = { 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 = { "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 = { 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 #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 = !{!"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 = !{!12, !10, i64 48}
!12 = !{!"_ZTSN2BT12FallbackNodeE", !13, i64 0, !10, i64 40, !10, i64 48, !25, i64 56}
!13 = !{!"_ZTSN2BT11ControlNodeE", !14, i64 0, !21, i64 16}
!14 = !{!"_ZTSN2BT8TreeNodeE", !15, i64 8}
!15 = !{!"_ZTSSt10unique_ptrIN2BT8TreeNode5PImplESt14default_deleteIS2_EE", !16, i64 0}
!16 = !{!"_ZTSSt15__uniq_ptr_dataIN2BT8TreeNode5PImplESt14default_deleteIS2_ELb1ELb1EE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_implIN2BT8TreeNode5PImplESt14default_deleteIS2_EE", !18, i64 0}
!18 = !{!"_ZTSSt5tupleIJPN2BT8TreeNode5PImplESt14default_deleteIS2_EEE", !19, i64 0}
!19 = !{!"_ZTSSt11_Tuple_implILm0EJPN2BT8TreeNode5PImplESt14default_deleteIS2_EEE", !20, i64 0}
!20 = !{!"_ZTSSt10_Head_baseILm0EPN2BT8TreeNode5PImplELb0EE", !6, i64 0}
!21 = !{!"_ZTSSt6vectorIPN2BT8TreeNodeESaIS2_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseIPN2BT8TreeNodeESaIS2_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIPN2BT8TreeNodeESaIS2_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIPN2BT8TreeNodeESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!"bool", !7, i64 0}
!26 = !{!12, !10, i64 40}
!27 = !{!28, !28, i64 0}
!28 = !{!"_ZTSN2BT10NodeStatusE", !7, i64 0}
!29 = !{!30, !30, i64 0}
!30 = !{!"vtable pointer", !8, i64 0}
!31 = !{!12, !25, i64 56}
!32 = !{i8 0, i8 2}
!33 = !{}
!34 = distinct !{!34, !35}
!35 = !{!"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.13 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [37 x i8], align 1
@_ZTIN2BT10LogicErrorE = external dso_local constant { ptr, ptr, ptr }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2BT12FallbackNode4tickEv(ptr noundef nonnull align 8 dereferenceable(57) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = tail call noundef i64 @_ZNKSt6vectorIPN2BT8TreeNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #4
  %4 = tail call noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %8

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %6, %1
  tail call void @_ZN2BT8TreeNode9setStatusENS_10NodeStatusE(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 1)
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = load i64, ptr %9, align 8, !tbaa !24
  %11 = icmp ult i64 %10, %3
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  br label %13

13:                                               ; preds = %.lr.ph, %45
  %14 = phi i64 [ %10, %.lr.ph ], [ %46, %45 ]
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN2BT8TreeNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %14) #4
  %16 = load ptr, ptr %15, align 8, !tbaa !25
  %17 = tail call noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16) %16)
  %18 = load ptr, ptr %16, align 8, !tbaa !26
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load ptr, ptr %19, align 8
  %21 = tail call noundef i32 %20(ptr noundef nonnull align 8 dereferenceable(16) %16)
  switch i32 %21, label %._crit_edge37 [
    i32 1, label %.thread
    i32 2, label %22
    i32 3, label %23
    i32 4, label %34
    i32 0, label %38
  ]

._crit_edge37:                                    ; preds = %13
  %.pre = load i64, ptr %9, align 8, !tbaa !24
  br label %45

22:                                               ; preds = %13
  tail call void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  store i64 0, ptr %9, align 8, !tbaa !24
  br label %.thread

23:                                               ; preds = %13
  %24 = load i64, ptr %9, align 8, !tbaa !24
  %25 = add i64 %24, 1
  store i64 %25, ptr %9, align 8, !tbaa !24
  %26 = load i8, ptr %12, align 8, !tbaa !28, !range !29, !noundef !30
  %27 = trunc nuw i8 %26 to i1
  br i1 %27, label %28, label %45

28:                                               ; preds = %23
  %29 = tail call noundef zeroext i1 @_ZNK2BT8TreeNode14requiresWakeUpEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %30 = icmp eq i32 %17, 0
  %or.cond = and i1 %30, %29
  %31 = load i64, ptr %9, align 8
  %32 = icmp ult i64 %31, %3
  %or.cond23 = select i1 %or.cond, i1 %32, i1 false
  br i1 %or.cond23, label %33, label %45

33:                                               ; preds = %28
  tail call void @_ZN2BT8TreeNode16emitWakeUpSignalEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  br label %.thread

34:                                               ; preds = %13
  %35 = load <2 x i64>, ptr %9, align 8, !tbaa !31
  %36 = add <2 x i64> %35, <i64 1, i64 1>
  store <2 x i64> %36, ptr %9, align 8, !tbaa !31
  %37 = extractelement <2 x i64> %36, i64 0
  br label %45

38:                                               ; preds = %13
  %39 = tail call ptr @__cxa_allocate_exception(i64 40) #4
  %40 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK2BT8TreeNode4nameB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(16) %0)
          to label %41 unwind label %43

41:                                               ; preds = %38
  invoke void @_ZN2BT10LogicErrorC2IJA2_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEA37_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %39, ptr noundef nonnull align 1 dereferenceable(2) @.str.13, ptr noundef nonnull align 8 dereferenceable(32) %40, ptr noundef nonnull align 1 dereferenceable(37) @.str.14)
          to label %42 unwind label %43

42:                                               ; preds = %41
  tail call void @__cxa_throw(ptr nonnull %39, ptr nonnull @_ZTIN2BT10LogicErrorE, ptr nonnull @_ZN2BT21BehaviorTreeExceptionD2Ev) #5
  unreachable

43:                                               ; preds = %41, %38
  %44 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %39) #4
  resume { ptr, i32 } %44

45:                                               ; preds = %._crit_edge37, %34, %28, %23
  %46 = phi i64 [ %.pre, %._crit_edge37 ], [ %37, %34 ], [ %31, %28 ], [ %25, %23 ]
  %47 = icmp ult i64 %46, %3
  br i1 %47, label %13, label %._crit_edge, !llvm.loop !32

._crit_edge:                                      ; preds = %45, %8
  %.lcssa = phi i64 [ %10, %8 ], [ %46, %45 ]
  %48 = icmp eq i64 %.lcssa, %3
  br i1 %48, label %49, label %50

49:                                               ; preds = %._crit_edge
  tail call void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  store i64 0, ptr %9, align 8, !tbaa !24
  br label %50

50:                                               ; preds = %49, %._crit_edge
  %51 = getelementptr inbounds i8, ptr %0, i64 48
  %52 = load i64, ptr %51, align 8, !tbaa !5
  %53 = icmp eq i64 %52, %3
  %54 = select i1 %53, i32 4, i32 3
  br label %.thread

.thread:                                          ; preds = %13, %22, %33, %50
  %.2 = phi i32 [ %54, %50 ], [ 2, %22 ], [ 1, %33 ], [ %21, %13 ]
  ret i32 %.2
}

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

declare noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

declare void @_ZN2BT8TreeNode9setStatusENS_10NodeStatusE(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #2

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

declare void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2

declare noundef zeroext i1 @_ZNK2BT8TreeNode14requiresWakeUpEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

declare void @_ZN2BT8TreeNode16emitWakeUpSignalEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNK2BT8TreeNode4nameB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2BT10LogicErrorC2IJA2_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEA37_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 1 dereferenceable(2), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 1 dereferenceable(37)) unnamed_addr #0 align 2

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 #3 align 2

attributes #0 = { 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 #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 = { "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 = { 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 #4 = { nounwind }
attributes #5 = { 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, !22, i64 48}
!6 = !{!"_ZTSN2BT12FallbackNodeE", !7, i64 0, !22, i64 40, !22, i64 48, !23, i64 56}
!7 = !{!"_ZTSN2BT11ControlNodeE", !8, i64 0, !18, i64 16}
!8 = !{!"_ZTSN2BT8TreeNodeE", !9, i64 8}
!9 = !{!"_ZTSSt10unique_ptrIN2BT8TreeNode5PImplESt14default_deleteIS2_EE", !10, i64 0}
!10 = !{!"_ZTSSt15__uniq_ptr_dataIN2BT8TreeNode5PImplESt14default_deleteIS2_ELb1ELb1EE", !11, i64 0}
!11 = !{!"_ZTSSt15__uniq_ptr_implIN2BT8TreeNode5PImplESt14default_deleteIS2_EE", !12, i64 0}
!12 = !{!"_ZTSSt5tupleIJPN2BT8TreeNode5PImplESt14default_deleteIS2_EEE", !13, i64 0}
!13 = !{!"_ZTSSt11_Tuple_implILm0EJPN2BT8TreeNode5PImplESt14default_deleteIS2_EEE", !14, i64 0}
!14 = !{!"_ZTSSt10_Head_baseILm0EPN2BT8TreeNode5PImplELb0EE", !15, i64 0}
!15 = !{!"any pointer", !16, i64 0}
!16 = !{!"omnipotent char", !17, i64 0}
!17 = !{!"Simple C++ TBAA"}
!18 = !{!"_ZTSSt6vectorIPN2BT8TreeNodeESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIPN2BT8TreeNodeESaIS2_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIPN2BT8TreeNodeESaIS2_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIPN2BT8TreeNodeESaIS2_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!22 = !{!"long", !16, i64 0}
!23 = !{!"bool", !16, i64 0}
!24 = !{!6, !22, i64 40}
!25 = !{!15, !15, i64 0}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !17, i64 0}
!28 = !{!6, !23, i64 56}
!29 = !{i8 0, i8 2}
!30 = !{}
!31 = !{!22, !22, i64 0}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass