; LLVM IR from facebook/redex :: service/cse (CommonSubexpressionElimination)

; 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.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 }
%"struct.cse_impl::Barrier" = type { i16, %union.anon.251 }
%union.anon.251 = type { ptr }
%"class.std::initializer_list" = type { ptr, i64 }
%union.CseLocation = type { ptr }

@_ZN12_GLOBAL__N_112no_locationsE = external hidden global %class.UnorderedSet, align 8

; 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 void @_ZN12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS0_EEC2ESt16initializer_listIS0_E(ptr noundef nonnull align 8 dereferenceable(56), ptr, i64) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8cse_impl11SharedState30get_relevant_written_locationsEPK13IRInstructionP7DexTypeRK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS7_EE(ptr dead_on_unwind noalias writable sret(%class.UnorderedSet) align 8 %0, ptr noundef nonnull align 8 dereferenceable(520) %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull align 8 dereferenceable(56) %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %"struct.cse_impl::Barrier", align 8
  %12 = alloca %"class.std::initializer_list", align 8
  %13 = alloca [1 x %union.CseLocation], align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = call noundef zeroext i1 @_ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520) %15, ptr noundef %16, ptr noundef %17)
  br i1 %18, label %19, label %49

19:                                               ; preds = %5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %20)
  %22 = call noundef zeroext i1 @_ZN6opcode12is_an_invokeE8IROpcode(i16 noundef zeroext %21)
  br i1 %22, label %23, label %26

23:                                               ; preds = %19
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN8cse_impl11SharedState30get_relevant_written_locationsEPK13IRInstructionRK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS5_EE(ptr dead_on_unwind writable sret(%class.UnorderedSet) align 8 %0, ptr noundef nonnull align 8 dereferenceable(520) %15, ptr noundef %24, ptr noundef nonnull align 8 dereferenceable(56) %25)
  br label %50

26:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call { i16, ptr } @_ZN12_GLOBAL__N_112make_barrierEPK13IRInstruction(ptr noundef %27)
  %29 = getelementptr inbounds { i16, ptr }, ptr %11, i32 0, i32 0
  %30 = extractvalue { i16, ptr } %28, 0
  store i16 %30, ptr %29, align 8
  %31 = getelementptr inbounds { i16, ptr }, ptr %11, i32 0, i32 1
  %32 = extractvalue { i16, ptr } %28, 1
  store ptr %32, ptr %31, align 8
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = call noundef zeroext i1 @_ZN12_GLOBAL__N_119is_barrier_relevantERKN8cse_impl7BarrierERK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS5_EE(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(56) %33)
  br i1 %34, label %35, label %44

35:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %36 = call ptr @_ZN12_GLOBAL__N_120get_written_locationERKN8cse_impl7BarrierE(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %37 = getelementptr inbounds %union.CseLocation, ptr %13, i32 0, i32 0
  store ptr %36, ptr %37, align 8
  %38 = getelementptr inbounds %"class.std::initializer_list", ptr %12, i32 0, i32 0
  store ptr %13, ptr %38, align 8, !tbaa !9
  %39 = getelementptr inbounds %"class.std::initializer_list", ptr %12, i32 0, i32 1
  store i64 1, ptr %39, align 8, !tbaa !12
  %40 = getelementptr inbounds { ptr, i64 }, ptr %12, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8
  %42 = getelementptr inbounds { ptr, i64 }, ptr %12, i32 0, i32 1
  %43 = load i64, ptr %42, align 8
  call void @_ZN12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS0_EEC2ESt16initializer_listIS0_E(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr %41, i64 %43)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  store i32 1, ptr %14, align 4
  br label %45

44:                                               ; preds = %26
  store i32 0, ptr %14, align 4
  br label %45

45:                                               ; preds = %44, %35
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  %46 = load i32, ptr %14, align 4
  switch i32 %46, label %51 [
    i32 0, label %47
    i32 1, label %50
  ]

47:                                               ; preds = %45
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48, %5
  call void @_ZN12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS0_EEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 8 dereferenceable(56) @_ZN12_GLOBAL__N_112no_locationsE)
  br label %50

50:                                               ; preds = %49, %45, %23
  ret void

51:                                               ; preds = %45
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520), ptr noundef, ptr noundef) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode12is_an_invokeE8IROpcode(i16 noundef zeroext) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8cse_impl11SharedState30get_relevant_written_locationsEPK13IRInstructionRK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS5_EE(ptr dead_on_unwind noalias writable sret(%class.UnorderedSet) align 8, ptr noundef nonnull align 8 dereferenceable(520), ptr noundef, ptr noundef nonnull align 8 dereferenceable(56)) #1 align 2

; Function Attrs: mustprogress uwtable
declare hidden { i16, ptr } @_ZN12_GLOBAL__N_112make_barrierEPK13IRInstruction(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN12_GLOBAL__N_119is_barrier_relevantERKN8cse_impl7BarrierERK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS5_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(56)) #1

; Function Attrs: mustprogress uwtable
declare hidden ptr @_ZN12_GLOBAL__N_120get_written_locationERKN8cse_impl7BarrierE(ptr noundef nonnull align 8 dereferenceable(16)) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS0_EEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #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 = { 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 #3 = { 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 0}
!10 = !{!"_ZTSSt16initializer_listI11CseLocationE", !6, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, 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"

%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 }
%"struct.cse_impl::Barrier" = type { i16, %union.anon.251 }
%union.anon.251 = type { ptr }
%union.CseLocation = type { ptr }

@_ZN12_GLOBAL__N_112no_locationsE = external hidden global %class.UnorderedSet, align 8

; 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
declare dso_local void @_ZN12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS0_EEC2ESt16initializer_listIS0_E(ptr noundef nonnull align 8 dereferenceable(56), ptr, i64) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8cse_impl11SharedState30get_relevant_written_locationsEPK13IRInstructionP7DexTypeRK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS7_EE(ptr dead_on_unwind noalias writable sret(%class.UnorderedSet) align 8 %0, ptr noundef nonnull align 8 dereferenceable(520) %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull align 8 dereferenceable(56) %4) local_unnamed_addr #1 align 2 {
  %6 = alloca %"struct.cse_impl::Barrier", align 8
  %7 = alloca [1 x %union.CseLocation], align 8
  %8 = tail call noundef zeroext i1 @_ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520) %1, ptr noundef %2, ptr noundef %3)
  br i1 %8, label %9, label %21

9:                                                ; preds = %5
  %10 = tail call noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %11 = tail call noundef zeroext i1 @_ZN6opcode12is_an_invokeE8IROpcode(i16 noundef zeroext %10)
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  tail call void @_ZN8cse_impl11SharedState30get_relevant_written_locationsEPK13IRInstructionRK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS5_EE(ptr dead_on_unwind writable sret(%class.UnorderedSet) align 8 %0, ptr noundef nonnull align 8 dereferenceable(520) %1, ptr noundef nonnull %2, ptr noundef nonnull align 8 dereferenceable(56) %4)
  br label %22

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  %14 = tail call { i16, ptr } @_ZN12_GLOBAL__N_112make_barrierEPK13IRInstruction(ptr noundef nonnull %2)
  %15 = extractvalue { i16, ptr } %14, 0
  store i16 %15, ptr %6, align 8
  %16 = getelementptr inbounds i8, ptr %6, i64 8
  %17 = extractvalue { i16, ptr } %14, 1
  store ptr %17, ptr %16, align 8
  %18 = call noundef zeroext i1 @_ZN12_GLOBAL__N_119is_barrier_relevantERKN8cse_impl7BarrierERK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS5_EE(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(56) %4)
  br i1 %18, label %19, label %.thread

.thread:                                          ; preds = %13
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  br label %21

19:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %20 = call ptr @_ZN12_GLOBAL__N_120get_written_locationERKN8cse_impl7BarrierE(ptr noundef nonnull align 8 dereferenceable(16) %6)
  store ptr %20, ptr %7, align 8
  call void @_ZN12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS0_EEC2ESt16initializer_listIS0_E(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr nonnull %7, i64 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  br label %22

21:                                               ; preds = %.thread, %5
  call void @_ZN12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS0_EEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 8 dereferenceable(56) @_ZN12_GLOBAL__N_112no_locationsE)
  br label %22

22:                                               ; preds = %19, %21, %12
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8cse_impl11SharedState14may_be_barrierEPK13IRInstructionP7DexType(ptr noundef nonnull align 8 dereferenceable(520), ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode12is_an_invokeE8IROpcode(i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZNK13IRInstruction6opcodeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8cse_impl11SharedState30get_relevant_written_locationsEPK13IRInstructionRK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS5_EE(ptr dead_on_unwind noalias writable sret(%class.UnorderedSet) align 8, ptr noundef nonnull align 8 dereferenceable(520), ptr noundef, ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare hidden { i16, ptr } @_ZN12_GLOBAL__N_112make_barrierEPK13IRInstruction(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN12_GLOBAL__N_119is_barrier_relevantERKN8cse_impl7BarrierERK12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS5_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden ptr @_ZN12_GLOBAL__N_120get_written_locationERKN8cse_impl7BarrierE(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12UnorderedSetI11CseLocation17CseLocationHasherSt8equal_toIS0_EEC2ERKS4_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(56)) unnamed_addr #1 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 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 = { 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)"}


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