; LLVM IR from Lakhankumawat/LearnCPP :: T-Tree/B-BinaryTree/Diameter.ll (Z9takeinputv)

; 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.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<binaryTreeNode<int> *, std::allocator<binaryTreeNode<int> *>>::_Deque_impl" }
%"struct.std::_Deque_base<binaryTreeNode<int> *, std::allocator<binaryTreeNode<int> *>>::_Deque_impl" = type { %"struct.std::_Deque_base<binaryTreeNode<int> *, std::allocator<binaryTreeNode<int> *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<binaryTreeNode<int> *, std::allocator<binaryTreeNode<int> *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%class.binaryTreeNode = type { i32, ptr, ptr }

@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z9takeinputv() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.std::queue", align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #7
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  %10 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #8
  %11 = load i32, ptr %1, align 4, !tbaa !5
  invoke void @_ZN14binaryTreeNodeIiEC2Ei(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef %11)
          to label %12 unwind label %36

12:                                               ; preds = %0
  store ptr %10, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 80, ptr %5) #7
  call void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEEC2IS5_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
  invoke void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE4pushERKS2_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %13 unwind label %40

13:                                               ; preds = %12
  br label %14

14:                                               ; preds = %86, %13
  %15 = invoke noundef zeroext i1 @_ZNKSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %16 unwind label %40

16:                                               ; preds = %14
  %17 = xor i1 %15, true
  br i1 %17, label %18, label %88

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %19 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %20 unwind label %44

20:                                               ; preds = %18
  %21 = load ptr, ptr %19, align 8, !tbaa !9
  store ptr %21, ptr %6, align 8, !tbaa !9
  invoke void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %22 unwind label %44

22:                                               ; preds = %20
  %23 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
          to label %24 unwind label %44

24:                                               ; preds = %22
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = icmp ne i32 %25, -1
  br i1 %26, label %27, label %57

27:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %28 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #8
          to label %29 unwind label %48

29:                                               ; preds = %27
  %30 = load i32, ptr %1, align 4, !tbaa !5
  invoke void @_ZN14binaryTreeNodeIiEC2Ei(ptr noundef nonnull align 8 dereferenceable(24) %28, i32 noundef %30)
          to label %31 unwind label %52

31:                                               ; preds = %29
  store ptr %28, ptr %7, align 8, !tbaa !9
  invoke void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE4pushERKS2_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %32 unwind label %48

32:                                               ; preds = %31
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  %34 = load ptr, ptr %6, align 8, !tbaa !9
  %35 = getelementptr inbounds %class.binaryTreeNode, ptr %34, i32 0, i32 1
  store ptr %33, ptr %35, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %60

36:                                               ; preds = %0
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %3, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %10, i64 noundef 24) #9
  br label %91

40:                                               ; preds = %14, %12
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %3, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %4, align 4
  br label %90

44:                                               ; preds = %60, %22, %20, %18
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %3, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %4, align 4
  br label %87

48:                                               ; preds = %31, %27
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %3, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %4, align 4
  br label %56

52:                                               ; preds = %29
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %3, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %28, i64 noundef 24) #9
  br label %56

56:                                               ; preds = %52, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %87

57:                                               ; preds = %24
  %58 = load ptr, ptr %6, align 8, !tbaa !9
  %59 = getelementptr inbounds %class.binaryTreeNode, ptr %58, i32 0, i32 1
  store ptr null, ptr %59, align 8, !tbaa !11
  br label %60

60:                                               ; preds = %57, %32
  %61 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
          to label %62 unwind label %44

62:                                               ; preds = %60
  %63 = load i32, ptr %1, align 4, !tbaa !5
  %64 = icmp ne i32 %63, -1
  br i1 %64, label %65, label %83

65:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %66 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #8
          to label %67 unwind label %74

67:                                               ; preds = %65
  %68 = load i32, ptr %1, align 4, !tbaa !5
  invoke void @_ZN14binaryTreeNodeIiEC2Ei(ptr noundef nonnull align 8 dereferenceable(24) %66, i32 noundef %68)
          to label %69 unwind label %78

69:                                               ; preds = %67
  store ptr %66, ptr %8, align 8, !tbaa !9
  invoke void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE4pushERKS2_(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %70 unwind label %74

70:                                               ; preds = %69
  %71 = load ptr, ptr %8, align 8, !tbaa !9
  %72 = load ptr, ptr %6, align 8, !tbaa !9
  %73 = getelementptr inbounds %class.binaryTreeNode, ptr %72, i32 0, i32 2
  store ptr %71, ptr %73, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %86

74:                                               ; preds = %69, %65
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %3, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %4, align 4
  br label %82

78:                                               ; preds = %67
  %79 = landingpad { ptr, i32 }
          cleanup
  %80 = extractvalue { ptr, i32 } %79, 0
  store ptr %80, ptr %3, align 8
  %81 = extractvalue { ptr, i32 } %79, 1
  store i32 %81, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %66, i64 noundef 24) #9
  br label %82

82:                                               ; preds = %78, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %87

83:                                               ; preds = %62
  %84 = load ptr, ptr %6, align 8, !tbaa !9
  %85 = getelementptr inbounds %class.binaryTreeNode, ptr %84, i32 0, i32 2
  store ptr null, ptr %85, align 8, !tbaa !13
  br label %86

86:                                               ; preds = %83, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %14, !llvm.loop !14

87:                                               ; preds = %82, %56, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %90

88:                                               ; preds = %16
  %89 = load ptr, ptr %2, align 8, !tbaa !9
  call void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #7
  ret ptr %89

90:                                               ; preds = %87, %40
  call void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #7
  br label %91

91:                                               ; preds = %90, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #7
  br label %92

92:                                               ; preds = %91
  %93 = load ptr, ptr %3, align 8
  %94 = load i32, ptr %4, align 4
  %95 = insertvalue { ptr, i32 } poison, ptr %93, 0
  %96 = insertvalue { ptr, i32 } %95, i32 %94, 1
  resume { ptr, i32 } %96
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14binaryTreeNodeIiEC2Ei(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEEC2IS5_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE4pushERKS2_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) #4 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #6 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin allocsize(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 = { 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 = { nobuiltin nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS14binaryTreeNodeIiE", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"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.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<binaryTreeNode<int> *, std::allocator<binaryTreeNode<int> *>>::_Deque_impl" }
%"struct.std::_Deque_base<binaryTreeNode<int> *, std::allocator<binaryTreeNode<int> *>>::_Deque_impl" = type { %"struct.std::_Deque_base<binaryTreeNode<int> *, std::allocator<binaryTreeNode<int> *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<binaryTreeNode<int> *, std::allocator<binaryTreeNode<int> *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z9takeinputv() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca %"class.std::queue", align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %7 = call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #7
  %8 = load i32, ptr %1, align 4, !tbaa !5
  call void @_ZN14binaryTreeNodeIiEC2Ei(ptr noundef nonnull align 8 dereferenceable(24) %7, i32 noundef %8)
  store ptr %7, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %3) #6
  call void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEEC2IS5_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  invoke void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE4pushERKS2_(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %.preheader unwind label %21

.preheader:                                       ; preds = %0
  %9 = call noundef zeroext i1 @_ZNKSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  br i1 %9, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %43
  %10 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  %12 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
          to label %13 unwind label %23

13:                                               ; preds = %.lr.ph
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %14, -1
  br i1 %.not, label %27, label %15

15:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %16 = invoke noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #7
          to label %17 unwind label %25

17:                                               ; preds = %15
  call void @_ZN14binaryTreeNodeIiEC2Ei(ptr noundef nonnull align 8 dereferenceable(24) %16, i32 noundef %14)
  store ptr %16, ptr %4, align 8, !tbaa !9
  invoke void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE4pushERKS2_(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %18 unwind label %25

18:                                               ; preds = %17
  %19 = load ptr, ptr %4, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %11, i64 8
  store ptr %19, ptr %20, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %29

21:                                               ; preds = %0
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %46

23:                                               ; preds = %29, %.lr.ph
  %24 = landingpad { ptr, i32 }
          cleanup
  br label %46

25:                                               ; preds = %17, %15
  %26 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %46

27:                                               ; preds = %13
  %28 = getelementptr inbounds i8, ptr %11, i64 8
  store ptr null, ptr %28, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %27, %18
  %30 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
          to label %31 unwind label %23

31:                                               ; preds = %29
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %.not7 = icmp eq i32 %32, -1
  br i1 %.not7, label %41, label %33

33:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %34 = invoke noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #7
          to label %35 unwind label %39

35:                                               ; preds = %33
  call void @_ZN14binaryTreeNodeIiEC2Ei(ptr noundef nonnull align 8 dereferenceable(24) %34, i32 noundef %32)
  store ptr %34, ptr %5, align 8, !tbaa !9
  invoke void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE4pushERKS2_(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %36 unwind label %39

36:                                               ; preds = %35
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %11, i64 16
  store ptr %37, ptr %38, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %43

39:                                               ; preds = %35, %33
  %40 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %46

41:                                               ; preds = %31
  %42 = getelementptr inbounds i8, ptr %11, i64 16
  store ptr null, ptr %42, align 8, !tbaa !13
  br label %43

43:                                               ; preds = %41, %36
  %44 = call noundef zeroext i1 @_ZNKSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  br i1 %44, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %43, %.preheader
  %45 = load ptr, ptr %2, align 8, !tbaa !9
  call void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret ptr %45

46:                                               ; preds = %23, %25, %39, %21
  %.pn.pn = phi { ptr, i32 } [ %22, %21 ], [ %40, %39 ], [ %24, %23 ], [ %26, %25 ]
  call void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn.pn
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14binaryTreeNodeIiEC2Ei(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEEC2IS5_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE4pushERKS2_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #4 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIP14binaryTreeNodeIiESt5dequeIS2_SaIS2_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #5 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin allocsize(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 = { 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 = { 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 = { builtin allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS14binaryTreeNodeIiE", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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