; LLVM IR from VAR-solutions/Algorithms :: data structures/Red Black/CPP/arvore_rb_c.ll (ZN4Tree5deletEP4node)

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Tree5deletEP4node(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.node, ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %12, ptr %7, align 4, !tbaa !12
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.node, ptr %13, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = getelementptr inbounds %class.Tree, ptr %8, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = icmp eq ptr %15, %17
  br i1 %18, label %19, label %27

19:                                               ; preds = %2
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.node, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  store ptr %22, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.node, ptr %24, i32 0, i32 3
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  call void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %23, ptr noundef %26)
  br label %96

27:                                               ; preds = %2
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.node, ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds %class.Tree, ptr %8, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = icmp eq ptr %30, %32
  br i1 %33, label %34, label %42

34:                                               ; preds = %27
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.node, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  store ptr %37, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.node, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  call void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %38, ptr noundef %41)
  br label %95

42:                                               ; preds = %27
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.node, ptr %43, i32 0, i32 3
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  %46 = call noundef ptr @_ZN4Tree7minimumEP4node(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %45)
  store ptr %46, ptr %5, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.node, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 4, !tbaa !9
  store i32 %49, ptr %7, align 4, !tbaa !12
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.node, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  store ptr %52, ptr %6, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.node, ptr %53, i32 0, i32 4
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = icmp eq ptr %55, %56
  br i1 %57, label %58, label %62

58:                                               ; preds = %42
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.node, ptr %60, i32 0, i32 4
  store ptr %59, ptr %61, align 8, !tbaa !17
  br label %77

62:                                               ; preds = %42
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.node, ptr %64, i32 0, i32 3
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  call void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %63, ptr noundef %66)
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.node, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.node, ptr %70, i32 0, i32 3
  store ptr %69, ptr %71, align 8, !tbaa !16
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.node, ptr %73, i32 0, i32 3
  %75 = load ptr, ptr %74, align 8, !tbaa !16
  %76 = getelementptr inbounds %struct.node, ptr %75, i32 0, i32 4
  store ptr %72, ptr %76, align 8, !tbaa !17
  br label %77

77:                                               ; preds = %62, %58
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %78, ptr noundef %79)
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.node, ptr %80, i32 0, i32 2
  %82 = load ptr, ptr %81, align 8, !tbaa !13
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.node, ptr %83, i32 0, i32 2
  store ptr %82, ptr %84, align 8, !tbaa !13
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.node, ptr %86, i32 0, i32 2
  %88 = load ptr, ptr %87, align 8, !tbaa !13
  %89 = getelementptr inbounds %struct.node, ptr %88, i32 0, i32 4
  store ptr %85, ptr %89, align 8, !tbaa !17
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.node, ptr %90, i32 0, i32 1
  %92 = load i32, ptr %91, align 4, !tbaa !9
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.node, ptr %93, i32 0, i32 1
  store i32 %92, ptr %94, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %77, %34
  br label %96

96:                                               ; preds = %95, %19
  %97 = load i32, ptr %7, align 4, !tbaa !12
  %98 = icmp eq i32 %97, 1
  br i1 %98, label %99, label %101

99:                                               ; preds = %96
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN4Tree12deleteFix_RBEP4node(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %100)
  br label %101

101:                                              ; preds = %99, %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !11, i64 4}
!10 = !{!"_ZTS4node", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!15, !6, i64 8}
!15 = !{!"_ZTS4Tree", !6, i64 0, !6, i64 8}
!16 = !{!10, !6, i64 16}
!17 = !{!10, !6, i64 24}


; 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 void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Tree5deletEP4node(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = icmp eq ptr %6, %8
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  br i1 %9, label %12, label %13

12:                                               ; preds = %2
  tail call void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %1, ptr noundef %11)
  br label %33

13:                                               ; preds = %2
  %14 = icmp eq ptr %11, %8
  br i1 %14, label %15, label %16

15:                                               ; preds = %13
  tail call void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %1, ptr noundef %6)
  br label %33

16:                                               ; preds = %13
  %17 = tail call noundef ptr @_ZN4Tree7minimumEP4node(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %11)
  %18 = getelementptr inbounds i8, ptr %17, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %17, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %17, i64 24
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = icmp eq ptr %23, %1
  br i1 %24, label %27, label %25

25:                                               ; preds = %16
  tail call void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %17, ptr noundef %21)
  %26 = load ptr, ptr %10, align 8, !tbaa !14
  store ptr %26, ptr %20, align 8, !tbaa !14
  br label %27

27:                                               ; preds = %16, %25
  %.sink37 = phi ptr [ %26, %25 ], [ %21, %16 ]
  %28 = getelementptr inbounds i8, ptr %.sink37, i64 24
  store ptr %17, ptr %28, align 8, !tbaa !15
  tail call void @_ZN4Tree10transplantEP4nodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %1, ptr noundef nonnull %17)
  %29 = load ptr, ptr %5, align 8, !tbaa !11
  %30 = getelementptr inbounds i8, ptr %17, i64 8
  store ptr %29, ptr %30, align 8, !tbaa !11
  %31 = getelementptr inbounds i8, ptr %29, i64 24
  store ptr %17, ptr %31, align 8, !tbaa !15
  %32 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %32, ptr %18, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %15, %27, %12
  %.033 = phi ptr [ %11, %12 ], [ %6, %15 ], [ %21, %27 ]
  %.0 = phi i32 [ %4, %12 ], [ %4, %15 ], [ %19, %27 ]
  %34 = icmp eq i32 %.0, 1
  br i1 %34, label %35, label %36

35:                                               ; preds = %33
  tail call void @_ZN4Tree12deleteFix_RBEP4node(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %.033)
  br label %36

36:                                               ; preds = %35, %33
  ret void
}

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

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

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

!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 4}
!6 = !{!"_ZTS4node", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24}
!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 = !{!13, !10, i64 8}
!13 = !{!"_ZTS4Tree", !10, i64 0, !10, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 24}


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