; LLVM IR from xtaci/algorithms :: src (binary_search_tree_demo)

; 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.alg::BST" = type { %"class.alg::BST<int, int>::BSTException", ptr }
%"class.alg::BST<int, int>::BSTException" = type { %"class.std::exception" }
%"class.std::exception" = type { ptr }
%"struct.alg::BST<int, int>::treeNode" = type { i32, i32, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [10 x i32], align 16
  %4 = alloca [10 x i32], align 16
  %5 = alloca %"class.alg::BST", align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 10, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #6
  call void @_ZN3alg3BSTIiiEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  %9 = call i64 @time(ptr noundef null) #6
  %10 = trunc i64 %9 to i32
  call void @srand(i32 noundef %10) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %25, %0
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 10
  br i1 %13, label %14, label %28

14:                                               ; preds = %11
  %15 = call i32 @rand() #6
  %16 = srem i32 %15, 100
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [10 x i32], ptr %3, i64 0, i64 %18
  store i32 %16, ptr %19, align 4, !tbaa !5
  %20 = call i32 @rand() #6
  %21 = srem i32 %20, 1000
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [10 x i32], ptr %4, i64 0, i64 %23
  store i32 %21, ptr %24, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %14
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %6, align 4, !tbaa !5
  br label %11, !llvm.loop !9

28:                                               ; preds = %11
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %50, %28
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = icmp slt i32 %30, 10
  br i1 %31, label %32, label %57

32:                                               ; preds = %29
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10 x i32], ptr %3, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [10 x i32], ptr %4, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = invoke i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %36, i32 noundef %40)
          to label %42 unwind label %53

42:                                               ; preds = %32
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [10 x i32], ptr %3, i64 0, i64 %44
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [10 x i32], ptr %4, i64 0, i64 %47
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) %45, ptr noundef nonnull align 4 dereferenceable(4) %48)
          to label %49 unwind label %53

49:                                               ; preds = %42
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %6, align 4, !tbaa !5
  br label %29, !llvm.loop !11

53:                                               ; preds = %89, %88, %83, %71, %62, %57, %42, %32
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %7, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @_ZN3alg3BSTIiiED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %101

57:                                               ; preds = %29
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %58 unwind label %53

58:                                               ; preds = %57
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %76, %58
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = icmp slt i32 %60, 10
  br i1 %61, label %62, label %79

62:                                               ; preds = %59
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [10 x i32], ptr %3, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [10 x i32], ptr %3, i64 0, i64 %68
  %70 = invoke noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) %69)
          to label %71 unwind label %53

71:                                               ; preds = %62
  %72 = getelementptr inbounds %"struct.alg::BST<int, int>::treeNode", ptr %70, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !12
  %74 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %66, i32 noundef %73)
          to label %75 unwind label %53

75:                                               ; preds = %71
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %6, align 4, !tbaa !5
  br label %59, !llvm.loop !15

79:                                               ; preds = %59
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %96, %79
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = icmp slt i32 %81, 10
  br i1 %82, label %83, label %99

83:                                               ; preds = %80
  %84 = load i32, ptr %6, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [10 x i32], ptr %3, i64 0, i64 %85
  %87 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) %86)
          to label %88 unwind label %53

88:                                               ; preds = %83
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %89 unwind label %53

89:                                               ; preds = %88
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [10 x i32], ptr %3, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %93)
          to label %95 unwind label %53

95:                                               ; preds = %89
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %6, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %6, align 4, !tbaa !5
  br label %80, !llvm.loop !16

99:                                               ; preds = %80
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @_ZN3alg3BSTIiiED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %100 = load i32, ptr %1, align 4
  ret i32 %100

101:                                              ; preds = %53
  %102 = load ptr, ptr %7, align 8
  %103 = load i32, ptr %8, align 4
  %104 = insertvalue { ptr, i32 } poison, ptr %102, 0
  %105 = insertvalue { ptr, i32 } %104, i32 %103, 1
  resume { ptr, i32 } %105
}

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

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

; Function Attrs: nounwind
declare void @srand(i32 noundef) #3

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @rand() #3

declare i32 @printf(ptr noundef, ...) #4

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16)) #5 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #5 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: mustprogress nounwind uwtable
declare dso_local void @_ZN3alg3BSTIiiED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

attributes #0 = { mustprogress norecurse 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 = { 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 = { 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 #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 = { 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 #6 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !6, i64 4}
!13 = !{!"_ZTSN3alg3BSTIiiE8treeNodeE", !6, i64 0, !6, i64 4, !14, i64 8, !14, i64 16, !14, i64 24}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


; 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.alg::BST" = type { %"class.alg::BST<int, int>::BSTException", ptr }
%"class.alg::BST<int, int>::BSTException" = type { %"class.std::exception" }
%"class.std::exception" = type { ptr }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
.preheader21.preheader:
  %0 = alloca [10 x i32], align 16
  %1 = alloca [10 x i32], align 16
  %2 = alloca %"class.alg::BST", align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %0) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #6
  call void @_ZN3alg3BSTIiiEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %3 = call i64 @time(ptr noundef null) #6
  %4 = trunc i64 %3 to i32
  call void @srand(i32 noundef %4) #6
  %5 = call i32 @rand() #6
  %6 = srem i32 %5, 100
  store i32 %6, ptr %0, align 16, !tbaa !5
  %7 = call i32 @rand() #6
  %8 = srem i32 %7, 1000
  store i32 %8, ptr %1, align 16, !tbaa !5
  %9 = call i32 @rand() #6
  %10 = srem i32 %9, 100
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %10, ptr %11, align 4, !tbaa !5
  %12 = call i32 @rand() #6
  %13 = srem i32 %12, 1000
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %13, ptr %14, align 4, !tbaa !5
  %15 = call i32 @rand() #6
  %16 = srem i32 %15, 100
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %16, ptr %17, align 8, !tbaa !5
  %18 = call i32 @rand() #6
  %19 = srem i32 %18, 1000
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %19, ptr %20, align 8, !tbaa !5
  %21 = call i32 @rand() #6
  %22 = srem i32 %21, 100
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %22, ptr %23, align 4, !tbaa !5
  %24 = call i32 @rand() #6
  %25 = srem i32 %24, 1000
  %26 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 %25, ptr %26, align 4, !tbaa !5
  %27 = call i32 @rand() #6
  %28 = srem i32 %27, 100
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %28, ptr %29, align 16, !tbaa !5
  %30 = call i32 @rand() #6
  %31 = srem i32 %30, 1000
  %32 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 %31, ptr %32, align 16, !tbaa !5
  %33 = call i32 @rand() #6
  %34 = srem i32 %33, 100
  %35 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %34, ptr %35, align 4, !tbaa !5
  %36 = call i32 @rand() #6
  %37 = srem i32 %36, 1000
  %38 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 %37, ptr %38, align 4, !tbaa !5
  %39 = call i32 @rand() #6
  %40 = srem i32 %39, 100
  %41 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %40, ptr %41, align 8, !tbaa !5
  %42 = call i32 @rand() #6
  %43 = srem i32 %42, 1000
  %44 = getelementptr inbounds i8, ptr %1, i64 24
  store i32 %43, ptr %44, align 8, !tbaa !5
  %45 = call i32 @rand() #6
  %46 = srem i32 %45, 100
  %47 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %46, ptr %47, align 4, !tbaa !5
  %48 = call i32 @rand() #6
  %49 = srem i32 %48, 1000
  %50 = getelementptr inbounds i8, ptr %1, i64 28
  store i32 %49, ptr %50, align 4, !tbaa !5
  %51 = call i32 @rand() #6
  %52 = srem i32 %51, 100
  %53 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %52, ptr %53, align 16, !tbaa !5
  %54 = call i32 @rand() #6
  %55 = srem i32 %54, 1000
  %56 = getelementptr inbounds i8, ptr %1, i64 32
  store i32 %55, ptr %56, align 16, !tbaa !5
  %57 = call i32 @rand() #6
  %58 = srem i32 %57, 100
  %59 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 %58, ptr %59, align 4, !tbaa !5
  %60 = call i32 @rand() #6
  %61 = srem i32 %60, 1000
  %62 = getelementptr inbounds i8, ptr %1, i64 36
  store i32 %61, ptr %62, align 4, !tbaa !5
  %63 = load i32, ptr %0, align 16, !tbaa !5
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %63, i32 noundef %8)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %1)
          to label %.preheader21.1 unwind label %.loopexit.split-lp.loopexit

.preheader21.1:                                   ; preds = %.preheader21.preheader
  %65 = load i32, ptr %11, align 4, !tbaa !5
  %66 = load i32, ptr %14, align 4, !tbaa !5
  %67 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %65, i32 noundef %66)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %14)
          to label %.preheader21.2 unwind label %.loopexit.split-lp.loopexit

.preheader21.2:                                   ; preds = %.preheader21.1
  %68 = load i32, ptr %17, align 8, !tbaa !5
  %69 = load i32, ptr %20, align 8, !tbaa !5
  %70 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %68, i32 noundef %69)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %20)
          to label %.preheader21.3 unwind label %.loopexit.split-lp.loopexit

.preheader21.3:                                   ; preds = %.preheader21.2
  %71 = load i32, ptr %23, align 4, !tbaa !5
  %72 = load i32, ptr %26, align 4, !tbaa !5
  %73 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %71, i32 noundef %72)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %23, ptr noundef nonnull align 4 dereferenceable(4) %26)
          to label %.preheader21.4 unwind label %.loopexit.split-lp.loopexit

.preheader21.4:                                   ; preds = %.preheader21.3
  %74 = load i32, ptr %29, align 16, !tbaa !5
  %75 = load i32, ptr %32, align 16, !tbaa !5
  %76 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %74, i32 noundef %75)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %29, ptr noundef nonnull align 4 dereferenceable(4) %32)
          to label %.preheader21.5 unwind label %.loopexit.split-lp.loopexit

.preheader21.5:                                   ; preds = %.preheader21.4
  %77 = load i32, ptr %35, align 4, !tbaa !5
  %78 = load i32, ptr %38, align 4, !tbaa !5
  %79 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %77, i32 noundef %78)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %35, ptr noundef nonnull align 4 dereferenceable(4) %38)
          to label %.preheader21.6 unwind label %.loopexit.split-lp.loopexit

.preheader21.6:                                   ; preds = %.preheader21.5
  %80 = load i32, ptr %41, align 8, !tbaa !5
  %81 = load i32, ptr %44, align 8, !tbaa !5
  %82 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %80, i32 noundef %81)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %41, ptr noundef nonnull align 4 dereferenceable(4) %44)
          to label %.preheader21.7 unwind label %.loopexit.split-lp.loopexit

.preheader21.7:                                   ; preds = %.preheader21.6
  %83 = load i32, ptr %47, align 4, !tbaa !5
  %84 = load i32, ptr %50, align 4, !tbaa !5
  %85 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %83, i32 noundef %84)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %47, ptr noundef nonnull align 4 dereferenceable(4) %50)
          to label %.preheader21.8 unwind label %.loopexit.split-lp.loopexit

.preheader21.8:                                   ; preds = %.preheader21.7
  %86 = load i32, ptr %53, align 16, !tbaa !5
  %87 = load i32, ptr %56, align 16, !tbaa !5
  %88 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %86, i32 noundef %87)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %53, ptr noundef nonnull align 4 dereferenceable(4) %56)
          to label %.preheader21.9 unwind label %.loopexit.split-lp.loopexit

.preheader21.9:                                   ; preds = %.preheader21.8
  %89 = load i32, ptr %59, align 4, !tbaa !5
  %90 = load i32, ptr %62, align 4, !tbaa !5
  %91 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %89, i32 noundef %90)
  invoke void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %59, ptr noundef nonnull align 4 dereferenceable(4) %62)
          to label %92 unwind label %.loopexit.split-lp.loopexit

92:                                               ; preds = %.preheader21.9
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader20.preheader unwind label %.loopexit.split-lp.loopexit.split-lp

.loopexit:                                        ; preds = %180, %.preheader.9, %176, %.preheader.8, %172, %.preheader.7, %168, %.preheader.6, %164, %.preheader.5, %160, %.preheader.4, %156, %.preheader.3, %152, %.preheader.2, %148, %.preheader.1, %.preheader20.preheader, %144
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit:                      ; preds = %.preheader21.9, %.preheader21.8, %.preheader21.7, %.preheader21.6, %.preheader21.5, %.preheader21.4, %.preheader21.3, %.preheader21.2, %.preheader21.1, %.preheader21.preheader
  %lpad.loopexit22 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp:             ; preds = %92
  %lpad.loopexit.split-lp23 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp:                               ; preds = %.loopexit.split-lp.loopexit, %.loopexit.split-lp.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit22, %.loopexit.split-lp.loopexit ], [ %lpad.loopexit.split-lp23, %.loopexit.split-lp.loopexit.split-lp ]
  call void @_ZN3alg3BSTIiiED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %0) #6
  resume { ptr, i32 } %lpad.phi

.preheader20.preheader:                           ; preds = %92
  %93 = load i32, ptr %0, align 16, !tbaa !5
  %94 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %0)
  %95 = getelementptr inbounds i8, ptr %94, i64 4
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %93, i32 noundef %96)
  %98 = load i32, ptr %11, align 4, !tbaa !5
  %99 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %100 = getelementptr inbounds i8, ptr %99, i64 4
  %101 = load i32, ptr %100, align 4, !tbaa !9
  %102 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %98, i32 noundef %101)
  %103 = load i32, ptr %17, align 8, !tbaa !5
  %104 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %105 = getelementptr inbounds i8, ptr %104, i64 4
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %103, i32 noundef %106)
  %108 = load i32, ptr %23, align 4, !tbaa !5
  %109 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %23)
  %110 = getelementptr inbounds i8, ptr %109, i64 4
  %111 = load i32, ptr %110, align 4, !tbaa !9
  %112 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %108, i32 noundef %111)
  %113 = load i32, ptr %29, align 16, !tbaa !5
  %114 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %29)
  %115 = getelementptr inbounds i8, ptr %114, i64 4
  %116 = load i32, ptr %115, align 4, !tbaa !9
  %117 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %113, i32 noundef %116)
  %118 = load i32, ptr %35, align 4, !tbaa !5
  %119 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %35)
  %120 = getelementptr inbounds i8, ptr %119, i64 4
  %121 = load i32, ptr %120, align 4, !tbaa !9
  %122 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %118, i32 noundef %121)
  %123 = load i32, ptr %41, align 8, !tbaa !5
  %124 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %41)
  %125 = getelementptr inbounds i8, ptr %124, i64 4
  %126 = load i32, ptr %125, align 4, !tbaa !9
  %127 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %123, i32 noundef %126)
  %128 = load i32, ptr %47, align 4, !tbaa !5
  %129 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %47)
  %130 = getelementptr inbounds i8, ptr %129, i64 4
  %131 = load i32, ptr %130, align 4, !tbaa !9
  %132 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %128, i32 noundef %131)
  %133 = load i32, ptr %53, align 16, !tbaa !5
  %134 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %53)
  %135 = getelementptr inbounds i8, ptr %134, i64 4
  %136 = load i32, ptr %135, align 4, !tbaa !9
  %137 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %133, i32 noundef %136)
  %138 = load i32, ptr %59, align 4, !tbaa !5
  %139 = call noundef ptr @_ZN3alg3BSTIiiE4findERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %59)
  %140 = getelementptr inbounds i8, ptr %139, i64 4
  %141 = load i32, ptr %140, align 4, !tbaa !9
  %142 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %138, i32 noundef %141)
  %143 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %0)
          to label %144 unwind label %.loopexit

144:                                              ; preds = %.preheader20.preheader
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.1 unwind label %.loopexit

.preheader.1:                                     ; preds = %144
  %145 = load i32, ptr %0, align 16, !tbaa !5
  %146 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %145)
  %147 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %11)
          to label %148 unwind label %.loopexit

148:                                              ; preds = %.preheader.1
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.2 unwind label %.loopexit

.preheader.2:                                     ; preds = %148
  %149 = load i32, ptr %11, align 4, !tbaa !5
  %150 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %149)
  %151 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %17)
          to label %152 unwind label %.loopexit

152:                                              ; preds = %.preheader.2
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.3 unwind label %.loopexit

.preheader.3:                                     ; preds = %152
  %153 = load i32, ptr %17, align 8, !tbaa !5
  %154 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %153)
  %155 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %23)
          to label %156 unwind label %.loopexit

156:                                              ; preds = %.preheader.3
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.4 unwind label %.loopexit

.preheader.4:                                     ; preds = %156
  %157 = load i32, ptr %23, align 4, !tbaa !5
  %158 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %157)
  %159 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %29)
          to label %160 unwind label %.loopexit

160:                                              ; preds = %.preheader.4
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.5 unwind label %.loopexit

.preheader.5:                                     ; preds = %160
  %161 = load i32, ptr %29, align 16, !tbaa !5
  %162 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %161)
  %163 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %35)
          to label %164 unwind label %.loopexit

164:                                              ; preds = %.preheader.5
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.6 unwind label %.loopexit

.preheader.6:                                     ; preds = %164
  %165 = load i32, ptr %35, align 4, !tbaa !5
  %166 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %165)
  %167 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %41)
          to label %168 unwind label %.loopexit

168:                                              ; preds = %.preheader.6
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.7 unwind label %.loopexit

.preheader.7:                                     ; preds = %168
  %169 = load i32, ptr %41, align 8, !tbaa !5
  %170 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %169)
  %171 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %47)
          to label %172 unwind label %.loopexit

172:                                              ; preds = %.preheader.7
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.8 unwind label %.loopexit

.preheader.8:                                     ; preds = %172
  %173 = load i32, ptr %47, align 4, !tbaa !5
  %174 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %173)
  %175 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %53)
          to label %176 unwind label %.loopexit

176:                                              ; preds = %.preheader.8
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %.preheader.9 unwind label %.loopexit

.preheader.9:                                     ; preds = %176
  %177 = load i32, ptr %53, align 16, !tbaa !5
  %178 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %177)
  %179 = invoke noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) %59)
          to label %180 unwind label %.loopexit

180:                                              ; preds = %.preheader.9
  invoke void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %181 unwind label %.loopexit

181:                                              ; preds = %180
  %182 = load i32, ptr %59, align 4, !tbaa !5
  %183 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %182)
  call void @_ZN3alg3BSTIiiED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %0) #6
  ret i32 0
}

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

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

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3alg3BSTIiiE6insertERKiS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3alg3BSTIiiE12print_helperEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #5 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3alg3BSTIiiE9deleteKeyERKi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5 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: mustprogress nounwind uwtable
declare dso_local void @_ZN3alg3BSTIiiED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

attributes #0 = { mustprogress norecurse 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 = { 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 = { 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 #4 = { nofree 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 #5 = { 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 #6 = { 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, !6, i64 4}
!10 = !{!"_ZTSN3alg3BSTIiiE8treeNodeE", !6, i64 0, !6, i64 4, !11, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass