; LLVM IR from BehaviorTree/BehaviorTree.CPP :: src/decorators/repeat_node.ll (ZN2BT10RepeatNode4tickEv)

; 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.nonstd::expected_lite::expected" = type { %"class.nonstd::expected_lite::detail::storage_t" }
%"class.nonstd::expected_lite::detail::storage_t" = type { %"class.nonstd::expected_lite::detail::storage_t_impl.base", [7 x i8] }
%"class.nonstd::expected_lite::detail::storage_t_impl.base" = type <{ %union.anon.19, i8 }>
%union.anon.19 = type { %"class.std::__cxx11::basic_string" }
%"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] }
%"class.std::allocator" = type { i8 }
%"class.BT::RepeatNode" = type <{ %"class.BT::DecoratorNode", i32, i32, i8, [7 x i8] }>
%"class.BT::DecoratorNode" = type { %"class.BT::TreeNode", ptr }
%"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 }

@.str.12 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [20 x i8], align 1
@_ZN2BT10RepeatNode10NUM_CYCLESE = external dso_local constant ptr, align 8
@.str.14 = external hidden unnamed_addr constant [16 x i8], align 1
@_ZTIN2BT12RuntimeErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.15 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.16 = 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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

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

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 nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2BT10RepeatNode4tickEv(ptr noundef nonnull align 8 dereferenceable(33) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca %"class.nonstd::expected_lite::expected", align 8
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  %6 = alloca %"class.std::allocator", align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8
  %14 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 3
  %15 = load i8, ptr %14, align 8, !tbaa !9, !range !21, !noundef !22
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %40

17:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef @.str.12, ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %18 unwind label %26

18:                                               ; preds = %17
  %19 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 1
  invoke void @_ZNK2BT8TreeNode8getInputIiEEN6nonstd13expected_lite8expectedISt9monostateNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERKSB_RT_(ptr dead_on_unwind writable sret(%"class.nonstd::expected_lite::expected") align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull align 4 dereferenceable(4) %19)
          to label %20 unwind label %30

20:                                               ; preds = %18
  %21 = call noundef zeroext i1 @_ZNK6nonstd13expected_lite8expectedISt9monostateNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEcvbEv(ptr noundef nonnull align 8 dereferenceable(40) %4) #6
  %22 = xor i1 %21, true
  call void @_ZN6nonstd13expected_lite8expectedISt9monostateNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %4) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #6
  br i1 %22, label %23, label %39

23:                                               ; preds = %20
  %24 = call ptr @__cxa_allocate_exception(i64 40) #6
  invoke void @_ZN2BT12RuntimeErrorC2IJA20_cPKcA16_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %24, ptr noundef nonnull align 1 dereferenceable(20) @.str.13, ptr noundef nonnull align 8 dereferenceable(8) @_ZN2BT10RepeatNode10NUM_CYCLESE, ptr noundef nonnull align 1 dereferenceable(16) @.str.14)
          to label %25 unwind label %35

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

26:                                               ; preds = %17
  %27 = landingpad { ptr, i32 }
          cleanup
  %28 = extractvalue { ptr, i32 } %27, 0
  store ptr %28, ptr %7, align 8
  %29 = extractvalue { ptr, i32 } %27, 1
  store i32 %29, ptr %8, align 4
  br label %34

30:                                               ; preds = %18
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %7, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %8, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #6
  br label %34

34:                                               ; preds = %30, %26
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #6
  br label %113

35:                                               ; preds = %23
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %7, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %8, align 4
  call void @__cxa_free_exception(ptr %24) #6
  br label %113

39:                                               ; preds = %20
  br label %40

40:                                               ; preds = %39, %1
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #6
  %41 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !23
  %43 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !24
  %45 = icmp slt i32 %42, %44
  br i1 %45, label %50, label %46

46:                                               ; preds = %40
  %47 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 1
  %48 = load i32, ptr %47, align 8, !tbaa !24
  %49 = icmp eq i32 %48, -1
  br label %50

50:                                               ; preds = %46, %40
  %51 = phi i1 [ true, %40 ], [ %49, %46 ]
  %52 = zext i1 %51 to i8
  store i8 %52, ptr %9, align 1, !tbaa !25
  call void @_ZN2BT8TreeNode9setStatusENS_10NodeStatusE(ptr noundef nonnull align 8 dereferenceable(16) %13, i32 noundef 1)
  br label %53

53:                                               ; preds = %108, %50
  %54 = load i8, ptr %9, align 1, !tbaa !25, !range !21, !noundef !22
  %55 = trunc i8 %54 to i1
  br i1 %55, label %56, label %109

56:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %57 = getelementptr inbounds %"class.BT::DecoratorNode", ptr %13, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !26
  %59 = call noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16) %58)
  store i32 %59, ptr %10, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %60 = getelementptr inbounds %"class.BT::DecoratorNode", ptr %13, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !26
  %62 = load ptr, ptr %61, align 8, !tbaa !29
  %63 = getelementptr inbounds ptr, ptr %62, i64 2
  %64 = load ptr, ptr %63, align 8
  %65 = call noundef i32 %64(ptr noundef nonnull align 8 dereferenceable(16) %61)
  store i32 %65, ptr %11, align 4, !tbaa !27
  %66 = load i32, ptr %11, align 4, !tbaa !27
  switch i32 %66, label %105 [
    i32 2, label %67
    i32 3, label %92
    i32 1, label %94
    i32 4, label %95
    i32 0, label %96
  ]

67:                                               ; preds = %56
  %68 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 2
  %69 = load i32, ptr %68, align 4, !tbaa !23
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %68, align 4, !tbaa !23
  %71 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 2
  %72 = load i32, ptr %71, align 4, !tbaa !23
  %73 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 1
  %74 = load i32, ptr %73, align 8, !tbaa !24
  %75 = icmp slt i32 %72, %74
  br i1 %75, label %80, label %76

76:                                               ; preds = %67
  %77 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 1
  %78 = load i32, ptr %77, align 8, !tbaa !24
  %79 = icmp eq i32 %78, -1
  br label %80

80:                                               ; preds = %76, %67
  %81 = phi i1 [ true, %67 ], [ %79, %76 ]
  %82 = zext i1 %81 to i8
  store i8 %82, ptr %9, align 1, !tbaa !25
  call void @_ZN2BT13DecoratorNode10resetChildEv(ptr noundef nonnull align 8 dereferenceable(24) %13)
  %83 = call noundef zeroext i1 @_ZNK2BT8TreeNode14requiresWakeUpEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  br i1 %83, label %84, label %91

84:                                               ; preds = %80
  %85 = load i32, ptr %10, align 4, !tbaa !27
  %86 = icmp eq i32 %85, 0
  br i1 %86, label %87, label %91

87:                                               ; preds = %84
  %88 = load i8, ptr %9, align 1, !tbaa !25, !range !21, !noundef !22
  %89 = trunc i8 %88 to i1
  br i1 %89, label %90, label %91

90:                                               ; preds = %87
  call void @_ZN2BT8TreeNode16emitWakeUpSignalEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %106

91:                                               ; preds = %87, %84, %80
  br label %105

92:                                               ; preds = %56
  %93 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 2
  store i32 0, ptr %93, align 4, !tbaa !23
  call void @_ZN2BT13DecoratorNode10resetChildEv(ptr noundef nonnull align 8 dereferenceable(24) %13)
  store i32 3, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %106

94:                                               ; preds = %56
  store i32 1, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %106

95:                                               ; preds = %56
  call void @_ZN2BT13DecoratorNode10resetChildEv(ptr noundef nonnull align 8 dereferenceable(24) %13)
  store i32 4, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %106

96:                                               ; preds = %56
  %97 = call ptr @__cxa_allocate_exception(i64 40) #6
  %98 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK2BT8TreeNode4nameB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(16) %13)
          to label %99 unwind label %101

99:                                               ; preds = %96
  invoke void @_ZN2BT10LogicErrorC2IJA2_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEA37_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %97, ptr noundef nonnull align 1 dereferenceable(2) @.str.15, ptr noundef nonnull align 8 dereferenceable(32) %98, ptr noundef nonnull align 1 dereferenceable(37) @.str.16)
          to label %100 unwind label %101

100:                                              ; preds = %99
  call void @__cxa_throw(ptr %97, ptr @_ZTIN2BT10LogicErrorE, ptr @_ZN2BT21BehaviorTreeExceptionD2Ev) #7
  unreachable

101:                                              ; preds = %99, %96
  %102 = landingpad { ptr, i32 }
          cleanup
  %103 = extractvalue { ptr, i32 } %102, 0
  store ptr %103, ptr %7, align 8
  %104 = extractvalue { ptr, i32 } %102, 1
  store i32 %104, ptr %8, align 4
  call void @__cxa_free_exception(ptr %97) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  br label %113

105:                                              ; preds = %91, %56
  store i32 0, ptr %12, align 4
  br label %106

106:                                              ; preds = %105, %95, %94, %92, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %107 = load i32, ptr %12, align 4
  switch i32 %107, label %111 [
    i32 0, label %108
  ]

108:                                              ; preds = %106
  br label %53, !llvm.loop !31

109:                                              ; preds = %53
  %110 = getelementptr inbounds %"class.BT::RepeatNode", ptr %13, i32 0, i32 2
  store i32 0, ptr %110, align 4, !tbaa !23
  store i32 2, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %111

111:                                              ; preds = %109, %106
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  %112 = load i32, ptr %2, align 4
  ret i32 %112

113:                                              ; preds = %101, %35, %34
  %114 = load ptr, ptr %7, align 8
  %115 = load i32, ptr %8, align 4
  %116 = insertvalue { ptr, i32 } poison, ptr %114, 0
  %117 = insertvalue { ptr, i32 } %116, i32 %115, 1
  resume { ptr, i32 } %117
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK2BT8TreeNode8getInputIiEEN6nonstd13expected_lite8expectedISt9monostateNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERKSB_RT_(ptr dead_on_unwind noalias writable sret(%"class.nonstd::expected_lite::expected") align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

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

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

declare ptr @__cxa_allocate_exception(i64)

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

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

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

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

declare void @_ZN2BT13DecoratorNode10resetChildEv(ptr noundef nonnull align 8 dereferenceable(24)) #4

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !20, i64 32}
!10 = !{!"_ZTSN2BT10RepeatNodeE", !11, i64 0, !19, i64 24, !19, i64 28, !20, i64 32}
!11 = !{!"_ZTSN2BT13DecoratorNodeE", !12, i64 0, !6, i64 16}
!12 = !{!"_ZTSN2BT8TreeNodeE", !13, i64 8}
!13 = !{!"_ZTSSt10unique_ptrIN2BT8TreeNode5PImplESt14default_deleteIS2_EE", !14, i64 0}
!14 = !{!"_ZTSSt15__uniq_ptr_dataIN2BT8TreeNode5PImplESt14default_deleteIS2_ELb1ELb1EE", !15, i64 0}
!15 = !{!"_ZTSSt15__uniq_ptr_implIN2BT8TreeNode5PImplESt14default_deleteIS2_EE", !16, i64 0}
!16 = !{!"_ZTSSt5tupleIJPN2BT8TreeNode5PImplESt14default_deleteIS2_EEE", !17, i64 0}
!17 = !{!"_ZTSSt11_Tuple_implILm0EJPN2BT8TreeNode5PImplESt14default_deleteIS2_EEE", !18, i64 0}
!18 = !{!"_ZTSSt10_Head_baseILm0EPN2BT8TreeNode5PImplELb0EE", !6, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!10, !19, i64 28}
!24 = !{!10, !19, i64 24}
!25 = !{!20, !20, i64 0}
!26 = !{!11, !6, i64 16}
!27 = !{!28, !28, i64 0}
!28 = !{!"_ZTSN2BT10NodeStatusE", !7, i64 0}
!29 = !{!30, !30, i64 0}
!30 = !{!"vtable pointer", !8, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"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"

%"class.nonstd::expected_lite::expected" = type { %"class.nonstd::expected_lite::detail::storage_t" }
%"class.nonstd::expected_lite::detail::storage_t" = type { %"class.nonstd::expected_lite::detail::storage_t_impl.base", [7 x i8] }
%"class.nonstd::expected_lite::detail::storage_t_impl.base" = type <{ %union.anon.19, i8 }>
%union.anon.19 = type { %"class.std::__cxx11::basic_string" }
%"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] }
%"class.std::allocator" = type { i8 }

@.str.12 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [20 x i8], align 1
@_ZN2BT10RepeatNode10NUM_CYCLESE = external dso_local constant ptr, align 8
@.str.14 = external hidden unnamed_addr constant [16 x i8], align 1
@_ZTIN2BT12RuntimeErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.15 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [37 x i8], align 1
@_ZTIN2BT10LogicErrorE = external dso_local constant { ptr, ptr, ptr }, align 8

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2BT10RepeatNode4tickEv(ptr noundef nonnull align 8 dereferenceable(33) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.nonstd::expected_lite::expected", align 8
  %3 = alloca %"class.std::__cxx11::basic_string", align 8
  %4 = alloca %"class.std::allocator", align 1
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load i8, ptr %5, align 8, !tbaa !5, !range !20, !noundef !21
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %23

8:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull @.str.12, ptr noundef nonnull align 1 dereferenceable(1) %4)
          to label %9 unwind label %16

9:                                                ; preds = %8
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  invoke void @_ZNK2BT8TreeNode8getInputIiEEN6nonstd13expected_lite8expectedISt9monostateNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERKSB_RT_(ptr dead_on_unwind nonnull writable sret(%"class.nonstd::expected_lite::expected") align 8 %2, ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 4 dereferenceable(4) %10)
          to label %11 unwind label %18

11:                                               ; preds = %9
  %12 = call noundef zeroext i1 @_ZNK6nonstd13expected_lite8expectedISt9monostateNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEcvbEv(ptr noundef nonnull align 8 dereferenceable(40) %2) #6
  call void @_ZN6nonstd13expected_lite8expectedISt9monostateNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %2) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #6
  br i1 %12, label %23, label %13

13:                                               ; preds = %11
  %14 = call ptr @__cxa_allocate_exception(i64 40) #6
  invoke void @_ZN2BT12RuntimeErrorC2IJA20_cPKcA16_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %14, ptr noundef nonnull align 1 dereferenceable(20) @.str.13, ptr noundef nonnull align 8 dereferenceable(8) @_ZN2BT10RepeatNode10NUM_CYCLESE, ptr noundef nonnull align 1 dereferenceable(16) @.str.14)
          to label %15 unwind label %21

15:                                               ; preds = %13
  call void @__cxa_throw(ptr nonnull %14, ptr nonnull @_ZTIN2BT12RuntimeErrorE, ptr nonnull @_ZN2BT21BehaviorTreeExceptionD2Ev) #7
  unreachable

16:                                               ; preds = %8
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %20

18:                                               ; preds = %9
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #6
  br label %20

20:                                               ; preds = %18, %16
  %.pn = phi { ptr, i32 } [ %19, %18 ], [ %17, %16 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #6
  br label %58

21:                                               ; preds = %13
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %14) #6
  br label %58

23:                                               ; preds = %11, %1
  %24 = getelementptr inbounds i8, ptr %0, i64 28
  %25 = load i32, ptr %24, align 4, !tbaa !22
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  %27 = load i32, ptr %26, align 8, !tbaa !23
  %28 = icmp slt i32 %25, %27
  %29 = icmp eq i32 %27, -1
  %narrow = or i1 %28, %29
  call void @_ZN2BT8TreeNode9setStatusENS_10NodeStatusE(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 1)
  br i1 %narrow, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %23
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  br label %.critedge

.critedge:                                        ; preds = %.critedge.backedge, %.lr.ph
  %31 = load ptr, ptr %30, align 8, !tbaa !24
  %32 = call noundef i32 @_ZNK2BT8TreeNode6statusEv(ptr noundef nonnull align 8 dereferenceable(16) %31)
  %33 = load ptr, ptr %30, align 8, !tbaa !24
  %34 = load ptr, ptr %33, align 8, !tbaa !25
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %36 = load ptr, ptr %35, align 8
  %37 = call noundef i32 %36(ptr noundef nonnull align 8 dereferenceable(16) %33)
  switch i32 %37, label %.critedge.backedge [
    i32 2, label %38
    i32 3, label %48
    i32 1, label %.thread
    i32 4, label %49
    i32 0, label %50
  ]

38:                                               ; preds = %.critedge
  %39 = load i32, ptr %24, align 4, !tbaa !22
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %24, align 4, !tbaa !22
  %41 = load i32, ptr %26, align 8, !tbaa !23
  %42 = icmp slt i32 %40, %41
  %43 = icmp eq i32 %41, -1
  %spec.select = or i1 %42, %43
  call void @_ZN2BT13DecoratorNode10resetChildEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %44 = call noundef zeroext i1 @_ZNK2BT8TreeNode14requiresWakeUpEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %45 = icmp eq i32 %32, 0
  %or.cond = and i1 %45, %44
  %46 = select i1 %or.cond, i1 %spec.select, i1 false
  br i1 %46, label %47, label %57

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

48:                                               ; preds = %.critedge
  store i32 0, ptr %24, align 4, !tbaa !22
  call void @_ZN2BT13DecoratorNode10resetChildEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  br label %.thread

49:                                               ; preds = %.critedge
  call void @_ZN2BT13DecoratorNode10resetChildEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  br label %.thread

50:                                               ; preds = %.critedge
  %51 = call ptr @__cxa_allocate_exception(i64 40) #6
  %52 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK2BT8TreeNode4nameB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(16) %0)
          to label %53 unwind label %55

53:                                               ; preds = %50
  invoke void @_ZN2BT10LogicErrorC2IJA2_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEA37_cEEEDpRKT_(ptr noundef nonnull align 8 dereferenceable(40) %51, ptr noundef nonnull align 1 dereferenceable(2) @.str.15, ptr noundef nonnull align 8 dereferenceable(32) %52, ptr noundef nonnull align 1 dereferenceable(37) @.str.16)
          to label %54 unwind label %55

54:                                               ; preds = %53
  call void @__cxa_throw(ptr nonnull %51, ptr nonnull @_ZTIN2BT10LogicErrorE, ptr nonnull @_ZN2BT21BehaviorTreeExceptionD2Ev) #7
  unreachable

55:                                               ; preds = %53, %50
  %56 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %51) #6
  br label %58

57:                                               ; preds = %38
  br i1 %spec.select, label %.critedge.backedge, label %._crit_edge

.critedge.backedge:                               ; preds = %57, %.critedge
  br label %.critedge, !llvm.loop !27

._crit_edge:                                      ; preds = %57, %23
  store i32 0, ptr %24, align 4, !tbaa !22
  br label %.thread

.thread:                                          ; preds = %.critedge, %47, %48, %49, %._crit_edge
  %.2 = phi i32 [ 2, %._crit_edge ], [ 1, %47 ], [ 3, %48 ], [ 4, %49 ], [ %37, %.critedge ]
  ret i32 %.2

58:                                               ; preds = %55, %21, %20
  %.pn20 = phi { ptr, i32 } [ %22, %21 ], [ %56, %55 ], [ %.pn, %20 ]
  resume { ptr, i32 } %.pn20
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK2BT8TreeNode8getInputIiEEN6nonstd13expected_lite8expectedISt9monostateNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERKSB_RT_(ptr dead_on_unwind noalias writable sret(%"class.nonstd::expected_lite::expected") align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

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

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

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

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

declare void @__cxa_free_exception(ptr) local_unnamed_addr

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

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

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

declare void @_ZN2BT13DecoratorNode10resetChildEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4

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

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

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

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

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

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

attributes #0 = { mustprogress 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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !19, i64 32}
!6 = !{!"_ZTSN2BT10RepeatNodeE", !7, i64 0, !18, i64 24, !18, i64 28, !19, i64 32}
!7 = !{!"_ZTSN2BT13DecoratorNodeE", !8, i64 0, !15, 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 = !{!"int", !16, i64 0}
!19 = !{!"bool", !16, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!6, !18, i64 28}
!23 = !{!6, !18, i64 24}
!24 = !{!7, !15, i64 16}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !17, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


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