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

; 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.std::vector.63" = type { %"struct.std::_Vector_base.64" }
%"struct.std::_Vector_base.64" = type { %"struct.std::_Vector_base<call_graph::CallSite, std::allocator<call_graph::CallSite>>::_Vector_impl" }
%"struct.std::_Vector_base<call_graph::CallSite, std::allocator<call_graph::CallSite>>::_Vector_impl" = type { %"struct.std::_Vector_base<call_graph::CallSite, std::allocator<call_graph::CallSite>>::_Vector_impl_data" }
%"struct.std::_Vector_base<call_graph::CallSite, std::allocator<call_graph::CallSite>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.anon = type { ptr, ptr, 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_graph20SingleCalleeStrategy13get_callsitesEPK9DexMethod(ptr dead_on_unwind noalias writable sret(%"class.std::vector.63") align 8 %0, ptr noundef nonnull align 8 dereferenceable(2680) %1, ptr noundef %2) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %class.anon, align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  store i1 false, ptr %7, align 1
  call void @_ZNSt6vectorIN10call_graph8CallSiteESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = invoke noundef ptr @_ZNK9DexMethod8get_codeEv(ptr noundef nonnull align 8 dereferenceable(88) %14)
          to label %16 unwind label %20

16:                                               ; preds = %3
  store ptr %15, ptr %8, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  store i1 true, ptr %7, align 1
  store i32 1, ptr %11, align 4
  br label %30

20:                                               ; preds = %24, %3
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %9, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @_ZNSt6vectorIN10call_graph8CallSiteESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  br label %34

24:                                               ; preds = %16
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.anon, ptr %12, i32 0, i32 0
  store ptr %6, ptr %26, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.anon, ptr %12, i32 0, i32 1
  store ptr %13, ptr %27, align 8, !tbaa !9
  %28 = getelementptr inbounds %class.anon, ptr %12, i32 0, i32 2
  store ptr %0, ptr %28, align 8, !tbaa !5
  invoke void @"_ZN20editable_cfg_adapter21iterate_with_iteratorIZNK10call_graph20SingleCalleeStrategy13get_callsitesEPK9DexMethodE3$_0EEvP6IRCodeT_"(ptr noundef %25, ptr noundef byval(%class.anon) align 8 %12)
          to label %29 unwind label %20

29:                                               ; preds = %24
  store i1 true, ptr %7, align 1
  store i32 1, ptr %11, align 4
  br label %30

30:                                               ; preds = %29, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %31 = load i1, ptr %7, align 1
  br i1 %31, label %33, label %32

32:                                               ; preds = %30
  call void @_ZNSt6vectorIN10call_graph8CallSiteESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  br label %33

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

34:                                               ; preds = %20
  %35 = load ptr, ptr %9, align 8
  %36 = load i32, ptr %10, 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 nounwind uwtable
declare dso_local void @_ZNSt6vectorIN10call_graph8CallSiteESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZN20editable_cfg_adapter21iterate_with_iteratorIZNK10call_graph20SingleCalleeStrategy13get_callsitesEPK9DexMethodE3$_0EEvP6IRCodeT_"(ptr noundef, ptr noundef byval(%class.anon) align 8) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN10call_graph8CallSiteESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 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 = { 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 #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, !6, i64 8}
!10 = !{!"_ZTSZNK10call_graph20SingleCalleeStrategy13get_callsitesEPK9DexMethodE3$_0", !6, i64 0, !6, i64 8, !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"

%"class.std::vector.63" = type { %"struct.std::_Vector_base.64" }
%"struct.std::_Vector_base.64" = type { %"struct.std::_Vector_base<call_graph::CallSite, std::allocator<call_graph::CallSite>>::_Vector_impl" }
%"struct.std::_Vector_base<call_graph::CallSite, std::allocator<call_graph::CallSite>>::_Vector_impl" = type { %"struct.std::_Vector_base<call_graph::CallSite, std::allocator<call_graph::CallSite>>::_Vector_impl_data" }
%"struct.std::_Vector_base<call_graph::CallSite, std::allocator<call_graph::CallSite>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.anon = type { ptr, ptr, ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10call_graph20SingleCalleeStrategy13get_callsitesEPK9DexMethod(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::vector.63") align 8 %0, ptr noundef nonnull align 8 dereferenceable(2680) %1, ptr noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca %class.anon, align 8
  store ptr %2, ptr %4, align 8, !tbaa !5
  tail call void @_ZNSt6vectorIN10call_graph8CallSiteESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %6 = tail call noundef ptr @_ZNK9DexMethod8get_codeEv(ptr noundef nonnull align 8 dereferenceable(88) %2)
  %7 = icmp eq ptr %6, null
  br i1 %7, label %13, label %10

8:                                                ; preds = %10
  %9 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorIN10call_graph8CallSiteESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  resume { ptr, i32 } %9

10:                                               ; preds = %3
  store ptr %4, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %1, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %0, ptr %12, align 8, !tbaa !5
  invoke void @"_ZN20editable_cfg_adapter21iterate_with_iteratorIZNK10call_graph20SingleCalleeStrategy13get_callsitesEPK9DexMethodE3$_0EEvP6IRCodeT_"(ptr noundef nonnull %6, ptr noundef nonnull byval(%class.anon) align 8 %5)
          to label %13 unwind label %8

13:                                               ; preds = %3, %10
  ret void
}

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

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

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZN20editable_cfg_adapter21iterate_with_iteratorIZNK10call_graph20SingleCalleeStrategy13get_callsitesEPK9DexMethodE3$_0EEvP6IRCodeT_"(ptr noundef, ptr noundef byval(%class.anon) align 8) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN10call_graph8CallSiteESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 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 = { 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 = !{!"_ZTSZNK10call_graph20SingleCalleeStrategy13get_callsitesEPK9DexMethodE3$_0", !6, i64 0, !6, i64 8, !6, i64 16}


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