; 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.VmaStlAllocator.3 = type { ptr }
%class.VmaBlockMetadata_Linear = type { %class.VmaBlockMetadata.base, i64, %class.VmaVector.2, %class.VmaVector.2, i32, i32, i64, i64, i64 }
%class.VmaBlockMetadata.base = type <{ ptr, i64, ptr, i64, i8 }>
%class.VmaVector.2 = type { %struct.VmaStlAllocator.3, ptr, i64, i64 }

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

; 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

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 #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN23VmaBlockMetadata_LinearC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef %1, i64 noundef %2, i1 noundef zeroext %3) unnamed_addr #2 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 %struct.VmaStlAllocator.3, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.VmaStlAllocator.3, align 8
  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
  %13 = zext i1 %3 to i8
  store i8 %13, ptr %8, align 1, !tbaa !11
  %14 = load ptr, ptr %5, align 8
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %18 = trunc i8 %17 to i1
  call void @_ZN16VmaBlockMetadataC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(33) %14, ptr noundef %15, i64 noundef %16, i1 noundef zeroext %18)
  store ptr getelementptr inbounds inrange(-16, 192) ({ [26 x ptr] }, ptr @_ZTV23VmaBlockMetadata_Linear, i32 0, i32 0, i32 2), ptr %14, align 8, !tbaa !15
  %19 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %14, i32 0, i32 1
  store i64 0, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %14, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN15VmaStlAllocatorI16VmaSuballocationEC2EPK21VkAllocationCallbacks(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef %21)
          to label %22 unwind label %33

22:                                               ; preds = %4
  invoke void @_ZN9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(32) %20, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %23 unwind label %33

23:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %24 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %14, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN15VmaStlAllocatorI16VmaSuballocationEC2EPK21VkAllocationCallbacks(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef %25)
          to label %26 unwind label %37

26:                                               ; preds = %23
  invoke void @_ZN9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(32) %24, ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %27 unwind label %37

27:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %28 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %14, i32 0, i32 4
  store i32 0, ptr %28, align 8, !tbaa !24
  %29 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %14, i32 0, i32 5
  store i32 0, ptr %29, align 4, !tbaa !25
  %30 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %14, i32 0, i32 6
  store i64 0, ptr %30, align 8, !tbaa !26
  %31 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %14, i32 0, i32 7
  store i64 0, ptr %31, align 8, !tbaa !27
  %32 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %14, i32 0, i32 8
  store i64 0, ptr %32, align 8, !tbaa !28
  ret void

33:                                               ; preds = %22, %4
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %10, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %41

37:                                               ; preds = %26, %23
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %10, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @_ZN9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #3
  br label %41

41:                                               ; preds = %37, %33
  call void @_ZN16VmaBlockMetadataD2Ev(ptr noundef nonnull align 8 dereferenceable(33) %14) #3
  br label %42

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"_ZTS23VmaBlockMetadata_Linear", !19, i64 0, !10, i64 40, !20, i64 48, !20, i64 80, !22, i64 112, !23, i64 116, !10, i64 120, !10, i64 128, !10, i64 136}
!19 = !{!"_ZTS16VmaBlockMetadata", !10, i64 8, !6, i64 16, !10, i64 24, !12, i64 32}
!20 = !{!"_ZTS9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE", !21, i64 0, !6, i64 8, !10, i64 16, !10, i64 24}
!21 = !{!"_ZTS15VmaStlAllocatorI16VmaSuballocationE", !6, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!"_ZTSN23VmaBlockMetadata_Linear18SECOND_VECTOR_MODEE", !7, i64 0}
!24 = !{!18, !22, i64 112}
!25 = !{!18, !23, i64 116}
!26 = !{!18, !10, i64 120}
!27 = !{!18, !10, i64 128}
!28 = !{!18, !10, i64 136}


; 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.VmaStlAllocator.3 = type { ptr }

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

; 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

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 #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN23VmaBlockMetadata_LinearC2EPK21VkAllocationCallbacksmb(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef %1, i64 noundef %2, i1 noundef zeroext %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %struct.VmaStlAllocator.3, align 8
  %6 = alloca %struct.VmaStlAllocator.3, align 8
  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 @_ZTV23VmaBlockMetadata_Linear, i64 16), ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  store i64 0, ptr %7, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @_ZN15VmaStlAllocatorI16VmaSuballocationEC2EPK21VkAllocationCallbacks(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef %1)
  call void @_ZN9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 80
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @_ZN15VmaStlAllocatorI16VmaSuballocationEC2EPK21VkAllocationCallbacks(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef %1)
  call void @_ZN9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  %10 = getelementptr inbounds i8, ptr %0, i64 112
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %10, i8 0, i64 32, i1 false)
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !11, i64 40}
!9 = !{!"_ZTS23VmaBlockMetadata_Linear", !10, i64 0, !11, i64 40, !15, i64 48, !15, i64 80, !17, i64 112, !18, i64 116, !11, i64 120, !11, i64 128, !11, i64 136}
!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 = !{!"_ZTS9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE", !16, i64 0, !13, i64 8, !11, i64 16, !11, i64 24}
!16 = !{!"_ZTS15VmaStlAllocatorI16VmaSuballocationE", !13, i64 0}
!17 = !{!"int", !12, i64 0}
!18 = !{!"_ZTSN23VmaBlockMetadata_Linear18SECOND_VECTOR_MODEE", !12, i64 0}


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