; LLVM IR from facebook/redex :: libredex/HierarchyUtil.ll (ZNK14hierarchy_util21NonOverriddenVirtuals5countEPK9DexMethod)

; 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.hierarchy_util::NonOverriddenVirtuals" = type { %class.ConcurrentSet }
%class.ConcurrentSet = type { %class.ConcurrentContainer }
%class.ConcurrentContainer = type { ptr, [83 x %"class.cc_impl::ConcurrentHashtable"] }
%"class.cc_impl::ConcurrentHashtable" = type { %"struct.std::atomic", %"struct.std::atomic.1", %"struct.std::atomic.3", %"struct.std::atomic.5" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { ptr }
%"struct.std::atomic.1" = type { %"struct.std::__atomic_base.2" }
%"struct.std::__atomic_base.2" = type { i64 }
%"struct.std::atomic.3" = type { %"struct.std::__atomic_base.4" }
%"struct.std::__atomic_base.4" = type { i8 }
%"struct.std::atomic.5" = type { %"struct.std::__atomic_base.6" }
%"struct.std::__atomic_base.6" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZNK14hierarchy_util21NonOverriddenVirtuals5countEPK9DexMethod(ptr noundef nonnull align 8 dereferenceable(2664) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = call noundef zeroext i1 @_ZNK12DexMethodRef11is_externalEv(ptr noundef nonnull align 8 dereferenceable(26) %7)
  br i1 %8, label %9, label %20

9:                                                ; preds = %2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_Z8is_finalIK9DexMethodEbPT_(ptr noundef %10)
  br i1 %11, label %17, label %12

12:                                               ; preds = %9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26) %13)
  %15 = call noundef ptr @_Z10type_classPK7DexType(ptr noundef %14)
  %16 = call noundef zeroext i1 @_Z8is_finalI8DexClassEbPT_(ptr noundef %15)
  br label %17

17:                                               ; preds = %12, %9
  %18 = phi i1 [ true, %9 ], [ %16, %12 ]
  %19 = zext i1 %18 to i64
  store i64 %19, ptr %3, align 8
  br label %23

20:                                               ; preds = %2
  %21 = getelementptr inbounds %"class.hierarchy_util::NonOverriddenVirtuals", ptr %6, i32 0, i32 0
  %22 = call noundef i64 @_ZNK19ConcurrentContainerISt13unordered_setIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ESaIS3_EELm83EE12count_unsafeERKS3_(ptr noundef nonnull align 8 dereferenceable(2664) %21, ptr noundef nonnull align 8 dereferenceable(8) %5)
  store i64 %22, ptr %3, align 8
  br label %23

23:                                               ; preds = %20, %17
  %24 = load i64, ptr %3, align 8
  ret i64 %24
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK12DexMethodRef11is_externalEv(ptr noundef nonnull align 8 dereferenceable(26)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z8is_finalIK9DexMethodEbPT_(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z8is_finalI8DexClassEbPT_(ptr noundef) #0

declare noundef ptr @_Z10type_classPK7DexType(ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK19ConcurrentContainerISt13unordered_setIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ESaIS3_EELm83EE12count_unsafeERKS3_(ptr noundef nonnull align 8 dereferenceable(2664), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

attributes #0 = { 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 #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 = { "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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 uwtable
define dso_local noundef i64 @_ZNK14hierarchy_util21NonOverriddenVirtuals5countEPK9DexMethod(ptr noundef nonnull align 8 dereferenceable(2664) %0, ptr noundef nonnull %1) local_unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  %4 = tail call noundef zeroext i1 @_ZNK12DexMethodRef11is_externalEv(ptr noundef nonnull align 8 dereferenceable(26) %1)
  br i1 %4, label %5, label %12

5:                                                ; preds = %2
  %6 = tail call noundef zeroext i1 @_Z8is_finalIK9DexMethodEbPT_(ptr noundef nonnull %1)
  br i1 %6, label %14, label %7

7:                                                ; preds = %5
  %8 = tail call noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26) %1)
  %9 = tail call noundef ptr @_Z10type_classPK7DexType(ptr noundef %8)
  %10 = tail call noundef zeroext i1 @_Z8is_finalI8DexClassEbPT_(ptr noundef %9)
  %11 = zext i1 %10 to i64
  br label %14

12:                                               ; preds = %2
  %13 = call noundef i64 @_ZNK19ConcurrentContainerISt13unordered_setIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ESaIS3_EELm83EE12count_unsafeERKS3_(ptr noundef nonnull align 8 dereferenceable(2664) %0, ptr noundef nonnull align 8 dereferenceable(8) %3)
  br label %14

14:                                               ; preds = %5, %7, %12
  %.0 = phi i64 [ %13, %12 ], [ 1, %5 ], [ %11, %7 ]
  ret i64 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK12DexMethodRef11is_externalEv(ptr noundef nonnull align 8 dereferenceable(26)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z8is_finalIK9DexMethodEbPT_(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z8is_finalI8DexClassEbPT_(ptr noundef) local_unnamed_addr #0

declare noundef ptr @_Z10type_classPK7DexType(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK19ConcurrentContainerISt13unordered_setIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ESaIS3_EELm83EE12count_unsafeERKS3_(ptr noundef nonnull align 8 dereferenceable(2664), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

attributes #0 = { 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 #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 = { "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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