; LLVM IR from PetarV-/Algorithms :: Data Structures/Proto-vEB Tree.ll (ZN13Proto_vEBTree6DeleteEy)

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

@_ZTIi = external constant ptr

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

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

declare ptr @__cxa_allocate_exception(i64)

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN13Proto_vEBTree6DeleteEy(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %1) #3 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  %11 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !11
  %13 = icmp eq i64 %12, 2
  br i1 %13, label %14, label %40

14:                                               ; preds = %2
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = icmp eq i64 %15, 0
  br i1 %16, label %17, label %26

17:                                               ; preds = %14
  %18 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 3
  store i8 0, ptr %18, align 8, !tbaa !15
  %19 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 5
  %20 = load i32, ptr %19, align 4, !tbaa !16
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr %19, align 4, !tbaa !16
  %22 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 4
  %23 = load i8, ptr %22, align 1, !tbaa !17, !range !18, !noundef !19
  %24 = trunc i8 %23 to i1
  %25 = xor i1 %24, true
  store i1 %25, ptr %3, align 1
  br label %85

26:                                               ; preds = %14
  %27 = load i64, ptr %5, align 8, !tbaa !9
  %28 = icmp eq i64 %27, 1
  br i1 %28, label %29, label %38

29:                                               ; preds = %26
  %30 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 4
  store i8 0, ptr %30, align 1, !tbaa !17
  %31 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 5
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = add nsw i32 %32, -1
  store i32 %33, ptr %31, align 4, !tbaa !16
  %34 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 3
  %35 = load i8, ptr %34, align 8, !tbaa !15, !range !18, !noundef !19
  %36 = trunc i8 %35 to i1
  %37 = xor i1 %36, true
  store i1 %37, ptr %3, align 1
  br label %85

38:                                               ; preds = %26
  %39 = call ptr @__cxa_allocate_exception(i64 4) #4
  store i32 -1, ptr %39, align 16, !tbaa !20
  call void @__cxa_throw(ptr %39, ptr @_ZTIi, ptr null) #5
  unreachable

40:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %41 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 0
  %42 = load i64, ptr %41, align 8, !tbaa !11
  %43 = call noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %42)
  %44 = fptoui double %43 to i64
  store i64 %44, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %45 = load i64, ptr %5, align 8, !tbaa !9
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = udiv i64 %45, %46
  store i64 %47, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %48 = load i64, ptr %5, align 8, !tbaa !9
  %49 = load i64, ptr %6, align 8, !tbaa !9
  %50 = urem i64 %48, %49
  store i64 %50, ptr %8, align 8, !tbaa !9
  %51 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !21
  %53 = load i64, ptr %7, align 8, !tbaa !9
  %54 = getelementptr inbounds ptr, ptr %52, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = load i64, ptr %8, align 8, !tbaa !9
  %57 = call noundef zeroext i1 @_ZN13Proto_vEBTree6DeleteEy(ptr noundef nonnull align 8 dereferenceable(32) %55, i64 noundef %56)
  br i1 %57, label %58, label %83

58:                                               ; preds = %40
  %59 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  %61 = load i64, ptr %7, align 8, !tbaa !9
  %62 = getelementptr inbounds ptr, ptr %60, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = icmp eq ptr %63, null
  br i1 %64, label %66, label %65

65:                                               ; preds = %58
  call void @_ZdlPvm(ptr noundef %63, i64 noundef 32) #6
  br label %66

66:                                               ; preds = %65, %58
  %67 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !21
  %69 = load i64, ptr %7, align 8, !tbaa !9
  %70 = getelementptr inbounds ptr, ptr %68, i64 %69
  store ptr null, ptr %70, align 8, !tbaa !5
  %71 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 5
  %72 = load i32, ptr %71, align 4, !tbaa !16
  %73 = add nsw i32 %72, -1
  store i32 %73, ptr %71, align 4, !tbaa !16
  %74 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 5
  %75 = load i32, ptr %74, align 4, !tbaa !16
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %82

77:                                               ; preds = %66
  %78 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !22
  %80 = load i64, ptr %7, align 8, !tbaa !9
  %81 = call noundef zeroext i1 @_ZN13Proto_vEBTree6DeleteEy(ptr noundef nonnull align 8 dereferenceable(32) %79, i64 noundef %80)
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %84

82:                                               ; preds = %66
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %84

83:                                               ; preds = %40
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %84

84:                                               ; preds = %83, %82, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %85

85:                                               ; preds = %84, %29, %17
  %86 = load i1, ptr %3, align 1
  ret i1 %86
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nobuiltin nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { noreturn }
attributes #6 = { builtin 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 = !{!"long long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS13Proto_vEBTree", !10, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !13, i64 25, !14, i64 28}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !13, i64 24}
!16 = !{!12, !14, i64 28}
!17 = !{!12, !13, i64 25}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!14, !14, i64 0}
!21 = !{!12, !6, i64 16}
!22 = !{!12, !6, i64 8}


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

@_ZTIi = external constant ptr

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN13Proto_vEBTree6DeleteEy(ptr nocapture noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %1) local_unnamed_addr #2 align 2 {
  %3 = load i64, ptr %0, align 8, !tbaa !5
  %4 = icmp ne i64 %3, 2
  br i1 %4, label %.lr.ph.preheader, label %tailrecurse._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %5 = tail call noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %3)
  %6 = fptoui double %5 to i64
  %7 = udiv i64 %1, %6
  %8 = urem i64 %1, %6
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds ptr, ptr %10, i64 %7
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %13 = tail call noundef zeroext i1 @_ZN13Proto_vEBTree6DeleteEy(ptr noundef nonnull align 8 dereferenceable(32) %12, i64 noundef %8)
  br i1 %13, label %14, label %.loopexit

14:                                               ; preds = %.lr.ph.preheader
  %15 = load ptr, ptr %9, align 8, !tbaa !13
  %16 = getelementptr inbounds ptr, ptr %15, i64 %7
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = icmp eq ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  tail call void @_ZdlPvm(ptr noundef nonnull %17, i64 noundef 32) #3
  %.pre = load ptr, ptr %9, align 8, !tbaa !13
  br label %20

20:                                               ; preds = %19, %14
  %21 = phi ptr [ %.pre, %19 ], [ %15, %14 ]
  %22 = getelementptr inbounds ptr, ptr %21, i64 %7
  store ptr null, ptr %22, align 8, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %0, i64 28
  %24 = load i32, ptr %23, align 4, !tbaa !15
  %25 = add nsw i32 %24, -1
  store i32 %25, ptr %23, align 4, !tbaa !15
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %tailrecurse.peel, label %.loopexit

tailrecurse.peel:                                 ; preds = %20
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = load i64, ptr %28, align 8, !tbaa !5
  %30 = icmp eq i64 %29, 2
  br i1 %30, label %tailrecurse._crit_edge, label %.lr.ph

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %tailrecurse.peel, %2
  %.tr.lcssa = phi ptr [ %0, %2 ], [ %28, %tailrecurse.peel ], [ %75, %tailrecurse ]
  %.tr15.lcssa = phi i64 [ %1, %2 ], [ %7, %tailrecurse.peel ], [ %54, %tailrecurse ]
  switch i64 %.tr15.lcssa, label %49 [
    i64 0, label %31
    i64 1, label %40
  ]

31:                                               ; preds = %tailrecurse._crit_edge
  %32 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 24
  store i8 0, ptr %32, align 8, !tbaa !17
  %33 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 28
  %34 = load i32, ptr %33, align 4, !tbaa !15
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %33, align 4, !tbaa !15
  %36 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 25
  %37 = load i8, ptr %36, align 1, !tbaa !18, !range !19, !noundef !20
  %38 = trunc nuw i8 %37 to i1
  %39 = xor i1 %38, true
  br label %.loopexit

40:                                               ; preds = %tailrecurse._crit_edge
  %41 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 25
  store i8 0, ptr %41, align 1, !tbaa !18
  %42 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 28
  %43 = load i32, ptr %42, align 4, !tbaa !15
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr %42, align 4, !tbaa !15
  %45 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 24
  %46 = load i8, ptr %45, align 8, !tbaa !17, !range !19, !noundef !20
  %47 = trunc nuw i8 %46 to i1
  %48 = xor i1 %47, true
  br label %.loopexit

49:                                               ; preds = %tailrecurse._crit_edge
  %50 = tail call ptr @__cxa_allocate_exception(i64 4) #4
  store i32 -1, ptr %50, align 16, !tbaa !21
  tail call void @__cxa_throw(ptr nonnull %50, ptr nonnull @_ZTIi, ptr null) #5
  unreachable

.lr.ph:                                           ; preds = %tailrecurse.peel, %tailrecurse
  %51 = phi i64 [ %76, %tailrecurse ], [ %29, %tailrecurse.peel ]
  %.tr1524 = phi i64 [ %54, %tailrecurse ], [ %7, %tailrecurse.peel ]
  %.tr23 = phi ptr [ %75, %tailrecurse ], [ %28, %tailrecurse.peel ]
  %52 = tail call noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %51)
  %53 = fptoui double %52 to i64
  %54 = udiv i64 %.tr1524, %53
  %55 = urem i64 %.tr1524, %53
  %56 = getelementptr inbounds i8, ptr %.tr23, i64 16
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = getelementptr inbounds ptr, ptr %57, i64 %54
  %59 = load ptr, ptr %58, align 8, !tbaa !14
  %60 = tail call noundef zeroext i1 @_ZN13Proto_vEBTree6DeleteEy(ptr noundef nonnull align 8 dereferenceable(32) %59, i64 noundef %55)
  br i1 %60, label %61, label %.loopexit

61:                                               ; preds = %.lr.ph
  %62 = load ptr, ptr %56, align 8, !tbaa !13
  %63 = getelementptr inbounds ptr, ptr %62, i64 %54
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = icmp eq ptr %64, null
  br i1 %65, label %67, label %66

66:                                               ; preds = %61
  tail call void @_ZdlPvm(ptr noundef nonnull %64, i64 noundef 32) #3
  %.pre35 = load ptr, ptr %56, align 8, !tbaa !13
  br label %67

67:                                               ; preds = %66, %61
  %68 = phi ptr [ %.pre35, %66 ], [ %62, %61 ]
  %69 = getelementptr inbounds ptr, ptr %68, i64 %54
  store ptr null, ptr %69, align 8, !tbaa !14
  %70 = getelementptr inbounds i8, ptr %.tr23, i64 28
  %71 = load i32, ptr %70, align 4, !tbaa !15
  %72 = add nsw i32 %71, -1
  store i32 %72, ptr %70, align 4, !tbaa !15
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %tailrecurse, label %.loopexit

tailrecurse:                                      ; preds = %67
  %74 = getelementptr inbounds i8, ptr %.tr23, i64 8
  %75 = load ptr, ptr %74, align 8, !tbaa !16
  %76 = load i64, ptr %75, align 8, !tbaa !5
  %77 = icmp eq i64 %76, 2
  br i1 %77, label %tailrecurse._crit_edge, label %.lr.ph, !llvm.loop !22

.loopexit:                                        ; preds = %67, %.lr.ph, %.lr.ph.preheader, %20, %40, %31
  %ret.known.tr18 = phi i1 [ %4, %31 ], [ %4, %40 ], [ false, %.lr.ph.preheader ], [ false, %20 ], [ true, %.lr.ph ], [ true, %67 ]
  %.1 = phi i1 [ %39, %31 ], [ %48, %40 ], [ false, %.lr.ph.preheader ], [ false, %20 ], [ false, %.lr.ph ], [ false, %67 ]
  %current.ret.tr16 = select i1 %ret.known.tr18, i1 true, i1 %.1
  ret i1 %current.ret.tr16
}

attributes #0 = { 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 #1 = { nobuiltin nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { builtin nounwind }
attributes #4 = { nounwind }
attributes #5 = { noreturn }

!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 = !{!"_ZTS13Proto_vEBTree", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !11, i64 25, !12, i64 28}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !10, i64 16}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !12, i64 28}
!16 = !{!6, !10, i64 8}
!17 = !{!6, !11, i64 24}
!18 = !{!6, !11, i64 25}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!12, !12, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass