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

; 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

declare i32 @__gxx_personality_v0(...)

; 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
declare dso_local noundef i64 @_ZN13Proto_vEBTree3maxEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN13Proto_vEBTree4predEy(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i64, align 8
  %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 i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8
  %17 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !11
  %19 = icmp eq i64 %18, 2
  br i1 %19, label %20, label %30

20:                                               ; preds = %2
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = icmp eq i64 %21, 1
  br i1 %22, label %23, label %28

23:                                               ; preds = %20
  %24 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 3
  %25 = load i8, ptr %24, align 8, !tbaa !15, !range !16, !noundef !17
  %26 = trunc i8 %25 to i1
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  store i64 0, ptr %3, align 8
  br label %108

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

30:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %31 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !11
  %33 = call noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %32)
  %34 = fptoui double %33 to i64
  store i64 %34, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %35 = load i64, ptr %5, align 8, !tbaa !9
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = udiv i64 %35, %36
  store i64 %37, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %38 = load i64, ptr %5, align 8, !tbaa !9
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = urem i64 %38, %39
  store i64 %40, ptr %8, align 8, !tbaa !9
  %41 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 2
  %42 = load ptr, ptr %41, align 8, !tbaa !19
  %43 = load i64, ptr %7, align 8, !tbaa !9
  %44 = getelementptr inbounds ptr, ptr %42, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %62

47:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %48 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !20
  %50 = load i64, ptr %7, align 8, !tbaa !9
  %51 = call noundef i64 @_ZN13Proto_vEBTree4predEy(ptr noundef nonnull align 8 dereferenceable(32) %49, i64 noundef %50)
  store i64 %51, ptr %9, align 8, !tbaa !9
  %52 = load i64, ptr %9, align 8, !tbaa !9
  %53 = load i64, ptr %6, align 8, !tbaa !9
  %54 = mul i64 %52, %53
  %55 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !19
  %57 = load i64, ptr %9, align 8, !tbaa !9
  %58 = getelementptr inbounds ptr, ptr %56, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = call noundef i64 @_ZN13Proto_vEBTree3maxEv(ptr noundef nonnull align 8 dereferenceable(32) %59)
  %61 = add i64 %54, %60
  store i64 %61, ptr %3, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %107

62:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %63 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %63, ptr %12, align 8, !tbaa !9
  %64 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %66 = load i64, ptr %7, align 8, !tbaa !9
  %67 = getelementptr inbounds ptr, ptr %65, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = load i64, ptr %8, align 8, !tbaa !9
  %70 = invoke noundef i64 @_ZN13Proto_vEBTree4predEy(ptr noundef nonnull align 8 dereferenceable(32) %68, i64 noundef %69)
          to label %71 unwind label %72

71:                                               ; preds = %62
  store i64 %70, ptr %11, align 8, !tbaa !9
  br label %96

72:                                               ; preds = %62
  %73 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTIi
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %13, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %14, align 4
  br label %76

76:                                               ; preds = %72
  %77 = load i32, ptr %14, align 4
  %78 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIi) #4
  %79 = icmp eq i32 %77, %78
  br i1 %79, label %80, label %106

80:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %81 = load ptr, ptr %13, align 8
  %82 = call ptr @__cxa_begin_catch(ptr %81) #4
  %83 = load i32, ptr %82, align 4, !tbaa !18
  store i32 %83, ptr %15, align 4, !tbaa !18
  %84 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 1
  %85 = load ptr, ptr %84, align 8, !tbaa !20
  %86 = load i64, ptr %7, align 8, !tbaa !9
  %87 = invoke noundef i64 @_ZN13Proto_vEBTree4predEy(ptr noundef nonnull align 8 dereferenceable(32) %85, i64 noundef %86)
          to label %88 unwind label %102

88:                                               ; preds = %80
  store i64 %87, ptr %12, align 8, !tbaa !9
  %89 = getelementptr inbounds %class.Proto_vEBTree, ptr %16, i32 0, i32 2
  %90 = load ptr, ptr %89, align 8, !tbaa !19
  %91 = load i64, ptr %12, align 8, !tbaa !9
  %92 = getelementptr inbounds ptr, ptr %90, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  %94 = invoke noundef i64 @_ZN13Proto_vEBTree3maxEv(ptr noundef nonnull align 8 dereferenceable(32) %93)
          to label %95 unwind label %102

95:                                               ; preds = %88
  store i64 %94, ptr %11, align 8, !tbaa !9
  call void @__cxa_end_catch() #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %96

96:                                               ; preds = %95, %71
  %97 = load i64, ptr %12, align 8, !tbaa !9
  %98 = load i64, ptr %6, align 8, !tbaa !9
  %99 = mul i64 %97, %98
  %100 = load i64, ptr %11, align 8, !tbaa !9
  %101 = add i64 %99, %100
  store i64 %101, ptr %3, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %107

102:                                              ; preds = %88, %80
  %103 = landingpad { ptr, i32 }
          cleanup
  %104 = extractvalue { ptr, i32 } %103, 0
  store ptr %104, ptr %13, align 8
  %105 = extractvalue { ptr, i32 } %103, 1
  store i32 %105, ptr %14, align 4
  call void @__cxa_end_catch() #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %106

106:                                              ; preds = %102, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  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 %110

107:                                              ; preds = %96, %47
  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 %108

108:                                              ; preds = %107, %27
  %109 = load i64, ptr %3, align 8
  ret i64 %109

110:                                              ; preds = %106
  %111 = load ptr, ptr %13, align 8
  %112 = load i32, ptr %14, align 4
  %113 = insertvalue { ptr, i32 } poison, ptr %111, 0
  %114 = insertvalue { ptr, i32 } %113, i32 %112, 1
  resume { ptr, i32 } %114
}

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #3

declare ptr @__cxa_begin_catch(ptr)

declare void @__cxa_end_catch()

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 = { 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 memory(none) }
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, !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 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!14, !14, i64 0}
!19 = !{!12, !6, i64 16}
!20 = !{!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

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN13Proto_vEBTree3maxEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN13Proto_vEBTree4predEy(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0, i64 noundef %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = load i64, ptr %0, align 8, !tbaa !5
  %4 = icmp eq i64 %3, 2
  br i1 %4, label %5, label %13

5:                                                ; preds = %2
  %6 = icmp eq i64 %1, 1
  br i1 %6, label %7, label %11

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i8, ptr %8, align 8, !tbaa !13, !range !14, !noundef !15
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %common.ret30, label %11

11:                                               ; preds = %7, %5
  %12 = tail call ptr @__cxa_allocate_exception(i64 4) #3
  store i32 -1, ptr %12, align 16, !tbaa !16
  tail call void @__cxa_throw(ptr nonnull %12, ptr nonnull @_ZTIi, ptr null) #4
  unreachable

13:                                               ; preds = %2
  %14 = tail call noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %3)
  %15 = fptoui double %14 to i64
  %16 = udiv i64 %1, %15
  %17 = urem i64 %1, %15
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !17
  %20 = getelementptr inbounds ptr, ptr %19, i64 %16
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %33

common.ret30:                                     ; preds = %52, %7, %23
  %common.ret30.op = phi i64 [ %32, %23 ], [ 0, %7 ], [ %54, %52 ]
  ret i64 %common.ret30.op

23:                                               ; preds = %13
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !19
  %26 = tail call noundef i64 @_ZN13Proto_vEBTree4predEy(ptr noundef nonnull align 8 dereferenceable(32) %25, i64 noundef %16)
  %27 = mul i64 %26, %15
  %28 = load ptr, ptr %18, align 8, !tbaa !17
  %29 = getelementptr inbounds ptr, ptr %28, i64 %26
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = tail call noundef i64 @_ZN13Proto_vEBTree3maxEv(ptr noundef nonnull align 8 dereferenceable(32) %30)
  %32 = add i64 %31, %27
  br label %common.ret30

33:                                               ; preds = %13
  %34 = invoke noundef i64 @_ZN13Proto_vEBTree4predEy(ptr noundef nonnull align 8 dereferenceable(32) %21, i64 noundef %17)
          to label %52 unwind label %35

35:                                               ; preds = %33
  %36 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTIi
  %37 = extractvalue { ptr, i32 } %36, 1
  %38 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTIi) #3
  %39 = icmp eq i32 %37, %38
  br i1 %39, label %40, label %57

40:                                               ; preds = %35
  %41 = extractvalue { ptr, i32 } %36, 0
  %42 = tail call ptr @__cxa_begin_catch(ptr %41) #3
  %43 = getelementptr inbounds i8, ptr %0, i64 8
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = invoke noundef i64 @_ZN13Proto_vEBTree4predEy(ptr noundef nonnull align 8 dereferenceable(32) %44, i64 noundef %16)
          to label %46 unwind label %55

46:                                               ; preds = %40
  %47 = load ptr, ptr %18, align 8, !tbaa !17
  %48 = getelementptr inbounds ptr, ptr %47, i64 %45
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = invoke noundef i64 @_ZN13Proto_vEBTree3maxEv(ptr noundef nonnull align 8 dereferenceable(32) %49)
          to label %51 unwind label %55

51:                                               ; preds = %46
  tail call void @__cxa_end_catch() #3
  br label %52

52:                                               ; preds = %33, %51
  %.026 = phi i64 [ %50, %51 ], [ %34, %33 ]
  %.025 = phi i64 [ %45, %51 ], [ %16, %33 ]
  %53 = mul i64 %.025, %15
  %54 = add i64 %53, %.026
  br label %common.ret30

55:                                               ; preds = %46, %40
  %56 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_end_catch() #3
  br label %57

57:                                               ; preds = %55, %35
  %.merged = phi { ptr, i32 } [ %56, %55 ], [ %36, %35 ]
  resume { ptr, i32 } %.merged
}

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #2

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

declare void @__cxa_end_catch() local_unnamed_addr

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 = { 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 = { nofree nosync nounwind memory(none) }
attributes #3 = { nounwind }
attributes #4 = { 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, !11, i64 24}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!12, !12, i64 0}
!17 = !{!6, !10, i64 16}
!18 = !{!10, !10, i64 0}
!19 = !{!6, !10, i64 8}


; Effective O3 passes: DivRemPairsPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass