; LLVM IR from facebook/redex :: libredex/CallGraph.ll (ZNK10call_graph22MultipleCalleeStrategy9get_rootsEv)

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

%"struct.call_graph::RootAndDynamic" = type { %class.UnorderedSet, %class.UnorderedSet }
%class.UnorderedSet = type { %"class.std::unordered_set" }
%"class.std::unordered_set" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%class.anon.140 = type { ptr }
%"class.call_graph::MultipleCalleeStrategy" = type { %"class.call_graph::MultipleCalleeBaseStrategy", %class.ConcurrentSet, %class.ConcurrentSet }
%"class.call_graph::MultipleCalleeBaseStrategy" = type { %"class.call_graph::SingleCalleeStrategy", ptr, %class.InsertOnlyConcurrentMap.48 }
%"class.call_graph::SingleCalleeStrategy" = type { %"class.call_graph::BuildStrategy", ptr, %class.InsertOnlyConcurrentSet }
%"class.call_graph::BuildStrategy" = type { ptr }
%class.InsertOnlyConcurrentSet = type { %class.ConcurrentContainer.31 }
%class.ConcurrentContainer.31 = type { ptr, [83 x %"class.cc_impl::ConcurrentHashtable.32"] }
%"class.cc_impl::ConcurrentHashtable.32" = type { %"struct.std::atomic.33", %"struct.std::atomic.3", %"struct.std::atomic.5", %"struct.std::atomic.35" }
%"struct.std::atomic.33" = type { %"struct.std::__atomic_base.34" }
%"struct.std::__atomic_base.34" = type { ptr }
%"struct.std::atomic.3" = type { %"struct.std::__atomic_base.4" }
%"struct.std::__atomic_base.4" = type { i64 }
%"struct.std::atomic.5" = type { %"struct.std::__atomic_base.6" }
%"struct.std::__atomic_base.6" = type { i8 }
%"struct.std::atomic.35" = type { %"struct.std::__atomic_base.36" }
%"struct.std::__atomic_base.36" = type { ptr }
%class.InsertOnlyConcurrentMap.48 = type { %class.ConcurrentContainer.49 }
%class.ConcurrentContainer.49 = type { ptr, [83 x %"class.cc_impl::ConcurrentHashtable.50"] }
%"class.cc_impl::ConcurrentHashtable.50" = type { %"struct.std::atomic.51", %"struct.std::atomic.3", %"struct.std::atomic.5", %"struct.std::atomic.53" }
%"struct.std::atomic.51" = type { %"struct.std::__atomic_base.52" }
%"struct.std::__atomic_base.52" = type { ptr }
%"struct.std::atomic.53" = type { %"struct.std::__atomic_base.54" }
%"struct.std::__atomic_base.54" = type { ptr }
%class.ConcurrentSet = type { %class.ConcurrentContainer.56 }
%class.ConcurrentContainer.56 = type { ptr, [83 x %"class.cc_impl::ConcurrentHashtable.57"] }
%"class.cc_impl::ConcurrentHashtable.57" = type { %"struct.std::atomic.58", %"struct.std::atomic.3", %"struct.std::atomic.5", %"struct.std::atomic.60" }
%"struct.std::atomic.58" = type { %"struct.std::__atomic_base.59" }
%"struct.std::__atomic_base.59" = type { ptr }
%"struct.std::atomic.60" = type { %"struct.std::__atomic_base.61" }
%"struct.std::__atomic_base.61" = type { ptr }

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN10call_graph14RootAndDynamicD2Ev(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK10call_graph26MultipleCalleeBaseStrategy9get_rootsEv(ptr dead_on_unwind noalias writable sret(%"struct.call_graph::RootAndDynamic") align 8, ptr noundef nonnull align 8 dereferenceable(5352)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10call_graph22MultipleCalleeStrategy9get_rootsEv(ptr dead_on_unwind noalias writable sret(%"struct.call_graph::RootAndDynamic") align 8 %0, ptr noundef nonnull align 8 dereferenceable(10680) %1) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca %class.anon.140, align 8
  %7 = alloca %class.anon.140, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %class.anon.140, align 8
  %11 = alloca %class.anon.140, align 8
  %12 = alloca %class.anon.140, align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  store i1 false, ptr %5, align 1
  call void @_ZNK10call_graph26MultipleCalleeBaseStrategy9get_rootsEv(ptr dead_on_unwind writable sret(%"struct.call_graph::RootAndDynamic") align 8 %0, ptr noundef nonnull align 8 dereferenceable(5352) %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %14 = getelementptr inbounds %class.anon.140, ptr %6, i32 0, i32 0
  store ptr %0, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.call_graph::MultipleCalleeStrategy", ptr %13, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %6, i64 8, i1 false), !tbaa.struct !9
  %16 = getelementptr inbounds %class.anon.140, ptr %7, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8
  %18 = invoke ptr @"_Z18unordered_for_eachI13ConcurrentSetIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ELm83EEZNK10call_graph22MultipleCalleeStrategy9get_rootsEvE3$_0ET0_RKT_SC_"(ptr noundef nonnull align 8 dereferenceable(2664) %15, ptr %17)
          to label %19 unwind label %28

19:                                               ; preds = %2
  %20 = getelementptr inbounds %class.anon.140, ptr %10, i32 0, i32 0
  store ptr %18, ptr %20, align 8
  %21 = getelementptr inbounds %"class.call_graph::MultipleCalleeStrategy", ptr %13, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %6, i64 8, i1 false), !tbaa.struct !9
  %22 = getelementptr inbounds %class.anon.140, ptr %11, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8
  %24 = invoke ptr @"_Z18unordered_for_eachI13ConcurrentSetIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ELm83EEZNK10call_graph22MultipleCalleeStrategy9get_rootsEvE3$_0ET0_RKT_SC_"(ptr noundef nonnull align 8 dereferenceable(2664) %21, ptr %23)
          to label %25 unwind label %28

25:                                               ; preds = %19
  %26 = getelementptr inbounds %class.anon.140, ptr %12, i32 0, i32 0
  store ptr %24, ptr %26, align 8
  store i1 true, ptr %5, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %27 = load i1, ptr %5, align 1
  br i1 %27, label %33, label %32

28:                                               ; preds = %19, %2
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %8, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @_ZN10call_graph14RootAndDynamicD2Ev(ptr noundef nonnull align 8 dereferenceable(112) %0) #4
  br label %34

32:                                               ; preds = %25
  call void @_ZN10call_graph14RootAndDynamicD2Ev(ptr noundef nonnull align 8 dereferenceable(112) %0) #4
  br label %33

33:                                               ; preds = %32, %25
  ret void

34:                                               ; preds = %28
  %35 = load ptr, ptr %8, align 8
  %36 = load i32, ptr %9, align 4
  %37 = insertvalue { ptr, i32 } poison, ptr %35, 0
  %38 = insertvalue { ptr, i32 } %37, i32 %36, 1
  resume { ptr, i32 } %38
}

; Function Attrs: mustprogress uwtable
declare hidden ptr @"_Z18unordered_for_eachI13ConcurrentSetIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ELm83EEZNK10call_graph22MultipleCalleeStrategy9get_rootsEvE3$_0ET0_RKT_SC_"(ptr noundef nonnull align 8 dereferenceable(2664), ptr) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{i64 0, i64 8, !5}


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

%"struct.call_graph::RootAndDynamic" = type { %class.UnorderedSet, %class.UnorderedSet }
%class.UnorderedSet = type { %"class.std::unordered_set" }
%"class.std::unordered_set" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN10call_graph14RootAndDynamicD2Ev(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK10call_graph26MultipleCalleeBaseStrategy9get_rootsEv(ptr dead_on_unwind noalias writable sret(%"struct.call_graph::RootAndDynamic") align 8, ptr noundef nonnull align 8 dereferenceable(5352)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10call_graph22MultipleCalleeStrategy9get_rootsEv(ptr dead_on_unwind noalias writable sret(%"struct.call_graph::RootAndDynamic") align 8 %0, ptr noundef nonnull align 8 dereferenceable(10680) %1) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZNK10call_graph26MultipleCalleeBaseStrategy9get_rootsEv(ptr dead_on_unwind writable sret(%"struct.call_graph::RootAndDynamic") align 8 %0, ptr noundef nonnull align 8 dereferenceable(5352) %1)
  %3 = getelementptr inbounds i8, ptr %1, i64 5352
  %4 = invoke ptr @"_Z18unordered_for_eachI13ConcurrentSetIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ELm83EEZNK10call_graph22MultipleCalleeStrategy9get_rootsEvE3$_0ET0_RKT_SC_"(ptr noundef nonnull align 8 dereferenceable(2664) %3, ptr %0)
          to label %5 unwind label %8

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 8016
  %7 = invoke ptr @"_Z18unordered_for_eachI13ConcurrentSetIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ELm83EEZNK10call_graph22MultipleCalleeStrategy9get_rootsEvE3$_0ET0_RKT_SC_"(ptr noundef nonnull align 8 dereferenceable(2664) %6, ptr %0)
          to label %10 unwind label %8

8:                                                ; preds = %5, %2
  %9 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN10call_graph14RootAndDynamicD2Ev(ptr noundef nonnull align 8 dereferenceable(112) %0) #2
  resume { ptr, i32 } %9

10:                                               ; preds = %5
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden ptr @"_Z18unordered_for_eachI13ConcurrentSetIPK9DexMethodSt4hashIS3_ESt8equal_toIS3_ELm83EEZNK10call_graph22MultipleCalleeStrategy9get_rootsEvE3$_0ET0_RKT_SC_"(ptr noundef nonnull align 8 dereferenceable(2664), ptr) local_unnamed_addr #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 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 = { 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)"}


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