; LLVM IR from BehaviorTree/BehaviorTree.CPP :: src/controls/reactive_fallback.ll (ZN2BT16ReactiveFallback4tickEv)

; 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::ReactiveFallback" = type <{ %"class.BT::ControlNode", i32, [4 x i8] }>
%"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 }

@_ZN2BT16ReactiveFallback25throw_if_multiple_runningE = external dso_local global i8, align 1
@.str.11 = external hidden unnamed_addr constant [133 x i8], align 1
@_ZTIN2BT10LogicErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [37 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: mustprogress uwtable
define dso_local noundef i32 @_ZN2BT16ReactiveFallback4tickEv(ptr noundef nonnull align 8 dereferenceable(44) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #5
  store i8 1, ptr %4, align 1, !tbaa !9
  %13 = call noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %1
  %16 = getelementptr inbounds %"class.BT::ReactiveFallback", ptr %12, i32 0, i32 1
  store i32 -1, ptr %16, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %15, %1
  call void @_ZN2BT8TreeNode9setStatusENS_10NodeStatusE(ptr noundef nonnull align 8 dereferenceable(16) %12, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !26
  br label %18

18:                                               ; preds = %101, %17
  %19 = load i64, ptr %5, align 8, !tbaa !26
  %20 = call noundef i64 @_ZNK2BT11ControlNode13childrenCountEv(ptr noundef nonnull align 8 dereferenceable(40) %12)
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 2, ptr %6, align 4
  br label %105

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %24 = getelementptr inbounds %"class.BT::ControlNode", ptr %12, i32 0, i32 1
  %25 = load i64, ptr %5, align 8, !tbaa !26
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN2BT8TreeNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %25) #5
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  store ptr %27, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %28, align 8, !tbaa !28
  %30 = getelementptr inbounds ptr, ptr %29, i64 2
  %31 = load ptr, ptr %30, align 8
  %32 = call noundef i32 %31(ptr noundef nonnull align 8 dereferenceable(16) %28)
  store i32 %32, ptr %8, align 4, !tbaa !30
  %33 = load i32, ptr %8, align 4, !tbaa !30
  %34 = icmp eq i32 %33, 4
  %35 = zext i1 %34 to i32
  %36 = load i8, ptr %4, align 1, !tbaa !9, !range !32, !noundef !33
  %37 = trunc i8 %36 to i1
  %38 = zext i1 %37 to i32
  %39 = and i32 %38, %35
  %40 = icmp ne i32 %39, 0
  %41 = zext i1 %40 to i8
  store i8 %41, ptr %4, align 1, !tbaa !9
  %42 = load i32, ptr %8, align 4, !tbaa !30
  switch i32 %42, label %97 [
    i32 1, label %43
    i32 3, label %97
    i32 2, label %85
    i32 4, label %86
    i32 0, label %88
  ]

43:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !26
  br label %44

44:                                               ; preds = %56, %43
  %45 = load i64, ptr %9, align 8, !tbaa !26
  %46 = call noundef i64 @_ZNK2BT11ControlNode13childrenCountEv(ptr noundef nonnull align 8 dereferenceable(40) %12)
  %47 = icmp ult i64 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 6, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %59

49:                                               ; preds = %44
  %50 = load i64, ptr %9, align 8, !tbaa !26
  %51 = load i64, ptr %5, align 8, !tbaa !26
  %52 = icmp ne i64 %50, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %49
  %54 = load i64, ptr %9, align 8, !tbaa !26
  call void @_ZN2BT11ControlNode9haltChildEm(ptr noundef nonnull align 8 dereferenceable(40) %12, i64 noundef %54)
  br label %55

55:                                               ; preds = %53, %49
  br label %56

56:                                               ; preds = %55
  %57 = load i64, ptr %9, align 8, !tbaa !26
  %58 = add i64 %57, 1
  store i64 %58, ptr %9, align 8, !tbaa !26
  br label %44, !llvm.loop !34

59:                                               ; preds = %48
  %60 = getelementptr inbounds %"class.BT::ReactiveFallback", ptr %12, i32 0, i32 1
  %61 = load i32, ptr %60, align 8, !tbaa !11
  %62 = icmp eq i32 %61, -1
  br i1 %62, label %63, label %67

63:                                               ; preds = %59
  %64 = load i64, ptr %5, align 8, !tbaa !26
  %65 = trunc i64 %64 to i32
  %66 = getelementptr inbounds %"class.BT::ReactiveFallback", ptr %12, i32 0, i32 1
  store i32 %65, ptr %66, align 8, !tbaa !11
  br label %84

67:                                               ; preds = %59
  %68 = load i8, ptr @_ZN2BT16ReactiveFallback25throw_if_multiple_runningE, align 1, !tbaa !9, !range !32, !noundef !33
  %69 = trunc i8 %68 to i1
  br i1 %69, label %70, label %83

70:                                               ; preds = %67
  %71 = getelementptr inbounds %"class.BT::ReactiveFallback", ptr %12, i32 0, i32 1
  %72 = load i32, ptr %71, align 8, !tbaa !11
  %73 = load i64, ptr %5, align 8, !tbaa !26
  %74 = trunc i64 %73 to i32
  %75 = icmp ne i32 %72, %74
  br i1 %75, label %76, label %83

76:                                               ; preds = %70
  %77 = call ptr @__cxa_allocate_exception(i64 40) #5
  invoke void @_ZN2BT10LogicErrorC2IJA133_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %77, ptr noundef nonnull align 1 dereferenceable(133) @.str.11)
          to label %78 unwind label %79

78:                                               ; preds = %76
  call void @__cxa_throw(ptr %77, ptr @_ZTIN2BT10LogicErrorE, ptr @_ZN2BT21BehaviorTreeExceptionD2Ev) #6
  unreachable

79:                                               ; preds = %76
  %80 = landingpad { ptr, i32 }
          cleanup
  %81 = extractvalue { ptr, i32 } %80, 0
  store ptr %81, ptr %10, align 8
  %82 = extractvalue { ptr, i32 } %80, 1
  store i32 %82, ptr %11, align 4
  call void @__cxa_free_exception(ptr %77) #5
  br label %104

83:                                               ; preds = %70, %67
  br label %84

84:                                               ; preds = %83, %63
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %98

85:                                               ; preds = %23
  call void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40) %12)
  store i32 2, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %98

86:                                               ; preds = %23
  %87 = load i64, ptr %5, align 8, !tbaa !26
  call void @_ZN2BT11ControlNode9haltChildEm(ptr noundef nonnull align 8 dereferenceable(40) %12, i64 noundef %87)
  br label %97

88:                                               ; preds = %23
  %89 = call ptr @__cxa_allocate_exception(i64 40) #5
  %90 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK2BT8TreeNode4nameB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(16) %12)
          to label %91 unwind label %93

91:                                               ; preds = %88
  invoke void @_ZN2BT10LogicErrorC2IJA2_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEA37_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %89, ptr noundef nonnull align 1 dereferenceable(2) @.str.12, ptr noundef nonnull align 8 dereferenceable(32) %90, ptr noundef nonnull align 1 dereferenceable(37) @.str.13)
          to label %92 unwind label %93

92:                                               ; preds = %91
  call void @__cxa_throw(ptr %89, ptr @_ZTIN2BT10LogicErrorE, ptr @_ZN2BT21BehaviorTreeExceptionD2Ev) #6
  unreachable

93:                                               ; preds = %91, %88
  %94 = landingpad { ptr, i32 }
          cleanup
  %95 = extractvalue { ptr, i32 } %94, 0
  store ptr %95, ptr %10, align 8
  %96 = extractvalue { ptr, i32 } %94, 1
  store i32 %96, ptr %11, align 4
  call void @__cxa_free_exception(ptr %89) #5
  br label %104

97:                                               ; preds = %86, %23, %23
  store i32 0, ptr %6, align 4
  br label %98

98:                                               ; preds = %97, %85, %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %99 = load i32, ptr %6, align 4
  switch i32 %99, label %105 [
    i32 0, label %100
  ]

100:                                              ; preds = %98
  br label %101

101:                                              ; preds = %100
  %102 = load i64, ptr %5, align 8, !tbaa !26
  %103 = add i64 %102, 1
  store i64 %103, ptr %5, align 8, !tbaa !26
  br label %18, !llvm.loop !36

104:                                              ; preds = %93, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #5
  br label %114

105:                                              ; preds = %98, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %106 = load i32, ptr %6, align 4
  switch i32 %106, label %112 [
    i32 2, label %107
  ]

107:                                              ; preds = %105
  call void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40) %12)
  %108 = load i8, ptr %4, align 1, !tbaa !9, !range !32, !noundef !33
  %109 = trunc i8 %108 to i1
  %110 = zext i1 %109 to i64
  %111 = select i1 %109, i32 4, i32 3
  store i32 %111, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %112

112:                                              ; preds = %107, %105
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #5
  %113 = load i32, ptr %2, align 4
  ret i32 %113

114:                                              ; preds = %104
  %115 = load ptr, ptr %10, align 8
  %116 = load i32, ptr %11, align 4
  %117 = insertvalue { ptr, i32 } poison, ptr %115, 0
  %118 = insertvalue { ptr, i32 } %117, i32 %116, 1
  resume { ptr, i32 } %118
}

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

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

declare noundef i64 @_ZNK2BT11ControlNode13childrenCountEv(ptr noundef nonnull align 8 dereferenceable(40)) #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) #3 align 2

declare void @_ZN2BT11ControlNode9haltChildEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #2

declare ptr @__cxa_allocate_exception(i64)

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

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

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

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNK2BT8TreeNode4nameB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(16)) #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 #1 align 2

; 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !25, i64 40}
!12 = !{!"_ZTSN2BT16ReactiveFallbackE", !13, i64 0, !25, i64 40}
!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 = !{!"int", !7, i64 0}
!26 = !{!27, !27, i64 0}
!27 = !{!"long", !7, i64 0}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !8, i64 0}
!30 = !{!31, !31, i64 0}
!31 = !{!"_ZTSN2BT10NodeStatusE", !7, i64 0}
!32 = !{i8 0, i8 2}
!33 = !{}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = distinct !{!36, !35}


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

@_ZN2BT16ReactiveFallback25throw_if_multiple_runningE = external dso_local local_unnamed_addr global i8, align 1
@.str.11 = external hidden unnamed_addr constant [133 x i8], align 1
@_ZTIN2BT10LogicErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [37 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2BT16ReactiveFallback4tickEv(ptr noundef nonnull align 8 dereferenceable(44) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = tail call noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %3 = icmp eq i32 %2, 0
  br i1 %3, label %4, label %6

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 -1, ptr %5, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %4, %1
  tail call void @_ZN2BT8TreeNode9setStatusENS_10NodeStatusE(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 1)
  %7 = tail call noundef i64 @_ZNK2BT11ControlNode13childrenCountEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %.not3351.not = icmp eq i64 %7, 0
  br i1 %.not3351.not, label %.thread37, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  br label %10

.thread37.loopexit:                               ; preds = %47
  %9 = select i1 %18, i32 4, i32 3
  br label %.thread37

.thread37:                                        ; preds = %.thread37.loopexit, %6
  %.025.lcssa = phi i32 [ 4, %6 ], [ %9, %.thread37.loopexit ]
  tail call void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  br label %51

10:                                               ; preds = %.lr.ph, %47
  %.02553 = phi i1 [ true, %.lr.ph ], [ %18, %47 ]
  %.02952 = phi i64 [ 0, %.lr.ph ], [ %48, %47 ]
  %11 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN2BT8TreeNodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %.02952) #4
  %12 = load ptr, ptr %11, align 8, !tbaa !23
  %13 = load ptr, ptr %12, align 8, !tbaa !24
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = load ptr, ptr %14, align 8
  %16 = tail call noundef i32 %15(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %17 = icmp eq i32 %16, 4
  %18 = select i1 %17, i1 %.02553, i1 false
  switch i32 %16, label %47 [
    i32 1, label %.preheader
    i32 0, label %40
    i32 2, label %.thread41
    i32 4, label %39
  ]

.preheader:                                       ; preds = %10
  %19 = tail call noundef i64 @_ZNK2BT11ControlNode13childrenCountEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %.not56 = icmp eq i64 %19, 0
  br i1 %.not56, label %._crit_edge, label %.lr.ph55

._crit_edge:                                      ; preds = %24, %.preheader
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  %21 = load i32, ptr %20, align 8, !tbaa !5
  %22 = icmp eq i32 %21, -1
  br i1 %22, label %28, label %30

.lr.ph55:                                         ; preds = %.preheader, %24
  %.02354 = phi i64 [ %25, %24 ], [ 0, %.preheader ]
  %.not32 = icmp eq i64 %.02354, %.02952
  br i1 %.not32, label %24, label %23

23:                                               ; preds = %.lr.ph55
  tail call void @_ZN2BT11ControlNode9haltChildEm(ptr noundef nonnull align 8 dereferenceable(40) %0, i64 noundef %.02354)
  br label %24

24:                                               ; preds = %.lr.ph55, %23
  %25 = add nuw i64 %.02354, 1
  %26 = tail call noundef i64 @_ZNK2BT11ControlNode13childrenCountEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %.lr.ph55, label %._crit_edge, !llvm.loop !26

28:                                               ; preds = %._crit_edge
  %29 = trunc i64 %.02952 to i32
  store i32 %29, ptr %20, align 8, !tbaa !5
  br label %51

30:                                               ; preds = %._crit_edge
  %31 = load i8, ptr @_ZN2BT16ReactiveFallback25throw_if_multiple_runningE, align 1, !tbaa !28, !range !30, !noundef !31
  %32 = trunc nuw i8 %31 to i1
  %33 = trunc i64 %.02952 to i32
  %.not = icmp ne i32 %21, %33
  %or.cond.not = and i1 %.not, %32
  br i1 %or.cond.not, label %34, label %51

34:                                               ; preds = %30
  %35 = tail call ptr @__cxa_allocate_exception(i64 40) #4
  invoke void @_ZN2BT10LogicErrorC2IJA133_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %35, ptr noundef nonnull align 1 dereferenceable(133) @.str.11)
          to label %36 unwind label %37

36:                                               ; preds = %34
  tail call void @__cxa_throw(ptr nonnull %35, ptr nonnull @_ZTIN2BT10LogicErrorE, ptr nonnull @_ZN2BT21BehaviorTreeExceptionD2Ev) #5
  unreachable

37:                                               ; preds = %34
  %38 = landingpad { ptr, i32 }
          cleanup
  br label %50

.thread41:                                        ; preds = %10
  tail call void @_ZN2BT11ControlNode13resetChildrenEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  br label %51

39:                                               ; preds = %10
  tail call void @_ZN2BT11ControlNode9haltChildEm(ptr noundef nonnull align 8 dereferenceable(40) %0, i64 noundef %.02952)
  br label %47

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

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

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

45:                                               ; preds = %43, %40
  %46 = landingpad { ptr, i32 }
          cleanup
  br label %50

47:                                               ; preds = %39, %10
  %48 = add nuw i64 %.02952, 1
  %49 = tail call noundef i64 @_ZNK2BT11ControlNode13childrenCountEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %.not33 = icmp ult i64 %48, %49
  br i1 %.not33, label %10, label %.thread37.loopexit, !llvm.loop !32

50:                                               ; preds = %45, %37
  %.sink = phi ptr [ %41, %45 ], [ %35, %37 ]
  %.pn = phi { ptr, i32 } [ %46, %45 ], [ %38, %37 ]
  tail call void @__cxa_free_exception(ptr %.sink) #4
  resume { ptr, i32 } %.pn

51:                                               ; preds = %28, %30, %.thread41, %.thread37
  %.3 = phi i32 [ %.025.lcssa, %.thread37 ], [ 2, %.thread41 ], [ 1, %30 ], [ 1, %28 ]
  ret i32 %.3
}

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

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

declare noundef i64 @_ZNK2BT11ControlNode13childrenCountEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1

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

declare void @_ZN2BT11ControlNode9haltChildEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

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

declare void @__cxa_free_exception(ptr) local_unnamed_addr

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

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

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

; 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

; 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 = { "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 = { 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 40}
!6 = !{!"_ZTSN2BT16ReactiveFallbackE", !7, i64 0, !22, i64 40}
!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 = !{!"int", !16, i64 0}
!23 = !{!15, !15, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"vtable pointer", !17, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!29, !29, i64 0}
!29 = !{!"bool", !16, i64 0}
!30 = !{i8 0, i8 2}
!31 = !{}
!32 = distinct !{!32, !27}


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