; LLVM IR from facebook/redex :: opt/resolve-refs (SpecializeRtype)

; 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.resolve_refs::RtypeSpecialization" = type { %"class.std::map", %class.XStoreRefs, %"struct.resolve_refs::RtypeStats" }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<DexMethod *, std::pair<DexMethod *const, const DexType *>, std::_Select1st<std::pair<DexMethod *const, const DexType *>>, dexmethods_comparator>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<DexMethod *, std::pair<DexMethod *const, const DexType *>, std::_Select1st<std::pair<DexMethod *const, const DexType *>>, dexmethods_comparator>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%class.XStoreRefs = type { %class.InsertOnlyConcurrentMap, %"class.std::vector.132", i64, %class.UnorderedMap.137, %class.UnorderedMap.137, %"class.std::__cxx11::basic_string" }
%class.InsertOnlyConcurrentMap = type { %class.ConcurrentContainer }
%class.ConcurrentContainer = type { ptr, [83 x %"class.cc_impl::ConcurrentHashtable"] }
%"class.cc_impl::ConcurrentHashtable" = type { %"struct.std::atomic.125", %"struct.std::atomic", %"struct.std::atomic.127", %"struct.std::atomic.129" }
%"struct.std::atomic.125" = type { %"struct.std::__atomic_base.126" }
%"struct.std::__atomic_base.126" = type { ptr }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i64 }
%"struct.std::atomic.127" = type { %"struct.std::__atomic_base.128" }
%"struct.std::__atomic_base.128" = type { i8 }
%"struct.std::atomic.129" = type { %"struct.std::__atomic_base.130" }
%"struct.std::__atomic_base.130" = type { ptr }
%"class.std::vector.132" = type { %"struct.std::_Vector_base.133" }
%"struct.std::_Vector_base.133" = type { %"struct.std::_Vector_base<const DexStore *, std::allocator<const DexStore *>>::_Vector_impl" }
%"struct.std::_Vector_base<const DexStore *, std::allocator<const DexStore *>>::_Vector_impl" = type { %"struct.std::_Vector_base<const DexStore *, std::allocator<const DexStore *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<const DexStore *, std::allocator<const DexStore *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.UnorderedMap.137 = type { %"class.std::unordered_map.139" }
%"class.std::unordered_map.139" = type { %"class.std::_Hashtable.140" }
%"class.std::_Hashtable.140" = 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.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"struct.resolve_refs::RtypeStats" = type { %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", i64 }

; 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
declare dso_local noundef zeroext i1 @_ZNK10XStoreRefs11illegal_refEPK7DexTypeS2_(ptr noundef nonnull align 8 dereferenceable(2840), ptr noundef, ptr noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK12resolve_refs19RtypeSpecialization32shares_identical_rtype_candidateEP9DexMethodPK7DexType(ptr noundef nonnull align 8 dereferenceable(2952) %0, ptr noundef %1, ptr noundef %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = call noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26) %12)
  %14 = call noundef ptr @_Z19type_class_internalPK7DexType(ptr noundef %13)
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  br label %46

17:                                               ; preds = %3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef ptr @_ZN9DexMethod8get_codeEv(ptr noundef nonnull align 8 dereferenceable(88) %18)
  %20 = icmp ne ptr %19, null
  br i1 %20, label %31, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  %22 = getelementptr inbounds %"class.resolve_refs::RtypeSpecialization", ptr %11, i32 0, i32 1
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = call noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26) %23)
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call noundef zeroext i1 @_ZNK10XStoreRefs11illegal_refEPK7DexTypeS2_(ptr noundef nonnull align 8 dereferenceable(2840) %22, ptr noundef %24, ptr noundef %25)
  %27 = zext i1 %26 to i8
  store i8 %27, ptr %8, align 1, !tbaa !9
  %28 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %29 = trunc i8 %28 to i1
  %30 = xor i1 %29, true
  store i1 %30, ptr %4, align 1
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %46

31:                                               ; preds = %17
  %32 = getelementptr inbounds %"class.resolve_refs::RtypeSpecialization", ptr %11, i32 0, i32 0
  %33 = call noundef i64 @_ZNKSt3mapIP9DexMethodPK7DexType21dexmethods_comparatorSaISt4pairIKS1_S4_EEE5countERS7_(ptr noundef nonnull align 8 dereferenceable(48) %32, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  store i1 false, ptr %4, align 1
  br label %46

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %37 = getelementptr inbounds %"class.resolve_refs::RtypeSpecialization", ptr %11, i32 0, i32 0
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt3mapIP9DexMethodPK7DexType21dexmethods_comparatorSaISt4pairIKS1_S4_EEE2atERS7_(ptr noundef nonnull align 8 dereferenceable(48) %37, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  store ptr %39, ptr %9, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = icmp ne ptr %40, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %36
  store i1 false, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %45

44:                                               ; preds = %36
  store i1 true, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %45

45:                                               ; preds = %44, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %46

46:                                               ; preds = %45, %35, %21, %16
  %47 = load i1, ptr %4, align 1
  ret i1 %47
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z19type_class_internalPK7DexType(ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3mapIP9DexMethodPK7DexType21dexmethods_comparatorSaISt4pairIKS1_S4_EEE5countERS7_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt3mapIP9DexMethodPK7DexType21dexmethods_comparatorSaISt4pairIKS1_S4_EEE2atERS7_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #1 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 = { 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 #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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}


; 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
declare dso_local noundef zeroext i1 @_ZNK10XStoreRefs11illegal_refEPK7DexTypeS2_(ptr noundef nonnull align 8 dereferenceable(2840), ptr noundef, ptr noundef) local_unnamed_addr #0 align 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
define dso_local noundef zeroext i1 @_ZNK12resolve_refs19RtypeSpecialization32shares_identical_rtype_candidateEP9DexMethodPK7DexType(ptr noundef nonnull align 8 dereferenceable(2952) %0, ptr noundef nonnull %1, ptr noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = tail call noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26) %1)
  %6 = tail call noundef ptr @_Z19type_class_internalPK7DexType(ptr noundef %5)
  %7 = icmp eq ptr %6, null
  br i1 %7, label %21, label %8

8:                                                ; preds = %3
  %9 = tail call noundef ptr @_ZN9DexMethod8get_codeEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %10, label %15

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = tail call noundef ptr @_ZNK12DexMethodRef9get_classEv(ptr noundef nonnull align 8 dereferenceable(26) %1)
  %13 = tail call noundef zeroext i1 @_ZNK10XStoreRefs11illegal_refEPK7DexTypeS2_(ptr noundef nonnull align 8 dereferenceable(2840) %11, ptr noundef %12, ptr noundef %2)
  %14 = xor i1 %13, true
  br label %21

15:                                               ; preds = %8
  %16 = call noundef i64 @_ZNKSt3mapIP9DexMethodPK7DexType21dexmethods_comparatorSaISt4pairIKS1_S4_EEE5countERS7_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %21, label %18

18:                                               ; preds = %15
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt3mapIP9DexMethodPK7DexType21dexmethods_comparatorSaISt4pairIKS1_S4_EEE2atERS7_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %.not5 = icmp eq ptr %20, %2
  br label %21

21:                                               ; preds = %15, %3, %18, %10
  %.1 = phi i1 [ %.not5, %18 ], [ %14, %10 ], [ false, %3 ], [ false, %15 ]
  ret i1 %.1
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_Z19type_class_internalPK7DexType(ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt3mapIP9DexMethodPK7DexType21dexmethods_comparatorSaISt4pairIKS1_S4_EEE2atERS7_(ptr noundef nonnull align 8 dereferenceable(48), 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 = { 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" }

!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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass