; 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.VmaAllocationRequest = type <{ ptr, i64, %"class.VmaList<VmaSuballocation, VmaStlAllocator<VmaSuballocation>>::iterator", ptr, i64, i32, [4 x i8] }>
%"class.VmaList<VmaSuballocation, VmaStlAllocator<VmaSuballocation>>::iterator" = type { 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 }
%"struct.VmaDefragmentationContext_T::StateBalanced" = type { i64, i64 }
%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
@.str.192 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb = external hidden unnamed_addr constant [98 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: mustprogress nounwind uwtable
declare dso_local void @_ZN7VmaListI16VmaSuballocation15VmaStlAllocatorIS0_EE8iteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14VmaBlockVector23CommitAllocationRequestER20VmaAllocationRequestP20VmaDeviceMemoryBlockmjPv20VmaSuballocationTypePP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(181), ptr noundef nonnull align 8 dereferenceable(52), ptr noundef, i64 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14VmaBlockVector8GetBlockEm(ptr noundef nonnull align 8 dereferenceable(181), i64 noundef) #3 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
define dso_local noundef zeroext i1 @_ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(181) %1, i64 noundef %2, i1 noundef zeroext %3) #3 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca %"struct.VmaDefragmentationContext_T::MoveAllocationData", align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca %struct.VmaAllocationRequest, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  %24 = zext i1 %3 to i8
  store i8 %24, ptr %9, align 1, !tbaa !11
  %25 = load ptr, ptr %6, align 8
  %26 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %25, i32 0, i32 14
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %4
  br label %32

30:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.192, ptr noundef @.str.2, i32 noundef 13599, ptr noundef @__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb) #4
  unreachable

31:                                               ; No predecessors!
  br label %32

32:                                               ; preds = %31, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %33 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %25, i32 0, i32 14
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::StateBalanced", ptr %34, i64 %35
  store ptr %36, ptr %10, align 8, !tbaa !5
  %37 = load i8, ptr %9, align 1, !tbaa !11, !range !19, !noundef !20
  %38 = trunc i8 %37 to i1
  br i1 %38, label %39, label %47

39:                                               ; preds = %32
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::StateBalanced", ptr %40, i32 0, i32 1
  %42 = load i64, ptr %41, align 8, !tbaa !21
  %43 = icmp eq i64 %42, -1
  br i1 %43, label %44, label %47

44:                                               ; preds = %39
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN27VmaDefragmentationContext_T22UpdateVectorStatisticsER14VmaBlockVectorRNS_13StateBalancedE(ptr noundef nonnull align 8 dereferenceable(168) %25, ptr noundef nonnull align 8 dereferenceable(181) %45, ptr noundef nonnull align 8 dereferenceable(16) %46)
  br label %47

47:                                               ; preds = %44, %39, %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %48 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %25, i32 0, i32 5
  %49 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %48)
  store i64 %49, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::StateBalanced", ptr %50, i32 0, i32 0
  %52 = load i64, ptr %51, align 8, !tbaa !23
  %53 = udiv i64 %52, 2
  store i64 %53, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = call noundef i64 @_ZNK14VmaBlockVector13GetBlockCountEv(ptr noundef nonnull align 8 dereferenceable(181) %54)
  %56 = sub i64 %55, 1
  store i64 %56, ptr %13, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %229, %47
  %58 = load i64, ptr %13, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %25, i32 0, i32 11
  %60 = load i64, ptr %59, align 8, !tbaa !24
  %61 = icmp ugt i64 %58, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %57
  store i32 2, ptr %14, align 4
  br label %232

63:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load i64, ptr %13, align 8, !tbaa !9
  %66 = call noundef ptr @_ZNK14VmaBlockVector8GetBlockEm(ptr noundef nonnull align 8 dereferenceable(181) %64, i64 noundef %65)
  store ptr %66, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  %68 = getelementptr inbounds %class.VmaDeviceMemoryBlock, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !25
  store ptr %69, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store i64 0, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %70 = load ptr, ptr %16, align 8, !tbaa !5
  %71 = load ptr, ptr %70, align 8, !tbaa !31
  %72 = getelementptr inbounds ptr, ptr %71, i64 11
  %73 = load ptr, ptr %72, align 8
  %74 = call noundef ptr %73(ptr noundef nonnull align 8 dereferenceable(33) %70)
  store ptr %74, ptr %18, align 8, !tbaa !5
  br label %75

75:                                               ; preds = %216, %63
  %76 = load ptr, ptr %18, align 8, !tbaa !5
  %77 = icmp ne ptr %76, null
  br i1 %77, label %79, label %78

78:                                               ; preds = %75
  store i32 5, ptr %14, align 4
  br label %223

79:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 48, ptr %19) #5
  %80 = load ptr, ptr %18, align 8, !tbaa !5
  %81 = load ptr, ptr %16, align 8, !tbaa !5
  call void @_ZN27VmaDefragmentationContext_T11GetMoveDataEP16VmaAllocHandle_TP16VmaBlockMetadata(ptr dead_on_unwind writable sret(%"struct.VmaDefragmentationContext_T::MoveAllocationData") align 8 %19, ptr noundef %80, ptr noundef %81)
  %82 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 4
  %83 = getelementptr inbounds %struct.VmaDefragmentationMove, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !33
  %85 = call noundef ptr @_ZNK15VmaAllocation_T11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(84) %84)
  %86 = icmp eq ptr %85, %25
  br i1 %86, label %87, label %88

87:                                               ; preds = %79
  store i32 7, ptr %14, align 4
  br label %213

88:                                               ; preds = %79
  %89 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 4
  %90 = getelementptr inbounds %struct.VmaDefragmentationMove, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !33
  %92 = call noundef i64 @_ZNK15VmaAllocation_T7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(84) %91)
  %93 = call noundef i32 @_ZN27VmaDefragmentationContext_T13CheckCountersEm(ptr noundef nonnull align 8 dereferenceable(168) %25, i64 noundef %92)
  switch i32 %93, label %96 [
    i32 1, label %94
    i32 2, label %95
    i32 0, label %97
  ]

94:                                               ; preds = %88
  store i32 7, ptr %14, align 4
  br label %213

95:                                               ; preds = %88
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %213

96:                                               ; preds = %88
  call void @__assert_fail(ptr noundef @.str.57, ptr noundef @.str.2, i32 noundef 13630, ptr noundef @__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb) #4
  unreachable

97:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %98 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %25, i32 0, i32 5
  %99 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %98)
  store i64 %99, ptr %20, align 8, !tbaa !9
  %100 = load i64, ptr %13, align 8, !tbaa !9
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = call noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17AllocInOtherBlockEmmRNS_18MoveAllocationDataER14VmaBlockVector(ptr noundef nonnull align 8 dereferenceable(168) %25, i64 noundef 0, i64 noundef %100, ptr noundef nonnull align 8 dereferenceable(48) %19, ptr noundef nonnull align 8 dereferenceable(181) %101)
  br i1 %102, label %103, label %104

103:                                              ; preds = %97
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %212

104:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %105 = load ptr, ptr %16, align 8, !tbaa !5
  %106 = load ptr, ptr %18, align 8, !tbaa !5
  %107 = load ptr, ptr %105, align 8, !tbaa !31
  %108 = getelementptr inbounds ptr, ptr %107, i64 13
  %109 = load ptr, ptr %108, align 8
  %110 = call noundef i64 %109(ptr noundef nonnull align 8 dereferenceable(33) %105, ptr noundef %106)
  store i64 %110, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %111 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 4
  %112 = getelementptr inbounds %struct.VmaDefragmentationMove, ptr %111, i32 0, i32 1
  %113 = load ptr, ptr %112, align 8, !tbaa !33
  %114 = call noundef i64 @_ZNK15VmaAllocation_T9GetOffsetEv(ptr noundef nonnull align 8 dereferenceable(84) %113)
  store i64 %114, ptr %22, align 8, !tbaa !9
  %115 = load i64, ptr %20, align 8, !tbaa !9
  %116 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %25, i32 0, i32 5
  %117 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %116)
  %118 = icmp eq i64 %115, %117
  br i1 %118, label %119, label %209

119:                                              ; preds = %104
  %120 = load i64, ptr %22, align 8, !tbaa !9
  %121 = icmp ne i64 %120, 0
  br i1 %121, label %122, label %209

122:                                              ; preds = %119
  %123 = load ptr, ptr %16, align 8, !tbaa !5
  %124 = load ptr, ptr %123, align 8, !tbaa !31
  %125 = getelementptr inbounds ptr, ptr %124, i64 6
  %126 = load ptr, ptr %125, align 8
  %127 = call noundef i64 %126(ptr noundef nonnull align 8 dereferenceable(33) %123)
  %128 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 0
  %129 = load i64, ptr %128, align 8, !tbaa !38
  %130 = icmp uge i64 %127, %129
  br i1 %130, label %131, label %209

131:                                              ; preds = %122
  %132 = load i64, ptr %17, align 8, !tbaa !9
  %133 = load i64, ptr %12, align 8, !tbaa !9
  %134 = icmp uge i64 %132, %133
  br i1 %134, label %153, label %135

135:                                              ; preds = %131
  %136 = load i64, ptr %21, align 8, !tbaa !9
  %137 = load i64, ptr %12, align 8, !tbaa !9
  %138 = icmp uge i64 %136, %137
  br i1 %138, label %153, label %139

139:                                              ; preds = %135
  %140 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 0
  %141 = load i64, ptr %140, align 8, !tbaa !38
  %142 = load ptr, ptr %10, align 8, !tbaa !5
  %143 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::StateBalanced", ptr %142, i32 0, i32 0
  %144 = load i64, ptr %143, align 8, !tbaa !23
  %145 = icmp ule i64 %141, %144
  br i1 %145, label %153, label %146

146:                                              ; preds = %139
  %147 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 0
  %148 = load i64, ptr %147, align 8, !tbaa !38
  %149 = load ptr, ptr %10, align 8, !tbaa !5
  %150 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::StateBalanced", ptr %149, i32 0, i32 1
  %151 = load i64, ptr %150, align 8, !tbaa !21
  %152 = icmp ule i64 %148, %151
  br i1 %152, label %153, label %208

153:                                              ; preds = %146, %139, %135, %131
  call void @llvm.lifetime.start.p0(i64 56, ptr %23) #5
  %154 = getelementptr inbounds %struct.VmaAllocationRequest, ptr %23, i32 0, i32 0
  store ptr null, ptr %154, align 8, !tbaa !39
  %155 = getelementptr inbounds %struct.VmaAllocationRequest, ptr %23, i32 0, i32 1
  store i64 0, ptr %155, align 8, !tbaa !43
  %156 = getelementptr inbounds %struct.VmaAllocationRequest, ptr %23, i32 0, i32 2
  call void @_ZN7VmaListI16VmaSuballocation15VmaStlAllocatorIS0_EE8iteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %156)
  %157 = getelementptr inbounds %struct.VmaAllocationRequest, ptr %23, i32 0, i32 3
  store ptr null, ptr %157, align 8, !tbaa !44
  %158 = getelementptr inbounds %struct.VmaAllocationRequest, ptr %23, i32 0, i32 4
  store i64 0, ptr %158, align 8, !tbaa !45
  %159 = getelementptr inbounds %struct.VmaAllocationRequest, ptr %23, i32 0, i32 5
  store i32 0, ptr %159, align 8, !tbaa !46
  %160 = load ptr, ptr %16, align 8, !tbaa !5
  %161 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 0
  %162 = load i64, ptr %161, align 8, !tbaa !38
  %163 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 1
  %164 = load i64, ptr %163, align 8, !tbaa !47
  %165 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 2
  %166 = load i32, ptr %165, align 8, !tbaa !48
  %167 = load ptr, ptr %160, align 8, !tbaa !31
  %168 = getelementptr inbounds ptr, ptr %167, i64 17
  %169 = load ptr, ptr %168, align 8
  %170 = call noundef zeroext i1 %169(ptr noundef nonnull align 8 dereferenceable(33) %160, i64 noundef %162, i64 noundef %164, i1 noundef zeroext false, i32 noundef %166, i32 noundef 262144, ptr noundef %23)
  br i1 %170, label %171, label %204

171:                                              ; preds = %153
  %172 = load ptr, ptr %16, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.VmaAllocationRequest, ptr %23, i32 0, i32 0
  %174 = load ptr, ptr %173, align 8, !tbaa !39
  %175 = load ptr, ptr %172, align 8, !tbaa !31
  %176 = getelementptr inbounds ptr, ptr %175, i64 9
  %177 = load ptr, ptr %176, align 8
  %178 = call noundef i64 %177(ptr noundef nonnull align 8 dereferenceable(33) %172, ptr noundef %174)
  %179 = load i64, ptr %22, align 8, !tbaa !9
  %180 = icmp ult i64 %178, %179
  br i1 %180, label %181, label %203

181:                                              ; preds = %171
  %182 = load ptr, ptr %7, align 8, !tbaa !5
  %183 = load ptr, ptr %15, align 8, !tbaa !5
  %184 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 1
  %185 = load i64, ptr %184, align 8, !tbaa !47
  %186 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 3
  %187 = load i32, ptr %186, align 4, !tbaa !49
  %188 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 2
  %189 = load i32, ptr %188, align 8, !tbaa !48
  %190 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 4
  %191 = getelementptr inbounds %struct.VmaDefragmentationMove, ptr %190, i32 0, i32 2
  %192 = call noundef i32 @_ZN14VmaBlockVector23CommitAllocationRequestER20VmaAllocationRequestP20VmaDeviceMemoryBlockmjPv20VmaSuballocationTypePP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(181) %182, ptr noundef nonnull align 8 dereferenceable(52) %23, ptr noundef %183, i64 noundef %185, i32 noundef %187, ptr noundef %25, i32 noundef %189, ptr noundef %191)
  %193 = icmp eq i32 %192, 0
  br i1 %193, label %194, label %202

194:                                              ; preds = %181
  %195 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %25, i32 0, i32 5
  %196 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 4
  call void @_ZN9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %195, ptr noundef nonnull align 8 dereferenceable(24) %196)
  %197 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::MoveAllocationData", ptr %19, i32 0, i32 0
  %198 = load i64, ptr %197, align 8, !tbaa !38
  %199 = call noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17IncrementCountersEm(ptr noundef nonnull align 8 dereferenceable(168) %25, i64 noundef %198)
  br i1 %199, label %200, label %201

200:                                              ; preds = %194
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %205

201:                                              ; preds = %194
  br label %202

202:                                              ; preds = %201, %181
  br label %203

203:                                              ; preds = %202, %171
  br label %204

204:                                              ; preds = %203, %153
  store i32 0, ptr %14, align 4
  br label %205

205:                                              ; preds = %204, %200
  call void @llvm.lifetime.end.p0(i64 56, ptr %23) #5
  %206 = load i32, ptr %14, align 4
  switch i32 %206, label %211 [
    i32 0, label %207
  ]

207:                                              ; preds = %205
  br label %208

208:                                              ; preds = %207, %146
  br label %209

209:                                              ; preds = %208, %122, %119, %104
  %210 = load i64, ptr %21, align 8, !tbaa !9
  store i64 %210, ptr %17, align 8, !tbaa !9
  store i32 0, ptr %14, align 4
  br label %211

211:                                              ; preds = %209, %205
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  br label %212

212:                                              ; preds = %211, %103
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  br label %213

213:                                              ; preds = %212, %95, %94, %87
  call void @llvm.lifetime.end.p0(i64 48, ptr %19) #5
  %214 = load i32, ptr %14, align 4
  switch i32 %214, label %223 [
    i32 0, label %215
    i32 7, label %216
  ]

215:                                              ; preds = %213
  br label %216

216:                                              ; preds = %215, %213
  %217 = load ptr, ptr %16, align 8, !tbaa !5
  %218 = load ptr, ptr %18, align 8, !tbaa !5
  %219 = load ptr, ptr %217, align 8, !tbaa !31
  %220 = getelementptr inbounds ptr, ptr %219, i64 12
  %221 = load ptr, ptr %220, align 8
  %222 = call noundef ptr %221(ptr noundef nonnull align 8 dereferenceable(33) %217, ptr noundef %218)
  store ptr %222, ptr %18, align 8, !tbaa !5
  br label %75, !llvm.loop !50

223:                                              ; preds = %213, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %224 = load i32, ptr %14, align 4
  switch i32 %224, label %226 [
    i32 5, label %225
  ]

225:                                              ; preds = %223
  store i32 0, ptr %14, align 4
  br label %226

226:                                              ; preds = %225, %223
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  %227 = load i32, ptr %14, align 4
  switch i32 %227, label %232 [
    i32 0, label %228
  ]

228:                                              ; preds = %226
  br label %229

229:                                              ; preds = %228
  %230 = load i64, ptr %13, align 8, !tbaa !9
  %231 = add i64 %230, -1
  store i64 %231, ptr %13, align 8, !tbaa !9
  br label %57, !llvm.loop !52

232:                                              ; preds = %226, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  %233 = load i32, ptr %14, align 4
  switch i32 %233, label %249 [
    i32 2, label %234
  ]

234:                                              ; preds = %232
  %235 = load i64, ptr %11, align 8, !tbaa !9
  %236 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %25, i32 0, i32 5
  %237 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %236)
  %238 = icmp eq i64 %235, %237
  br i1 %238, label %239, label %248

239:                                              ; preds = %234
  %240 = load i8, ptr %9, align 1, !tbaa !11, !range !19, !noundef !20
  %241 = trunc i8 %240 to i1
  br i1 %241, label %248, label %242

242:                                              ; preds = %239
  %243 = load ptr, ptr %10, align 8, !tbaa !5
  %244 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::StateBalanced", ptr %243, i32 0, i32 1
  store i64 -1, ptr %244, align 8, !tbaa !21
  %245 = load ptr, ptr %7, align 8, !tbaa !5
  %246 = load i64, ptr %8, align 8, !tbaa !9
  %247 = call noundef zeroext i1 @_ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb(ptr noundef nonnull align 8 dereferenceable(168) %25, ptr noundef nonnull align 8 dereferenceable(181) %245, i64 noundef %246, i1 noundef zeroext false)
  store i1 %247, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %249

248:                                              ; preds = %239, %234
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %249

249:                                              ; preds = %248, %242, %232
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %250 = load i1, ptr %5, align 1
  ret i1 %250
}

; 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) #3 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24)) #3 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)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN27VmaDefragmentationContext_T22UpdateVectorStatisticsER14VmaBlockVectorRNS_13StateBalancedE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(181), ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

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 = { 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 #4 = { noreturn nounwind }
attributes #5 = { 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 = !{!14, !6, i64 160}
!14 = !{!"_ZTS27VmaDefragmentationContext_T", !10, i64 0, !15, i64 8, !6, i64 16, !6, i64 24, !16, i64 32, !17, i64 40, !7, i64 72, !15, i64 76, !15, i64 80, !6, i64 88, !6, i64 96, !10, i64 104, !18, i64 112, !18, i64 136, !6, i64 160}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS15VmaStlAllocatorI22VmaDefragmentationMoveE", !6, i64 0}
!17 = !{!"_ZTS9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE", !16, i64 0, !6, i64 8, !10, i64 16, !10, i64 24}
!18 = !{!"_ZTS23VmaDefragmentationStats", !10, i64 0, !10, i64 8, !15, i64 16, !15, i64 20}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!22, !10, i64 8}
!22 = !{!"_ZTSN27VmaDefragmentationContext_T13StateBalancedE", !10, i64 0, !10, i64 8}
!23 = !{!22, !10, i64 0}
!24 = !{!14, !10, i64 104}
!25 = !{!26, !6, i64 0}
!26 = !{!"_ZTS20VmaDeviceMemoryBlock", !6, i64 0, !6, i64 8, !15, i64 16, !15, i64 20, !6, i64 24, !27, i64 32, !30, i64 72, !15, i64 84, !6, i64 88}
!27 = !{!"_ZTS8VmaMutex", !28, i64 0}
!28 = !{!"_ZTSSt5mutex", !29, i64 0}
!29 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!30 = !{!"_ZTS20VmaMappingHysteresis", !15, i64 0, !15, i64 4, !15, i64 8}
!31 = !{!32, !32, i64 0}
!32 = !{!"vtable pointer", !8, i64 0}
!33 = !{!34, !6, i64 32}
!34 = !{!"_ZTSN27VmaDefragmentationContext_T18MoveAllocationDataE", !10, i64 0, !10, i64 8, !35, i64 16, !15, i64 20, !36, i64 24}
!35 = !{!"_ZTS20VmaSuballocationType", !7, i64 0}
!36 = !{!"_ZTS22VmaDefragmentationMove", !37, i64 0, !6, i64 8, !6, i64 16}
!37 = !{!"_ZTS31VmaDefragmentationMoveOperation", !7, i64 0}
!38 = !{!34, !10, i64 0}
!39 = !{!40, !6, i64 0}
!40 = !{!"_ZTS20VmaAllocationRequest", !6, i64 0, !10, i64 8, !41, i64 16, !6, i64 32, !10, i64 40, !42, i64 48}
!41 = !{!"_ZTSN7VmaListI16VmaSuballocation15VmaStlAllocatorIS0_EE8iteratorE", !6, i64 0, !6, i64 8}
!42 = !{!"_ZTS24VmaAllocationRequestType", !7, i64 0}
!43 = !{!40, !10, i64 8}
!44 = !{!40, !6, i64 32}
!45 = !{!40, !10, i64 40}
!46 = !{!40, !42, i64 48}
!47 = !{!34, !10, i64 8}
!48 = !{!34, !35, i64 16}
!49 = !{!34, !15, i64 20}
!50 = distinct !{!50, !51}
!51 = !{!"llvm.loop.mustprogress"}
!52 = distinct !{!52, !51}


; 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 }
%struct.VmaAllocationRequest = type <{ ptr, i64, %"class.VmaList<VmaSuballocation, VmaStlAllocator<VmaSuballocation>>::iterator", ptr, i64, i32, [4 x i8] }>
%"class.VmaList<VmaSuballocation, VmaStlAllocator<VmaSuballocation>>::iterator" = type { ptr, ptr }
%"struct.VmaDefragmentationContext_T::StateBalanced" = type { i64, i64 }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.192 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb = external hidden unnamed_addr constant [98 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: mustprogress nounwind uwtable
declare dso_local void @_ZN7VmaListI16VmaSuballocation15VmaStlAllocatorIS0_EE8iteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN14VmaBlockVector23CommitAllocationRequestER20VmaAllocationRequestP20VmaDeviceMemoryBlockmjPv20VmaSuballocationTypePP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(181), ptr noundef nonnull align 8 dereferenceable(52), ptr noundef, i64 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14VmaBlockVector8GetBlockEm(ptr noundef nonnull align 8 dereferenceable(181), i64 noundef) local_unnamed_addr #3 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
define dso_local noundef zeroext i1 @_ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(181) %1, i64 noundef %2, i1 noundef zeroext %3) local_unnamed_addr #3 align 2 {
  %5 = alloca %"struct.VmaDefragmentationContext_T::MoveAllocationData", align 8
  %6 = alloca %struct.VmaAllocationRequest, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 160
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.192, ptr noundef nonnull @.str.2, i32 noundef 13599, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb) #5
  unreachable

10:                                               ; preds = %4
  %11 = getelementptr inbounds %"struct.VmaDefragmentationContext_T::StateBalanced", ptr %8, i64 %2
  br i1 %3, label %12, label %17

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %11, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !15
  %15 = icmp eq i64 %14, -1
  br i1 %15, label %16, label %17

16:                                               ; preds = %12
  tail call void @_ZN27VmaDefragmentationContext_T22UpdateVectorStatisticsER14VmaBlockVectorRNS_13StateBalancedE(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(181) %1, ptr noundef nonnull align 8 dereferenceable(16) %11)
  br label %17

17:                                               ; preds = %16, %12, %10
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = tail call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %18)
  %20 = load i64, ptr %11, align 8, !tbaa !17
  %21 = lshr i64 %20, 1
  %22 = tail call noundef i64 @_ZNK14VmaBlockVector13GetBlockCountEv(ptr noundef nonnull align 8 dereferenceable(181) %1)
  %23 = getelementptr inbounds i8, ptr %0, i64 104
  %.05292 = add i64 %22, -1
  %24 = load i64, ptr %23, align 8, !tbaa !18
  %25 = icmp ugt i64 %.05292, %24
  br i1 %25, label %.lr.ph94, label %._crit_edge

.lr.ph94:                                         ; preds = %17
  %26 = getelementptr inbounds i8, ptr %5, i64 24
  %27 = getelementptr inbounds i8, ptr %5, i64 32
  %28 = getelementptr inbounds i8, ptr %11, i64 8
  %29 = getelementptr inbounds i8, ptr %6, i64 16
  %30 = getelementptr inbounds i8, ptr %6, i64 32
  %31 = getelementptr inbounds i8, ptr %5, i64 8
  %32 = getelementptr inbounds i8, ptr %5, i64 16
  %33 = getelementptr inbounds i8, ptr %5, i64 20
  %34 = getelementptr inbounds i8, ptr %5, i64 40
  br label %37

.loopexit:                                        ; preds = %101, %37
  %.052 = add i64 %.05293, -1
  %35 = load i64, ptr %23, align 8, !tbaa !18
  %36 = icmp ugt i64 %.052, %35
  br i1 %36, label %37, label %._crit_edge, !llvm.loop !19

37:                                               ; preds = %.lr.ph94, %.loopexit
  %.05293 = phi i64 [ %.05292, %.lr.ph94 ], [ %.052, %.loopexit ]
  %38 = call noundef ptr @_ZNK14VmaBlockVector8GetBlockEm(ptr noundef nonnull align 8 dereferenceable(181) %1, i64 noundef %.05293)
  %39 = load ptr, ptr %38, align 8, !tbaa !21
  %40 = load ptr, ptr %39, align 8, !tbaa !27
  %41 = getelementptr inbounds i8, ptr %40, i64 88
  %42 = load ptr, ptr %41, align 8
  %43 = call noundef ptr %42(ptr noundef nonnull align 8 dereferenceable(33) %39)
  %.not6989 = icmp eq ptr %43, null
  br i1 %.not6989, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %37, %101
  %.05991 = phi ptr [ %105, %101 ], [ %43, %37 ]
  %.06090 = phi i64 [ %.363.ph, %101 ], [ 0, %37 ]
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #6
  call void @_ZN27VmaDefragmentationContext_T11GetMoveDataEP16VmaAllocHandle_TP16VmaBlockMetadata(ptr dead_on_unwind nonnull writable sret(%"struct.VmaDefragmentationContext_T::MoveAllocationData") align 8 %5, ptr noundef nonnull %.05991, ptr noundef nonnull %39)
  %44 = load ptr, ptr %27, align 8, !tbaa !29
  %45 = call noundef ptr @_ZNK15VmaAllocation_T11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(84) %44)
  %46 = icmp eq ptr %45, %0
  br i1 %46, label %101, label %47

47:                                               ; preds = %.lr.ph
  %48 = load ptr, ptr %27, align 8, !tbaa !29
  %49 = call noundef i64 @_ZNK15VmaAllocation_T7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(84) %48)
  %50 = call noundef i32 @_ZN27VmaDefragmentationContext_T13CheckCountersEm(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %49)
  switch i32 %50, label %51 [
    i32 1, label %101
    i32 2, label %.loopexit88
    i32 0, label %52
  ]

51:                                               ; preds = %47
  call void @__assert_fail(ptr noundef nonnull @.str.57, ptr noundef nonnull @.str.2, i32 noundef 13630, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb) #5
  unreachable

52:                                               ; preds = %47
  %53 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %18)
  %54 = call noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17AllocInOtherBlockEmmRNS_18MoveAllocationDataER14VmaBlockVector(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef 0, i64 noundef %.05293, ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(181) %1)
  br i1 %54, label %.loopexit88, label %55

55:                                               ; preds = %52
  %56 = load ptr, ptr %39, align 8, !tbaa !27
  %57 = getelementptr inbounds i8, ptr %56, i64 104
  %58 = load ptr, ptr %57, align 8
  %59 = call noundef i64 %58(ptr noundef nonnull align 8 dereferenceable(33) %39, ptr noundef nonnull %.05991)
  %60 = load ptr, ptr %27, align 8, !tbaa !29
  %61 = call noundef i64 @_ZNK15VmaAllocation_T9GetOffsetEv(ptr noundef nonnull align 8 dereferenceable(84) %60)
  %62 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %18)
  %63 = icmp eq i64 %53, %62
  %64 = icmp ne i64 %61, 0
  %or.cond = and i1 %64, %63
  br i1 %or.cond, label %65, label %101

65:                                               ; preds = %55
  %66 = load ptr, ptr %39, align 8, !tbaa !27
  %67 = getelementptr inbounds i8, ptr %66, i64 48
  %68 = load ptr, ptr %67, align 8
  %69 = call noundef i64 %68(ptr noundef nonnull align 8 dereferenceable(33) %39)
  %70 = load i64, ptr %5, align 8, !tbaa !34
  %.not70 = icmp ult i64 %69, %70
  br i1 %.not70, label %101, label %71

71:                                               ; preds = %65
  %.not71 = icmp ult i64 %.06090, %21
  %.not72 = icmp ult i64 %59, %21
  %or.cond75 = and i1 %.not71, %.not72
  br i1 %or.cond75, label %72, label %76

72:                                               ; preds = %71
  %73 = load i64, ptr %11, align 8, !tbaa !17
  %.not73 = icmp ugt i64 %70, %73
  br i1 %.not73, label %74, label %76

74:                                               ; preds = %72
  %75 = load i64, ptr %28, align 8, !tbaa !15
  %.not74 = icmp ugt i64 %70, %75
  br i1 %.not74, label %101, label %76

76:                                               ; preds = %74, %72, %71
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %6) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, i8 0, i64 16, i1 false)
  call void @_ZN7VmaListI16VmaSuballocation15VmaStlAllocatorIS0_EE8iteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %29)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %30, i8 0, i64 20, i1 false)
  %77 = load i64, ptr %5, align 8, !tbaa !34
  %78 = load i64, ptr %31, align 8, !tbaa !35
  %79 = load i32, ptr %32, align 8, !tbaa !36
  %80 = load ptr, ptr %39, align 8, !tbaa !27
  %81 = getelementptr inbounds i8, ptr %80, i64 136
  %82 = load ptr, ptr %81, align 8
  %83 = call noundef zeroext i1 %82(ptr noundef nonnull align 8 dereferenceable(33) %39, i64 noundef %77, i64 noundef %78, i1 noundef zeroext false, i32 noundef %79, i32 noundef 262144, ptr noundef nonnull %6)
  br i1 %83, label %84, label %.critedge

84:                                               ; preds = %76
  %85 = load ptr, ptr %6, align 8, !tbaa !37
  %86 = load ptr, ptr %39, align 8, !tbaa !27
  %87 = getelementptr inbounds i8, ptr %86, i64 72
  %88 = load ptr, ptr %87, align 8
  %89 = call noundef i64 %88(ptr noundef nonnull align 8 dereferenceable(33) %39, ptr noundef %85)
  %90 = icmp ult i64 %89, %61
  br i1 %90, label %91, label %.critedge

91:                                               ; preds = %84
  %92 = load i64, ptr %31, align 8, !tbaa !35
  %93 = load i32, ptr %33, align 4, !tbaa !41
  %94 = load i32, ptr %32, align 8, !tbaa !36
  %95 = call noundef i32 @_ZN14VmaBlockVector23CommitAllocationRequestER20VmaAllocationRequestP20VmaDeviceMemoryBlockmjPv20VmaSuballocationTypePP15VmaAllocation_T(ptr noundef nonnull align 8 dereferenceable(181) %1, ptr noundef nonnull align 8 dereferenceable(52) %6, ptr noundef nonnull %38, i64 noundef %92, i32 noundef %93, ptr noundef nonnull %0, i32 noundef %94, ptr noundef nonnull %34)
  %96 = icmp eq i32 %95, 0
  br i1 %96, label %97, label %.critedge

97:                                               ; preds = %91
  call void @_ZN9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %18, ptr noundef nonnull align 8 dereferenceable(24) %26)
  %98 = load i64, ptr %5, align 8, !tbaa !34
  %99 = call noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17IncrementCountersEm(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %98)
  br i1 %99, label %100, label %.critedge

.critedge:                                        ; preds = %84, %97, %91, %76
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %6) #6
  br label %101

100:                                              ; preds = %97
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %6) #6
  br label %.loopexit88

101:                                              ; preds = %.lr.ph, %47, %.critedge, %74, %65, %55
  %.363.ph = phi i64 [ %59, %55 ], [ %59, %65 ], [ %59, %74 ], [ %59, %.critedge ], [ %.06090, %47 ], [ %.06090, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #6
  %102 = load ptr, ptr %39, align 8, !tbaa !27
  %103 = getelementptr inbounds i8, ptr %102, i64 96
  %104 = load ptr, ptr %103, align 8
  %105 = call noundef ptr %104(ptr noundef nonnull align 8 dereferenceable(33) %39, ptr noundef nonnull %.05991)
  %.not69 = icmp eq ptr %105, null
  br i1 %.not69, label %.loopexit, label %.lr.ph, !llvm.loop !42

.loopexit88:                                      ; preds = %47, %52, %100
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #6
  br label %111

._crit_edge:                                      ; preds = %.loopexit, %17
  %106 = call noundef i64 @_ZNK9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %18)
  %107 = icmp ne i64 %19, %106
  %brmerge = or i1 %107, %3
  br i1 %brmerge, label %111, label %108

108:                                              ; preds = %._crit_edge
  %109 = getelementptr inbounds i8, ptr %11, i64 8
  store i64 -1, ptr %109, align 8, !tbaa !15
  %110 = call noundef zeroext i1 @_ZN27VmaDefragmentationContext_T31ComputeDefragmentation_BalancedER14VmaBlockVectormb(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(181) %1, i64 noundef %2, i1 noundef zeroext false)
  br label %111

111:                                              ; preds = %.loopexit88, %._crit_edge, %108
  %.9 = phi i1 [ %110, %108 ], [ true, %.loopexit88 ], [ false, %._crit_edge ]
  ret i1 %.9
}

; 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 #3 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 #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 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 #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN27VmaDefragmentationContext_T22UpdateVectorStatisticsER14VmaBlockVectorRNS_13StateBalancedE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(181), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

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

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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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, !11, i64 160}
!6 = !{!"_ZTS27VmaDefragmentationContext_T", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !13, i64 40, !8, i64 72, !10, i64 76, !10, i64 80, !11, i64 88, !11, i64 96, !7, i64 104, !14, i64 112, !14, i64 136, !11, i64 160}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTS15VmaStlAllocatorI22VmaDefragmentationMoveE", !11, i64 0}
!13 = !{!"_ZTS9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE", !12, i64 0, !11, i64 8, !7, i64 16, !7, i64 24}
!14 = !{!"_ZTS23VmaDefragmentationStats", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20}
!15 = !{!16, !7, i64 8}
!16 = !{!"_ZTSN27VmaDefragmentationContext_T13StateBalancedE", !7, i64 0, !7, i64 8}
!17 = !{!16, !7, i64 0}
!18 = !{!6, !7, i64 104}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !11, i64 0}
!22 = !{!"_ZTS20VmaDeviceMemoryBlock", !11, i64 0, !11, i64 8, !10, i64 16, !10, i64 20, !11, i64 24, !23, i64 32, !26, i64 72, !10, i64 84, !11, i64 88}
!23 = !{!"_ZTS8VmaMutex", !24, i64 0}
!24 = !{!"_ZTSSt5mutex", !25, i64 0}
!25 = !{!"_ZTSSt12__mutex_base", !8, i64 0}
!26 = !{!"_ZTS20VmaMappingHysteresis", !10, i64 0, !10, i64 4, !10, i64 8}
!27 = !{!28, !28, i64 0}
!28 = !{!"vtable pointer", !9, i64 0}
!29 = !{!30, !11, i64 32}
!30 = !{!"_ZTSN27VmaDefragmentationContext_T18MoveAllocationDataE", !7, i64 0, !7, i64 8, !31, i64 16, !10, i64 20, !32, i64 24}
!31 = !{!"_ZTS20VmaSuballocationType", !8, i64 0}
!32 = !{!"_ZTS22VmaDefragmentationMove", !33, i64 0, !11, i64 8, !11, i64 16}
!33 = !{!"_ZTS31VmaDefragmentationMoveOperation", !8, i64 0}
!34 = !{!30, !7, i64 0}
!35 = !{!30, !7, i64 8}
!36 = !{!30, !31, i64 16}
!37 = !{!38, !11, i64 0}
!38 = !{!"_ZTS20VmaAllocationRequest", !11, i64 0, !7, i64 8, !39, i64 16, !11, i64 32, !7, i64 40, !40, i64 48}
!39 = !{!"_ZTSN7VmaListI16VmaSuballocation15VmaStlAllocatorIS0_EE8iteratorE", !11, i64 0, !11, i64 8}
!40 = !{!"_ZTS24VmaAllocationRequestType", !8, i64 0}
!41 = !{!30, !10, i64 20}
!42 = distinct !{!42, !20}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass