; 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 = 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 }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.191 = external hidden unnamed_addr constant [137 x i8], align 1
@__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T17IncrementCountersEm = external hidden unnamed_addr constant [66 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17IncrementCountersEm(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %1) #1 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %4, align 8
  %7 = load i64, ptr %5, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 13
  %9 = getelementptr inbounds %struct.VmaDefragmentationStats, ptr %8, i32 0, i32 0
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = add i64 %10, %7
  store i64 %11, ptr %9, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 13
  %13 = getelementptr inbounds %struct.VmaDefragmentationStats, ptr %12, i32 0, i32 2
  %14 = load i32, ptr %13, align 8, !tbaa !17
  %15 = add i32 %14, 1
  store i32 %15, ptr %13, align 8, !tbaa !17
  %16 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !18
  %18 = icmp uge i32 %15, %17
  br i1 %18, label %26, label %19

19:                                               ; preds = %2
  %20 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 13
  %21 = getelementptr inbounds %struct.VmaDefragmentationStats, ptr %20, i32 0, i32 0
  %22 = load i64, ptr %21, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 0
  %24 = load i64, ptr %23, align 8, !tbaa !19
  %25 = icmp uge i64 %22, %24
  br i1 %25, label %26, label %47

26:                                               ; preds = %19, %2
  %27 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 13
  %28 = getelementptr inbounds %struct.VmaDefragmentationStats, ptr %27, i32 0, i32 2
  %29 = load i32, ptr %28, align 8, !tbaa !17
  %30 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 1
  %31 = load i32, ptr %30, align 8, !tbaa !18
  %32 = icmp eq i32 %29, %31
  br i1 %32, label %40, label %33

33:                                               ; preds = %26
  %34 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 13
  %35 = getelementptr inbounds %struct.VmaDefragmentationStats, ptr %34, i32 0, i32 0
  %36 = load i64, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.VmaDefragmentationContext_T, ptr %6, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !19
  %39 = icmp eq i64 %36, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %33, %26
  br label %41

41:                                               ; preds = %40, %33
  %42 = phi i1 [ false, %33 ], [ true, %40 ]
  br i1 %42, label %43, label %44

43:                                               ; preds = %41
  br label %46

44:                                               ; preds = %41
  call void @__assert_fail(ptr noundef @.str.191, ptr noundef @.str.2, i32 noundef 13467, ptr noundef @__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T17IncrementCountersEm) #2
  unreachable

45:                                               ; No predecessors!
  br label %46

46:                                               ; preds = %45, %43
  store i1 true, ptr %3, align 1
  br label %48

47:                                               ; preds = %19
  store i1 false, ptr %3, align 1
  br label %48

48:                                               ; preds = %47, %46
  %49 = load i1, ptr %3, align 1
  ret i1 %49
}

attributes #0 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 136}
!12 = !{!"_ZTS27VmaDefragmentationContext_T", !10, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !15, i64 40, !7, i64 72, !13, i64 76, !13, i64 80, !6, i64 88, !6, i64 96, !10, i64 104, !16, i64 112, !16, i64 136, !6, i64 160}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS15VmaStlAllocatorI22VmaDefragmentationMoveE", !6, i64 0}
!15 = !{!"_ZTS9VmaVectorI22VmaDefragmentationMove15VmaStlAllocatorIS0_EE", !14, i64 0, !6, i64 8, !10, i64 16, !10, i64 24}
!16 = !{!"_ZTS23VmaDefragmentationStats", !10, i64 0, !10, i64 8, !13, i64 16, !13, i64 20}
!17 = !{!12, !13, i64 152}
!18 = !{!12, !13, i64 8}
!19 = !{!12, !10, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.191 = external hidden unnamed_addr constant [137 x i8], align 1
@__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T17IncrementCountersEm = external hidden unnamed_addr constant [66 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN27VmaDefragmentationContext_T17IncrementCountersEm(ptr nocapture noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 136
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = add i64 %4, %1
  store i64 %5, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 152
  %7 = load i32, ptr %6, align 8, !tbaa !15
  %8 = add i32 %7, 1
  store i32 %8, ptr %6, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !16
  %.not = icmp uge i32 %8, %10
  %11 = load i64, ptr %0, align 8
  %.not2 = icmp uge i64 %5, %11
  %or.cond.not = select i1 %.not, i1 true, i1 %.not2
  br i1 %or.cond.not, label %12, label %15

12:                                               ; preds = %2
  %13 = icmp eq i32 %8, %10
  %14 = icmp eq i64 %5, %11
  %or.cond4 = select i1 %13, i1 true, i1 %14
  br i1 %or.cond4, label %15, label %.critedge

.critedge:                                        ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.191, ptr noundef nonnull @.str.2, i32 noundef 13467, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN27VmaDefragmentationContext_T17IncrementCountersEm) #2
  unreachable

15:                                               ; preds = %2, %12
  ret i1 %or.cond.not
}

attributes #0 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 136}
!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 = !{!6, !10, i64 152}
!16 = !{!6, !10, i64 8}


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