; LLVM IR from PacktPublishing/CPP-Data-Structures-and-Algorithms :: Chapter07/Binary_Search_Tree/src/AVLNode.ll (ZN3AVL6RemoveEP7BSTNodei)

; 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.BSTNode = type { i32, ptr, ptr, ptr, i32 }

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN3AVL6RemoveEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %209

18:                                               ; preds = %3
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.BSTNode, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp eq i32 %21, %22
  br i1 %23, label %24, label %93

24:                                               ; preds = %18
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.BSTNode, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %35

29:                                               ; preds = %24
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.BSTNode, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %29
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %92

35:                                               ; preds = %29, %24
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.BSTNode, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %56

40:                                               ; preds = %35
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.BSTNode, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %56

45:                                               ; preds = %40
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %class.BSTNode, ptr %46, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %class.BSTNode, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = getelementptr inbounds %class.BSTNode, ptr %51, i32 0, i32 3
  store ptr %48, ptr %52, align 8, !tbaa !15
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %class.BSTNode, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  store ptr %55, ptr %6, align 8, !tbaa !5
  br label %91

56:                                               ; preds = %40, %35
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %class.BSTNode, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !13
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %77

61:                                               ; preds = %56
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %class.BSTNode, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = icmp eq ptr %64, null
  br i1 %65, label %66, label %77

66:                                               ; preds = %61
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %class.BSTNode, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !15
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %class.BSTNode, ptr %70, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = getelementptr inbounds %class.BSTNode, ptr %72, i32 0, i32 3
  store ptr %69, ptr %73, align 8, !tbaa !15
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %class.BSTNode, ptr %74, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !13
  store ptr %76, ptr %6, align 8, !tbaa !5
  br label %90

77:                                               ; preds = %61, %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = call noundef i32 @_ZN3BST9SuccessorEi(ptr noundef nonnull align 8 dereferenceable(8) %14, i32 noundef %78)
  store i32 %79, ptr %8, align 4, !tbaa !9
  %80 = load i32, ptr %8, align 4, !tbaa !9
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %class.BSTNode, ptr %81, i32 0, i32 0
  store i32 %80, ptr %82, align 8, !tbaa !11
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %class.BSTNode, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !14
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = call noundef ptr @_ZN3AVL6RemoveEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %85, i32 noundef %86)
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = getelementptr inbounds %class.BSTNode, ptr %88, i32 0, i32 2
  store ptr %87, ptr %89, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %90

90:                                               ; preds = %77, %66
  br label %91

91:                                               ; preds = %90, %45
  br label %92

92:                                               ; preds = %91, %34
  br label %116

93:                                               ; preds = %18
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %class.BSTNode, ptr %94, i32 0, i32 0
  %96 = load i32, ptr %95, align 8, !tbaa !11
  %97 = load i32, ptr %7, align 4, !tbaa !9
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %99, label %107

99:                                               ; preds = %93
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds %class.BSTNode, ptr %100, i32 0, i32 2
  %102 = load ptr, ptr %101, align 8, !tbaa !14
  %103 = load i32, ptr %7, align 4, !tbaa !9
  %104 = call noundef ptr @_ZN3AVL6RemoveEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %102, i32 noundef %103)
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = getelementptr inbounds %class.BSTNode, ptr %105, i32 0, i32 2
  store ptr %104, ptr %106, align 8, !tbaa !14
  br label %115

107:                                              ; preds = %93
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = getelementptr inbounds %class.BSTNode, ptr %108, i32 0, i32 1
  %110 = load ptr, ptr %109, align 8, !tbaa !13
  %111 = load i32, ptr %7, align 4, !tbaa !9
  %112 = call noundef ptr @_ZN3AVL6RemoveEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %110, i32 noundef %111)
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = getelementptr inbounds %class.BSTNode, ptr %113, i32 0, i32 1
  store ptr %112, ptr %114, align 8, !tbaa !13
  br label %115

115:                                              ; preds = %107, %99
  br label %116

116:                                              ; preds = %115, %92
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = icmp ne ptr %117, null
  br i1 %118, label %119, label %207

119:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %120 = load ptr, ptr %6, align 8, !tbaa !5
  %121 = getelementptr inbounds %class.BSTNode, ptr %120, i32 0, i32 1
  %122 = load ptr, ptr %121, align 8, !tbaa !13
  %123 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %122)
  %124 = load ptr, ptr %6, align 8, !tbaa !5
  %125 = getelementptr inbounds %class.BSTNode, ptr %124, i32 0, i32 2
  %126 = load ptr, ptr %125, align 8, !tbaa !14
  %127 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %126)
  %128 = sub nsw i32 %123, %127
  store i32 %128, ptr %9, align 4, !tbaa !9
  %129 = load i32, ptr %9, align 4, !tbaa !9
  %130 = icmp eq i32 %129, 2
  br i1 %130, label %131, label %160

131:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = getelementptr inbounds %class.BSTNode, ptr %132, i32 0, i32 1
  %134 = load ptr, ptr %133, align 8, !tbaa !13
  %135 = getelementptr inbounds %class.BSTNode, ptr %134, i32 0, i32 1
  %136 = load ptr, ptr %135, align 8, !tbaa !13
  %137 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %136)
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = getelementptr inbounds %class.BSTNode, ptr %138, i32 0, i32 1
  %140 = load ptr, ptr %139, align 8, !tbaa !13
  %141 = getelementptr inbounds %class.BSTNode, ptr %140, i32 0, i32 2
  %142 = load ptr, ptr %141, align 8, !tbaa !14
  %143 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %142)
  %144 = sub nsw i32 %137, %143
  store i32 %144, ptr %10, align 4, !tbaa !9
  %145 = load i32, ptr %10, align 4, !tbaa !9
  %146 = icmp eq i32 %145, 1
  br i1 %146, label %147, label %150

147:                                              ; preds = %131
  %148 = load ptr, ptr %6, align 8, !tbaa !5
  %149 = call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %148)
  store ptr %149, ptr %6, align 8, !tbaa !5
  br label %159

150:                                              ; preds = %131
  %151 = load ptr, ptr %6, align 8, !tbaa !5
  %152 = getelementptr inbounds %class.BSTNode, ptr %151, i32 0, i32 1
  %153 = load ptr, ptr %152, align 8, !tbaa !13
  %154 = call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %153)
  %155 = load ptr, ptr %6, align 8, !tbaa !5
  %156 = getelementptr inbounds %class.BSTNode, ptr %155, i32 0, i32 1
  store ptr %154, ptr %156, align 8, !tbaa !13
  %157 = load ptr, ptr %6, align 8, !tbaa !5
  %158 = call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %157)
  store ptr %158, ptr %6, align 8, !tbaa !5
  br label %159

159:                                              ; preds = %150, %147
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %193

160:                                              ; preds = %119
  %161 = load i32, ptr %9, align 4, !tbaa !9
  %162 = icmp eq i32 %161, -2
  br i1 %162, label %163, label %192

163:                                              ; preds = %160
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %164 = load ptr, ptr %6, align 8, !tbaa !5
  %165 = getelementptr inbounds %class.BSTNode, ptr %164, i32 0, i32 2
  %166 = load ptr, ptr %165, align 8, !tbaa !14
  %167 = getelementptr inbounds %class.BSTNode, ptr %166, i32 0, i32 1
  %168 = load ptr, ptr %167, align 8, !tbaa !13
  %169 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %168)
  %170 = load ptr, ptr %6, align 8, !tbaa !5
  %171 = getelementptr inbounds %class.BSTNode, ptr %170, i32 0, i32 2
  %172 = load ptr, ptr %171, align 8, !tbaa !14
  %173 = getelementptr inbounds %class.BSTNode, ptr %172, i32 0, i32 2
  %174 = load ptr, ptr %173, align 8, !tbaa !14
  %175 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %174)
  %176 = sub nsw i32 %169, %175
  store i32 %176, ptr %11, align 4, !tbaa !9
  %177 = load i32, ptr %11, align 4, !tbaa !9
  %178 = icmp eq i32 %177, -1
  br i1 %178, label %179, label %182

179:                                              ; preds = %163
  %180 = load ptr, ptr %6, align 8, !tbaa !5
  %181 = call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %180)
  store ptr %181, ptr %6, align 8, !tbaa !5
  br label %191

182:                                              ; preds = %163
  %183 = load ptr, ptr %6, align 8, !tbaa !5
  %184 = getelementptr inbounds %class.BSTNode, ptr %183, i32 0, i32 2
  %185 = load ptr, ptr %184, align 8, !tbaa !14
  %186 = call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %185)
  %187 = load ptr, ptr %6, align 8, !tbaa !5
  %188 = getelementptr inbounds %class.BSTNode, ptr %187, i32 0, i32 2
  store ptr %186, ptr %188, align 8, !tbaa !14
  %189 = load ptr, ptr %6, align 8, !tbaa !5
  %190 = call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %189)
  store ptr %190, ptr %6, align 8, !tbaa !5
  br label %191

191:                                              ; preds = %182, %179
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %192

192:                                              ; preds = %191, %160
  br label %193

193:                                              ; preds = %192, %159
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %194 = load ptr, ptr %6, align 8, !tbaa !5
  %195 = getelementptr inbounds %class.BSTNode, ptr %194, i32 0, i32 1
  %196 = load ptr, ptr %195, align 8, !tbaa !13
  %197 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %196)
  store i32 %197, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %198 = load ptr, ptr %6, align 8, !tbaa !5
  %199 = getelementptr inbounds %class.BSTNode, ptr %198, i32 0, i32 2
  %200 = load ptr, ptr %199, align 8, !tbaa !14
  %201 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %200)
  store i32 %201, ptr %13, align 4, !tbaa !9
  %202 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %203 = load i32, ptr %202, align 4, !tbaa !9
  %204 = add nsw i32 %203, 1
  %205 = load ptr, ptr %6, align 8, !tbaa !5
  %206 = getelementptr inbounds %class.BSTNode, ptr %205, i32 0, i32 4
  store i32 %204, ptr %206, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %207

207:                                              ; preds = %193, %116
  %208 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %208, ptr %4, align 8
  br label %209

209:                                              ; preds = %207, %17
  %210 = load ptr, ptr %4, align 8
  ret ptr %210
}

declare noundef i32 @_ZN3BST9SuccessorEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS7BSTNode", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !10, i64 32}


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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) 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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN3AVL6RemoveEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = icmp eq ptr %1, null
  br i1 %6, label %94, label %7

7:                                                ; preds = %3
  %8 = load i32, ptr %1, align 8, !tbaa !5
  %9 = icmp eq i32 %8, %2
  br i1 %9, label %10, label %31

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp eq ptr %12, null
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = icmp eq ptr %15, null
  br i1 %13, label %17, label %22

17:                                               ; preds = %10
  br i1 %16, label %94, label %18

18:                                               ; preds = %17
  %19 = getelementptr inbounds i8, ptr %1, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %15, i64 24
  store ptr %20, ptr %21, align 8, !tbaa !13
  br label %41

22:                                               ; preds = %10
  br i1 %16, label %23, label %.thread63

23:                                               ; preds = %22
  %24 = getelementptr inbounds i8, ptr %1, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %12, i64 24
  store ptr %25, ptr %26, align 8, !tbaa !13
  br label %41

.thread63:                                        ; preds = %22
  %27 = tail call noundef i32 @_ZN3BST9SuccessorEi(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %2)
  store i32 %27, ptr %1, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %1, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  %30 = tail call noundef ptr @_ZN3AVL6RemoveEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %29, i32 noundef %27)
  store ptr %30, ptr %28, align 8, !tbaa !12
  br label %41

31:                                               ; preds = %7
  %32 = icmp slt i32 %8, %2
  br i1 %32, label %33, label %37

33:                                               ; preds = %31
  %34 = getelementptr inbounds i8, ptr %1, i64 16
  %35 = load ptr, ptr %34, align 8, !tbaa !12
  %36 = tail call noundef ptr @_ZN3AVL6RemoveEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %35, i32 noundef %2)
  store ptr %36, ptr %34, align 8, !tbaa !12
  br label %41

37:                                               ; preds = %31
  %38 = getelementptr inbounds i8, ptr %1, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = tail call noundef ptr @_ZN3AVL6RemoveEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %39, i32 noundef %2)
  store ptr %40, ptr %38, align 8, !tbaa !11
  br label %41

41:                                               ; preds = %18, %23, %.thread63, %33, %37
  %.053.ph = phi ptr [ %1, %37 ], [ %1, %33 ], [ %1, %.thread63 ], [ %12, %23 ], [ %15, %18 ]
  %42 = getelementptr inbounds i8, ptr %.053.ph, i64 8
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %43)
  %45 = getelementptr inbounds i8, ptr %.053.ph, i64 16
  %46 = load ptr, ptr %45, align 8, !tbaa !12
  %47 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %46)
  %48 = sub nsw i32 %44, %47
  switch i32 %48, label %83 [
    i32 2, label %49
    i32 -2, label %66
  ]

49:                                               ; preds = %41
  %50 = load ptr, ptr %42, align 8, !tbaa !11
  %51 = getelementptr inbounds i8, ptr %50, i64 8
  %52 = load ptr, ptr %51, align 8, !tbaa !11
  %53 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %52)
  %54 = load ptr, ptr %42, align 8, !tbaa !11
  %55 = getelementptr inbounds i8, ptr %54, i64 16
  %56 = load ptr, ptr %55, align 8, !tbaa !12
  %57 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %56)
  %58 = sub nsw i32 %53, %57
  %59 = icmp eq i32 %58, 1
  br i1 %59, label %60, label %62

60:                                               ; preds = %49
  %61 = tail call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %.053.ph)
  br label %83

62:                                               ; preds = %49
  %63 = load ptr, ptr %42, align 8, !tbaa !11
  %64 = tail call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %63)
  store ptr %64, ptr %42, align 8, !tbaa !11
  %65 = tail call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %.053.ph)
  br label %83

66:                                               ; preds = %41
  %67 = load ptr, ptr %45, align 8, !tbaa !12
  %68 = getelementptr inbounds i8, ptr %67, i64 8
  %69 = load ptr, ptr %68, align 8, !tbaa !11
  %70 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %69)
  %71 = load ptr, ptr %45, align 8, !tbaa !12
  %72 = getelementptr inbounds i8, ptr %71, i64 16
  %73 = load ptr, ptr %72, align 8, !tbaa !12
  %74 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %73)
  %75 = sub nsw i32 %70, %74
  %76 = icmp eq i32 %75, -1
  br i1 %76, label %77, label %79

77:                                               ; preds = %66
  %78 = tail call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %.053.ph)
  br label %83

79:                                               ; preds = %66
  %80 = load ptr, ptr %45, align 8, !tbaa !12
  %81 = tail call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %80)
  store ptr %81, ptr %45, align 8, !tbaa !12
  %82 = tail call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %.053.ph)
  br label %83

83:                                               ; preds = %77, %79, %41, %60, %62
  %.3 = phi ptr [ %61, %60 ], [ %65, %62 ], [ %.053.ph, %41 ], [ %78, %77 ], [ %82, %79 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %84 = getelementptr inbounds i8, ptr %.3, i64 8
  %85 = load ptr, ptr %84, align 8, !tbaa !11
  %86 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %85)
  store i32 %86, ptr %4, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %87 = getelementptr inbounds i8, ptr %.3, i64 16
  %88 = load ptr, ptr %87, align 8, !tbaa !12
  %89 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %88)
  store i32 %89, ptr %5, align 4, !tbaa !14
  %90 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %91 = load i32, ptr %90, align 4, !tbaa !14
  %92 = add nsw i32 %91, 1
  %93 = getelementptr inbounds i8, ptr %.3, i64 32
  store i32 %92, ptr %93, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  br label %94

94:                                               ; preds = %17, %83, %3
  %.0 = phi ptr [ null, %3 ], [ %.3, %83 ], [ null, %17 ]
  ret ptr %.0
}

declare noundef i32 @_ZN3BST9SuccessorEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = { 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 = !{!"_ZTS7BSTNode", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !10, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 32}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass