; 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.VkBufferCreateInfo = type { i32, ptr, i32, i64, i32, i32, i32, ptr }
%struct.VmaAllocationCreateInfo = type { i32, i32, i32, i32, i32, ptr, ptr, float }
%struct.VmaAllocationInfo = type { i32, ptr, i64, i64, ptr, ptr, ptr }
%class.VulkanMemoryAllocator = type { 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 @vmaCreateBuffer(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21VulkanMemoryAllocator12createBufferEmjjRP10VkBuffer_TRP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #2 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.VkBufferCreateInfo, align 8
  %14 = alloca %struct.VmaAllocationCreateInfo, align 8
  %15 = alloca %struct.VmaAllocationInfo, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !11
  store i32 %3, ptr %10, align 4, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr %13) #3
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 56, i1 false)
  %17 = getelementptr inbounds %struct.VkBufferCreateInfo, ptr %13, i32 0, i32 0
  store i32 12, ptr %17, align 8, !tbaa !13
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.VkBufferCreateInfo, ptr %13, i32 0, i32 3
  store i64 %18, ptr %19, align 8, !tbaa !17
  %20 = load i32, ptr %9, align 4, !tbaa !11
  %21 = getelementptr inbounds %struct.VkBufferCreateInfo, ptr %13, i32 0, i32 4
  store i32 %20, ptr %21, align 8, !tbaa !18
  %22 = getelementptr inbounds %struct.VkBufferCreateInfo, ptr %13, i32 0, i32 5
  store i32 0, ptr %22, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 48, ptr %14) #3
  call void @llvm.memset.p0.i64(ptr align 8 %14, i8 0, i64 48, i1 false)
  %23 = getelementptr inbounds %struct.VmaAllocationCreateInfo, ptr %14, i32 0, i32 1
  store i32 7, ptr %23, align 4, !tbaa !20
  %24 = getelementptr inbounds %struct.VmaAllocationCreateInfo, ptr %14, i32 0, i32 0
  store i32 1028, ptr %24, align 8, !tbaa !24
  %25 = load i32, ptr %10, align 4, !tbaa !11
  %26 = getelementptr inbounds %struct.VmaAllocationCreateInfo, ptr %14, i32 0, i32 2
  store i32 %25, ptr %26, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 56, ptr %15) #3
  %27 = getelementptr inbounds %class.VulkanMemoryAllocator, ptr %16, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !26
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = call i32 @vmaCreateBuffer(ptr noundef %28, ptr noundef %13, ptr noundef %14, ptr noundef %29, ptr noundef %30, ptr noundef %15)
  call void @llvm.lifetime.end.p0(i64 56, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 56, ptr %13) #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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTS18VkBufferCreateInfo", !15, i64 0, !6, i64 8, !12, i64 16, !10, i64 24, !12, i64 32, !16, i64 36, !12, i64 40, !6, i64 48}
!15 = !{!"_ZTS15VkStructureType", !7, i64 0}
!16 = !{!"_ZTS13VkSharingMode", !7, i64 0}
!17 = !{!14, !10, i64 24}
!18 = !{!14, !12, i64 32}
!19 = !{!14, !16, i64 36}
!20 = !{!21, !22, i64 4}
!21 = !{!"_ZTS23VmaAllocationCreateInfo", !12, i64 0, !22, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !6, i64 24, !6, i64 32, !23, i64 40}
!22 = !{!"_ZTS14VmaMemoryUsage", !7, i64 0}
!23 = !{!"float", !7, i64 0}
!24 = !{!21, !12, i64 0}
!25 = !{!21, !12, i64 8}
!26 = !{!27, !6, i64 0}
!27 = !{!"_ZTS21VulkanMemoryAllocator", !6, i64 0, !6, 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"

%struct.VkBufferCreateInfo = type { i32, ptr, i32, i64, i32, i32, i32, ptr }
%struct.VmaAllocationCreateInfo = type { i32, i32, i32, i32, i32, ptr, ptr, float }
%struct.VmaAllocationInfo = type { i32, ptr, i64, i64, 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

; 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 @vmaCreateBuffer(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21VulkanMemoryAllocator12createBufferEmjjRP10VkBuffer_TRP15VmaAllocation_T(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, i64 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) local_unnamed_addr #2 align 2 {
  %7 = alloca %struct.VkBufferCreateInfo, align 8
  %8 = alloca %struct.VmaAllocationCreateInfo, align 8
  %9 = alloca %struct.VmaAllocationInfo, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %7) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %7, i8 0, i64 56, i1 false)
  store i32 12, ptr %7, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %7, i64 24
  store i64 %1, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %7, i64 32
  store i32 %2, ptr %11, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %8) #3
  %12 = getelementptr inbounds i8, ptr %8, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %12, i8 0, i64 40, i1 false)
  %13 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 7, ptr %13, align 4, !tbaa !16
  store i32 1028, ptr %8, align 8, !tbaa !20
  %14 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %3, ptr %14, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %9) #3
  %15 = load ptr, ptr %0, align 8, !tbaa !22
  %16 = call i32 @vmaCreateBuffer(ptr noundef %15, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %9)
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %7) #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 0}
!6 = !{!"_ZTS18VkBufferCreateInfo", !7, i64 0, !10, i64 8, !11, i64 16, !12, i64 24, !11, i64 32, !13, i64 36, !11, i64 40, !10, i64 48}
!7 = !{!"_ZTS15VkStructureType", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_ZTS13VkSharingMode", !8, i64 0}
!14 = !{!6, !12, i64 24}
!15 = !{!6, !11, i64 32}
!16 = !{!17, !18, i64 4}
!17 = !{!"_ZTS23VmaAllocationCreateInfo", !11, i64 0, !18, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !10, i64 24, !10, i64 32, !19, i64 40}
!18 = !{!"_ZTS14VmaMemoryUsage", !8, i64 0}
!19 = !{!"float", !8, i64 0}
!20 = !{!17, !11, i64 0}
!21 = !{!17, !11, i64 8}
!22 = !{!23, !10, i64 0}
!23 = !{!"_ZTS21VulkanMemoryAllocator", !10, i64 0, !10, i64 8}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass