; LLVM IR from facebook/redex :: libredex (InitClassesWithSideEffects)

; 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.init_classes::InitClassesWithSideEffects" = type <{ %class.InsertOnlyConcurrentMap, %"struct.std::atomic.16", %"class.std::vector.22", i8, [7 x i8] }>
%class.InsertOnlyConcurrentMap = type { %class.ConcurrentContainer }
%class.ConcurrentContainer = type { ptr, [83 x %"class.cc_impl::ConcurrentHashtable"] }
%"class.cc_impl::ConcurrentHashtable" = type { %"struct.std::atomic.14", %"struct.std::atomic.16", %"struct.std::atomic.18", %"struct.std::atomic.20" }
%"struct.std::atomic.14" = type { %"struct.std::__atomic_base.15" }
%"struct.std::__atomic_base.15" = type { ptr }
%"struct.std::atomic.18" = type { %"struct.std::__atomic_base.19" }
%"struct.std::__atomic_base.19" = type { i8 }
%"struct.std::atomic.20" = type { %"struct.std::__atomic_base.21" }
%"struct.std::__atomic_base.21" = type { ptr }
%"struct.std::atomic.16" = type { %"struct.std::__atomic_base.17" }
%"struct.std::__atomic_base.17" = type { i64 }
%"class.std::vector.22" = type { %"struct.std::_Vector_base.23" }
%"struct.std::_Vector_base.23" = type { %"struct.std::_Vector_base<const DexClass *, std::allocator<const DexClass *>>::_Vector_impl" }
%"struct.std::_Vector_base<const DexClass *, std::allocator<const DexClass *>>::_Vector_impl" = type { %"struct.std::_Vector_base<const DexClass *, std::allocator<const DexClass *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<const DexClass *, std::allocator<const DexClass *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK12init_classes26InitClassesWithSideEffects6refineEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2697), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZNK12init_classes26InitClassesWithSideEffects22create_init_class_insnEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2697) %0, ptr noundef %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %"class.init_classes::InitClassesWithSideEffects", ptr %8, i32 0, i32 3
  %10 = load i8, ptr %9, align 8, !tbaa !9, !range !21, !noundef !22
  %11 = trunc i8 %10 to i1
  br i1 %11, label %13, label %12

12:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  br label %28

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noundef ptr @_ZNK12init_classes26InitClassesWithSideEffects6refineEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2697) %8, ptr noundef %14)
  store ptr %15, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  store ptr null, ptr %3, align 8
  br label %28

19:                                               ; preds = %13
  %20 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32) #4
  invoke void @_ZN13IRInstructionC1E8IROpcode(ptr noundef nonnull align 8 dereferenceable(32) %20, i16 noundef zeroext 166)
          to label %21 unwind label %24

21:                                               ; preds = %19
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call noundef ptr @_ZN13IRInstruction8set_typeEP7DexType(ptr noundef nonnull align 8 dereferenceable(32) %20, ptr noundef %22)
  store ptr %23, ptr %3, align 8
  br label %28

24:                                               ; preds = %19
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %6, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %20, i64 noundef 32) #5
  br label %30

28:                                               ; preds = %21, %18, %12
  %29 = load ptr, ptr %3, align 8
  ret ptr %29

30:                                               ; preds = %24
  %31 = load ptr, ptr %6, align 8
  %32 = load i32, ptr %7, align 4
  %33 = insertvalue { ptr, i32 } poison, ptr %31, 0
  %34 = insertvalue { ptr, i32 } %33, i32 %32, 1
  resume { ptr, i32 } %34
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

declare void @_ZN13IRInstructionC1E8IROpcode(ptr noundef nonnull align 8 dereferenceable(32), i16 noundef zeroext) unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN13IRInstruction8set_typeEP7DexType(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin nounwind "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 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !20, i64 2696}
!10 = !{!"_ZTSN12init_classes26InitClassesWithSideEffectsE", !11, i64 0, !13, i64 2664, !16, i64 2672, !20, i64 2696}
!11 = !{!"_ZTS23InsertOnlyConcurrentMapIPK7DexTypeSt6vectorIPK8DexClassSaIS6_EESt4hashIS2_ESt8equal_toIS2_ELm83EE", !12, i64 0}
!12 = !{!"_ZTS19ConcurrentContainerISt13unordered_mapIPK7DexTypeSt6vectorIPK8DexClassSaIS7_EESt4hashIS3_ESt8equal_toIS3_ESaISt4pairIKS3_S9_EEELm83EE", !7, i64 8}
!13 = !{!"_ZTSSt6atomicImE", !14, i64 0}
!14 = !{!"_ZTSSt13__atomic_baseImE", !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSSt6vectorIPK8DexClassSaIS2_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIPK8DexClassSaIS2_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIPK8DexClassSaIS2_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIPK8DexClassSaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"bool", !7, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}


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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZNK12init_classes26InitClassesWithSideEffects22create_init_class_insnEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2697) %0, ptr noundef %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 2696
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !20, !noundef !21
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %6, label %14

6:                                                ; preds = %2
  %7 = tail call noundef ptr @_ZNK12init_classes26InitClassesWithSideEffects6refineEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2697) %0, ptr noundef %1)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %14, label %8

8:                                                ; preds = %6
  %9 = tail call noalias noundef nonnull dereferenceable(32) ptr @_Znwm(i64 noundef 32) #4
  invoke void @_ZN13IRInstructionC1E8IROpcode(ptr noundef nonnull align 8 dereferenceable(32) %9, i16 noundef zeroext 166)
          to label %10 unwind label %12

10:                                               ; preds = %8
  %11 = tail call noundef ptr @_ZN13IRInstruction8set_typeEP7DexType(ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull %7)
  br label %14

12:                                               ; preds = %8
  %13 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %9, i64 noundef 32) #5
  resume { ptr, i32 } %13

14:                                               ; preds = %6, %2, %10
  %.0 = phi ptr [ %11, %10 ], [ null, %2 ], [ null, %6 ]
  ret ptr %.0
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

declare void @_ZN13IRInstructionC1E8IROpcode(ptr noundef nonnull align 8 dereferenceable(32), i16 noundef zeroext) unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN13IRInstruction8set_typeEP7DexType(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) 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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin nounwind "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 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !19, i64 2696}
!6 = !{!"_ZTSN12init_classes26InitClassesWithSideEffectsE", !7, i64 0, !11, i64 2664, !14, i64 2672, !19, i64 2696}
!7 = !{!"_ZTS23InsertOnlyConcurrentMapIPK7DexTypeSt6vectorIPK8DexClassSaIS6_EESt4hashIS2_ESt8equal_toIS2_ELm83EE", !8, i64 0}
!8 = !{!"_ZTS19ConcurrentContainerISt13unordered_mapIPK7DexTypeSt6vectorIPK8DexClassSaIS7_EESt4hashIS3_ESt8equal_toIS3_ESaISt4pairIKS3_S9_EEELm83EE", !9, i64 8}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSSt6atomicImE", !12, i64 0}
!12 = !{!"_ZTSSt13__atomic_baseImE", !13, i64 0}
!13 = !{!"long", !9, i64 0}
!14 = !{!"_ZTSSt6vectorIPK8DexClassSaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIPK8DexClassSaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPK8DexClassSaIS2_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIPK8DexClassSaIS2_EE17_Vector_impl_dataE", !18, i64 0, !18, i64 8, !18, i64 16}
!18 = !{!"any pointer", !9, i64 0}
!19 = !{!"bool", !9, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}


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