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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN13Proto_vEBTree6memberEy(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %1) #2 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 %30

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

17:                                               ; preds = %14
  %18 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 3
  %19 = load i8, ptr %18, align 8, !tbaa !15, !range !16, !noundef !17
  %20 = trunc i8 %19 to i1
  store i1 %20, ptr %3, align 1
  br label %57

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

24:                                               ; preds = %21
  %25 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 4
  %26 = load i8, ptr %25, align 1, !tbaa !18, !range !16, !noundef !17
  %27 = trunc i8 %26 to i1
  store i1 %27, ptr %3, align 1
  br label %57

28:                                               ; preds = %21
  br label %29

29:                                               ; preds = %28
  store i1 false, ptr %3, align 1
  br label %57

30:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %31 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, 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) #3
  %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) #3
  %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 %10, 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 %48

47:                                               ; preds = %30
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %56

48:                                               ; preds = %30
  %49 = getelementptr inbounds %class.Proto_vEBTree, ptr %10, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !19
  %51 = load i64, ptr %7, align 8, !tbaa !9
  %52 = getelementptr inbounds ptr, ptr %50, i64 %51
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = load i64, ptr %8, align 8, !tbaa !9
  %55 = call noundef zeroext i1 @_ZN13Proto_vEBTree6memberEy(ptr noundef nonnull align 8 dereferenceable(32) %53, i64 noundef %54)
  store i1 %55, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %56

56:                                               ; preds = %48, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %57

57:                                               ; preds = %56, %29, %24, %17
  %58 = load i1, ptr %3, align 1
  ret i1 %58
}

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 }

!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 = !{!12, !13, i64 25}
!19 = !{!12, !6, i64 16}


; 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: 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: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN13Proto_vEBTree6memberEy(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0, i64 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = load i64, ptr %0, align 8, !tbaa !5
  %4 = icmp eq i64 %3, 2
  br i1 %4, label %tailrecurse._crit_edge, label %.lr.ph

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %2
  %.tr.lcssa = phi ptr [ %0, %2 ], [ %21, %tailrecurse ]
  %.tr13.lcssa = phi i64 [ %1, %2 ], [ %17, %tailrecurse ]
  switch i64 %.tr13.lcssa, label %.loopexit [
    i64 0, label %5
    i64 1, label %9
  ]

5:                                                ; preds = %tailrecurse._crit_edge
  %6 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 24
  %7 = load i8, ptr %6, align 8, !tbaa !13, !range !14, !noundef !15
  %8 = trunc nuw i8 %7 to i1
  br label %.loopexit

9:                                                ; preds = %tailrecurse._crit_edge
  %10 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 25
  %11 = load i8, ptr %10, align 1, !tbaa !16, !range !14, !noundef !15
  %12 = trunc nuw i8 %11 to i1
  br label %.loopexit

.lr.ph:                                           ; preds = %2, %tailrecurse
  %13 = phi i64 [ %23, %tailrecurse ], [ %3, %2 ]
  %.tr1317 = phi i64 [ %17, %tailrecurse ], [ %1, %2 ]
  %.tr16 = phi ptr [ %21, %tailrecurse ], [ %0, %2 ]
  %14 = tail call noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %13)
  %15 = fptoui double %14 to i64
  %16 = udiv i64 %.tr1317, %15
  %17 = urem i64 %.tr1317, %15
  %18 = getelementptr inbounds i8, ptr %.tr16, 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 %.loopexit, label %tailrecurse

tailrecurse:                                      ; preds = %.lr.ph
  %23 = load i64, ptr %21, align 8, !tbaa !5
  %24 = icmp eq i64 %23, 2
  br i1 %24, label %tailrecurse._crit_edge, label %.lr.ph

.loopexit:                                        ; preds = %.lr.ph, %tailrecurse._crit_edge, %9, %5
  %.1 = phi i1 [ %8, %5 ], [ %12, %9 ], [ false, %tailrecurse._crit_edge ], [ false, %.lr.ph ]
  ret i1 %.1
}

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 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 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 = !{!6, !11, i64 25}
!17 = !{!6, !10, i64 16}
!18 = !{!10, !10, i64 0}


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