; LLVM IR from facebook/redex :: libredex/CallGraph.ll (ZNK10call_graph20SingleCalleeStrategy9get_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.105 = type { ptr, ptr }
%"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 }

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: mustprogress uwtable
define dso_local void @_ZNK10call_graph20SingleCalleeStrategy9get_rootsEv(ptr dead_on_unwind noalias writable sret(%"struct.call_graph::RootAndDynamic") align 8 %0, ptr noundef nonnull align 8 dereferenceable(2680) %1) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca %class.anon.105, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  store i1 false, ptr %5, align 1
  call void @_ZN10call_graph14RootAndDynamicC2Ev(ptr noundef nonnull align 8 dereferenceable(112) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %11 = getelementptr inbounds %"struct.call_graph::RootAndDynamic", ptr %0, i32 0, i32 0
  store ptr %11, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.call_graph::SingleCalleeStrategy", ptr %10, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  %14 = getelementptr inbounds %class.anon.105, ptr %7, i32 0, i32 0
  store ptr %10, ptr %14, align 8, !tbaa !14
  %15 = getelementptr inbounds %class.anon.105, ptr %7, i32 0, i32 1
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %16, ptr %15, align 8, !tbaa !5
  invoke void @"_ZN4walk4codeISt6vectorIP8DexClassSaIS3_EEZNK10call_graph20SingleCalleeStrategy9get_rootsEvE3$_0EEvRKT_RKT0_"(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(16) %7)
          to label %17 unwind label %19

17:                                               ; preds = %2
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  store i1 true, ptr %5, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %18 = load i1, ptr %5, align 1
  br i1 %18, label %24, label %23

19:                                               ; preds = %2
  %20 = landingpad { ptr, i32 }
          cleanup
  %21 = extractvalue { ptr, i32 } %20, 0
  store ptr %21, ptr %8, align 8
  %22 = extractvalue { ptr, i32 } %20, 1
  store i32 %22, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #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 %25

23:                                               ; preds = %17
  call void @_ZN10call_graph14RootAndDynamicD2Ev(ptr noundef nonnull align 8 dereferenceable(112) %0) #4
  br label %24

24:                                               ; preds = %23, %17
  ret void

25:                                               ; preds = %19
  %26 = load ptr, ptr %8, align 8
  %27 = load i32, ptr %9, align 4
  %28 = insertvalue { ptr, i32 } poison, ptr %26, 0
  %29 = insertvalue { ptr, i32 } %28, i32 %27, 1
  resume { ptr, i32 } %29
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZN4walk4codeISt6vectorIP8DexClassSaIS3_EEZNK10call_graph20SingleCalleeStrategy9get_rootsEvE3$_0EEvRKT_RKT0_"(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 #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 = !{!10, !6, i64 8}
!10 = !{!"_ZTSN10call_graph20SingleCalleeStrategyE", !11, i64 0, !6, i64 8, !12, i64 16}
!11 = !{!"_ZTSN10call_graph13BuildStrategyE"}
!12 = !{!"_ZTS23InsertOnlyConcurrentSetIP9DexMethodSt4hashIS1_ESt8equal_toIS1_ELm83EE", !13, i64 0}
!13 = !{!"_ZTS19ConcurrentContainerISt13unordered_setIP9DexMethodSt4hashIS2_ESt8equal_toIS2_ESaIS2_EELm83EE", !7, i64 8}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTSZNK10call_graph20SingleCalleeStrategy9get_rootsEvE3$_0", !6, i64 0, !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"

%"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.105 = type { ptr, ptr }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress 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 void @_ZNK10call_graph20SingleCalleeStrategy9get_rootsEv(ptr dead_on_unwind noalias nonnull writable sret(%"struct.call_graph::RootAndDynamic") align 8 %0, ptr noundef nonnull align 8 dereferenceable(2680) %1) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.anon.105, align 8
  tail call void @_ZN10call_graph14RootAndDynamicC2Ev(ptr noundef nonnull align 8 dereferenceable(112) %0)
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  store ptr %1, ptr %3, align 8, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %0, ptr %6, align 8, !tbaa !15
  invoke void @"_ZN4walk4codeISt6vectorIP8DexClassSaIS3_EEZNK10call_graph20SingleCalleeStrategy9get_rootsEvE3$_0EEvRKT_RKT0_"(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(16) %3)
          to label %7 unwind label %8

7:                                                ; preds = %2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  ret void

8:                                                ; preds = %2
  %9 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  call void @_ZN10call_graph14RootAndDynamicD2Ev(ptr noundef nonnull align 8 dereferenceable(112) %0) #4
  resume { ptr, i32 } %9
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZN4walk4codeISt6vectorIP8DexClassSaIS3_EEZNK10call_graph20SingleCalleeStrategy9get_rootsEvE3$_0EEvRKT_RKT0_"(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 #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, !8, i64 8}
!6 = !{!"_ZTSN10call_graph20SingleCalleeStrategyE", !7, i64 0, !8, i64 8, !11, i64 16}
!7 = !{!"_ZTSN10call_graph13BuildStrategyE"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS23InsertOnlyConcurrentSetIP9DexMethodSt4hashIS1_ESt8equal_toIS1_ELm83EE", !12, i64 0}
!12 = !{!"_ZTS19ConcurrentContainerISt13unordered_setIP9DexMethodSt4hashIS2_ESt8equal_toIS2_ESaIS2_EELm83EE", !9, i64 8}
!13 = !{!14, !8, i64 0}
!14 = !{!"_ZTSZNK10call_graph20SingleCalleeStrategy9get_rootsEvE3$_0", !8, i64 0, !8, i64 8}
!15 = !{!8, !8, i64 0}


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