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

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.345 = external hidden unnamed_addr constant [65 x i8], align 1
@__PRETTY_FUNCTION__.vmaAllocateMemory = external hidden unnamed_addr constant [188 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14VmaAllocator_T14AllocateMemoryERK20VkMemoryRequirementsbbP10VkBuffer_TP9VkImage_TjRK23VmaAllocationCreateInfo20VmaSuballocationTypemPP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(5916), ptr noundef nonnull align 8 dereferenceable(24), i1 noundef zeroext, i1 noundef zeroext, ptr noundef, ptr noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, i64 noundef, ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14VmaAllocator_T17GetAllocationInfoEP15VmaAllocation_TP17VmaAllocationInfo(ptr noundef nonnull align 8 dereferenceable(5916), ptr noundef, ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local i32 @vmaAllocateMemory(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %23

14:                                               ; preds = %5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %23

17:                                               ; preds = %14
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br label %23

23:                                               ; preds = %20, %17, %14, %5
  %24 = phi i1 [ false, %17 ], [ false, %14 ], [ false, %5 ], [ %22, %20 ]
  br i1 %24, label %25, label %26

25:                                               ; preds = %23
  br label %28

26:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.345, ptr noundef @.str.2, i32 noundef 16652, ptr noundef @__PRETTY_FUNCTION__.vmaAllocateMemory) #3
  unreachable

27:                                               ; No predecessors!
  br label %28

28:                                               ; preds = %27, %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = call noundef i32 @_ZN14VmaAllocator_T14AllocateMemoryERK20VkMemoryRequirementsbbP10VkBuffer_TP9VkImage_TjRK23VmaAllocationCreateInfo20VmaSuballocationTypemPP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(5916) %29, ptr noundef nonnull align 8 dereferenceable(24) %30, i1 noundef zeroext false, i1 noundef zeroext false, ptr noundef null, ptr noundef null, i32 noundef -1, ptr noundef nonnull align 8 dereferenceable(48) %31, i32 noundef 1, i64 noundef 1, ptr noundef %32)
  store i32 %33, ptr %11, align 4, !tbaa !9
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %44

36:                                               ; preds = %28
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %36
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN14VmaAllocator_T17GetAllocationInfoEP15VmaAllocation_TP17VmaAllocationInfo(ptr noundef nonnull align 8 dereferenceable(5916) %40, ptr noundef %42, ptr noundef %43)
  br label %44

44:                                               ; preds = %39, %36, %28
  %45 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret i32 %45
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS8VkResult", !7, i64 0}


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

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.345 = external hidden unnamed_addr constant [65 x i8], align 1
@__PRETTY_FUNCTION__.vmaAllocateMemory = external hidden unnamed_addr constant [188 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14VmaAllocator_T14AllocateMemoryERK20VkMemoryRequirementsbbP10VkBuffer_TP9VkImage_TjRK23VmaAllocationCreateInfo20VmaSuballocationTypemPP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(5916), ptr noundef nonnull align 8 dereferenceable(24), i1 noundef zeroext, i1 noundef zeroext, ptr noundef, ptr noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @vmaAllocateMemory(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %7 = insertelement <4 x ptr> %6, ptr %1, i64 1
  %8 = insertelement <4 x ptr> %7, ptr %2, i64 2
  %9 = insertelement <4 x ptr> %8, ptr %3, i64 3
  %10 = icmp eq <4 x ptr> %9, zeroinitializer
  %11 = bitcast <4 x i1> %10 to i4
  %12 = icmp eq i4 %11, 0
  br i1 %12, label %13, label %.critedge

.critedge:                                        ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.345, ptr noundef nonnull @.str.2, i32 noundef 16652, ptr noundef nonnull @__PRETTY_FUNCTION__.vmaAllocateMemory) #2
  unreachable

13:                                               ; preds = %5
  %14 = tail call noundef i32 @_ZN14VmaAllocator_T14AllocateMemoryERK20VkMemoryRequirementsbbP10VkBuffer_TP9VkImage_TjRK23VmaAllocationCreateInfo20VmaSuballocationTypemPP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(5916) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i1 noundef zeroext false, i1 noundef zeroext false, ptr noundef null, ptr noundef null, i32 noundef -1, ptr noundef nonnull align 8 dereferenceable(48) %2, i32 noundef 1, i64 noundef 1, ptr noundef nonnull %3)
  %15 = icmp ne ptr %4, null
  %16 = icmp eq i32 %14, 0
  %or.cond5 = and i1 %15, %16
  br i1 %or.cond5, label %17, label %19

17:                                               ; preds = %13
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void @_ZN14VmaAllocator_T17GetAllocationInfoEP15VmaAllocation_TP17VmaAllocationInfo(ptr noundef nonnull align 8 dereferenceable(5916) %0, ptr noundef %18, ptr noundef nonnull %4)
  br label %19

19:                                               ; preds = %17, %13
  ret i32 %14
}

attributes #0 = { noreturn 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 #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 = { noreturn 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"}


; Effective O3 passes: GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass