; LLVM IR from facebook/redex :: libredex/ReflectionAnalysis.ll (ZN10reflection14AbstractObject9join_withERKS0_)

; 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.boost::none_t" = type { i8 }
%"struct.reflection::AbstractObject" = type { i32, ptr, ptr, %"class.boost::optional", %class.UnorderedSet, i64, %"class.boost::optional.5" }
%"class.boost::optional" = type { %"class.boost::optional_detail::tc_optional_base" }
%"class.boost::optional_detail::tc_optional_base" = type { i8, i64 }
%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.boost::optional.5" = type { %"class.boost::optional_detail::optional_base" }
%"class.boost::optional_detail::optional_base" = type { i8, [7 x i8], %"class.boost::optional_detail::aligned_storage" }
%"class.boost::optional_detail::aligned_storage" = type { %"union.boost::optional_detail::aligned_storage<std::vector<DexType *>>::dummy_u" }
%"union.boost::optional_detail::aligned_storage<std::vector<DexType *>>::dummy_u" = type { [24 x i8] }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK10reflection14AbstractObject3leqERKS0_(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef nonnull align 8 dereferenceable(136)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN10reflection14AbstractObject9join_withERKS0_(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef nonnull align 8 dereferenceable(136) %1) #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.boost::none_t", align 1
  %7 = alloca %"struct.boost::none_t", align 1
  %8 = alloca %"struct.boost::none_t", align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_ZNK10reflection14AbstractObject3leqERKS0_(ptr noundef nonnull align 8 dereferenceable(136) %10, ptr noundef nonnull align 8 dereferenceable(136) %9)
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  store i32 1, ptr %3, align 4
  br label %42

13:                                               ; preds = %2
  %14 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = icmp ne i32 %15, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %13
  store i32 2, ptr %3, align 4
  br label %42

21:                                               ; preds = %13
  %22 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !9
  switch i32 %23, label %41 [
    i32 1, label %24
    i32 0, label %27
    i32 3, label %27
    i32 2, label %33
    i32 4, label %35
    i32 5, label %35
  ]

24:                                               ; preds = %21
  %25 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 3
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN5boost8optionalIlEaSENS_6none_tE(ptr noundef nonnull align 8 dereferenceable(16) %25) #2
  br label %41

27:                                               ; preds = %21, %21
  %28 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 1
  store ptr null, ptr %28, align 8, !tbaa !25
  %29 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 5
  store i64 0, ptr %29, align 8, !tbaa !26
  %30 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 6
  %31 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5boost8optionalISt6vectorIP7DexTypeSaIS3_EEEaSENS_6none_tE(ptr noundef nonnull align 8 dereferenceable(32) %30) #2
  %32 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 4
  call void @_ZN12UnorderedSetIP7DexTypeSt4hashIS1_ESt8equal_toIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(56) %32)
  br label %41

33:                                               ; preds = %21
  %34 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 2
  store ptr null, ptr %34, align 8, !tbaa !27
  br label %41

35:                                               ; preds = %21, %21
  %36 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 1
  store ptr null, ptr %36, align 8, !tbaa !25
  %37 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 2
  store ptr null, ptr %37, align 8, !tbaa !27
  %38 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 6
  %39 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5boost8optionalISt6vectorIP7DexTypeSaIS3_EEEaSENS_6none_tE(ptr noundef nonnull align 8 dereferenceable(32) %38) #2
  %40 = getelementptr inbounds %"struct.reflection::AbstractObject", ptr %9, i32 0, i32 4
  call void @_ZN12UnorderedSetIP7DexTypeSt4hashIS1_ESt8equal_toIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(56) %40)
  br label %41

41:                                               ; preds = %35, %33, %27, %24, %21
  store i32 1, ptr %3, align 4
  br label %42

42:                                               ; preds = %41, %20, %12
  %43 = load i32, ptr %3, align 4
  ret i32 %43
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN12UnorderedSetIP7DexTypeSt4hashIS1_ESt8equal_toIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(56)) #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, !11, i64 0}
!10 = !{!"_ZTSN10reflection14AbstractObjectE", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !16, i64 40, !15, i64 96, !22, i64 104}
!11 = !{!"_ZTSN10reflection18AbstractObjectKindE", !7, i64 0}
!12 = !{!"_ZTSN5boost8optionalIlEE", !13, i64 0}
!13 = !{!"_ZTSN5boost15optional_detail16tc_optional_baseIlEE", !14, i64 0, !15, i64 8}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTS12UnorderedSetIP7DexTypeSt4hashIS1_ESt8equal_toIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt13unordered_setIP7DexTypeSt4hashIS1_ESt8equal_toIS1_ESaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSSt10_HashtableIP7DexTypeS1_SaIS1_ENSt8__detail9_IdentityESt8equal_toIS1_ESt4hashIS1_ENS3_18_Mod_range_hashingENS3_20_Default_ranged_hashENS3_20_Prime_rehash_policyENS3_17_Hashtable_traitsILb0ELb1ELb1EEEE", !6, i64 0, !15, i64 8, !19, i64 16, !15, i64 24, !20, i64 32, !6, i64 48}
!19 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!20 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !21, i64 0, !15, i64 8}
!21 = !{!"float", !7, i64 0}
!22 = !{!"_ZTSN5boost8optionalISt6vectorIP7DexTypeSaIS3_EEEE", !23, i64 0}
!23 = !{!"_ZTSN5boost15optional_detail13optional_baseISt6vectorIP7DexTypeSaIS4_EEEE", !14, i64 0, !24, i64 8}
!24 = !{!"_ZTSN5boost15optional_detail15aligned_storageISt6vectorIP7DexTypeSaIS4_EEEE", !7, i64 0}
!25 = !{!10, !6, i64 8}
!26 = !{!10, !15, i64 96}
!27 = !{!10, !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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK10reflection14AbstractObject3leqERKS0_(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 1, 3) i32 @_ZN10reflection14AbstractObject9join_withERKS0_(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef nonnull align 8 dereferenceable(136) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef zeroext i1 @_ZNK10reflection14AbstractObject3leqERKS0_(ptr noundef nonnull align 8 dereferenceable(136) %1, ptr noundef nonnull align 8 dereferenceable(136) %0)
  br i1 %3, label %24, label %4

4:                                                ; preds = %2
  %5 = load i32, ptr %0, align 8, !tbaa !5
  %6 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %5, %6
  br i1 %.not, label %7, label %24

7:                                                ; preds = %4
  switch i32 %5, label %24 [
    i32 1, label %8
    i32 0, label %11
    i32 3, label %11
    i32 2, label %17
    i32 4, label %19
    i32 5, label %19
  ]

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN5boost8optionalIlEaSENS_6none_tE(ptr noundef nonnull align 8 dereferenceable(16) %9) #3
  br label %24

11:                                               ; preds = %7, %7
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %12, align 8, !tbaa !24
  %13 = getelementptr inbounds i8, ptr %0, i64 96
  store i64 0, ptr %13, align 8, !tbaa !25
  %14 = getelementptr inbounds i8, ptr %0, i64 104
  %15 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5boost8optionalISt6vectorIP7DexTypeSaIS3_EEEaSENS_6none_tE(ptr noundef nonnull align 8 dereferenceable(32) %14) #3
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZN12UnorderedSetIP7DexTypeSt4hashIS1_ESt8equal_toIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(56) %16)
  br label %24

17:                                               ; preds = %7
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %18, align 8, !tbaa !26
  br label %24

19:                                               ; preds = %7, %7
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %20, i8 0, i64 16, i1 false)
  %22 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5boost8optionalISt6vectorIP7DexTypeSaIS3_EEEaSENS_6none_tE(ptr noundef nonnull align 8 dereferenceable(32) %21) #3
  %23 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZN12UnorderedSetIP7DexTypeSt4hashIS1_ESt8equal_toIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(56) %23)
  br label %24

24:                                               ; preds = %7, %8, %11, %17, %19, %4, %2
  %.0 = phi i32 [ 1, %2 ], [ 2, %4 ], [ 1, %19 ], [ 1, %17 ], [ 1, %11 ], [ 1, %8 ], [ 1, %7 ]
  ret i32 %.0
}

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"_ZTSN10reflection14AbstractObjectE", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !15, i64 40, !14, i64 96, !21, i64 104}
!7 = !{!"_ZTSN10reflection18AbstractObjectKindE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSN5boost8optionalIlEE", !12, i64 0}
!12 = !{!"_ZTSN5boost15optional_detail16tc_optional_baseIlEE", !13, i64 0, !14, i64 8}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = !{!"_ZTS12UnorderedSetIP7DexTypeSt4hashIS1_ESt8equal_toIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt13unordered_setIP7DexTypeSt4hashIS1_ESt8equal_toIS1_ESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt10_HashtableIP7DexTypeS1_SaIS1_ENSt8__detail9_IdentityESt8equal_toIS1_ESt4hashIS1_ENS3_18_Mod_range_hashingENS3_20_Default_ranged_hashENS3_20_Prime_rehash_policyENS3_17_Hashtable_traitsILb0ELb1ELb1EEEE", !10, i64 0, !14, i64 8, !18, i64 16, !14, i64 24, !19, i64 32, !10, i64 48}
!18 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !10, i64 0}
!19 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !20, i64 0, !14, i64 8}
!20 = !{!"float", !8, i64 0}
!21 = !{!"_ZTSN5boost8optionalISt6vectorIP7DexTypeSaIS3_EEEE", !22, i64 0}
!22 = !{!"_ZTSN5boost15optional_detail13optional_baseISt6vectorIP7DexTypeSaIS4_EEEE", !13, i64 0, !23, i64 8}
!23 = !{!"_ZTSN5boost15optional_detail15aligned_storageISt6vectorIP7DexTypeSaIS4_EEEE", !8, i64 0}
!24 = !{!6, !10, i64 8}
!25 = !{!6, !14, i64 96}
!26 = !{!6, !10, i64 16}


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