; LLVM IR from hutusi/rethink-c :: test (test_bstree)

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

%struct._CBValue = type { [100 x ptr], i32, i32 }
%struct._BSTreeNode = type { ptr, ptr, ptr, ptr }
%struct._BSTree = type { ptr, ptr, i32 }

@__const.test_bstree.entries = external hidden unnamed_addr constant [10 x i32], align 16
@__const.test_bstree.sorted = external hidden unnamed_addr constant [10 x i32], align 16
@.str = external hidden unnamed_addr constant [35 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@__PRETTY_FUNCTION__.test_bstree = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 x i8], align 1
@__const.test_bstree.remain = external hidden unnamed_addr constant [7 x i32], align 16
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @test_bstree() #0 {
  %1 = alloca [10 x i32], align 16
  %2 = alloca [10 x i32], align 16
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct._CBValue, align 8
  %8 = alloca i32, align 4
  %9 = alloca [7 x i32], align 16
  %10 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 40, ptr %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %1, ptr align 16 @__const.test_bstree.entries, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.test_bstree.sorted, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 10, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %11 = call ptr @bs_tree_new(ptr noundef @int_compare)
  store ptr %11, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %34, %0
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %37

17:                                               ; preds = %12
  %18 = load ptr, ptr %4, align 8, !tbaa !9
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [10 x i32], ptr %1, i64 0, i64 %20
  %22 = call ptr @bs_tree_insert(ptr noundef %18, ptr noundef %21)
  store ptr %22, ptr %5, align 8, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct._BSTreeNode, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [10 x i32], ptr %1, i64 0, i64 %27
  %29 = call i32 @int_equal(ptr noundef %25, ptr noundef %28)
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %17
  br label %33

32:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 35, ptr noundef @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

33:                                               ; preds = %31
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %6, align 4, !tbaa !5
  br label %12, !llvm.loop !13

37:                                               ; preds = %16
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  %39 = getelementptr inbounds [10 x i32], ptr %1, i64 0, i64 3
  %40 = call ptr @bs_tree_lookup_data(ptr noundef %38, ptr noundef %39)
  store ptr %40, ptr %5, align 8, !tbaa !9
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct._BSTreeNode, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = getelementptr inbounds [10 x i32], ptr %1, i64 0, i64 3
  %45 = call i32 @int_equal(ptr noundef %43, ptr noundef %44)
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %37
  br label %49

48:                                               ; preds = %37
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 39, ptr noundef @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

49:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 808, ptr %7) #5
  %50 = getelementptr inbounds %struct._CBValue, ptr %7, i32 0, i32 1
  store i32 0, ptr %50, align 8, !tbaa !15
  %51 = load ptr, ptr %4, align 8, !tbaa !9
  call void @bs_tree_inorder_traverse(ptr noundef %51, ptr noundef @bs_tree_traverse_callback, ptr noundef %7)
  %52 = getelementptr inbounds %struct._CBValue, ptr %7, i32 0, i32 1
  %53 = load i32, ptr %52, align 8, !tbaa !15
  %54 = icmp eq i32 %53, 10
  br i1 %54, label %55, label %56

55:                                               ; preds = %49
  br label %57

56:                                               ; preds = %49
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 44, ptr noundef @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

57:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %77, %57
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %80

63:                                               ; preds = %58
  %64 = getelementptr inbounds %struct._CBValue, ptr %7, i32 0, i32 0
  %65 = load i32, ptr %8, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100 x ptr], ptr %64, i64 0, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [10 x i32], ptr %2, i64 0, i64 %70
  %72 = call i32 @int_equal(ptr noundef %68, ptr noundef %71)
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %63
  br label %76

75:                                               ; preds = %63
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 47, ptr noundef @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

76:                                               ; preds = %74
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %8, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %8, align 4, !tbaa !5
  br label %58, !llvm.loop !17

80:                                               ; preds = %62
  %81 = load ptr, ptr %4, align 8, !tbaa !9
  %82 = load ptr, ptr %4, align 8, !tbaa !9
  %83 = getelementptr inbounds [10 x i32], ptr %1, i64 0, i64 3
  %84 = call ptr @bs_tree_lookup_data(ptr noundef %82, ptr noundef %83)
  %85 = call ptr @bs_tree_remove_node(ptr noundef %81, ptr noundef %84)
  store ptr %85, ptr %5, align 8, !tbaa !9
  %86 = load ptr, ptr %5, align 8, !tbaa !9
  call void @alloc_test_free(ptr noundef %86)
  %87 = load ptr, ptr %4, align 8, !tbaa !9
  %88 = load ptr, ptr %4, align 8, !tbaa !9
  %89 = getelementptr inbounds [10 x i32], ptr %1, i64 0, i64 4
  %90 = call ptr @bs_tree_lookup_data(ptr noundef %88, ptr noundef %89)
  %91 = call ptr @bs_tree_remove_node(ptr noundef %87, ptr noundef %90)
  store ptr %91, ptr %5, align 8, !tbaa !9
  %92 = load ptr, ptr %5, align 8, !tbaa !9
  call void @alloc_test_free(ptr noundef %92)
  %93 = load ptr, ptr %4, align 8, !tbaa !9
  %94 = load ptr, ptr %4, align 8, !tbaa !9
  %95 = getelementptr inbounds [10 x i32], ptr %1, i64 0, i64 0
  %96 = call ptr @bs_tree_lookup_data(ptr noundef %94, ptr noundef %95)
  %97 = call ptr @bs_tree_remove_node(ptr noundef %93, ptr noundef %96)
  store ptr %97, ptr %5, align 8, !tbaa !9
  %98 = load ptr, ptr %5, align 8, !tbaa !9
  call void @alloc_test_free(ptr noundef %98)
  call void @llvm.lifetime.start.p0(i64 28, ptr %9) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 @__const.test_bstree.remain, i64 28, i1 false)
  %99 = getelementptr inbounds %struct._CBValue, ptr %7, i32 0, i32 1
  store i32 0, ptr %99, align 8, !tbaa !15
  %100 = load ptr, ptr %4, align 8, !tbaa !9
  call void @bs_tree_inorder_traverse(ptr noundef %100, ptr noundef @bs_tree_traverse_callback, ptr noundef %7)
  %101 = getelementptr inbounds %struct._CBValue, ptr %7, i32 0, i32 1
  %102 = load i32, ptr %101, align 8, !tbaa !15
  %103 = load ptr, ptr %4, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct._BSTree, ptr %103, i32 0, i32 2
  %105 = load i32, ptr %104, align 8, !tbaa !18
  %106 = icmp eq i32 %102, %105
  br i1 %106, label %107, label %108

107:                                              ; preds = %80
  br label %109

108:                                              ; preds = %80
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 78, ptr noundef @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

109:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %131, %109
  %111 = load i32, ptr %10, align 4, !tbaa !5
  %112 = load ptr, ptr %4, align 8, !tbaa !9
  %113 = getelementptr inbounds %struct._BSTree, ptr %112, i32 0, i32 2
  %114 = load i32, ptr %113, align 8, !tbaa !18
  %115 = icmp ult i32 %111, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %134

117:                                              ; preds = %110
  %118 = getelementptr inbounds %struct._CBValue, ptr %7, i32 0, i32 0
  %119 = load i32, ptr %10, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [100 x ptr], ptr %118, i64 0, i64 %120
  %122 = load ptr, ptr %121, align 8, !tbaa !9
  %123 = load i32, ptr %10, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [7 x i32], ptr %9, i64 0, i64 %124
  %126 = call i32 @int_equal(ptr noundef %122, ptr noundef %125)
  %127 = icmp ne i32 %126, 0
  br i1 %127, label %128, label %129

128:                                              ; preds = %117
  br label %130

129:                                              ; preds = %117
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 81, ptr noundef @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

130:                                              ; preds = %128
  br label %131

131:                                              ; preds = %130
  %132 = load i32, ptr %10, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %10, align 4, !tbaa !5
  br label %110, !llvm.loop !20

134:                                              ; preds = %116
  %135 = load ptr, ptr %4, align 8, !tbaa !9
  call void @bs_tree_free(ptr noundef %135)
  call void @llvm.lifetime.end.p0(i64 28, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 808, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %1) #5
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @bs_tree_new(ptr noundef) #3

declare i32 @int_compare(ptr noundef, ptr noundef) #3

declare ptr @bs_tree_insert(ptr noundef, ptr noundef) #3

declare i32 @int_equal(ptr noundef, ptr noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

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

declare ptr @bs_tree_lookup_data(ptr noundef, ptr noundef) #3

declare void @bs_tree_inorder_traverse(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @bs_tree_traverse_callback(ptr noundef, ptr noundef) #0

declare ptr @bs_tree_remove_node(ptr noundef, ptr noundef) #3

declare void @alloc_test_free(ptr noundef) #3

declare void @bs_tree_free(ptr noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree 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 = { noreturn 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 = { nounwind }
attributes #6 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_BSTreeNode", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 800}
!16 = !{!"_CBValue", !7, i64 0, !6, i64 800, !6, i64 804}
!17 = distinct !{!17, !14}
!18 = !{!19, !6, i64 16}
!19 = !{!"_BSTree", !10, i64 0, !10, i64 8, !6, i64 16}
!20 = distinct !{!20, !14}


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

%struct._CBValue = type { [100 x ptr], i32, i32 }

@__const.test_bstree.entries = external hidden unnamed_addr constant [10 x i32], align 16
@__const.test_bstree.sorted = external hidden unnamed_addr constant [10 x i32], align 16
@.str = external hidden unnamed_addr constant [35 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@__PRETTY_FUNCTION__.test_bstree = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 x i8], align 1
@__const.test_bstree.remain = external hidden unnamed_addr constant [7 x i32], align 16
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @test_bstree() local_unnamed_addr #0 {
  %1 = alloca [10 x i32], align 16
  %2 = alloca [10 x i32], align 16
  %3 = alloca %struct._CBValue, align 8
  %4 = alloca [7 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(40) %1, ptr noundef nonnull align 16 dereferenceable(40) @__const.test_bstree.entries, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(40) %2, ptr noundef nonnull align 16 dereferenceable(40) @__const.test_bstree.sorted, i64 40, i1 false)
  %5 = tail call ptr @bs_tree_new(ptr noundef nonnull @int_compare) #5
  %6 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %1) #5
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = call i32 @int_equal(ptr noundef %7, ptr noundef nonnull %1) #5
  %.not35 = icmp eq i32 %8, 0
  br i1 %.not35, label %58, label %9

9:                                                ; preds = %0
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %10) #5
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = call i32 @int_equal(ptr noundef %12, ptr noundef nonnull %10) #5
  %.not35.1 = icmp eq i32 %13, 0
  br i1 %.not35.1, label %58, label %14

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %15) #5
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = call i32 @int_equal(ptr noundef %17, ptr noundef nonnull %15) #5
  %.not35.2 = icmp eq i32 %18, 0
  br i1 %.not35.2, label %58, label %19

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %1, i64 12
  %21 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %20) #5
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = call i32 @int_equal(ptr noundef %22, ptr noundef nonnull %20) #5
  %.not35.3 = icmp eq i32 %23, 0
  br i1 %.not35.3, label %58, label %24

24:                                               ; preds = %19
  %25 = getelementptr inbounds i8, ptr %1, i64 16
  %26 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %25) #5
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = call i32 @int_equal(ptr noundef %27, ptr noundef nonnull %25) #5
  %.not35.4 = icmp eq i32 %28, 0
  br i1 %.not35.4, label %58, label %29

29:                                               ; preds = %24
  %30 = getelementptr inbounds i8, ptr %1, i64 20
  %31 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %30) #5
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = call i32 @int_equal(ptr noundef %32, ptr noundef nonnull %30) #5
  %.not35.5 = icmp eq i32 %33, 0
  br i1 %.not35.5, label %58, label %34

34:                                               ; preds = %29
  %35 = getelementptr inbounds i8, ptr %1, i64 24
  %36 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %35) #5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = call i32 @int_equal(ptr noundef %37, ptr noundef nonnull %35) #5
  %.not35.6 = icmp eq i32 %38, 0
  br i1 %.not35.6, label %58, label %39

39:                                               ; preds = %34
  %40 = getelementptr inbounds i8, ptr %1, i64 28
  %41 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %40) #5
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = call i32 @int_equal(ptr noundef %42, ptr noundef nonnull %40) #5
  %.not35.7 = icmp eq i32 %43, 0
  br i1 %.not35.7, label %58, label %44

44:                                               ; preds = %39
  %45 = getelementptr inbounds i8, ptr %1, i64 32
  %46 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %45) #5
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = call i32 @int_equal(ptr noundef %47, ptr noundef nonnull %45) #5
  %.not35.8 = icmp eq i32 %48, 0
  br i1 %.not35.8, label %58, label %49

49:                                               ; preds = %44
  %50 = getelementptr inbounds i8, ptr %1, i64 36
  %51 = call ptr @bs_tree_insert(ptr noundef %5, ptr noundef nonnull %50) #5
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = call i32 @int_equal(ptr noundef %52, ptr noundef nonnull %50) #5
  %.not35.9 = icmp eq i32 %53, 0
  br i1 %.not35.9, label %58, label %54

54:                                               ; preds = %49
  %55 = call ptr @bs_tree_lookup_data(ptr noundef %5, ptr noundef nonnull %20) #5
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = call i32 @int_equal(ptr noundef %56, ptr noundef nonnull %20) #5
  %.not = icmp eq i32 %57, 0
  br i1 %.not, label %59, label %60

58:                                               ; preds = %49, %44, %39, %34, %29, %24, %19, %14, %9, %0
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 35, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

59:                                               ; preds = %54
  call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 39, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

60:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 808, ptr nonnull %3) #5
  %61 = getelementptr inbounds i8, ptr %3, i64 800
  store i32 0, ptr %61, align 8, !tbaa !10
  call void @bs_tree_inorder_traverse(ptr noundef %5, ptr noundef nonnull @bs_tree_traverse_callback, ptr noundef nonnull %3) #5
  %62 = load i32, ptr %61, align 8, !tbaa !10
  %63 = icmp eq i32 %62, 10
  br i1 %63, label %.preheader36.preheader, label %66

.preheader36.preheader:                           ; preds = %60
  %64 = load ptr, ptr %3, align 8, !tbaa !13
  %65 = call i32 @int_equal(ptr noundef %64, ptr noundef nonnull %2) #5
  %.not34 = icmp eq i32 %65, 0
  br i1 %.not34, label %114, label %.preheader36.1

66:                                               ; preds = %60
  call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 44, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

.preheader36.1:                                   ; preds = %.preheader36.preheader
  %67 = getelementptr inbounds i8, ptr %3, i64 8
  %68 = load ptr, ptr %67, align 8, !tbaa !13
  %69 = getelementptr inbounds i8, ptr %2, i64 4
  %70 = call i32 @int_equal(ptr noundef %68, ptr noundef nonnull %69) #5
  %.not34.1 = icmp eq i32 %70, 0
  br i1 %.not34.1, label %114, label %.preheader36.2

.preheader36.2:                                   ; preds = %.preheader36.1
  %71 = getelementptr inbounds i8, ptr %3, i64 16
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = getelementptr inbounds i8, ptr %2, i64 8
  %74 = call i32 @int_equal(ptr noundef %72, ptr noundef nonnull %73) #5
  %.not34.2 = icmp eq i32 %74, 0
  br i1 %.not34.2, label %114, label %.preheader36.3

.preheader36.3:                                   ; preds = %.preheader36.2
  %75 = getelementptr inbounds i8, ptr %3, i64 24
  %76 = load ptr, ptr %75, align 8, !tbaa !13
  %77 = getelementptr inbounds i8, ptr %2, i64 12
  %78 = call i32 @int_equal(ptr noundef %76, ptr noundef nonnull %77) #5
  %.not34.3 = icmp eq i32 %78, 0
  br i1 %.not34.3, label %114, label %.preheader36.4

.preheader36.4:                                   ; preds = %.preheader36.3
  %79 = getelementptr inbounds i8, ptr %3, i64 32
  %80 = load ptr, ptr %79, align 8, !tbaa !13
  %81 = getelementptr inbounds i8, ptr %2, i64 16
  %82 = call i32 @int_equal(ptr noundef %80, ptr noundef nonnull %81) #5
  %.not34.4 = icmp eq i32 %82, 0
  br i1 %.not34.4, label %114, label %.preheader36.5

.preheader36.5:                                   ; preds = %.preheader36.4
  %83 = getelementptr inbounds i8, ptr %3, i64 40
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = getelementptr inbounds i8, ptr %2, i64 20
  %86 = call i32 @int_equal(ptr noundef %84, ptr noundef nonnull %85) #5
  %.not34.5 = icmp eq i32 %86, 0
  br i1 %.not34.5, label %114, label %.preheader36.6

.preheader36.6:                                   ; preds = %.preheader36.5
  %87 = getelementptr inbounds i8, ptr %3, i64 48
  %88 = load ptr, ptr %87, align 8, !tbaa !13
  %89 = getelementptr inbounds i8, ptr %2, i64 24
  %90 = call i32 @int_equal(ptr noundef %88, ptr noundef nonnull %89) #5
  %.not34.6 = icmp eq i32 %90, 0
  br i1 %.not34.6, label %114, label %.preheader36.7

.preheader36.7:                                   ; preds = %.preheader36.6
  %91 = getelementptr inbounds i8, ptr %3, i64 56
  %92 = load ptr, ptr %91, align 8, !tbaa !13
  %93 = getelementptr inbounds i8, ptr %2, i64 28
  %94 = call i32 @int_equal(ptr noundef %92, ptr noundef nonnull %93) #5
  %.not34.7 = icmp eq i32 %94, 0
  br i1 %.not34.7, label %114, label %.preheader36.8

.preheader36.8:                                   ; preds = %.preheader36.7
  %95 = getelementptr inbounds i8, ptr %3, i64 64
  %96 = load ptr, ptr %95, align 8, !tbaa !13
  %97 = getelementptr inbounds i8, ptr %2, i64 32
  %98 = call i32 @int_equal(ptr noundef %96, ptr noundef nonnull %97) #5
  %.not34.8 = icmp eq i32 %98, 0
  br i1 %.not34.8, label %114, label %.preheader36.9

.preheader36.9:                                   ; preds = %.preheader36.8
  %99 = getelementptr inbounds i8, ptr %3, i64 72
  %100 = load ptr, ptr %99, align 8, !tbaa !13
  %101 = getelementptr inbounds i8, ptr %2, i64 36
  %102 = call i32 @int_equal(ptr noundef %100, ptr noundef nonnull %101) #5
  %.not34.9 = icmp eq i32 %102, 0
  br i1 %.not34.9, label %114, label %103

103:                                              ; preds = %.preheader36.9
  %104 = call ptr @bs_tree_lookup_data(ptr noundef %5, ptr noundef nonnull %20) #5
  %105 = call ptr @bs_tree_remove_node(ptr noundef %5, ptr noundef %104) #5
  call void @alloc_test_free(ptr noundef %105) #5
  %106 = call ptr @bs_tree_lookup_data(ptr noundef %5, ptr noundef nonnull %25) #5
  %107 = call ptr @bs_tree_remove_node(ptr noundef %5, ptr noundef %106) #5
  call void @alloc_test_free(ptr noundef %107) #5
  %108 = call ptr @bs_tree_lookup_data(ptr noundef %5, ptr noundef nonnull %1) #5
  %109 = call ptr @bs_tree_remove_node(ptr noundef %5, ptr noundef %108) #5
  call void @alloc_test_free(ptr noundef %109) #5
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(28) %4, ptr noundef nonnull align 16 dereferenceable(28) @__const.test_bstree.remain, i64 28, i1 false)
  store i32 0, ptr %61, align 8, !tbaa !10
  call void @bs_tree_inorder_traverse(ptr noundef %5, ptr noundef nonnull @bs_tree_traverse_callback, ptr noundef nonnull %3) #5
  %110 = load i32, ptr %61, align 8, !tbaa !10
  %111 = getelementptr inbounds i8, ptr %5, i64 16
  %112 = load i32, ptr %111, align 8, !tbaa !14
  %113 = icmp eq i32 %110, %112
  br i1 %113, label %.preheader, label %115

.preheader:                                       ; preds = %103
  %.not40 = icmp eq i32 %110, 0
  br i1 %.not40, label %._crit_edge, label %.lr.ph

114:                                              ; preds = %.preheader36.9, %.preheader36.8, %.preheader36.7, %.preheader36.6, %.preheader36.5, %.preheader36.4, %.preheader36.3, %.preheader36.2, %.preheader36.1, %.preheader36.preheader
  call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 47, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

115:                                              ; preds = %103
  call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 78, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable

116:                                              ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %117 = load i32, ptr %111, align 8, !tbaa !14
  %118 = zext i32 %117 to i64
  %119 = icmp ult i64 %indvars.iv.next, %118
  br i1 %119, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %116, %.preheader
  call void @bs_tree_free(ptr noundef nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 808, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #5
  ret void

.lr.ph:                                           ; preds = %.preheader, %116
  %indvars.iv = phi i64 [ %indvars.iv.next, %116 ], [ 0, %.preheader ]
  %120 = getelementptr inbounds [100 x ptr], ptr %3, i64 0, i64 %indvars.iv
  %121 = load ptr, ptr %120, align 8, !tbaa !13
  %122 = getelementptr inbounds [7 x i32], ptr %4, i64 0, i64 %indvars.iv
  %123 = call i32 @int_equal(ptr noundef %121, ptr noundef nonnull %122) #5
  %.not33 = icmp eq i32 %123, 0
  br i1 %.not33, label %124, label %116

124:                                              ; preds = %.lr.ph
  call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 81, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bstree) #6
  unreachable
}

; 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 nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @bs_tree_new(ptr noundef) local_unnamed_addr #3

declare i32 @int_compare(ptr noundef, ptr noundef) #3

declare ptr @bs_tree_insert(ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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

declare ptr @bs_tree_lookup_data(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @bs_tree_inorder_traverse(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @bs_tree_traverse_callback(ptr noundef, ptr noundef) #0

declare ptr @bs_tree_remove_node(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @alloc_test_free(ptr noundef) local_unnamed_addr #3

declare void @bs_tree_free(ptr noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree 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 = { noreturn 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 = { nounwind }
attributes #6 = { noreturn 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, !7, i64 0}
!6 = !{!"_BSTreeNode", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 800}
!11 = !{!"_CBValue", !8, i64 0, !12, i64 800, !12, i64 804}
!12 = !{!"int", !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !12, i64 16}
!15 = !{!"_BSTree", !7, i64 0, !7, i64 8, !12, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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