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

%class.VmaBlockMetadata_TLSF = type { %class.VmaBlockMetadata.base, i64, i64, i64, i32, i8, [58 x i32], i32, ptr, %class.VmaPoolAllocator, ptr, %class.VmaBlockBufferImageGranularity }
%class.VmaBlockMetadata.base = type <{ ptr, i64, ptr, i64, i8 }>
%class.VmaPoolAllocator = type { ptr, i32, %class.VmaVector.4 }
%class.VmaVector.4 = type { %struct.VmaStlAllocator.5, ptr, i64, i64 }
%struct.VmaStlAllocator.5 = type { ptr }
%class.VmaBlockBufferImageGranularity = type { i64, i32, ptr }

@_ZTV21VmaBlockMetadata_TLSF = external dso_local unnamed_addr constant { [26 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN16VmaBlockMetadataC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, i64 noundef, i1 noundef zeroext) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21VmaBlockMetadata_TLSFC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(400) %0, ptr noundef %1, i64 noundef %2, i1 noundef zeroext %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %11 = zext i1 %3 to i8
  store i8 %11, ptr %8, align 1, !tbaa !11
  %12 = load ptr, ptr %5, align 8
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load i64, ptr %7, align 8, !tbaa !9
  %15 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  call void @_ZN16VmaBlockMetadataC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(33) %12, ptr noundef %13, i64 noundef %14, i1 noundef zeroext %16)
  store ptr getelementptr inbounds inrange(-16, 192) ({ [26 x ptr] }, ptr @_ZTV21VmaBlockMetadata_TLSF, i32 0, i32 0, i32 2), ptr %12, align 8, !tbaa !15
  %17 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 1
  store i64 0, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 2
  store i64 0, ptr %18, align 8, !tbaa !25
  %19 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 3
  store i64 0, ptr %19, align 8, !tbaa !26
  %20 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 4
  store i32 0, ptr %20, align 8, !tbaa !27
  %21 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 5
  store i8 0, ptr %21, align 4, !tbaa !28
  %22 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 7
  store i32 0, ptr %22, align 8, !tbaa !29
  %23 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 8
  store ptr null, ptr %23, align 8, !tbaa !30
  %24 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 9
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEEC2EPK21VkAllocationCallbacksj(ptr noundef nonnull align 8 dereferenceable(48) %24, ptr noundef %25, i32 noundef 16)
          to label %26 unwind label %31

26:                                               ; preds = %4
  %27 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 10
  store ptr null, ptr %27, align 8, !tbaa !31
  %28 = getelementptr inbounds %class.VmaBlockMetadata_TLSF, ptr %12, i32 0, i32 11
  %29 = load i64, ptr %7, align 8, !tbaa !9
  invoke void @_ZN30VmaBlockBufferImageGranularityC1Em(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %29)
          to label %30 unwind label %35

30:                                               ; preds = %26
  ret void

31:                                               ; preds = %4
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %9, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %10, align 4
  br label %39

35:                                               ; preds = %26
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %9, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %10, align 4
  call void @_ZN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %24) #2
  br label %39

39:                                               ; preds = %35, %31
  call void @_ZN16VmaBlockMetadataD2Ev(ptr noundef nonnull align 8 dereferenceable(33) %12) #2
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %9, align 8
  %42 = load i32, ptr %10, align 4
  %43 = insertvalue { ptr, i32 } poison, ptr %41, 0
  %44 = insertvalue { ptr, i32 } %43, i32 %42, 1
  resume { ptr, i32 } %44
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEEC2EPK21VkAllocationCallbacksj(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i32 noundef) unnamed_addr #1 align 2

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

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

declare void @_ZN30VmaBlockBufferImageGranularityC1Em(ptr, i64)

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 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 = { 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 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !10, i64 40}
!18 = !{!"_ZTS21VmaBlockMetadata_TLSF", !19, i64 0, !10, i64 40, !10, i64 48, !10, i64 56, !20, i64 64, !7, i64 68, !7, i64 72, !20, i64 304, !6, i64 312, !21, i64 320, !6, i64 368, !24, i64 376}
!19 = !{!"_ZTS16VmaBlockMetadata", !10, i64 8, !6, i64 16, !10, i64 24, !12, i64 32}
!20 = !{!"int", !7, i64 0}
!21 = !{!"_ZTS16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEE", !6, i64 0, !20, i64 8, !22, i64 16}
!22 = !{!"_ZTS9VmaVectorIN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEE9ItemBlockE15VmaStlAllocatorIS4_EE", !23, i64 0, !6, i64 8, !10, i64 16, !10, i64 24}
!23 = !{!"_ZTS15VmaStlAllocatorIN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEE9ItemBlockEE", !6, i64 0}
!24 = !{!"_ZTS30VmaBlockBufferImageGranularity", !10, i64 0, !20, i64 8, !6, i64 16}
!25 = !{!18, !10, i64 48}
!26 = !{!18, !10, i64 56}
!27 = !{!18, !20, i64 64}
!28 = !{!18, !7, i64 68}
!29 = !{!18, !20, i64 304}
!30 = !{!18, !6, i64 312}
!31 = !{!18, !6, i64 368}


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

@_ZTV21VmaBlockMetadata_TLSF = external dso_local unnamed_addr constant { [26 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN16VmaBlockMetadataC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, i64 noundef, i1 noundef zeroext) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21VmaBlockMetadata_TLSFC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(400) %0, ptr noundef %1, i64 noundef %2, i1 noundef zeroext %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN16VmaBlockMetadataC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef %1, i64 noundef %2, i1 noundef zeroext %3)
  store ptr getelementptr inbounds inrange(-16, 192) (i8, ptr @_ZTV21VmaBlockMetadata_TLSF, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = getelementptr inbounds i8, ptr %0, i64 304
  store i32 0, ptr %6, align 8, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %0, i64 312
  store ptr null, ptr %7, align 8, !tbaa !20
  %8 = getelementptr inbounds i8, ptr %0, i64 320
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(29) %5, i8 0, i64 29, i1 false)
  invoke void @_ZN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEEC2EPK21VkAllocationCallbacksj(ptr noundef nonnull align 8 dereferenceable(48) %8, ptr noundef %1, i32 noundef 16)
          to label %9 unwind label %13

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %0, i64 368
  store ptr null, ptr %10, align 8, !tbaa !21
  %11 = getelementptr inbounds i8, ptr %0, i64 376
  invoke void @_ZN30VmaBlockBufferImageGranularityC1Em(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %2)
          to label %12 unwind label %15

12:                                               ; preds = %9
  ret void

13:                                               ; preds = %4
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %17

15:                                               ; preds = %9
  %16 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %8) #3
  br label %17

17:                                               ; preds = %15, %13
  %.pn = phi { ptr, i32 } [ %16, %15 ], [ %14, %13 ]
  tail call void @_ZN16VmaBlockMetadataD2Ev(ptr noundef nonnull align 8 dereferenceable(33) %0) #3
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEEC2EPK21VkAllocationCallbacksj(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i32 noundef) unnamed_addr #1 align 2

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

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

declare void @_ZN30VmaBlockBufferImageGranularityC1Em(ptr, i64) local_unnamed_addr

; 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 = { 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 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !15, i64 304}
!9 = !{!"_ZTS21VmaBlockMetadata_TLSF", !10, i64 0, !11, i64 40, !11, i64 48, !11, i64 56, !15, i64 64, !12, i64 68, !12, i64 72, !15, i64 304, !13, i64 312, !16, i64 320, !13, i64 368, !19, i64 376}
!10 = !{!"_ZTS16VmaBlockMetadata", !11, i64 8, !13, i64 16, !11, i64 24, !14, i64 32}
!11 = !{!"long", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"any pointer", !12, i64 0}
!14 = !{!"bool", !12, i64 0}
!15 = !{!"int", !12, i64 0}
!16 = !{!"_ZTS16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEE", !13, i64 0, !15, i64 8, !17, i64 16}
!17 = !{!"_ZTS9VmaVectorIN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEE9ItemBlockE15VmaStlAllocatorIS4_EE", !18, i64 0, !13, i64 8, !11, i64 16, !11, i64 24}
!18 = !{!"_ZTS15VmaStlAllocatorIN16VmaPoolAllocatorIN21VmaBlockMetadata_TLSF5BlockEE9ItemBlockEE", !13, i64 0}
!19 = !{!"_ZTS30VmaBlockBufferImageGranularity", !11, i64 0, !15, i64 8, !13, i64 16}
!20 = !{!9, !13, i64 312}
!21 = !{!9, !13, i64 368}


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