; LLVM IR from geefr/vulkan-physics :: vulkanutils/util (deviceinstance)

; 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.vk::MemoryRequirements" = type <{ i64, i64, i32, [4 x i8] }>
%"class.vk::Flags.53" = type { i32 }
%"struct.vk::PhysicalDeviceMemoryProperties" = type { i32, %"class.vk::ArrayWrapper1D", i32, %"class.vk::ArrayWrapper1D.54" }
%"class.vk::ArrayWrapper1D" = type { %"struct.std::array" }
%"struct.std::array" = type { [32 x %"struct.vk::MemoryType"] }
%"struct.vk::MemoryType" = type { %"class.vk::Flags.53", i32 }
%"class.vk::ArrayWrapper1D.54" = type { %"struct.std::array.55" }
%"struct.std::array.55" = type { [16 x %"struct.vk::MemoryHeap"] }
%"struct.vk::MemoryHeap" = type <{ i64, %"class.vk::Flags.56", [4 x i8] }>
%"class.vk::Flags.56" = type { i32 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%class.DeviceInstance = type { %"class.std::vector.0", %"class.vk::UniqueHandle", %"class.vk::UniqueHandle.5", %"class.std::vector.6" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<vk::PhysicalDevice, std::allocator<vk::PhysicalDevice>>::_Vector_impl" }
%"struct.std::_Vector_base<vk::PhysicalDevice, std::allocator<vk::PhysicalDevice>>::_Vector_impl" = type { %"struct.std::_Vector_base<vk::PhysicalDevice, std::allocator<vk::PhysicalDevice>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vk::PhysicalDevice, std::allocator<vk::PhysicalDevice>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.vk::UniqueHandle" = type { %"class.vk::ObjectDestroy", %"class.vk::Instance" }
%"class.vk::ObjectDestroy" = type { %"class.vk::Optional", ptr }
%"class.vk::Optional" = type { ptr }
%"class.vk::Instance" = type { ptr }
%"class.vk::UniqueHandle.5" = type { %"class.vk::ObjectDestroy", %"class.vk::Device" }
%"class.vk::Device" = type { ptr }
%"class.std::vector.6" = type { %"struct.std::_Vector_base.7" }
%"struct.std::_Vector_base.7" = type { %"struct.std::_Vector_base<DeviceInstance::QueueRef, std::allocator<DeviceInstance::QueueRef>>::_Vector_impl" }
%"struct.std::_Vector_base<DeviceInstance::QueueRef, std::allocator<DeviceInstance::QueueRef>>::_Vector_impl" = type { %"struct.std::_Vector_base<DeviceInstance::QueueRef, std::allocator<DeviceInstance::QueueRef>>::_Vector_impl_data" }
%"struct.std::_Vector_base<DeviceInstance::QueueRef, std::allocator<DeviceInstance::QueueRef>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTISt13runtime_error = external constant ptr
@.str.2 = external hidden unnamed_addr constant [46 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #0 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(9) ptr @_ZN2vkL23getDispatchLoaderStaticEv() #2

; 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) #3

declare ptr @__cxa_allocate_exception(i64)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

declare void @__cxa_throw(ptr, ptr, ptr)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN14DeviceInstance22selectDeviceMemoryHeapEN2vk18MemoryRequirementsENS0_5FlagsINS0_22MemoryPropertyFlagBitsEEE(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef byval(%"struct.vk::MemoryRequirements") align 8 %1, i32 %2) #5 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca %"class.vk::Flags.53", align 4
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.vk::PhysicalDeviceMemoryProperties", align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"struct.vk::MemoryType", align 4
  %12 = alloca %"class.vk::Flags.53", align 4
  %13 = alloca %"class.std::__cxx11::basic_string", align 8
  %14 = alloca %"class.std::__cxx11::basic_string", align 8
  %15 = alloca %"class.vk::Flags.53", align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i1, align 1
  %19 = getelementptr inbounds %"class.vk::Flags.53", ptr %5, i32 0, i32 0
  store i32 %2, ptr %19, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 520, ptr %7) #10
  %21 = getelementptr inbounds %class.DeviceInstance, ptr %20, i32 0, i32 0
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIN2vk14PhysicalDeviceESaIS1_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %21) #10
  %23 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZN2vkL23getDispatchLoaderStaticEv()
  call void @_ZNK2vk14PhysicalDevice19getMemoryPropertiesINS_20DispatchLoaderStaticEEENS_30PhysicalDeviceMemoryPropertiesERKT_(ptr dead_on_unwind writable sret(%"struct.vk::PhysicalDeviceMemoryProperties") align 8 %7, ptr noundef nonnull align 8 dereferenceable(8) %22, ptr noundef nonnull align 8 dereferenceable(9) %23) #10
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #10
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %55, %3
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = icmp ult i32 %25, 32
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 2, ptr %9, align 4
  br label %58

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #10
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = shl i32 1, %29
  store i32 %30, ptr %10, align 4, !tbaa !9
  %31 = getelementptr inbounds %"struct.vk::MemoryRequirements", ptr %1, i32 0, i32 2
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = and i32 %32, %33
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %51

36:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #10
  %37 = getelementptr inbounds %"struct.vk::PhysicalDeviceMemoryProperties", ptr %7, i32 0, i32 1
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5arrayIN2vk10MemoryTypeELm32EEixEm(ptr noundef nonnull align 4 dereferenceable(256) %37, i64 noundef %39) #10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %40, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #10
  %41 = getelementptr inbounds %"struct.vk::MemoryType", ptr %11, i32 0, i32 0
  %42 = call i32 @_ZNK2vk5FlagsINS_22MemoryPropertyFlagBitsEEanERKS2_(ptr noundef nonnull align 4 dereferenceable(4) %41, ptr noundef nonnull align 4 dereferenceable(4) %5) #10
  %43 = getelementptr inbounds %"class.vk::Flags.53", ptr %12, i32 0, i32 0
  store i32 %42, ptr %43, align 4
  %44 = call noundef zeroext i1 @_ZNK2vk5FlagsINS_22MemoryPropertyFlagBitsEEeqERKS2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %5) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #10
  br i1 %44, label %45, label %47

45:                                               ; preds = %36
  %46 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %46, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %48

47:                                               ; preds = %36
  store i32 0, ptr %9, align 4
  br label %48

48:                                               ; preds = %47, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #10
  %49 = load i32, ptr %9, align 4
  switch i32 %49, label %52 [
    i32 0, label %50
  ]

50:                                               ; preds = %48
  br label %51

51:                                               ; preds = %50, %28
  store i32 0, ptr %9, align 4
  br label %52

52:                                               ; preds = %51, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #10
  %53 = load i32, ptr %9, align 4
  switch i32 %53, label %58 [
    i32 0, label %54
  ]

54:                                               ; preds = %52
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = add i32 %56, 1
  store i32 %57, ptr %8, align 4, !tbaa !9
  br label %24, !llvm.loop !15

58:                                               ; preds = %52, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #10
  %59 = load i32, ptr %9, align 4
  switch i32 %59, label %84 [
    i32 2, label %60
  ]

60:                                               ; preds = %58
  store i1 true, ptr %18, align 1
  %61 = call ptr @__cxa_allocate_exception(i64 16) #10
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #10
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %5, i64 4, i1 false), !tbaa.struct !17
  %62 = getelementptr inbounds %"class.vk::Flags.53", ptr %15, i32 0, i32 0
  %63 = load i32, ptr %62, align 4
  invoke void @_ZN2vk9to_stringB5cxx11ENS_5FlagsINS_22MemoryPropertyFlagBitsEEE(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %14, i32 %63)
          to label %64 unwind label %67

64:                                               ; preds = %60
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_OS8_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %13, ptr noundef @.str.2, ptr noundef nonnull align 8 dereferenceable(32) %14)
          to label %65 unwind label %71

65:                                               ; preds = %64
  invoke void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16) %61, ptr noundef nonnull align 8 dereferenceable(32) %13)
          to label %66 unwind label %75

66:                                               ; preds = %65
  store i1 false, ptr %18, align 1
  invoke void @__cxa_throw(ptr %61, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #11
          to label %91 unwind label %75

67:                                               ; preds = %60
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %16, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %17, align 4
  br label %80

71:                                               ; preds = %64
  %72 = landingpad { ptr, i32 }
          cleanup
  %73 = extractvalue { ptr, i32 } %72, 0
  store ptr %73, ptr %16, align 8
  %74 = extractvalue { ptr, i32 } %72, 1
  store i32 %74, ptr %17, align 4
  br label %79

75:                                               ; preds = %66, %65
  %76 = landingpad { ptr, i32 }
          cleanup
  %77 = extractvalue { ptr, i32 } %76, 0
  store ptr %77, ptr %16, align 8
  %78 = extractvalue { ptr, i32 } %76, 1
  store i32 %78, ptr %17, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #10
  br label %79

79:                                               ; preds = %75, %71
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14) #10
  br label %80

80:                                               ; preds = %79, %67
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #10
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #10
  %81 = load i1, ptr %18, align 1
  br i1 %81, label %82, label %83

82:                                               ; preds = %80
  call void @__cxa_free_exception(ptr %61) #10
  br label %83

83:                                               ; preds = %82, %80
  call void @llvm.lifetime.end.p0(i64 520, ptr %7) #10
  br label %86

84:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 520, ptr %7) #10
  %85 = load i32, ptr %4, align 4
  ret i32 %85

86:                                               ; preds = %83
  %87 = load ptr, ptr %16, align 8
  %88 = load i32, ptr %17, align 4
  %89 = insertvalue { ptr, i32 } poison, ptr %87, 0
  %90 = insertvalue { ptr, i32 } %89, i32 %88, 1
  resume { ptr, i32 } %90

91:                                               ; preds = %66
  unreachable
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNK2vk14PhysicalDevice19getMemoryPropertiesINS_20DispatchLoaderStaticEEENS_30PhysicalDeviceMemoryPropertiesERKT_(ptr dead_on_unwind noalias writable sret(%"struct.vk::PhysicalDeviceMemoryProperties") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(9)) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5arrayIN2vk10MemoryTypeELm32EEixEm(ptr noundef nonnull align 4 dereferenceable(256), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @_ZNK2vk5FlagsINS_22MemoryPropertyFlagBitsEEanERKS2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_OS8_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) #7

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN2vk9to_stringB5cxx11ENS_5FlagsINS_22MemoryPropertyFlagBitsEEE(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i32) #8

declare void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #9

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #6 = { alwaysinline 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 #7 = { 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 #8 = { alwaysinline 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 #9 = { "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 #10 = { nounwind }
attributes #11 = { noreturn }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTSN2vk18MemoryRequirementsE", !13, i64 0, !13, i64 8, !10, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{i64 0, i64 4, !9, i64 4, i64 4, !9}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i64 0, i64 4, !9}


; 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.vk::MemoryRequirements" = type <{ i64, i64, i32, [4 x i8] }>
%"class.vk::Flags.53" = type { i32 }
%"struct.vk::PhysicalDeviceMemoryProperties" = type { i32, %"class.vk::ArrayWrapper1D", i32, %"class.vk::ArrayWrapper1D.54" }
%"class.vk::ArrayWrapper1D" = type { %"struct.std::array" }
%"struct.std::array" = type { [32 x %"struct.vk::MemoryType"] }
%"struct.vk::MemoryType" = type { %"class.vk::Flags.53", i32 }
%"class.vk::ArrayWrapper1D.54" = type { %"struct.std::array.55" }
%"struct.std::array.55" = type { [16 x %"struct.vk::MemoryHeap"] }
%"struct.vk::MemoryHeap" = type <{ i64, %"class.vk::Flags.56", [4 x i8] }>
%"class.vk::Flags.56" = type { i32 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@_ZTISt13runtime_error = external constant ptr
@.str.2 = external hidden unnamed_addr constant [46 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #0 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(9) ptr @_ZN2vkL23getDispatchLoaderStaticEv() local_unnamed_addr #2

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN14DeviceInstance22selectDeviceMemoryHeapEN2vk18MemoryRequirementsENS0_5FlagsINS0_22MemoryPropertyFlagBitsEEE(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr nocapture noundef readonly byval(%"struct.vk::MemoryRequirements") align 8 %1, i32 %2) local_unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.vk::Flags.53", align 4
  %5 = alloca %"struct.vk::PhysicalDeviceMemoryProperties", align 8
  %6 = alloca %"struct.vk::MemoryType", align 8
  %7 = alloca %"class.vk::Flags.53", align 4
  %8 = alloca %"class.std::__cxx11::basic_string", align 8
  %9 = alloca %"class.std::__cxx11::basic_string", align 8
  store i32 %2, ptr %4, align 4
  call void @llvm.lifetime.start.p0(i64 520, ptr nonnull %5) #9
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIN2vk14PhysicalDeviceESaIS1_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #9
  %11 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZN2vkL23getDispatchLoaderStaticEv()
  call void @_ZNK2vk14PhysicalDevice19getMemoryPropertiesINS_20DispatchLoaderStaticEEENS_30PhysicalDeviceMemoryPropertiesERKT_(ptr dead_on_unwind nonnull writable sret(%"struct.vk::PhysicalDeviceMemoryProperties") align 8 %5, ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(9) %11) #9
  %12 = getelementptr inbounds i8, ptr %1, i64 16
  %13 = load i32, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %5, i64 4
  br label %15

15:                                               ; preds = %3, %.thread
  %indvars.iv = phi i64 [ 0, %3 ], [ %indvars.iv.next, %.thread ]
  %16 = trunc nuw nsw i64 %indvars.iv to i32
  %17 = shl nuw i32 1, %16
  %18 = and i32 %13, %17
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %.thread, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #9
  %20 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5arrayIN2vk10MemoryTypeELm32EEixEm(ptr noundef nonnull align 4 dereferenceable(256) %14, i64 noundef %indvars.iv) #9
  %21 = load i64, ptr %20, align 4
  store i64 %21, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #9
  %22 = call i32 @_ZNK2vk5FlagsINS_22MemoryPropertyFlagBitsEEanERKS2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %4) #9
  store i32 %22, ptr %7, align 4
  %23 = call noundef zeroext i1 @_ZNK2vk5FlagsINS_22MemoryPropertyFlagBitsEEeqERKS2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %4) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #9
  br i1 %23, label %35, label %.thread

.thread:                                          ; preds = %15, %19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, 32
  br i1 %exitcond, label %24, label %15, !llvm.loop !11

24:                                               ; preds = %.thread
  %25 = call ptr @__cxa_allocate_exception(i64 16) #9
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #9
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #9
  %.sroa.0.0.copyload = load i32, ptr %4, align 4, !tbaa !13
  invoke void @_ZN2vk9to_stringB5cxx11ENS_5FlagsINS_22MemoryPropertyFlagBitsEEE(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %9, i32 %.sroa.0.0.copyload)
          to label %26 unwind label %.thread33

26:                                               ; preds = %24
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_OS8_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %8, ptr noundef nonnull @.str.2, ptr noundef nonnull align 8 dereferenceable(32) %9)
          to label %27 unwind label %.thread38

27:                                               ; preds = %26
  invoke void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(32) %8)
          to label %28 unwind label %31

28:                                               ; preds = %27
  invoke void @__cxa_throw(ptr nonnull %25, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #10
          to label %36 unwind label %31

.thread33:                                        ; preds = %24
  %29 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #9
  br label %33

.thread38:                                        ; preds = %26
  %30 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #9
  br label %33

31:                                               ; preds = %27, %28
  %.0 = phi i1 [ false, %28 ], [ true, %27 ]
  %32 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #9
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #9
  br i1 %.0, label %33, label %34

33:                                               ; preds = %.thread38, %.thread33, %31
  %.pn.pn37 = phi { ptr, i32 } [ %29, %.thread33 ], [ %32, %31 ], [ %30, %.thread38 ]
  call void @__cxa_free_exception(ptr %25) #9
  br label %34

34:                                               ; preds = %33, %31
  %.pn.pn36 = phi { ptr, i32 } [ %.pn.pn37, %33 ], [ %32, %31 ]
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %5) #9
  resume { ptr, i32 } %.pn.pn36

35:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %5) #9
  ret i32 %16

36:                                               ; preds = %28
  unreachable
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNK2vk14PhysicalDevice19getMemoryPropertiesINS_20DispatchLoaderStaticEEENS_30PhysicalDeviceMemoryPropertiesERKT_(ptr dead_on_unwind noalias writable sret(%"struct.vk::PhysicalDeviceMemoryProperties") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(9)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5arrayIN2vk10MemoryTypeELm32EEixEm(ptr noundef nonnull align 4 dereferenceable(256), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @_ZNK2vk5FlagsINS_22MemoryPropertyFlagBitsEEanERKS2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_OS8_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #6

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN2vk9to_stringB5cxx11ENS_5FlagsINS_22MemoryPropertyFlagBitsEEE(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i32) local_unnamed_addr #7

declare void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #8

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 #5 = { alwaysinline 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 #6 = { 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 #7 = { alwaysinline 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 #8 = { "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 #9 = { nounwind }
attributes #10 = { noreturn }

!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, !10, i64 16}
!6 = !{!"_ZTSN2vk18MemoryRequirementsE", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !10, i64 0}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass