; LLVM IR from nonstriater/Learn-Algorithms :: 4 Tree/2-二叉查找树/BiSearchTree (main)

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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %4 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %5 = call ptr (...) @bisearch_tree_new()
  store ptr %5, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = call ptr @bisearch_tree_insert(ptr noundef %6, i32 noundef 19)
  store ptr %7, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = call ptr @bisearch_tree_insert(ptr noundef %8, i32 noundef 3)
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %10)
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = call ptr @bisearch_tree_insert(ptr noundef %11, i32 noundef 122)
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call ptr @bisearch_tree_insert(ptr noundef %13, i32 noundef 55)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call ptr @bisearch_tree_insert(ptr noundef %15, i32 noundef 65)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = call ptr @bisearch_tree_insert(ptr noundef %17, i32 noundef 180)
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %20)
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 55, ptr %3, align 4, !tbaa !9
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = call i32 @bisearch_tree_search(ptr noundef %22, i32 noundef %23)
  %25 = icmp slt i32 %24, 0
  br i1 %25, label %26, label %29

26:                                               ; preds = %0
  %27 = load i32, ptr %3, align 4, !tbaa !9
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %27)
  br label %32

29:                                               ; preds = %0
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %30)
  br label %32

32:                                               ; preds = %29, %26
  store i32 33, ptr %3, align 4, !tbaa !9
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = call i32 @bisearch_tree_search(ptr noundef %33, i32 noundef %34)
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %37, label %40

37:                                               ; preds = %32
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %38)
  br label %43

40:                                               ; preds = %32
  %41 = load i32, ptr %3, align 4, !tbaa !9
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %41)
  br label %43

43:                                               ; preds = %40, %37
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  store i32 4, ptr %3, align 4, !tbaa !9
  %45 = load i32, ptr %3, align 4, !tbaa !9
  %46 = call i32 @bisearch_tree_delete(ptr noundef %2, i32 noundef %45)
  %47 = icmp slt i32 %46, 0
  br i1 %47, label %48, label %51

48:                                               ; preds = %43
  %49 = load i32, ptr %3, align 4, !tbaa !9
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %49)
  br label %58

51:                                               ; preds = %43
  %52 = load i32, ptr %3, align 4, !tbaa !9
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %52)
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %54)
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = load i32, ptr %3, align 4, !tbaa !9
  %57 = call ptr @bisearch_tree_insert(ptr noundef %55, i32 noundef %56)
  br label %58

58:                                               ; preds = %51, %48
  store i32 65, ptr %3, align 4, !tbaa !9
  %59 = load i32, ptr %3, align 4, !tbaa !9
  %60 = call i32 @bisearch_tree_delete(ptr noundef %2, i32 noundef %59)
  %61 = icmp slt i32 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %58
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %71

64:                                               ; preds = %58
  %65 = load i32, ptr %3, align 4, !tbaa !9
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %65)
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %67)
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = load i32, ptr %3, align 4, !tbaa !9
  %70 = call ptr @bisearch_tree_insert(ptr noundef %68, i32 noundef %69)
  br label %71

71:                                               ; preds = %64, %62
  store i32 55, ptr %3, align 4, !tbaa !9
  %72 = load i32, ptr %3, align 4, !tbaa !9
  %73 = call i32 @bisearch_tree_delete(ptr noundef %2, i32 noundef %72)
  %74 = icmp slt i32 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %71
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %84

77:                                               ; preds = %71
  %78 = load i32, ptr %3, align 4, !tbaa !9
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %78)
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %80)
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = load i32, ptr %3, align 4, !tbaa !9
  %83 = call ptr @bisearch_tree_insert(ptr noundef %81, i32 noundef %82)
  br label %84

84:                                               ; preds = %77, %75
  store i32 122, ptr %3, align 4, !tbaa !9
  %85 = load i32, ptr %3, align 4, !tbaa !9
  %86 = call i32 @bisearch_tree_delete(ptr noundef %2, i32 noundef %85)
  %87 = icmp slt i32 %86, 0
  br i1 %87, label %88, label %90

88:                                               ; preds = %84
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %97

90:                                               ; preds = %84
  %91 = load i32, ptr %3, align 4, !tbaa !9
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %91)
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %93)
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = load i32, ptr %3, align 4, !tbaa !9
  %96 = call ptr @bisearch_tree_insert(ptr noundef %94, i32 noundef %95)
  br label %97

97:                                               ; preds = %90, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret i32 0
}

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

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

declare ptr @bisearch_tree_new(...) #1

declare ptr @bisearch_tree_insert(ptr noundef, i32 noundef) #1

declare void @bisearch_tree_inorder_traversal(ptr noundef) #1

declare i32 @bisearch_tree_search(ptr noundef, i32 noundef) #1

declare i32 @bisearch_tree_delete(ptr noundef, i32 noundef) #1

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

attributes #0 = { 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 #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca ptr, align 8
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %3 = tail call ptr (...) @bisearch_tree_new() #4
  %4 = tail call ptr @bisearch_tree_insert(ptr noundef %3, i32 noundef 19) #4
  store ptr %4, ptr %1, align 8, !tbaa !5
  %5 = tail call ptr @bisearch_tree_insert(ptr noundef %4, i32 noundef 3) #4
  tail call void @bisearch_tree_inorder_traversal(ptr noundef %4) #4
  %6 = tail call ptr @bisearch_tree_insert(ptr noundef %4, i32 noundef 122) #4
  %7 = tail call ptr @bisearch_tree_insert(ptr noundef %4, i32 noundef 55) #4
  %8 = tail call ptr @bisearch_tree_insert(ptr noundef %4, i32 noundef 65) #4
  %9 = tail call ptr @bisearch_tree_insert(ptr noundef %4, i32 noundef 180) #4
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  tail call void @bisearch_tree_inorder_traversal(ptr noundef %4) #4
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %12 = tail call i32 @bisearch_tree_search(ptr noundef %4, i32 noundef 55) #4
  %13 = icmp slt i32 %12, 0
  %.str.3..str.4 = select i1 %13, ptr @.str.3, ptr @.str.4
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.3..str.4, i32 noundef 55)
  %15 = tail call i32 @bisearch_tree_search(ptr noundef %4, i32 noundef 33) #4
  %16 = icmp slt i32 %15, 0
  %.str.4.sink19 = select i1 %16, ptr @.str.3, ptr @.str.4
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.4.sink19, i32 noundef 33)
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %19 = call i32 @bisearch_tree_delete(ptr noundef nonnull %1, i32 noundef 4) #4
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %0
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef 4)
  br label %28

23:                                               ; preds = %0
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef 4)
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %25) #4
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = call ptr @bisearch_tree_insert(ptr noundef %26, i32 noundef 4) #4
  br label %28

28:                                               ; preds = %23, %21
  %29 = call i32 @bisearch_tree_delete(ptr noundef nonnull %1, i32 noundef 65) #4
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %28
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  br label %38

33:                                               ; preds = %28
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef 65)
  %35 = load ptr, ptr %1, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %35) #4
  %36 = load ptr, ptr %1, align 8, !tbaa !5
  %37 = call ptr @bisearch_tree_insert(ptr noundef %36, i32 noundef 65) #4
  br label %38

38:                                               ; preds = %33, %31
  %39 = call i32 @bisearch_tree_delete(ptr noundef nonnull %1, i32 noundef 55) #4
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %41, label %43

41:                                               ; preds = %38
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  br label %48

43:                                               ; preds = %38
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef 55)
  %45 = load ptr, ptr %1, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %45) #4
  %46 = load ptr, ptr %1, align 8, !tbaa !5
  %47 = call ptr @bisearch_tree_insert(ptr noundef %46, i32 noundef 55) #4
  br label %48

48:                                               ; preds = %43, %41
  %49 = call i32 @bisearch_tree_delete(ptr noundef nonnull %1, i32 noundef 122) #4
  %50 = icmp slt i32 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %48
  %52 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  br label %58

53:                                               ; preds = %48
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef 122)
  %55 = load ptr, ptr %1, align 8, !tbaa !5
  call void @bisearch_tree_inorder_traversal(ptr noundef %55) #4
  %56 = load ptr, ptr %1, align 8, !tbaa !5
  %57 = call ptr @bisearch_tree_insert(ptr noundef %56, i32 noundef 122) #4
  br label %58

58:                                               ; preds = %53, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 0
}

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

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

declare ptr @bisearch_tree_new(...) local_unnamed_addr #3

declare ptr @bisearch_tree_insert(ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @bisearch_tree_inorder_traversal(ptr noundef) local_unnamed_addr #3

declare i32 @bisearch_tree_search(ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @bisearch_tree_delete(ptr noundef, i32 noundef) local_unnamed_addr #3

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

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass