; 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.VmaAllocation_T = type <{ %union.anon, i64, i64, ptr, ptr, i32, i8, i8, i8, i8, i32, [4 x i8] }>
%union.anon = type { %"struct.VmaAllocation_T::DedicatedAllocation" }
%"struct.VmaAllocation_T::DedicatedAllocation" = type { ptr, ptr, ptr, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.157 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [153 x i8], align 1
@__PRETTY_FUNCTION__._ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm = external hidden unnamed_addr constant [125 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [19 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK15VmaAllocation_T16IsMappingAllowedEv(ptr noundef nonnull align 8 dereferenceable(84)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm(ptr noundef nonnull align 8 dereferenceable(84) %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6) #2 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !11
  store ptr %5, ptr %13, align 8, !tbaa !5
  store i64 %6, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %8, align 8
  %16 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 6
  %17 = load i8, ptr %16, align 4, !tbaa !15
  %18 = zext i8 %17 to i32
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %7
  br label %23

21:                                               ; preds = %7
  call void @__assert_fail(ptr noundef @.str.157, ptr noundef @.str.2, i32 noundef 12100, ptr noundef @__PRETTY_FUNCTION__._ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm) #3
  unreachable

22:                                               ; No predecessors!
  br label %23

23:                                               ; preds = %22, %20
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %29

27:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.161, ptr noundef @.str.2, i32 noundef 12101, ptr noundef @__PRETTY_FUNCTION__._ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm) #3
  unreachable

28:                                               ; No predecessors!
  br label %29

29:                                               ; preds = %28, %26
  %30 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 6
  store i8 2, ptr %30, align 4, !tbaa !15
  %31 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 1
  store i64 0, ptr %31, align 8, !tbaa !17
  %32 = load i64, ptr %14, align 8, !tbaa !13
  %33 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 2
  store i64 %32, ptr %33, align 8, !tbaa !18
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 5
  store i32 %34, ptr %35, align 8, !tbaa !19
  %36 = load i32, ptr %12, align 4, !tbaa !11
  %37 = trunc i32 %36 to i8
  %38 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 7
  store i8 %37, ptr %38, align 1, !tbaa !20
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %55

41:                                               ; preds = %29
  %42 = call noundef zeroext i1 @_ZNK15VmaAllocation_T16IsMappingAllowedEv(ptr noundef nonnull align 8 dereferenceable(84) %15)
  br i1 %42, label %43, label %44

43:                                               ; preds = %41
  br label %44

44:                                               ; preds = %43, %41
  %45 = phi i1 [ false, %41 ], [ true, %43 ]
  br i1 %45, label %46, label %47

46:                                               ; preds = %44
  br label %49

47:                                               ; preds = %44
  call void @__assert_fail(ptr noundef @.str.160, ptr noundef @.str.2, i32 noundef 12109, ptr noundef @__PRETTY_FUNCTION__._ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm) #3
  unreachable

48:                                               ; No predecessors!
  br label %49

49:                                               ; preds = %48, %46
  %50 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 9
  %51 = load i8, ptr %50, align 1, !tbaa !21
  %52 = zext i8 %51 to i32
  %53 = or i32 %52, 1
  %54 = trunc i32 %53 to i8
  store i8 %54, ptr %50, align 1, !tbaa !21
  br label %55

55:                                               ; preds = %49, %29
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 0
  %58 = getelementptr inbounds %"struct.VmaAllocation_T::DedicatedAllocation", ptr %57, i32 0, i32 0
  store ptr %56, ptr %58, align 8, !tbaa !22
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 0
  %61 = getelementptr inbounds %"struct.VmaAllocation_T::DedicatedAllocation", ptr %60, i32 0, i32 1
  store ptr %59, ptr %61, align 8, !tbaa !22
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 0
  %64 = getelementptr inbounds %"struct.VmaAllocation_T::DedicatedAllocation", ptr %63, i32 0, i32 2
  store ptr %62, ptr %64, align 8, !tbaa !22
  %65 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 0
  %66 = getelementptr inbounds %"struct.VmaAllocation_T::DedicatedAllocation", ptr %65, i32 0, i32 3
  store ptr null, ptr %66, align 8, !tbaa !22
  %67 = getelementptr inbounds %struct.VmaAllocation_T, ptr %15, i32 0, i32 0
  %68 = getelementptr inbounds %"struct.VmaAllocation_T::DedicatedAllocation", ptr %67, i32 0, i32 4
  store ptr null, ptr %68, align 8, !tbaa !22
  ret void
}

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 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 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS20VmaSuballocationType", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !7, i64 76}
!16 = !{!"_ZTS15VmaAllocation_T", !7, i64 0, !14, i64 40, !14, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !7, i64 76, !7, i64 77, !7, i64 78, !7, i64 79, !10, i64 80}
!17 = !{!16, !14, i64 40}
!18 = !{!16, !14, i64 48}
!19 = !{!16, !10, i64 72}
!20 = !{!16, !7, i64 77}
!21 = !{!16, !7, i64 79}
!22 = !{!7, !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.157 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [153 x i8], align 1
@__PRETTY_FUNCTION__._ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm = external hidden unnamed_addr constant [125 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [19 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK15VmaAllocation_T16IsMappingAllowedEv(ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm(ptr noundef nonnull align 8 dereferenceable(84) %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6) local_unnamed_addr #1 align 2 {
  %8 = getelementptr inbounds i8, ptr %0, i64 76
  %9 = load i8, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i8 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.157, ptr noundef nonnull @.str.2, i32 noundef 12100, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm) #3
  unreachable

12:                                               ; preds = %7
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %13, label %14

13:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.161, ptr noundef nonnull @.str.2, i32 noundef 12101, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm) #3
  unreachable

14:                                               ; preds = %12
  store i8 2, ptr %8, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  store i64 0, ptr %15, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %6, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 72
  store i32 %2, ptr %17, align 8, !tbaa !14
  %18 = trunc i32 %4 to i8
  %19 = getelementptr inbounds i8, ptr %0, i64 77
  store i8 %18, ptr %19, align 1, !tbaa !15
  %.not8 = icmp eq ptr %5, null
  br i1 %.not8, label %27, label %20

20:                                               ; preds = %14
  %21 = tail call noundef zeroext i1 @_ZNK15VmaAllocation_T16IsMappingAllowedEv(ptr noundef nonnull align 8 dereferenceable(84) %0)
  br i1 %21, label %23, label %22

22:                                               ; preds = %20
  tail call void @__assert_fail(ptr noundef nonnull @.str.160, ptr noundef nonnull @.str.2, i32 noundef 12109, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN15VmaAllocation_T23InitDedicatedAllocationEP9VmaPool_TjP16VkDeviceMemory_T20VmaSuballocationTypePvm) #3
  unreachable

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %0, i64 79
  %25 = load i8, ptr %24, align 1, !tbaa !16
  %26 = or i8 %25, 1
  store i8 %26, ptr %24, align 1, !tbaa !16
  br label %27

27:                                               ; preds = %23, %14
  store ptr %1, ptr %0, align 8, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %3, ptr %28, align 8, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %5, ptr %29, align 8, !tbaa !17
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %30, i8 0, i64 16, i1 false)
  ret void
}

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

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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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, !7, i64 76}
!6 = !{!"_ZTS15VmaAllocation_T", !7, i64 0, !9, i64 40, !9, i64 48, !10, i64 56, !10, i64 64, !11, i64 72, !7, i64 76, !7, i64 77, !7, i64 78, !7, i64 79, !11, i64 80}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!6, !9, i64 40}
!13 = !{!6, !9, i64 48}
!14 = !{!6, !11, i64 72}
!15 = !{!6, !7, i64 77}
!16 = !{!6, !7, i64 79}
!17 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass