; LLVM IR from HarshCasper/NeoAlgo :: C-Plus-Plus/ds/avl_tree.ll (Z11delete_nodeP4Nodeii)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z11find_heightP4Node(ptr noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z19find_balance_factorP4Node(ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z16find_parent_nodeP4NodeS0_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z18find_critical_nodeP4Node(ptr noundef) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z12balance_treeP4Node(ptr noundef) #0

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

14:                                               ; preds = %3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %15, ptr %4, align 8
  br label %206

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Node, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp sgt i32 %19, %20
  br i1 %21, label %22, label %31

22:                                               ; preds = %16
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Node, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = call noundef ptr @_Z11delete_nodeP4Nodeii(ptr noundef %25, i32 noundef %26, i32 noundef %27)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.Node, ptr %29, i32 0, i32 0
  store ptr %28, ptr %30, align 8, !tbaa !13
  br label %161

31:                                               ; preds = %16
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Node, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %46

37:                                               ; preds = %31
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.Node, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = call noundef ptr @_Z11delete_nodeP4Nodeii(ptr noundef %40, i32 noundef %41, i32 noundef %42)
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Node, ptr %44, i32 0, i32 1
  store ptr %43, ptr %45, align 8, !tbaa !14
  br label %160

46:                                               ; preds = %31
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Node, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = icmp eq ptr %49, null
  br i1 %50, label %51, label %57

51:                                               ; preds = %46
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Node, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !14
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %57

56:                                               ; preds = %51
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %122

57:                                               ; preds = %51, %46
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.Node, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %71

62:                                               ; preds = %57
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Node, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !14
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %71

67:                                               ; preds = %62
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.Node, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !13
  store ptr %70, ptr %5, align 8, !tbaa !5
  br label %121

71:                                               ; preds = %62, %57
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.Node, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !13
  %75 = icmp eq ptr %74, null
  br i1 %75, label %76, label %85

76:                                               ; preds = %71
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.Node, ptr %77, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !14
  %80 = icmp ne ptr %79, null
  br i1 %80, label %81, label %85

81:                                               ; preds = %76
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.Node, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !14
  store ptr %84, ptr %5, align 8, !tbaa !5
  br label %120

85:                                               ; preds = %76, %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = call noundef ptr @_Z16find_predecessorP4NodeRS0_(ptr noundef %86, ptr noundef nonnull align 8 dereferenceable(8) %8)
  store ptr %87, ptr %9, align 8, !tbaa !5
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = icmp eq ptr %88, %89
  br i1 %90, label %91, label %97

91:                                               ; preds = %85
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.Node, ptr %92, i32 0, i32 1
  %94 = load ptr, ptr %93, align 8, !tbaa !14
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.Node, ptr %95, i32 0, i32 1
  store ptr %94, ptr %96, align 8, !tbaa !14
  br label %118

97:                                               ; preds = %85
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.Node, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !13
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.Node, ptr %101, i32 0, i32 0
  store ptr %100, ptr %102, align 8, !tbaa !13
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.Node, ptr %103, i32 0, i32 1
  %105 = load ptr, ptr %104, align 8, !tbaa !14
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.Node, ptr %106, i32 0, i32 1
  store ptr %105, ptr %107, align 8, !tbaa !14
  %108 = load ptr, ptr %8, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.Node, ptr %108, i32 0, i32 1
  store ptr null, ptr %109, align 8, !tbaa !14
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = call noundef i32 @_Z11find_heightP4Node(ptr noundef %110)
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.Node, ptr %112, i32 0, i32 4
  store i32 %111, ptr %113, align 8, !tbaa !15
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  %115 = call noundef i32 @_Z19find_balance_factorP4Node(ptr noundef %114)
  %116 = load ptr, ptr %8, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.Node, ptr %116, i32 0, i32 3
  store i32 %115, ptr %117, align 4, !tbaa !16
  br label %118

118:                                              ; preds = %97, %91
  %119 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %119, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %120

120:                                              ; preds = %118, %81
  br label %121

121:                                              ; preds = %120, %67
  br label %122

122:                                              ; preds = %121, %56
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = icmp ne ptr %123, null
  br i1 %124, label %125, label %147

125:                                              ; preds = %122
  %126 = load ptr, ptr %5, align 8, !tbaa !5
  %127 = call noundef i32 @_Z11find_heightP4Node(ptr noundef %126)
  %128 = load ptr, ptr %5, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.Node, ptr %128, i32 0, i32 4
  store i32 %127, ptr %129, align 8, !tbaa !15
  %130 = load ptr, ptr %5, align 8, !tbaa !5
  %131 = call noundef i32 @_Z19find_balance_factorP4Node(ptr noundef %130)
  %132 = load ptr, ptr %5, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.Node, ptr %132, i32 0, i32 3
  store i32 %131, ptr %133, align 4, !tbaa !16
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.Node, ptr %134, i32 0, i32 3
  %136 = load i32, ptr %135, align 4, !tbaa !16
  %137 = icmp sgt i32 %136, 1
  br i1 %137, label %143, label %138

138:                                              ; preds = %125
  %139 = load ptr, ptr %5, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.Node, ptr %139, i32 0, i32 3
  %141 = load i32, ptr %140, align 4, !tbaa !16
  %142 = icmp slt i32 %141, -1
  br i1 %142, label %143, label %146

143:                                              ; preds = %138, %125
  %144 = load ptr, ptr %5, align 8, !tbaa !5
  %145 = call noundef ptr @_Z12balance_treeP4Node(ptr noundef %144)
  store ptr %145, ptr %5, align 8, !tbaa !5
  br label %146

146:                                              ; preds = %143, %138
  br label %147

147:                                              ; preds = %146, %122
  %148 = load i32, ptr %6, align 4, !tbaa !9
  %149 = load i32, ptr %7, align 4, !tbaa !9
  %150 = icmp ne i32 %148, %149
  br i1 %150, label %151, label %153

151:                                              ; preds = %147
  %152 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %152, ptr %4, align 8
  br label %206

153:                                              ; preds = %147
  %154 = load ptr, ptr %5, align 8, !tbaa !5
  %155 = icmp eq ptr %154, null
  br i1 %155, label %156, label %158

156:                                              ; preds = %153
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %157, ptr %4, align 8
  br label %206

158:                                              ; preds = %153
  br label %159

159:                                              ; preds = %158
  br label %160

160:                                              ; preds = %159, %37
  br label %161

161:                                              ; preds = %160, %22
  %162 = load i32, ptr %6, align 4, !tbaa !9
  %163 = load i32, ptr %7, align 4, !tbaa !9
  %164 = icmp eq i32 %162, %163
  br i1 %164, label %165, label %194

165:                                              ; preds = %161
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %166 = load ptr, ptr %5, align 8, !tbaa !5
  %167 = call noundef ptr @_Z18find_critical_nodeP4Node(ptr noundef %166)
  store ptr %167, ptr %10, align 8, !tbaa !5
  %168 = load ptr, ptr %10, align 8, !tbaa !5
  %169 = icmp ne ptr %168, null
  br i1 %169, label %170, label %192

170:                                              ; preds = %165
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %171 = load ptr, ptr %5, align 8, !tbaa !5
  %172 = load ptr, ptr %10, align 8, !tbaa !5
  %173 = call noundef ptr @_Z16find_parent_nodeP4NodeS0_(ptr noundef %171, ptr noundef %172)
  store ptr %173, ptr %11, align 8, !tbaa !5
  %174 = load ptr, ptr %10, align 8, !tbaa !5
  %175 = call noundef ptr @_Z12balance_treeP4Node(ptr noundef %174)
  store ptr %175, ptr %10, align 8, !tbaa !5
  %176 = load ptr, ptr %11, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.Node, ptr %176, i32 0, i32 2
  %178 = load i32, ptr %177, align 8, !tbaa !11
  %179 = load ptr, ptr %10, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.Node, ptr %179, i32 0, i32 2
  %181 = load i32, ptr %180, align 8, !tbaa !11
  %182 = icmp sgt i32 %178, %181
  br i1 %182, label %183, label %187

183:                                              ; preds = %170
  %184 = load ptr, ptr %10, align 8, !tbaa !5
  %185 = load ptr, ptr %11, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.Node, ptr %185, i32 0, i32 0
  store ptr %184, ptr %186, align 8, !tbaa !13
  br label %191

187:                                              ; preds = %170
  %188 = load ptr, ptr %10, align 8, !tbaa !5
  %189 = load ptr, ptr %11, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.Node, ptr %189, i32 0, i32 1
  store ptr %188, ptr %190, align 8, !tbaa !14
  br label %191

191:                                              ; preds = %187, %183
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %192

192:                                              ; preds = %191, %165
  %193 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %193, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %206

194:                                              ; preds = %161
  %195 = load ptr, ptr %5, align 8, !tbaa !5
  %196 = call noundef i32 @_Z11find_heightP4Node(ptr noundef %195)
  %197 = load ptr, ptr %5, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.Node, ptr %197, i32 0, i32 4
  store i32 %196, ptr %198, align 8, !tbaa !15
  %199 = load ptr, ptr %5, align 8, !tbaa !5
  %200 = call noundef i32 @_Z19find_balance_factorP4Node(ptr noundef %199)
  %201 = load ptr, ptr %5, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.Node, ptr %201, i32 0, i32 3
  store i32 %200, ptr %202, align 4, !tbaa !16
  %203 = load ptr, ptr %5, align 8, !tbaa !5
  %204 = call noundef ptr @_Z12balance_treeP4Node(ptr noundef %203)
  store ptr %204, ptr %5, align 8, !tbaa !5
  %205 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %205, ptr %4, align 8
  br label %206

206:                                              ; preds = %194, %192, %156, %151, %14
  %207 = load ptr, ptr %4, align 8
  ret ptr %207
}

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


; 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 @_Z11find_heightP4Node(ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z19find_balance_factorP4Node(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z16find_parent_nodeP4NodeS0_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z18find_critical_nodeP4Node(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z12balance_treeP4Node(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_Z11delete_nodeP4Nodeii(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  %5 = icmp eq ptr %0, null
  br i1 %5, label %.thread87, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = icmp sgt i32 %8, %1
  br i1 %9, label %.sink.split, label %10

10:                                               ; preds = %6
  %11 = icmp slt i32 %8, %1
  br i1 %11, label %12, label %14

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  br label %.sink.split

14:                                               ; preds = %10
  %15 = load ptr, ptr %0, align 8, !tbaa !11
  %16 = icmp eq ptr %15, null
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = icmp eq ptr %18, null
  br i1 %16, label %20, label %21

20:                                               ; preds = %14
  br i1 %19, label %.thread87, label %41

21:                                               ; preds = %14
  br i1 %19, label %41, label %22

22:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  store ptr null, ptr %4, align 8, !tbaa !13
  %23 = call noundef ptr @_Z16find_predecessorP4NodeRS0_(ptr noundef nonnull %0, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %24 = load ptr, ptr %4, align 8, !tbaa !13
  %25 = icmp eq ptr %24, %0
  br i1 %25, label %26, label %30

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !12
  %29 = getelementptr inbounds i8, ptr %23, i64 8
  store ptr %28, ptr %29, align 8, !tbaa !12
  br label %40

30:                                               ; preds = %22
  %31 = load <2 x ptr>, ptr %0, align 8, !tbaa !13
  store <2 x ptr> %31, ptr %23, align 8, !tbaa !13
  %32 = load ptr, ptr %4, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  store ptr null, ptr %33, align 8, !tbaa !12
  %34 = call noundef i32 @_Z11find_heightP4Node(ptr noundef %32)
  %35 = load ptr, ptr %4, align 8, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %35, i64 24
  store i32 %34, ptr %36, align 8, !tbaa !14
  %37 = call noundef i32 @_Z19find_balance_factorP4Node(ptr noundef %35)
  %38 = load ptr, ptr %4, align 8, !tbaa !13
  %39 = getelementptr inbounds i8, ptr %38, i64 20
  store i32 %37, ptr %39, align 4, !tbaa !15
  br label %40

40:                                               ; preds = %30, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  br label %41

41:                                               ; preds = %20, %40, %21
  %.064.ph = phi ptr [ %15, %21 ], [ %23, %40 ], [ %18, %20 ]
  %42 = call noundef i32 @_Z11find_heightP4Node(ptr noundef nonnull %.064.ph)
  %43 = getelementptr inbounds i8, ptr %.064.ph, i64 24
  store i32 %42, ptr %43, align 8, !tbaa !14
  %44 = call noundef i32 @_Z19find_balance_factorP4Node(ptr noundef nonnull %.064.ph)
  %45 = getelementptr inbounds i8, ptr %.064.ph, i64 20
  store i32 %44, ptr %45, align 4, !tbaa !15
  %46 = add i32 %44, -2
  %or.cond = icmp ult i32 %46, -3
  br i1 %or.cond, label %47, label %49

47:                                               ; preds = %41
  %48 = call noundef ptr @_Z12balance_treeP4Node(ptr noundef nonnull %.064.ph)
  br label %49

49:                                               ; preds = %41, %47
  %.1 = phi ptr [ %48, %47 ], [ %.064.ph, %41 ]
  %.not76 = icmp eq i32 %1, %2
  br i1 %.not76, label %50, label %.thread87

50:                                               ; preds = %49
  %51 = icmp eq ptr %.1, null
  br i1 %51, label %.thread87, label %54

.sink.split:                                      ; preds = %6, %12
  %.sink = phi ptr [ %13, %12 ], [ %0, %6 ]
  %52 = load ptr, ptr %.sink, align 8, !tbaa !13
  %53 = tail call noundef ptr @_Z11delete_nodeP4Nodeii(ptr noundef %52, i32 noundef %1, i32 noundef %2)
  store ptr %53, ptr %.sink, align 8, !tbaa !13
  br label %54

54:                                               ; preds = %.sink.split, %50
  %.2 = phi ptr [ %.1, %50 ], [ %0, %.sink.split ]
  %55 = icmp eq i32 %1, %2
  br i1 %55, label %56, label %69

56:                                               ; preds = %54
  %57 = call noundef ptr @_Z18find_critical_nodeP4Node(ptr noundef nonnull %.2)
  %.not77 = icmp eq ptr %57, null
  br i1 %.not77, label %.thread87, label %58

58:                                               ; preds = %56
  %59 = call noundef ptr @_Z16find_parent_nodeP4NodeS0_(ptr noundef nonnull %.2, ptr noundef nonnull %57)
  %60 = call noundef ptr @_Z12balance_treeP4Node(ptr noundef nonnull %57)
  %61 = getelementptr inbounds i8, ptr %59, i64 16
  %62 = load i32, ptr %61, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %60, i64 16
  %64 = load i32, ptr %63, align 8, !tbaa !5
  %65 = icmp sgt i32 %62, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %58
  store ptr %60, ptr %59, align 8, !tbaa !11
  br label %.thread87

67:                                               ; preds = %58
  %68 = getelementptr inbounds i8, ptr %59, i64 8
  store ptr %60, ptr %68, align 8, !tbaa !12
  br label %.thread87

69:                                               ; preds = %54
  %70 = call noundef i32 @_Z11find_heightP4Node(ptr noundef nonnull %.2)
  %71 = getelementptr inbounds i8, ptr %.2, i64 24
  store i32 %70, ptr %71, align 8, !tbaa !14
  %72 = call noundef i32 @_Z19find_balance_factorP4Node(ptr noundef nonnull %.2)
  %73 = getelementptr inbounds i8, ptr %.2, i64 20
  store i32 %72, ptr %73, align 4, !tbaa !15
  %74 = call noundef ptr @_Z12balance_treeP4Node(ptr noundef nonnull %.2)
  br label %.thread87

.thread87:                                        ; preds = %20, %56, %67, %66, %50, %49, %3, %69
  %.0 = phi ptr [ %74, %69 ], [ null, %3 ], [ %.1, %49 ], [ null, %50 ], [ %.2, %66 ], [ %.2, %67 ], [ %.2, %56 ], [ null, %20 ]
  ret ptr %.0
}

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


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