; LLVM IR from PetarV-/Algorithms :: Data Structures/van Emde Boas Tree.ll (ZN3vEB6memberEy)

; 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.vEB = type { i64, ptr, ptr, 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: 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 @_ZN3vEB6memberEy(ptr noundef nonnull align 8 dereferenceable(40) %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.vEB, 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 %37

14:                                               ; preds = %2
  %15 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i1 false, ptr %3, align 1
  br label %95

19:                                               ; preds = %14
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %22, label %27

22:                                               ; preds = %19
  %23 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = icmp eq i64 %25, 0
  store i1 %26, ptr %3, align 1
  br label %95

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

30:                                               ; preds = %27
  %31 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = icmp eq i64 %33, 1
  store i1 %34, ptr %3, align 1
  br label %95

35:                                               ; preds = %27
  br label %36

36:                                               ; preds = %35
  store i1 false, ptr %3, align 1
  br label %95

37:                                               ; preds = %2
  %38 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %42

41:                                               ; preds = %37
  store i1 false, ptr %3, align 1
  br label %95

42:                                               ; preds = %37
  %43 = load i64, ptr %5, align 8, !tbaa !9
  %44 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = icmp ult i64 %43, %46
  br i1 %47, label %54, label %48

48:                                               ; preds = %42
  %49 = load i64, ptr %5, align 8, !tbaa !9
  %50 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = icmp ugt i64 %49, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %48, %42
  store i1 false, ptr %3, align 1
  br label %95

55:                                               ; preds = %48
  %56 = load i64, ptr %5, align 8, !tbaa !9
  %57 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = load i64, ptr %58, align 8, !tbaa !9
  %60 = icmp eq i64 %56, %59
  br i1 %60, label %67, label %61

61:                                               ; preds = %55
  %62 = load i64, ptr %5, align 8, !tbaa !9
  %63 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = load i64, ptr %64, align 8, !tbaa !9
  %66 = icmp eq i64 %62, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %61, %55
  store i1 true, ptr %3, align 1
  br label %95

68:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %69 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 0
  %70 = load i64, ptr %69, align 8, !tbaa !11
  %71 = call noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %70)
  %72 = fptoui double %71 to i64
  store i64 %72, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %73 = load i64, ptr %5, align 8, !tbaa !9
  %74 = load i64, ptr %6, align 8, !tbaa !9
  %75 = udiv i64 %73, %74
  store i64 %75, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %76 = load i64, ptr %5, align 8, !tbaa !9
  %77 = load i64, ptr %6, align 8, !tbaa !9
  %78 = urem i64 %76, %77
  store i64 %78, ptr %8, align 8, !tbaa !9
  %79 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 4
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = load i64, ptr %7, align 8, !tbaa !9
  %82 = getelementptr inbounds ptr, ptr %80, i64 %81
  %83 = load ptr, ptr %82, align 8, !tbaa !5
  %84 = icmp eq ptr %83, null
  br i1 %84, label %85, label %86

85:                                               ; preds = %68
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %94

86:                                               ; preds = %68
  %87 = getelementptr inbounds %class.vEB, ptr %10, i32 0, i32 4
  %88 = load ptr, ptr %87, align 8, !tbaa !15
  %89 = load i64, ptr %7, align 8, !tbaa !9
  %90 = getelementptr inbounds ptr, ptr %88, i64 %89
  %91 = load ptr, ptr %90, align 8, !tbaa !5
  %92 = load i64, ptr %8, align 8, !tbaa !9
  %93 = call noundef zeroext i1 @_ZN3vEB6memberEy(ptr noundef nonnull align 8 dereferenceable(40) %91, i64 noundef %92)
  store i1 %93, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %94

94:                                               ; preds = %86, %85
  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 %95

95:                                               ; preds = %94, %67, %54, %41, %36, %30, %22, %18
  %96 = load i1, ptr %3, align 1
  ret i1 %96
}

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


; 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 @_ZN3vEB6memberEy(ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %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 ], [ %35, %tailrecurse ]
  %.tr22.lcssa = phi i64 [ %1, %2 ], [ %31, %tailrecurse ]
  %5 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  %7 = icmp eq ptr %6, null
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %tailrecurse._crit_edge
  switch i64 %.tr22.lcssa, label %.loopexit [
    i64 0, label %.loopexit.sink.split
    i64 1, label %9
  ]

9:                                                ; preds = %8
  %10 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  br label %.loopexit.sink.split

.lr.ph:                                           ; preds = %2, %tailrecurse
  %12 = phi i64 [ %37, %tailrecurse ], [ %3, %2 ]
  %.tr2226 = phi i64 [ %31, %tailrecurse ], [ %1, %2 ]
  %.tr25 = phi ptr [ %35, %tailrecurse ], [ %0, %2 ]
  %13 = getelementptr inbounds i8, ptr %.tr25, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = icmp eq ptr %14, null
  br i1 %15, label %.loopexit, label %16

16:                                               ; preds = %.lr.ph
  %17 = load i64, ptr %14, align 8, !tbaa !13
  %18 = icmp ugt i64 %17, %.tr2226
  br i1 %18, label %.loopexit, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %.tr25, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = load i64, ptr %21, align 8, !tbaa !13
  %23 = icmp ult i64 %22, %.tr2226
  br i1 %23, label %.loopexit, label %24

24:                                               ; preds = %19
  %25 = icmp eq i64 %17, %.tr2226
  %26 = icmp eq i64 %22, %.tr2226
  %or.cond = or i1 %25, %26
  br i1 %or.cond, label %.loopexit, label %27

27:                                               ; preds = %24
  %28 = tail call noundef double @_ZSt4sqrtIyEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %12)
  %29 = fptoui double %28 to i64
  %30 = udiv i64 %.tr2226, %29
  %31 = urem i64 %.tr2226, %29
  %32 = getelementptr inbounds i8, ptr %.tr25, i64 32
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = getelementptr inbounds ptr, ptr %33, i64 %30
  %35 = load ptr, ptr %34, align 8, !tbaa !15
  %36 = icmp eq ptr %35, null
  br i1 %36, label %.loopexit, label %tailrecurse

tailrecurse:                                      ; preds = %27
  %37 = load i64, ptr %35, align 8, !tbaa !5
  %38 = icmp eq i64 %37, 2
  br i1 %38, label %tailrecurse._crit_edge, label %.lr.ph

.loopexit.sink.split:                             ; preds = %8, %9
  %.sink31 = phi ptr [ %11, %9 ], [ %6, %8 ]
  %39 = load i64, ptr %.sink31, align 8, !tbaa !13
  %40 = icmp eq i64 %39, %.tr22.lcssa
  br label %.loopexit

.loopexit:                                        ; preds = %27, %24, %16, %19, %.lr.ph, %.loopexit.sink.split, %8, %tailrecurse._crit_edge
  %.1 = phi i1 [ false, %tailrecurse._crit_edge ], [ false, %8 ], [ %40, %.loopexit.sink.split ], [ false, %27 ], [ true, %24 ], [ false, %16 ], [ false, %19 ], [ 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 = !{!"_ZTS3vEB", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"long long", !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 = !{!6, !10, i64 16}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !10, i64 32}
!15 = !{!10, !10, i64 0}


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