; 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.VmaDefragmentationContext_T::MoveAllocationData" = type { i64, i64, i32, i32, %struct.VmaDefragmentationMove }
%struct.VmaDefragmentationMove = type { i32, ptr, ptr }
%struct.VmaDefragmentationContext_T = type { i64, i32, ptr, ptr, %struct.VmaStlAllocator.17, %class.VmaVector.18, i8, i32, i32, ptr, ptr, i64, %struct.VmaDefragmentationStats, %struct.VmaDefragmentationStats, ptr }
%struct.VmaStlAllocator.17 = type { ptr }
%class.VmaVector.18 = type { %struct.VmaStlAllocator.17, ptr, i64, i64 }
%struct.VmaDefragmentationStats = type { i64, i64, i32, i32 }
%class.VmaDeviceMemoryBlock = type { ptr, ptr, i32, i32, ptr, %class.VmaMutex, %class.VmaMappingHysteresis, i32, ptr }
%class.VmaMutex = type { %"class.std::mutex" }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%class.VmaMappingHysteresis = type { i32, i32, i32 }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T20MoveDataToFreeBlocksE20VmaSuballocationTypeR14VmaBlockVectormRbS3_S3_ = external hidden unnamed_addr constant [127 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 nounwind uwtable
declare dso_local noundef i64 @_ZNK15VmaAllocation_T7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(84)) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL35VmaIsBufferImageGranularityConflict20VmaSuballocationTypeS_(i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK14VmaBlockVector13GetBlockCountEv(ptr noundef nonnull align 8 dereferenceable(181)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14VmaBlockVector8GetBlockEm(ptr noundef nonnull align 8 dereferenceable(181), i64 noundef) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN27VmaDefragmentationContext_T11GetMoveDataEP16VmaAllocHandle_TP16VmaBlockMetadata(ptr dead_on_unwind noalias writable sret(%"struct.VmaDefragmentationContext_T::MoveAllocationData") align 8, ptr noundef, ptr noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN27VmaDefragmentationContext_T13CheckCountersEm(ptr noundef nonnull align 8 dereferenceable(168), i64 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17AllocInOtherBlockEmmRNS_18MoveAllocationDataER14VmaBlockVector(ptr noundef nonnull align 8 dereferenceable(168), i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(181)) #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN27VmaDefragmentationContext_T20MoveDataToFreeBlocksE20VmaSuballocationTypeR14VmaBlockVectormRbS3_S3_(ptr noundef nonnull align 8 dereferenceable(168) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(181) %2, i64 noundef %3, ptr noundef nonnull align 1 dereferenceable(1) %4, ptr noundef nonnull align 1 dereferenceable(1) %5, ptr noundef nonnull align 1 dereferenceable(1) %6) #4 align 2 {
  %8 = alloca i1, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca %"struct.VmaDefragmentationContext_T::MoveAllocationData", align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store ptr %2, ptr %11, align 8, !tbaa !5
  store i64 %3, ptr %12, align 8, !tbaa !11
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %24 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %23, i32 0, i32 5
  %25 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %24)
  store i64 %25, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %26 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %26, ptr %17, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %110, %7
  %28 = load i64, ptr %17, align 8, !tbaa !11
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  store i32 2, ptr %18, align 4
  br label %111

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = load i64, ptr %17, align 8, !tbaa !11
  %34 = add i64 %33, -1
  store i64 %34, ptr %17, align 8, !tbaa !11
  %35 = call noundef ptr @_ZNK14VmaBlockVector8GetBlockEm(ptr noundef nonnull align 8 dereferenceable(181) %32, i64 noundef %34)
  store ptr %35, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %36 = load ptr, ptr %19, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.VmaDeviceMemoryBlock, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  store ptr %38, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %39 = load ptr, ptr %20, align 8, !tbaa !5
  %40 = load ptr, ptr %39, align 8, !tbaa !20
  %41 = getelementptr inbounds ptr, ptr %40, i64 11
  %42 = load ptr, ptr %41, align 8
  %43 = call noundef ptr %42(ptr noundef nonnull align 8 dereferenceable(33) %39)
  store ptr %43, ptr %21, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %98, %31
  %45 = load ptr, ptr %21, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  store i32 4, ptr %18, align 4
  br label %105

48:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 48, ptr %22) #5
  %49 = load ptr, ptr %21, align 8, !tbaa !5
  %50 = load ptr, ptr %20, align 8, !tbaa !5
  call void @_ZN27VmaDefragmentationContext_T11GetMoveDataEP16VmaAllocHandle_TP16VmaBlockMetadata(ptr dead_on_unwind writable sret(%"struct.VmaDefragmentationContext_T::MoveAllocationData") align 8 %22, ptr noundef %49, ptr noundef %50)
  %51 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %22, i32 0, i32 4
  %52 = getelementptr inbounds %struct.VmaDefragmentationMove, ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !22
  %54 = call noundef ptr @_ZNK15VmaAllocation_T11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(84) %53)
  %55 = icmp eq ptr %54, %23
  br i1 %55, label %56, label %57

56:                                               ; preds = %48
  store i32 6, ptr %18, align 4
  br label %95

57:                                               ; preds = %48
  %58 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %22, i32 0, i32 4
  %59 = getelementptr inbounds %struct.VmaDefragmentationMove, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !22
  %61 = call noundef i64 @_ZNK15VmaAllocation_T7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(84) %60)
  %62 = call noundef i32 @_ZN27VmaDefragmentationContext_T13CheckCountersEm(ptr noundef nonnull align 8 dereferenceable(168) %23, i64 noundef %61)
  switch i32 %62, label %65 [
    i32 1, label %63
    i32 2, label %64
    i32 0, label %66
  ]

63:                                               ; preds = %57
  store i32 6, ptr %18, align 4
  br label %95

64:                                               ; preds = %57
  store i1 true, ptr %8, align 1
  store i32 1, ptr %18, align 4
  br label %95

65:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str.57, ptr noundef @.str.2, i32 noundef 13997, ptr noundef @__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T20MoveDataToFreeBlocksE20VmaSuballocationTypeR14VmaBlockVectormRbS3_S3_) #6
  unreachable

66:                                               ; preds = %57
  %67 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %22, i32 0, i32 2
  %68 = load i32, ptr %67, align 8, !tbaa !26
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = call noundef zeroext i1 @_ZL35VmaIsBufferImageGranularityConflict20VmaSuballocationTypeS_(i32 noundef %68, i32 noundef %69)
  br i1 %70, label %79, label %71

71:                                               ; preds = %66
  %72 = load i64, ptr %12, align 8, !tbaa !11
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = call noundef i64 @_ZNK14VmaBlockVector13GetBlockCountEv(ptr noundef nonnull align 8 dereferenceable(181) %73)
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = call noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17AllocInOtherBlockEmmRNS_18MoveAllocationDataER14VmaBlockVector(ptr noundef nonnull align 8 dereferenceable(168) %23, i64 noundef %72, i64 noundef %74, ptr noundef nonnull align 8 dereferenceable(48) %22, ptr noundef nonnull align 8 dereferenceable(181) %75)
  br i1 %76, label %77, label %78

77:                                               ; preds = %71
  store i1 false, ptr %8, align 1
  store i32 1, ptr %18, align 4
  br label %95

78:                                               ; preds = %71
  br label %79

79:                                               ; preds = %78, %66
  %80 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %22, i32 0, i32 2
  %81 = load i32, ptr %80, align 8, !tbaa !26
  %82 = call noundef zeroext i1 @_ZL35VmaIsBufferImageGranularityConflict20VmaSuballocationTypeS_(i32 noundef %81, i32 noundef 5)
  br i1 %82, label %85, label %83

83:                                               ; preds = %79
  %84 = load ptr, ptr %13, align 8, !tbaa !5
  store i8 1, ptr %84, align 1, !tbaa !27
  br label %94

85:                                               ; preds = %79
  %86 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %22, i32 0, i32 2
  %87 = load i32, ptr %86, align 8, !tbaa !26
  %88 = call noundef zeroext i1 @_ZL35VmaIsBufferImageGranularityConflict20VmaSuballocationTypeS_(i32 noundef %87, i32 noundef 2)
  br i1 %88, label %91, label %89

89:                                               ; preds = %85
  %90 = load ptr, ptr %14, align 8, !tbaa !5
  store i8 1, ptr %90, align 1, !tbaa !27
  br label %93

91:                                               ; preds = %85
  %92 = load ptr, ptr %15, align 8, !tbaa !5
  store i8 1, ptr %92, align 1, !tbaa !27
  br label %93

93:                                               ; preds = %91, %89
  br label %94

94:                                               ; preds = %93, %83
  store i32 0, ptr %18, align 4
  br label %95

95:                                               ; preds = %94, %77, %64, %63, %56
  call void @llvm.lifetime.end.p0(i64 48, ptr %22) #5
  %96 = load i32, ptr %18, align 4
  switch i32 %96, label %105 [
    i32 0, label %97
    i32 6, label %98
  ]

97:                                               ; preds = %95
  br label %98

98:                                               ; preds = %97, %95
  %99 = load ptr, ptr %20, align 8, !tbaa !5
  %100 = load ptr, ptr %21, align 8, !tbaa !5
  %101 = load ptr, ptr %99, align 8, !tbaa !20
  %102 = getelementptr inbounds ptr, ptr %101, i64 12
  %103 = load ptr, ptr %102, align 8
  %104 = call noundef ptr %103(ptr noundef nonnull align 8 dereferenceable(33) %99, ptr noundef %100)
  store ptr %104, ptr %21, align 8, !tbaa !5
  br label %44, !llvm.loop !29

105:                                              ; preds = %95, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  %106 = load i32, ptr %18, align 4
  switch i32 %106, label %108 [
    i32 4, label %107
  ]

107:                                              ; preds = %105
  store i32 0, ptr %18, align 4
  br label %108

108:                                              ; preds = %107, %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  %109 = load i32, ptr %18, align 4
  switch i32 %109, label %111 [
    i32 0, label %110
  ]

110:                                              ; preds = %108
  br label %27, !llvm.loop !31

111:                                              ; preds = %108, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  %112 = load i32, ptr %18, align 4
  switch i32 %112, label %118 [
    i32 2, label %113
  ]

113:                                              ; preds = %111
  %114 = load i64, ptr %16, align 8, !tbaa !11
  %115 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %23, i32 0, i32 5
  %116 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %115)
  %117 = icmp eq i64 %114, %116
  store i1 %117, ptr %8, align 1
  store i32 1, ptr %18, align 4
  br label %118

118:                                              ; preds = %113, %111
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %119 = load i1, ptr %8, align 1
  ret i1 %119
}

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 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 #3 = { inlinehint 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"_ZTS20VmaSuballocationType", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS20VmaDeviceMemoryBlock", !6, i64 0, !6, i64 8, !15, i64 16, !15, i64 20, !6, i64 24, !16, i64 32, !19, i64 72, !15, i64 84, !6, i64 88}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS8VmaMutex", !17, i64 0}
!17 = !{!"_ZTSSt5mutex", !18, i64 0}
!18 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!19 = !{!"_ZTS20VmaMappingHysteresis", !15, i64 0, !15, i64 4, !15, i64 8}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !8, i64 0}
!22 = !{!23, !6, i64 32}
!23 = !{!"_ZTSN27VmaDefragmentationContext_T18MoveAllocationDataE", !12, i64 0, !12, i64 8, !10, i64 16, !15, i64 20, !24, i64 24}
!24 = !{!"_ZTS22VmaDefragmentationMove", !25, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!"_ZTS31VmaDefragmentationMoveOperation", !7, i64 0}
!26 = !{!23, !10, i64 16}
!27 = !{!28, !28, i64 0}
!28 = !{!"bool", !7, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = distinct !{!31, !30}


; 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.VmaDefragmentationContext_T::MoveAllocationData" = type { i64, i64, i32, i32, %struct.VmaDefragmentationMove }
%struct.VmaDefragmentationMove = type { i32, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T20MoveDataToFreeBlocksE20VmaSuballocationTypeR14VmaBlockVectormRbS3_S3_ = external hidden unnamed_addr constant [127 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK15VmaAllocation_T7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK15VmaAllocation_T11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL35VmaIsBufferImageGranularityConflict20VmaSuballocationTypeS_(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK14VmaBlockVector13GetBlockCountEv(ptr noundef nonnull align 8 dereferenceable(181)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14VmaBlockVector8GetBlockEm(ptr noundef nonnull align 8 dereferenceable(181), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN27VmaDefragmentationContext_T11GetMoveDataEP16VmaAllocHandle_TP16VmaBlockMetadata(ptr dead_on_unwind noalias writable sret(%"struct.VmaDefragmentationContext_T::MoveAllocationData") align 8, ptr noundef, ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN27VmaDefragmentationContext_T13CheckCountersEm(ptr noundef nonnull align 8 dereferenceable(168), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17AllocInOtherBlockEmmRNS_18MoveAllocationDataER14VmaBlockVector(ptr noundef nonnull align 8 dereferenceable(168), i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(181)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN27VmaDefragmentationContext_T20MoveDataToFreeBlocksE20VmaSuballocationTypeR14VmaBlockVectormRbS3_S3_(ptr noundef nonnull align 8 dereferenceable(168) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(181) %2, i64 noundef %3, ptr nocapture noundef nonnull writeonly align 1 dereferenceable(1) %4, ptr nocapture noundef nonnull writeonly align 1 dereferenceable(1) %5, ptr nocapture noundef nonnull writeonly align 1 dereferenceable(1) %6) local_unnamed_addr #4 align 2 {
  %8 = alloca %"struct.VmaDefragmentationContext_T::MoveAllocationData", align 8
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = tail call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %.not45 = icmp eq i64 %3, 0
  br i1 %.not45, label %.thread41, label %.lr.ph47

.lr.ph47:                                         ; preds = %7
  %11 = getelementptr inbounds i8, ptr %8, i64 32
  %12 = getelementptr inbounds i8, ptr %8, i64 16
  br label %13

.loopexit:                                        ; preds = %41, %13
  %.not = icmp eq i64 %14, 0
  br i1 %.not, label %.thread41, label %13

13:                                               ; preds = %.lr.ph47, %.loopexit
  %.02746 = phi i64 [ %3, %.lr.ph47 ], [ %14, %.loopexit ]
  %14 = add i64 %.02746, -1
  %15 = call noundef ptr @_ZNK14VmaBlockVector8GetBlockEm(ptr noundef nonnull align 8 dereferenceable(181) %2, i64 noundef %14)
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %17, i64 88
  %19 = load ptr, ptr %18, align 8
  %20 = call noundef ptr %19(ptr noundef nonnull align 8 dereferenceable(33) %16)
  %.not3243 = icmp eq ptr %20, null
  br i1 %.not3243, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %13, %41
  %.044 = phi ptr [ %45, %41 ], [ %20, %13 ]
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %8) #5
  call void @_ZN27VmaDefragmentationContext_T11GetMoveDataEP16VmaAllocHandle_TP16VmaBlockMetadata(ptr dead_on_unwind nonnull writable sret(%"struct.VmaDefragmentationContext_T::MoveAllocationData") align 8 %8, ptr noundef nonnull %.044, ptr noundef nonnull %16)
  %21 = load ptr, ptr %11, align 8, !tbaa !17
  %22 = call noundef ptr @_ZNK15VmaAllocation_T11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(84) %21)
  %23 = icmp eq ptr %22, %0
  br i1 %23, label %41, label %24

24:                                               ; preds = %.lr.ph
  %25 = load ptr, ptr %11, align 8, !tbaa !17
  %26 = call noundef i64 @_ZNK15VmaAllocation_T7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(84) %25)
  %27 = call noundef i32 @_ZN27VmaDefragmentationContext_T13CheckCountersEm(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %26)
  switch i32 %27, label %28 [
    i32 1, label %41
    i32 2, label %46
    i32 0, label %29
  ]

28:                                               ; preds = %24
  call void @__assert_fail(ptr noundef nonnull @.str.57, ptr noundef nonnull @.str.2, i32 noundef 13997, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T20MoveDataToFreeBlocksE20VmaSuballocationTypeR14VmaBlockVectormRbS3_S3_) #6
  unreachable

29:                                               ; preds = %24
  %30 = load i32, ptr %12, align 8, !tbaa !23
  %31 = call noundef zeroext i1 @_ZL35VmaIsBufferImageGranularityConflict20VmaSuballocationTypeS_(i32 noundef %30, i32 noundef %1)
  br i1 %31, label %35, label %32

32:                                               ; preds = %29
  %33 = call noundef i64 @_ZNK14VmaBlockVector13GetBlockCountEv(ptr noundef nonnull align 8 dereferenceable(181) %2)
  %34 = call noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17AllocInOtherBlockEmmRNS_18MoveAllocationDataER14VmaBlockVector(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %3, i64 noundef %33, ptr noundef nonnull align 8 dereferenceable(48) %8, ptr noundef nonnull align 8 dereferenceable(181) %2)
  br i1 %34, label %46, label %35

35:                                               ; preds = %32, %29
  %36 = load i32, ptr %12, align 8, !tbaa !23
  %37 = call noundef zeroext i1 @_ZL35VmaIsBufferImageGranularityConflict20VmaSuballocationTypeS_(i32 noundef %36, i32 noundef 5)
  br i1 %37, label %38, label %.sink.split

38:                                               ; preds = %35
  %39 = load i32, ptr %12, align 8, !tbaa !23
  %40 = call noundef zeroext i1 @_ZL35VmaIsBufferImageGranularityConflict20VmaSuballocationTypeS_(i32 noundef %39, i32 noundef 2)
  %. = select i1 %40, ptr %6, ptr %5
  br label %.sink.split

.sink.split:                                      ; preds = %38, %35
  %.sink = phi ptr [ %4, %35 ], [ %., %38 ]
  store i8 1, ptr %.sink, align 1, !tbaa !24
  br label %41

41:                                               ; preds = %.sink.split, %.lr.ph, %24
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %8) #5
  %42 = load ptr, ptr %16, align 8, !tbaa !15
  %43 = getelementptr inbounds i8, ptr %42, i64 96
  %44 = load ptr, ptr %43, align 8
  %45 = call noundef ptr %44(ptr noundef nonnull align 8 dereferenceable(33) %16, ptr noundef nonnull %.044)
  %.not32 = icmp eq ptr %45, null
  br i1 %.not32, label %.loopexit, label %.lr.ph, !llvm.loop !26

46:                                               ; preds = %24, %32
  %.2 = phi i1 [ false, %32 ], [ true, %24 ]
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %8) #5
  br label %49

.thread41:                                        ; preds = %.loopexit, %7
  %47 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %48 = icmp eq i64 %10, %47
  br label %49

49:                                               ; preds = %46, %.thread41
  %.5 = phi i1 [ %48, %.thread41 ], [ %.2, %46 ]
  ret i1 %.5
}

attributes #0 = { mustprogress 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 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 #3 = { inlinehint 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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 0}
!6 = !{!"_ZTS20VmaDeviceMemoryBlock", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !11, i64 32, !14, i64 72, !10, i64 84, !7, i64 88}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS8VmaMutex", !12, i64 0}
!12 = !{!"_ZTSSt5mutex", !13, i64 0}
!13 = !{!"_ZTSSt12__mutex_base", !8, i64 0}
!14 = !{!"_ZTS20VmaMappingHysteresis", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !9, i64 0}
!17 = !{!18, !7, i64 32}
!18 = !{!"_ZTSN27VmaDefragmentationContext_T18MoveAllocationDataE", !19, i64 0, !19, i64 8, !20, i64 16, !10, i64 20, !21, i64 24}
!19 = !{!"long", !8, i64 0}
!20 = !{!"_ZTS20VmaSuballocationType", !8, i64 0}
!21 = !{!"_ZTS22VmaDefragmentationMove", !22, i64 0, !7, i64 8, !7, i64 16}
!22 = !{!"_ZTS31VmaDefragmentationMoveOperation", !8, i64 0}
!23 = !{!18, !20, i64 16}
!24 = !{!25, !25, i64 0}
!25 = !{!"bool", !8, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass