; LLVM IR from BehaviorTree/BehaviorTree.CPP :: src/controls/sequence_node.ll (ZN2BT12SequenceNode4tickEv)

; 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::SequenceNode" = 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 @_ZN2BT12SequenceNode4tickEv(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::SequenceNode", 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 = %80, %18
  %20 = getelementptr inbounds %"class.BT::SequenceNode", 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 %81

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::SequenceNode", 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 %77 [
    i32 1, label %38
    i32 3, label %39
    i32 2, label %42
    i32 4, label %61
    i32 0, label %68
  ]

38:                                               ; preds = %24
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %78

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

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

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

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

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

59:                                               ; preds = %54
  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 %78

60:                                               ; preds = %54, %51, %49, %42
  br label %77

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

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

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

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

73:                                               ; preds = %71, %68
  %74 = landingpad { ptr, i32 }
          cleanup
  %75 = extractvalue { ptr, i32 } %74, 0
  store ptr %75, ptr %9, align 8
  %76 = extractvalue { ptr, i32 } %74, 1
  store i32 %76, ptr %10, align 4
  call void @__cxa_free_exception(ptr %69) #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 %97

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

78:                                               ; preds = %77, %59, %39, %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
  %79 = load i32, ptr %8, align 4
  switch i32 %79, label %95 [
    i32 0, label %80
  ]

80:                                               ; preds = %78
  br label %19, !llvm.loop !34

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

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

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

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

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

; 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 = !{!"_ZTSN2BT12SequenceNodeE", !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 @_ZN2BT12SequenceNode4tickEv(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_edge35 [
    i32 1, label %.thread
    i32 3, label %22
    i32 2, label %23
    i32 4, label %34
    i32 0, label %38
  ]

._crit_edge35:                                    ; 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.cond21 = select i1 %or.cond, i1 %32, i1 false
  br i1 %or.cond21, 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_edge35, %34, %28, %23
  %46 = phi i64 [ %.pre, %._crit_edge35 ], [ %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 2
  br label %.thread

.thread:                                          ; preds = %13, %22, %33, %50
  %.2 = phi i32 [ %54, %50 ], [ 3, %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 = !{!"_ZTSN2BT12SequenceNodeE", !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