; LLVM IR from khushmmehta/Scorch-V :: src/ScorchVkEngine/Abstractions (VulkanMemoryAllocator)

; 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.VmaAllocatorCreateInfo = type { i32, ptr, ptr, i64, ptr, ptr, ptr, ptr, ptr, i32, ptr }
%class.VulkanMemoryAllocator = type { ptr, ptr }
%class.PresentationManager = type { ptr, ptr, ptr, ptr, %struct.QueueFamilyIndices, ptr, i32, %struct.VkExtent2D, %"class.std::vector.23", i8, %"class.std::vector.28", %"class.std::vector.33", %struct.SwapChainSupportDetails }
%struct.QueueFamilyIndices = type { %"class.std::optional", %"class.std::optional" }
%"class.std::optional" = type { %"struct.std::_Optional_base" }
%"struct.std::_Optional_base" = type { %"struct.std::_Optional_payload" }
%"struct.std::_Optional_payload" = type { %"struct.std::_Optional_payload_base.base", [3 x i8] }
%"struct.std::_Optional_payload_base.base" = type <{ %"union.std::_Optional_payload_base<unsigned int>::_Storage", i8 }>
%"union.std::_Optional_payload_base<unsigned int>::_Storage" = type { i32 }
%struct.VkExtent2D = type { i32, i32 }
%"class.std::vector.23" = type { %"struct.std::_Vector_base.24" }
%"struct.std::_Vector_base.24" = type { %"struct.std::_Vector_base<VkFramebuffer_T *, std::allocator<VkFramebuffer_T *>>::_Vector_impl" }
%"struct.std::_Vector_base<VkFramebuffer_T *, std::allocator<VkFramebuffer_T *>>::_Vector_impl" = type { %"struct.std::_Vector_base<VkFramebuffer_T *, std::allocator<VkFramebuffer_T *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<VkFramebuffer_T *, std::allocator<VkFramebuffer_T *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.28" = type { %"struct.std::_Vector_base.29" }
%"struct.std::_Vector_base.29" = type { %"struct.std::_Vector_base<VkImage_T *, std::allocator<VkImage_T *>>::_Vector_impl" }
%"struct.std::_Vector_base<VkImage_T *, std::allocator<VkImage_T *>>::_Vector_impl" = type { %"struct.std::_Vector_base<VkImage_T *, std::allocator<VkImage_T *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<VkImage_T *, std::allocator<VkImage_T *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.33" = type { %"struct.std::_Vector_base.34" }
%"struct.std::_Vector_base.34" = type { %"struct.std::_Vector_base<VkImageView_T *, std::allocator<VkImageView_T *>>::_Vector_impl" }
%"struct.std::_Vector_base<VkImageView_T *, std::allocator<VkImageView_T *>>::_Vector_impl" = type { %"struct.std::_Vector_base<VkImageView_T *, std::allocator<VkImageView_T *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<VkImageView_T *, std::allocator<VkImageView_T *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.SwapChainSupportDetails = type { %struct.VkSurfaceCapabilitiesKHR, %"class.std::vector.38", %"class.std::vector.43" }
%struct.VkSurfaceCapabilitiesKHR = type { i32, i32, %struct.VkExtent2D, %struct.VkExtent2D, %struct.VkExtent2D, i32, i32, i32, i32, i32 }
%"class.std::vector.38" = type { %"struct.std::_Vector_base.39" }
%"struct.std::_Vector_base.39" = type { %"struct.std::_Vector_base<VkSurfaceFormatKHR, std::allocator<VkSurfaceFormatKHR>>::_Vector_impl" }
%"struct.std::_Vector_base<VkSurfaceFormatKHR, std::allocator<VkSurfaceFormatKHR>>::_Vector_impl" = type { %"struct.std::_Vector_base<VkSurfaceFormatKHR, std::allocator<VkSurfaceFormatKHR>>::_Vector_impl_data" }
%"struct.std::_Vector_base<VkSurfaceFormatKHR, std::allocator<VkSurfaceFormatKHR>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.43" = type { %"struct.std::_Vector_base.44" }
%"struct.std::_Vector_base.44" = type { %"struct.std::_Vector_base<VkPresentModeKHR, std::allocator<VkPresentModeKHR>>::_Vector_impl" }
%"struct.std::_Vector_base<VkPresentModeKHR, std::allocator<VkPresentModeKHR>>::_Vector_impl" = type { %"struct.std::_Vector_base<VkPresentModeKHR, std::allocator<VkPresentModeKHR>>::_Vector_impl_data" }
%"struct.std::_Vector_base<VkPresentModeKHR, std::allocator<VkPresentModeKHR>>::_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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local i32 @vmaCreateAllocator(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21VulkanMemoryAllocator15createAllocatorEP12VkInstance_T(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.VmaAllocatorCreateInfo, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 88, ptr %5) #3
  call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 88, i1 false)
  %7 = getelementptr inbounds %struct.VmaAllocatorCreateInfo, ptr %5, i32 0, i32 9
  store i32 4206592, ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds %class.VulkanMemoryAllocator, ptr %6, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds %class.PresentationManager, ptr %9, i32 0, i32 2
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds %struct.VmaAllocatorCreateInfo, ptr %5, i32 0, i32 1
  store ptr %11, ptr %12, align 8, !tbaa !48
  %13 = getelementptr inbounds %class.VulkanMemoryAllocator, ptr %6, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = getelementptr inbounds %class.PresentationManager, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !49
  %17 = getelementptr inbounds %struct.VmaAllocatorCreateInfo, ptr %5, i32 0, i32 2
  store ptr %16, ptr %17, align 8, !tbaa !50
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.VmaAllocatorCreateInfo, ptr %5, i32 0, i32 8
  store ptr %18, ptr %19, align 8, !tbaa !51
  %20 = getelementptr inbounds %class.VulkanMemoryAllocator, ptr %6, i32 0, i32 0
  %21 = call i32 @vmaCreateAllocator(ptr noundef %5, ptr noundef %20)
  call void @llvm.lifetime.end.p0(i64 88, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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, !11, i64 72}
!10 = !{!"_ZTS22VmaAllocatorCreateInfo", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !6, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS21VulkanMemoryAllocator", !6, i64 0, !6, i64 8}
!15 = !{!16, !6, i64 16}
!16 = !{!"_ZTS19PresentationManager", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !17, i64 32, !6, i64 48, !23, i64 56, !24, i64 60, !25, i64 72, !22, i64 96, !29, i64 104, !33, i64 128, !37, i64 152}
!17 = !{!"_ZTS18QueueFamilyIndices", !18, i64 0, !18, i64 8}
!18 = !{!"_ZTSSt8optionalIjE", !19, i64 0}
!19 = !{!"_ZTSSt14_Optional_baseIjLb1ELb1EE", !20, i64 0}
!20 = !{!"_ZTSSt17_Optional_payloadIjLb1ELb1ELb1EE", !21, i64 0}
!21 = !{!"_ZTSSt22_Optional_payload_baseIjE", !7, i64 0, !22, i64 4}
!22 = !{!"bool", !7, i64 0}
!23 = !{!"_ZTS8VkFormat", !7, i64 0}
!24 = !{!"_ZTS10VkExtent2D", !11, i64 0, !11, i64 4}
!25 = !{!"_ZTSSt6vectorIP15VkFramebuffer_TSaIS1_EE", !26, i64 0}
!26 = !{!"_ZTSSt12_Vector_baseIP15VkFramebuffer_TSaIS1_EE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIP15VkFramebuffer_TSaIS1_EE12_Vector_implE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIP15VkFramebuffer_TSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!29 = !{!"_ZTSSt6vectorIP9VkImage_TSaIS1_EE", !30, i64 0}
!30 = !{!"_ZTSSt12_Vector_baseIP9VkImage_TSaIS1_EE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIP9VkImage_TSaIS1_EE12_Vector_implE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIP9VkImage_TSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!33 = !{!"_ZTSSt6vectorIP13VkImageView_TSaIS1_EE", !34, i64 0}
!34 = !{!"_ZTSSt12_Vector_baseIP13VkImageView_TSaIS1_EE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIP13VkImageView_TSaIS1_EE12_Vector_implE", !36, i64 0}
!36 = !{!"_ZTSNSt12_Vector_baseIP13VkImageView_TSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!37 = !{!"_ZTS23SwapChainSupportDetails", !38, i64 0, !40, i64 56, !44, i64 80}
!38 = !{!"_ZTS24VkSurfaceCapabilitiesKHR", !11, i64 0, !11, i64 4, !24, i64 8, !24, i64 16, !24, i64 24, !11, i64 32, !11, i64 36, !39, i64 40, !11, i64 44, !11, i64 48}
!39 = !{!"_ZTS29VkSurfaceTransformFlagBitsKHR", !7, i64 0}
!40 = !{!"_ZTSSt6vectorI18VkSurfaceFormatKHRSaIS0_EE", !41, i64 0}
!41 = !{!"_ZTSSt12_Vector_baseI18VkSurfaceFormatKHRSaIS0_EE", !42, i64 0}
!42 = !{!"_ZTSNSt12_Vector_baseI18VkSurfaceFormatKHRSaIS0_EE12_Vector_implE", !43, i64 0}
!43 = !{!"_ZTSNSt12_Vector_baseI18VkSurfaceFormatKHRSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!44 = !{!"_ZTSSt6vectorI16VkPresentModeKHRSaIS0_EE", !45, i64 0}
!45 = !{!"_ZTSSt12_Vector_baseI16VkPresentModeKHRSaIS0_EE", !46, i64 0}
!46 = !{!"_ZTSNSt12_Vector_baseI16VkPresentModeKHRSaIS0_EE12_Vector_implE", !47, i64 0}
!47 = !{!"_ZTSNSt12_Vector_baseI16VkPresentModeKHRSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!48 = !{!10, !6, i64 8}
!49 = !{!16, !6, i64 24}
!50 = !{!10, !6, i64 16}
!51 = !{!10, !6, i64 64}


; 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.VmaAllocatorCreateInfo = type { i32, ptr, ptr, i64, ptr, ptr, ptr, ptr, ptr, i32, ptr }

; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local i32 @vmaCreateAllocator(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21VulkanMemoryAllocator15createAllocatorEP12VkInstance_T(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %struct.VmaAllocatorCreateInfo, align 8
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %3) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(88) %3, i8 0, i64 88, i1 false)
  %4 = getelementptr inbounds i8, ptr %3, i64 72
  store i32 4206592, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = load <2 x ptr>, ptr %7, align 8, !tbaa !14
  store <2 x ptr> %9, ptr %8, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %3, i64 64
  store ptr %1, ptr %10, align 8, !tbaa !15
  %11 = call i32 @vmaCreateAllocator(ptr noundef nonnull %3, ptr noundef nonnull %0)
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %3) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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, !7, i64 72}
!6 = !{!"_ZTS22VmaAllocatorCreateInfo", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !7, i64 72, !10, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !10, i64 8}
!13 = !{!"_ZTS21VulkanMemoryAllocator", !10, i64 0, !10, i64 8}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !10, i64 64}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass