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

; 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 @_ZN3AVL6InsertEP7BSTNodei(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 i32, align 4
  %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
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %28

15:                                               ; preds = %3
  %16 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #5
  store ptr %16, ptr %5, align 8, !tbaa !5
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.BSTNode, ptr %18, i32 0, i32 0
  store i32 %17, ptr %19, align 8, !tbaa !11
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.BSTNode, ptr %20, i32 0, i32 1
  store ptr null, ptr %21, align 8, !tbaa !13
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.BSTNode, ptr %22, i32 0, i32 2
  store ptr null, ptr %23, align 8, !tbaa !14
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.BSTNode, ptr %24, i32 0, i32 3
  store ptr null, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.BSTNode, ptr %26, i32 0, i32 4
  store i32 0, ptr %27, align 8, !tbaa !16
  br label %61

28:                                               ; preds = %3
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.BSTNode, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %47

34:                                               ; preds = %28
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.BSTNode, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = call noundef ptr @_ZN3AVL6InsertEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %37, i32 noundef %38)
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %class.BSTNode, ptr %40, i32 0, i32 2
  store ptr %39, ptr %41, align 8, !tbaa !14
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %class.BSTNode, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = getelementptr inbounds %class.BSTNode, ptr %45, i32 0, i32 3
  store ptr %42, ptr %46, align 8, !tbaa !15
  br label %60

47:                                               ; preds = %28
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.BSTNode, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = call noundef ptr @_ZN3AVL6InsertEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %50, i32 noundef %51)
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %class.BSTNode, ptr %53, i32 0, i32 1
  store ptr %52, ptr %54, align 8, !tbaa !13
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %class.BSTNode, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = getelementptr inbounds %class.BSTNode, ptr %58, i32 0, i32 3
  store ptr %55, ptr %59, align 8, !tbaa !15
  br label %60

60:                                               ; preds = %47, %34
  br label %61

61:                                               ; preds = %60, %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %class.BSTNode, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !13
  %65 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %64)
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %class.BSTNode, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !14
  %69 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %68)
  %70 = sub nsw i32 %65, %69
  store i32 %70, ptr %7, align 4, !tbaa !9
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = icmp eq i32 %71, 2
  br i1 %72, label %73, label %102

73:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %class.BSTNode, ptr %74, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !13
  %77 = getelementptr inbounds %class.BSTNode, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !13
  %79 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %78)
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %class.BSTNode, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !13
  %83 = getelementptr inbounds %class.BSTNode, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !14
  %85 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %84)
  %86 = sub nsw i32 %79, %85
  store i32 %86, ptr %8, align 4, !tbaa !9
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = icmp eq i32 %87, 1
  br i1 %88, label %89, label %92

89:                                               ; preds = %73
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %90)
  store ptr %91, ptr %5, align 8, !tbaa !5
  br label %101

92:                                               ; preds = %73
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %class.BSTNode, ptr %93, i32 0, i32 1
  %95 = load ptr, ptr %94, align 8, !tbaa !13
  %96 = call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %95)
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %class.BSTNode, ptr %97, i32 0, i32 1
  store ptr %96, ptr %98, align 8, !tbaa !13
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %99)
  store ptr %100, ptr %5, align 8, !tbaa !5
  br label %101

101:                                              ; preds = %92, %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %135

102:                                              ; preds = %61
  %103 = load i32, ptr %7, align 4, !tbaa !9
  %104 = icmp eq i32 %103, -2
  br i1 %104, label %105, label %134

105:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %class.BSTNode, ptr %106, i32 0, i32 2
  %108 = load ptr, ptr %107, align 8, !tbaa !14
  %109 = getelementptr inbounds %class.BSTNode, ptr %108, i32 0, i32 1
  %110 = load ptr, ptr %109, align 8, !tbaa !13
  %111 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %110)
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %class.BSTNode, ptr %112, i32 0, i32 2
  %114 = load ptr, ptr %113, align 8, !tbaa !14
  %115 = getelementptr inbounds %class.BSTNode, ptr %114, i32 0, i32 2
  %116 = load ptr, ptr %115, align 8, !tbaa !14
  %117 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %116)
  %118 = sub nsw i32 %111, %117
  store i32 %118, ptr %9, align 4, !tbaa !9
  %119 = load i32, ptr %9, align 4, !tbaa !9
  %120 = icmp eq i32 %119, -1
  br i1 %120, label %121, label %124

121:                                              ; preds = %105
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %122)
  store ptr %123, ptr %5, align 8, !tbaa !5
  br label %133

124:                                              ; preds = %105
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds %class.BSTNode, ptr %125, i32 0, i32 2
  %127 = load ptr, ptr %126, align 8, !tbaa !14
  %128 = call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %127)
  %129 = load ptr, ptr %5, align 8, !tbaa !5
  %130 = getelementptr inbounds %class.BSTNode, ptr %129, i32 0, i32 2
  store ptr %128, ptr %130, align 8, !tbaa !14
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %131)
  store ptr %132, ptr %5, align 8, !tbaa !5
  br label %133

133:                                              ; preds = %124, %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %134

134:                                              ; preds = %133, %102
  br label %135

135:                                              ; preds = %134, %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %136 = load ptr, ptr %5, align 8, !tbaa !5
  %137 = getelementptr inbounds %class.BSTNode, ptr %136, i32 0, i32 1
  %138 = load ptr, ptr %137, align 8, !tbaa !13
  %139 = call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %138)
  store i32 %139, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %140 = load ptr, ptr %5, align 8, !tbaa !5
  %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) %12, ptr noundef %142)
  store i32 %143, ptr %11, align 4, !tbaa !9
  %144 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %145 = load i32, ptr %144, align 4, !tbaa !9
  %146 = add nsw i32 %145, 1
  %147 = load ptr, ptr %5, align 8, !tbaa !5
  %148 = getelementptr inbounds %class.BSTNode, ptr %147, i32 0, i32 4
  store i32 %146, ptr %148, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %149 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  ret ptr %149
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 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 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { builtin allocsize(0) }
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 = !{!"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 @_ZN3AVL6InsertEP7BSTNodei(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 %7, label %10

7:                                                ; preds = %3
  %8 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #6
  store i32 %2, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(28) %9, i8 0, i64 28, i1 false)
  br label %23

10:                                               ; preds = %3
  %11 = load i32, ptr %1, align 8, !tbaa !5
  %12 = icmp slt i32 %11, %2
  br i1 %12, label %13, label %18

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = tail call noundef ptr @_ZN3AVL6InsertEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %15, i32 noundef %2)
  store ptr %16, ptr %14, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %16, i64 24
  store ptr %1, ptr %17, align 8, !tbaa !12
  %.phi.trans.insert = getelementptr inbounds i8, ptr %1, i64 8
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !13
  br label %23

18:                                               ; preds = %10
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = tail call noundef ptr @_ZN3AVL6InsertEP7BSTNodei(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %20, i32 noundef %2)
  store ptr %21, ptr %19, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %21, i64 24
  store ptr %1, ptr %22, align 8, !tbaa !12
  br label %23

23:                                               ; preds = %13, %18, %7
  %24 = phi ptr [ null, %7 ], [ %.pre, %13 ], [ %21, %18 ]
  %.0 = phi ptr [ %8, %7 ], [ %1, %13 ], [ %1, %18 ]
  %25 = getelementptr inbounds i8, ptr %.0, i64 8
  %26 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %24)
  %27 = getelementptr inbounds i8, ptr %.0, i64 16
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %28)
  %30 = sub nsw i32 %26, %29
  switch i32 %30, label %65 [
    i32 2, label %31
    i32 -2, label %48
  ]

31:                                               ; preds = %23
  %32 = load ptr, ptr %25, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %34)
  %36 = load ptr, ptr %25, align 8, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %38)
  %40 = sub nsw i32 %35, %39
  %41 = icmp eq i32 %40, 1
  br i1 %41, label %42, label %44

42:                                               ; preds = %31
  %43 = tail call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %.0)
  br label %65

44:                                               ; preds = %31
  %45 = load ptr, ptr %25, align 8, !tbaa !13
  %46 = tail call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %45)
  store ptr %46, ptr %25, align 8, !tbaa !13
  %47 = tail call noundef ptr @_ZN3AVL11RotateRightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %.0)
  br label %65

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

59:                                               ; preds = %48
  %60 = tail call noundef ptr @_ZN3AVL10RotateLeftEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %.0)
  br label %65

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

65:                                               ; preds = %59, %61, %23, %42, %44
  %.3 = phi ptr [ %43, %42 ], [ %47, %44 ], [ %.0, %23 ], [ %60, %59 ], [ %64, %61 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %66 = getelementptr inbounds i8, ptr %.3, i64 8
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %67)
  store i32 %68, ptr %4, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %69 = getelementptr inbounds i8, ptr %.3, i64 16
  %70 = load ptr, ptr %69, align 8, !tbaa !11
  %71 = tail call noundef i32 @_ZN3AVL9GetHeightEP7BSTNode(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %70)
  store i32 %71, ptr %5, align 4, !tbaa !14
  %72 = 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)
  %73 = load i32, ptr %72, align 4, !tbaa !14
  %74 = add nsw i32 %73, 1
  %75 = getelementptr inbounds i8, ptr %.3, i64 32
  store i32 %74, ptr %75, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  ret ptr %.3
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { 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 16}
!12 = !{!6, !10, i64 24}
!13 = !{!6, !10, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 32}


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