; LLVM IR from thepowersgang/mrustc :: src/mir/visit_crate_mir.ll (ZN3MIR12OuterVisitor11visit_traitEN3HIR8ItemPathERNS1_5TraitE)

; 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.NullOnDrop = type { ptr }
%"class.HIR::ItemPath" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.MIR::OuterVisitor" = type { %"class.HIR::Visitor", %class.StaticTraitResolve, %"class.std::function.78" }
%"class.HIR::Visitor" = type { ptr, ptr }
%class.StaticTraitResolve = type { ptr, %struct.TraitResolveCommon, i32, %"class.std::map.67", %"class.std::map.67", %"class.std::map.67", %"class.std::map.72" }
%struct.TraitResolveCommon = type { ptr, ptr, ptr, %"class.std::map.56", %class.RangeVecMap, %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath", %"struct.HIR::SimplePath" }
%"class.std::map.56" = type { %"class.std::_Rb_tree.57" }
%"class.std::_Rb_tree.57" = type { %"struct.std::_Rb_tree<HIR::TypeRef, std::pair<const HIR::TypeRef, TraitResolveCommon::CachedEquality>, std::_Select1st<std::pair<const HIR::TypeRef, TraitResolveCommon::CachedEquality>>, std::less<HIR::TypeRef>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<HIR::TypeRef, std::pair<const HIR::TypeRef, TraitResolveCommon::CachedEquality>, std::_Select1st<std::pair<const HIR::TypeRef, TraitResolveCommon::CachedEquality>>, std::less<HIR::TypeRef>>::_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.RangeVecMap = type <{ %"class.std::vector.62", [8 x i8] }>
%"class.std::vector.62" = type { %"struct.std::_Vector_base.63" }
%"struct.std::_Vector_base.63" = type { %"struct.std::_Vector_base<std::unique_ptr<std::pair<std::pair<HIR::TypeRef, HIR::GenericPath>, TraitResolveCommon::CachedBound>>, std::allocator<std::unique_ptr<std::pair<std::pair<HIR::TypeRef, HIR::GenericPath>, TraitResolveCommon::CachedBound>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::unique_ptr<std::pair<std::pair<HIR::TypeRef, HIR::GenericPath>, TraitResolveCommon::CachedBound>>, std::allocator<std::unique_ptr<std::pair<std::pair<HIR::TypeRef, HIR::GenericPath>, TraitResolveCommon::CachedBound>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::unique_ptr<std::pair<std::pair<HIR::TypeRef, HIR::GenericPath>, TraitResolveCommon::CachedBound>>, std::allocator<std::unique_ptr<std::pair<std::pair<HIR::TypeRef, HIR::GenericPath>, TraitResolveCommon::CachedBound>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::unique_ptr<std::pair<std::pair<HIR::TypeRef, HIR::GenericPath>, TraitResolveCommon::CachedBound>>, std::allocator<std::unique_ptr<std::pair<std::pair<HIR::TypeRef, HIR::GenericPath>, TraitResolveCommon::CachedBound>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.HIR::SimplePath" = type { %class.ThinVector }
%class.ThinVector = type { ptr }
%"class.std::map.67" = type { %"class.std::_Rb_tree.68" }
%"class.std::_Rb_tree.68" = type { %"struct.std::_Rb_tree<HIR::TypeRef, std::pair<const HIR::TypeRef, bool>, std::_Select1st<std::pair<const HIR::TypeRef, bool>>, std::less<HIR::TypeRef>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<HIR::TypeRef, std::pair<const HIR::TypeRef, bool>, std::_Select1st<std::pair<const HIR::TypeRef, bool>>, std::less<HIR::TypeRef>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"class.std::map.72" = type { %"class.std::_Rb_tree.73" }
%"class.std::_Rb_tree.73" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, HIR::TypeRef>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, HIR::TypeRef>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, HIR::TypeRef>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, HIR::TypeRef>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"class.std::function.78" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.HIR::Trait" = type { %"class.HIR::GenericParams", %"struct.HIR::LifetimeRef", %"class.std::vector.13", i8, %"class.std::unordered_map", %"class.std::unordered_map.134", %"class.std::unordered_multimap", %"class.std::unordered_map.161", i32, %"class.std::vector.13", %"struct.HIR::SimplePath" }
%"class.HIR::GenericParams" = type { %"class.std::vector.36", %"class.std::vector.41", %"class.std::vector.46", %"class.std::vector.51" }
%"class.std::vector.36" = type { %"struct.std::_Vector_base.37" }
%"struct.std::_Vector_base.37" = type { %"struct.std::_Vector_base<HIR::TypeParamDef, std::allocator<HIR::TypeParamDef>>::_Vector_impl" }
%"struct.std::_Vector_base<HIR::TypeParamDef, std::allocator<HIR::TypeParamDef>>::_Vector_impl" = type { %"struct.std::_Vector_base<HIR::TypeParamDef, std::allocator<HIR::TypeParamDef>>::_Vector_impl_data" }
%"struct.std::_Vector_base<HIR::TypeParamDef, std::allocator<HIR::TypeParamDef>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.41" = type { %"struct.std::_Vector_base.42" }
%"struct.std::_Vector_base.42" = type { %"struct.std::_Vector_base<HIR::LifetimeDef, std::allocator<HIR::LifetimeDef>>::_Vector_impl" }
%"struct.std::_Vector_base<HIR::LifetimeDef, std::allocator<HIR::LifetimeDef>>::_Vector_impl" = type { %"struct.std::_Vector_base<HIR::LifetimeDef, std::allocator<HIR::LifetimeDef>>::_Vector_impl_data" }
%"struct.std::_Vector_base<HIR::LifetimeDef, std::allocator<HIR::LifetimeDef>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.46" = type { %"struct.std::_Vector_base.47" }
%"struct.std::_Vector_base.47" = type { %"struct.std::_Vector_base<HIR::ValueParamDef, std::allocator<HIR::ValueParamDef>>::_Vector_impl" }
%"struct.std::_Vector_base<HIR::ValueParamDef, std::allocator<HIR::ValueParamDef>>::_Vector_impl" = type { %"struct.std::_Vector_base<HIR::ValueParamDef, std::allocator<HIR::ValueParamDef>>::_Vector_impl_data" }
%"struct.std::_Vector_base<HIR::ValueParamDef, std::allocator<HIR::ValueParamDef>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.51" = type { %"struct.std::_Vector_base.52" }
%"struct.std::_Vector_base.52" = type { %"struct.std::_Vector_base<HIR::GenericBound, std::allocator<HIR::GenericBound>>::_Vector_impl" }
%"struct.std::_Vector_base<HIR::GenericBound, std::allocator<HIR::GenericBound>>::_Vector_impl" = type { %"struct.std::_Vector_base<HIR::GenericBound, std::allocator<HIR::GenericBound>>::_Vector_impl_data" }
%"struct.std::_Vector_base<HIR::GenericBound, std::allocator<HIR::GenericBound>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.HIR::LifetimeRef" = type { i32 }
%"class.std::unordered_map" = 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.std::unordered_map.134" = type { %"class.std::_Hashtable.135" }
%"class.std::_Hashtable.135" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"class.std::unordered_multimap" = type { %"class.std::_Hashtable.148" }
%"class.std::_Hashtable.148" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"class.std::unordered_map.161" = type { %"class.std::_Hashtable.162" }
%"class.std::_Hashtable.162" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"class.std::vector.13" = type { %"struct.std::_Vector_base.14" }
%"struct.std::_Vector_base.14" = type { %"struct.std::_Vector_base<HIR::TraitPath, std::allocator<HIR::TraitPath>>::_Vector_impl" }
%"struct.std::_Vector_base<HIR::TraitPath, std::allocator<HIR::TraitPath>>::_Vector_impl" = type { %"struct.std::_Vector_base<HIR::TraitPath, std::allocator<HIR::TraitPath>>::_Vector_impl_data" }
%"struct.std::_Vector_base<HIR::TraitPath, std::allocator<HIR::TraitPath>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN18StaticTraitResolve17set_impl_genericsE12MetadataTypeRKN3HIR13GenericParamsE(ptr dead_on_unwind noalias writable sret(%class.NullOnDrop) align 8, ptr noundef nonnull align 8 dereferenceable(424), i32 noundef, ptr noundef nonnull align 8 dereferenceable(96)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3MIR12OuterVisitor11visit_traitEN3HIR8ItemPathERNS1_5TraitE(ptr noundef nonnull align 8 dereferenceable(472) %0, ptr noundef byval(%"class.HIR::ItemPath") align 8 %1, ptr noundef nonnull align 8 dereferenceable(400) %2) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %class.NullOnDrop, align 8
  %7 = alloca %"class.HIR::ItemPath", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %11 = getelementptr inbounds %"class.MIR::OuterVisitor", ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.HIR::Trait", ptr %12, i32 0, i32 0
  call void @_ZN18StaticTraitResolve17set_impl_genericsE12MetadataTypeRKN3HIR13GenericParamsE(ptr dead_on_unwind writable sret(%class.NullOnDrop) align 8 %6, ptr noundef nonnull align 8 dereferenceable(424) %11, i32 noundef 4, ptr noundef nonnull align 8 dereferenceable(96) %13)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %1, i64 56, i1 false), !tbaa.struct !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN3HIR7Visitor11visit_traitENS_8ItemPathERNS_5TraitE(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef byval(%"class.HIR::ItemPath") align 8 %7, ptr noundef nonnull align 8 dereferenceable(400) %14)
          to label %15 unwind label %16

15:                                               ; preds = %3
  call void @_ZN10NullOnDropIKN3HIR13GenericParamsEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  ret void

16:                                               ; preds = %3
  %17 = landingpad { ptr, i32 }
          cleanup
  %18 = extractvalue { ptr, i32 } %17, 0
  store ptr %18, ptr %8, align 8
  %19 = extractvalue { ptr, i32 } %17, 1
  store i32 %19, ptr %9, align 4
  call void @_ZN10NullOnDropIKN3HIR13GenericParamsEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %8, align 8
  %22 = load i32, ptr %9, align 4
  %23 = insertvalue { ptr, i32 } poison, ptr %21, 0
  %24 = insertvalue { ptr, i32 } %23, i32 %22, 1
  resume { ptr, i32 } %24
}

declare void @_ZN3HIR7Visitor11visit_traitENS_8ItemPathERNS_5TraitE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef byval(%"class.HIR::ItemPath") align 8, ptr noundef nonnull align 8 dereferenceable(400)) unnamed_addr #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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { "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 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, 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"

%class.NullOnDrop = type { ptr }
%"class.HIR::ItemPath" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; 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 nounwind uwtable
declare dso_local void @_ZN10NullOnDropIKN3HIR13GenericParamsEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN18StaticTraitResolve17set_impl_genericsE12MetadataTypeRKN3HIR13GenericParamsE(ptr dead_on_unwind noalias writable sret(%class.NullOnDrop) align 8, ptr noundef nonnull align 8 dereferenceable(424), i32 noundef, ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3MIR12OuterVisitor11visit_traitEN3HIR8ItemPathERNS1_5TraitE(ptr noundef nonnull align 8 dereferenceable(472) %0, ptr nocapture noundef readonly byval(%"class.HIR::ItemPath") align 8 %1, ptr noundef nonnull align 8 dereferenceable(400) %2) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.NullOnDrop, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  call void @_ZN18StaticTraitResolve17set_impl_genericsE12MetadataTypeRKN3HIR13GenericParamsE(ptr dead_on_unwind nonnull writable sret(%class.NullOnDrop) align 8 %4, ptr noundef nonnull align 8 dereferenceable(424) %5, i32 noundef 4, ptr noundef nonnull align 8 dereferenceable(96) %2)
  invoke void @_ZN3HIR7Visitor11visit_traitENS_8ItemPathERNS_5TraitE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull byval(%"class.HIR::ItemPath") align 8 %1, ptr noundef nonnull align 8 dereferenceable(400) %2)
          to label %6 unwind label %7

6:                                                ; preds = %3
  call void @_ZN10NullOnDropIKN3HIR13GenericParamsEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret void

7:                                                ; preds = %3
  %8 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN10NullOnDropIKN3HIR13GenericParamsEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  resume { ptr, i32 } %8
}

declare void @_ZN3HIR7Visitor11visit_traitENS_8ItemPathERNS_5TraitE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef byval(%"class.HIR::ItemPath") align 8, ptr noundef nonnull align 8 dereferenceable(400)) unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { "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: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass