; LLVM IR from facebook/redex :: libredex/MatchFlowDetail.ll (ZNK2mf6detail10Constraint3srcEt)

; 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.mf::detail::Constraint::Src" = type { i64, i16, i16 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"struct.mf::detail::Constraint" = type { %"class.std::unique_ptr", %"class.std::vector", %"class.std::map" }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<mf::detail::Constraint::Src, std::allocator<mf::detail::Constraint::Src>>::_Vector_impl" }
%"struct.std::_Vector_base<mf::detail::Constraint::Src, std::allocator<mf::detail::Constraint::Src>>::_Vector_impl" = type { %"struct.std::_Vector_base<mf::detail::Constraint::Src, std::allocator<mf::detail::Constraint::Src>>::_Vector_impl_data" }
%"struct.std::_Vector_base<mf::detail::Constraint::Src, std::allocator<mf::detail::Constraint::Src>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned short, std::pair<const unsigned short, mf::detail::Constraint::Src>, std::_Select1st<std::pair<const unsigned short, mf::detail::Constraint::Src>>, std::less<unsigned short>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned short, std::pair<const unsigned short, mf::detail::Constraint::Src>, std::_Select1st<std::pair<const unsigned short, mf::detail::Constraint::Src>>, std::less<unsigned short>>::_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 }
%"struct.std::pair" = type { i16, %"struct.mf::detail::Constraint::Src" }

@_ZN2mf6detail10Constraint17UNCONSTRAINED_SRCE = external dso_local constant %"struct.mf::detail::Constraint::Src", 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
define dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK2mf6detail10Constraint3srcEt(ptr noundef nonnull align 8 dereferenceable(80) %0, i16 noundef zeroext %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %9 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %10 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %11 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  %12 = load ptr, ptr %4, align 8
  %13 = load i16, ptr %5, align 2, !tbaa !9
  %14 = zext i16 %13 to i64
  %15 = getelementptr inbounds %"struct.mf::detail::Constraint", ptr %12, i32 0, i32 1
  %16 = call noundef i64 @_ZNKSt6vectorIN2mf6detail10Constraint3SrcESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #5
  %17 = icmp ult i64 %14, %16
  br i1 %17, label %18, label %33

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %19 = getelementptr inbounds %"struct.mf::detail::Constraint", ptr %12, i32 0, i32 1
  %20 = load i16, ptr %5, align 2, !tbaa !9
  %21 = zext i16 %20 to i64
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorIN2mf6detail10Constraint3SrcESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %21) #5
  store ptr %22, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.mf::detail::Constraint::Src", ptr %23, i32 0, i32 0
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = icmp ne i64 %25, -1
  br i1 %26, label %27, label %29

27:                                               ; preds = %18
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %28, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %30

29:                                               ; preds = %18
  store i32 0, ptr %7, align 4
  br label %30

30:                                               ; preds = %29, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %31 = load i32, ptr %7, align 4
  switch i32 %31, label %52 [
    i32 0, label %32
    i32 1, label %50
  ]

32:                                               ; preds = %30
  br label %33

33:                                               ; preds = %32, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %34 = getelementptr inbounds %"struct.mf::detail::Constraint", ptr %12, i32 0, i32 2
  %35 = call ptr @_ZNKSt3mapItN2mf6detail10Constraint3SrcESt4lessItESaISt4pairIKtS3_EEE11upper_boundERS7_(ptr noundef nonnull align 8 dereferenceable(48) %34, ptr noundef nonnull align 2 dereferenceable(2) %5)
  %36 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %8, i32 0, i32 0
  store ptr %35, ptr %36, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %37 = getelementptr inbounds %"struct.mf::detail::Constraint", ptr %12, i32 0, i32 2
  %38 = call ptr @_ZNKSt3mapItN2mf6detail10Constraint3SrcESt4lessItESaISt4pairIKtS3_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %37) #5
  %39 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %9, i32 0, i32 0
  store ptr %38, ptr %39, align 8
  %40 = call noundef zeroext i1 @_ZSteqRKSt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEES9_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br i1 %40, label %41, label %42

41:                                               ; preds = %33
  store ptr @_ZN2mf6detail10Constraint17UNCONSTRAINED_SRCE, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %49

42:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %8, i64 8, i1 false), !tbaa.struct !16
  %43 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %11, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8
  %45 = call ptr @_ZSt4prevISt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEEET_S9_NSt15iterator_traitsIS9_E15difference_typeE(ptr %44, i64 noundef 1)
  %46 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %10, i32 0, i32 0
  store ptr %45, ptr %46, align 8
  %47 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  %48 = getelementptr inbounds %"struct.std::pair", ptr %47, i32 0, i32 1
  store ptr %48, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  store i32 1, ptr %7, align 4
  br label %49

49:                                               ; preds = %42, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %50

50:                                               ; preds = %49, %30
  %51 = load ptr, ptr %3, align 8
  ret ptr %51

52:                                               ; preds = %30
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorIN2mf6detail10Constraint3SrcESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN2mf6detail10Constraint3SrcE", !13, i64 0, !14, i64 8, !15, i64 10}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSN2mf6detail9AliasFlagE", !7, i64 0}
!15 = !{!"_ZTSN2mf6detail9QuantFlagE", !7, i64 0}
!16 = !{i64 0, i64 8, !5}


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

%"struct.mf::detail::Constraint::Src" = type { i64, i16, i16 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@_ZN2mf6detail10Constraint17UNCONSTRAINED_SRCE = external dso_local constant %"struct.mf::detail::Constraint::Src", 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
define dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK2mf6detail10Constraint3srcEt(ptr noundef nonnull align 8 dereferenceable(80) %0, i16 noundef zeroext %1) local_unnamed_addr #1 align 2 {
  %3 = alloca i16, align 2
  %4 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store i16 %1, ptr %3, align 2, !tbaa !5
  %7 = zext i16 %1 to i64
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = tail call noundef i64 @_ZNKSt6vectorIN2mf6detail10Constraint3SrcESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #4
  %10 = icmp ugt i64 %9, %7
  br i1 %10, label %11, label %14

11:                                               ; preds = %2
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorIN2mf6detail10Constraint3SrcESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %7) #4
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %.not.not = icmp eq i64 %13, -1
  br i1 %.not.not, label %14, label %24

14:                                               ; preds = %11, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = call ptr @_ZNKSt3mapItN2mf6detail10Constraint3SrcESt4lessItESaISt4pairIKtS3_EEE11upper_boundERS7_(ptr noundef nonnull align 8 dereferenceable(48) %15, ptr noundef nonnull align 2 dereferenceable(2) %3)
  store ptr %16, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %17 = call ptr @_ZNKSt3mapItN2mf6detail10Constraint3SrcESt4lessItESaISt4pairIKtS3_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %15) #4
  store ptr %17, ptr %5, align 8
  %18 = call noundef zeroext i1 @_ZSteqRKSt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEES9_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br i1 %18, label %23, label %19

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %.sroa.0.0.copyload = load ptr, ptr %4, align 8, !tbaa !14
  %20 = call ptr @_ZSt4prevISt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEEET_S9_NSt15iterator_traitsIS9_E15difference_typeE(ptr %.sroa.0.0.copyload, i64 noundef 1)
  store ptr %20, ptr %6, align 8
  %21 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br label %23

23:                                               ; preds = %14, %19
  %.1 = phi ptr [ %22, %19 ], [ @_ZN2mf6detail10Constraint17UNCONSTRAINED_SRCE, %14 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %24

24:                                               ; preds = %11, %23
  %.2 = phi ptr [ %12, %11 ], [ %.1, %23 ]
  ret ptr %.2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN2mf6detail10Constraint3SrcESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorIN2mf6detail10Constraint3SrcESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4prevISt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEEET_S9_NSt15iterator_traitsIS9_E15difference_typeE(ptr, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIKtN2mf6detail10Constraint3SrcEEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 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 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN2mf6detail10Constraint3SrcE", !11, i64 0, !12, i64 8, !13, i64 10}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTSN2mf6detail9AliasFlagE", !7, i64 0}
!13 = !{!"_ZTSN2mf6detail9QuantFlagE", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}


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