; LLVM IR from khushmmehta/Scorch-V :: src/ScorchVkEngine/Abstractions (VulkanMemoryAllocator)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.VmaBlockMetadata_Linear = type { %class.VmaBlockMetadata.base, i64, %class.VmaVector.2, %class.VmaVector.2, i32, i32, i64, i64, i64 }
%class.VmaBlockMetadata.base = type <{ ptr, i64, ptr, i64, i8 }>
%class.VmaVector.2 = type { %struct.VmaStlAllocator.3, ptr, i64, i64 }
%struct.VmaStlAllocator.3 = type { ptr }
%struct.VmaSuballocation = type { i64, i64, ptr, i32 }

; 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: mustprogress uwtable
declare dso_local void @_ZNK16VmaBlockMetadata18DebugLogAllocationEmmPv(ptr noundef nonnull align 8 dereferenceable(33), i64 noundef, i64 noundef, ptr noundef) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK23VmaBlockMetadata_Linear22DebugLogAllAllocationsEv(ptr noundef nonnull align 8 dereferenceable(144) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %8 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK23VmaBlockMetadata_Linear23AccessSuballocations1stEv(ptr noundef nonnull align 8 dereferenceable(144) %7)
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %11 = getelementptr inbounds %class.VmaBlockMetadata_Linear, ptr %7, i32 0, i32 6
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds %struct.VmaSuballocation, ptr %10, i64 %12
  store ptr %13, ptr %4, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %36, %1
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(32) %16)
  %18 = icmp ne ptr %15, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %39

20:                                               ; preds = %14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.VmaSuballocation, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 8, !tbaa !18
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %35

25:                                               ; preds = %20
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.VmaSuballocation, ptr %26, i32 0, i32 0
  %28 = load i64, ptr %27, align 8, !tbaa !21
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.VmaSuballocation, ptr %29, i32 0, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !22
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.VmaSuballocation, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !23
  call void @_ZNK16VmaBlockMetadata18DebugLogAllocationEmmPv(ptr noundef nonnull align 8 dereferenceable(33) %7, i64 noundef %28, i64 noundef %31, ptr noundef %34)
  br label %35

35:                                               ; preds = %25, %20
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.VmaSuballocation, ptr %37, i32 1
  store ptr %38, ptr %4, align 8, !tbaa !5
  br label %14, !llvm.loop !24

39:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %40 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK23VmaBlockMetadata_Linear23AccessSuballocations2ndEv(ptr noundef nonnull align 8 dereferenceable(144) %7)
  store ptr %40, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(32) %41)
  store ptr %42, ptr %6, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %65, %39
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(32) %45)
  %47 = icmp ne ptr %44, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %68

49:                                               ; preds = %43
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.VmaSuballocation, ptr %50, i32 0, i32 3
  %52 = load i32, ptr %51, align 8, !tbaa !18
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %64

54:                                               ; preds = %49
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.VmaSuballocation, ptr %55, i32 0, i32 0
  %57 = load i64, ptr %56, align 8, !tbaa !21
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.VmaSuballocation, ptr %58, i32 0, i32 1
  %60 = load i64, ptr %59, align 8, !tbaa !22
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.VmaSuballocation, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !23
  call void @_ZNK16VmaBlockMetadata18DebugLogAllocationEmmPv(ptr noundef nonnull align 8 dereferenceable(33) %7, i64 noundef %57, i64 noundef %60, ptr noundef %63)
  br label %64

64:                                               ; preds = %54, %49
  br label %65

65:                                               ; preds = %64
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.VmaSuballocation, ptr %66, i32 1
  store ptr %67, ptr %6, align 8, !tbaa !5
  br label %43, !llvm.loop !26

68:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { 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, !12, i64 120}
!10 = !{!"_ZTS23VmaBlockMetadata_Linear", !11, i64 0, !12, i64 40, !14, i64 48, !14, i64 80, !16, i64 112, !17, i64 116, !12, i64 120, !12, i64 128, !12, i64 136}
!11 = !{!"_ZTS16VmaBlockMetadata", !12, i64 8, !6, i64 16, !12, i64 24, !13, i64 32}
!12 = !{!"long", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE", !15, i64 0, !6, i64 8, !12, i64 16, !12, i64 24}
!15 = !{!"_ZTS15VmaStlAllocatorI16VmaSuballocationE", !6, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTSN23VmaBlockMetadata_Linear18SECOND_VECTOR_MODEE", !7, i64 0}
!18 = !{!19, !20, i64 24}
!19 = !{!"_ZTS16VmaSuballocation", !12, i64 0, !12, i64 8, !6, i64 16, !20, i64 24}
!20 = !{!"_ZTS20VmaSuballocationType", !7, i64 0}
!21 = !{!19, !12, i64 0}
!22 = !{!19, !12, i64 8}
!23 = !{!19, !6, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}


; 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.VmaSuballocation = type { i64, i64, ptr, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK16VmaBlockMetadata18DebugLogAllocationEmmPv(ptr noundef nonnull align 8 dereferenceable(33), i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK23VmaBlockMetadata_Linear22DebugLogAllAllocationsEv(ptr noundef nonnull align 8 dereferenceable(144) %0) unnamed_addr #0 align 2 {
  %2 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK23VmaBlockMetadata_Linear23AccessSuballocations1stEv(ptr noundef nonnull align 8 dereferenceable(144) %0)
  %3 = tail call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %4 = getelementptr inbounds i8, ptr %0, i64 120
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.VmaSuballocation, ptr %3, i64 %5
  %7 = tail call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %.not21 = icmp eq ptr %6, %7
  br i1 %.not21, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %19, %1
  %8 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK23VmaBlockMetadata_Linear23AccessSuballocations2ndEv(ptr noundef nonnull align 8 dereferenceable(144) %0)
  %9 = tail call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(32) %8)
  %10 = tail call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(32) %8)
  %.not1823 = icmp eq ptr %9, %10
  br i1 %.not1823, label %._crit_edge27, label %.lr.ph26

.lr.ph:                                           ; preds = %1, %19
  %.01722 = phi ptr [ %20, %19 ], [ %6, %1 ]
  %11 = getelementptr inbounds i8, ptr %.01722, i64 24
  %12 = load i32, ptr %11, align 8, !tbaa !17
  %.not20 = icmp eq i32 %12, 0
  br i1 %.not20, label %19, label %13

13:                                               ; preds = %.lr.ph
  %14 = load i64, ptr %.01722, align 8, !tbaa !20
  %15 = getelementptr inbounds i8, ptr %.01722, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !21
  %17 = getelementptr inbounds i8, ptr %.01722, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !22
  tail call void @_ZNK16VmaBlockMetadata18DebugLogAllocationEmmPv(ptr noundef nonnull align 8 dereferenceable(33) %0, i64 noundef %14, i64 noundef %16, ptr noundef %18)
  br label %19

19:                                               ; preds = %.lr.ph, %13
  %20 = getelementptr inbounds i8, ptr %.01722, i64 32
  %21 = tail call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %.not = icmp eq ptr %20, %21
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !23

._crit_edge27:                                    ; preds = %30, %._crit_edge
  ret void

.lr.ph26:                                         ; preds = %._crit_edge, %30
  %.024 = phi ptr [ %31, %30 ], [ %9, %._crit_edge ]
  %22 = getelementptr inbounds i8, ptr %.024, i64 24
  %23 = load i32, ptr %22, align 8, !tbaa !17
  %.not19 = icmp eq i32 %23, 0
  br i1 %.not19, label %30, label %24

24:                                               ; preds = %.lr.ph26
  %25 = load i64, ptr %.024, align 8, !tbaa !20
  %26 = getelementptr inbounds i8, ptr %.024, i64 8
  %27 = load i64, ptr %26, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %.024, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !22
  tail call void @_ZNK16VmaBlockMetadata18DebugLogAllocationEmmPv(ptr noundef nonnull align 8 dereferenceable(33) %0, i64 noundef %25, i64 noundef %27, ptr noundef %29)
  br label %30

30:                                               ; preds = %.lr.ph26, %24
  %31 = getelementptr inbounds i8, ptr %.024, i64 32
  %32 = tail call noundef ptr @_ZNK9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(32) %8)
  %.not18 = icmp eq ptr %31, %32
  br i1 %.not18, label %._crit_edge27, label %.lr.ph26, !llvm.loop !25
}

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

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

attributes #0 = { 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 #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" }

!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, !8, i64 120}
!6 = !{!"_ZTS23VmaBlockMetadata_Linear", !7, i64 0, !8, i64 40, !13, i64 48, !13, i64 80, !15, i64 112, !16, i64 116, !8, i64 120, !8, i64 128, !8, i64 136}
!7 = !{!"_ZTS16VmaBlockMetadata", !8, i64 8, !11, i64 16, !8, i64 24, !12, i64 32}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"_ZTS9VmaVectorI16VmaSuballocation15VmaStlAllocatorIS0_EE", !14, i64 0, !11, i64 8, !8, i64 16, !8, i64 24}
!14 = !{!"_ZTS15VmaStlAllocatorI16VmaSuballocationE", !11, i64 0}
!15 = !{!"int", !9, i64 0}
!16 = !{!"_ZTSN23VmaBlockMetadata_Linear18SECOND_VECTOR_MODEE", !9, i64 0}
!17 = !{!18, !19, i64 24}
!18 = !{!"_ZTS16VmaSuballocation", !8, i64 0, !8, i64 8, !11, i64 16, !19, i64 24}
!19 = !{!"_ZTS20VmaSuballocationType", !9, i64 0}
!20 = !{!18, !8, i64 0}
!21 = !{!18, !8, i64 8}
!22 = !{!18, !11, i64 16}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


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