; 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_TLSF::Block" = type { i64, i64, ptr, ptr, ptr, %union.anon.6 }
%union.anon.6 = type { ptr }
%struct.VmaVirtualAllocationInfo = type { i64, i64, ptr }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.111 = external hidden unnamed_addr constant [65 x i8], align 1
@__PRETTY_FUNCTION__._ZN21VmaBlockMetadata_TLSF17GetAllocationInfoEP16VmaAllocHandle_TR24VmaVirtualAllocationInfo = 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 zeroext i1 @_ZNK21VmaBlockMetadata_TLSF5Block6IsFreeEv(ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21VmaBlockMetadata_TLSF17GetAllocationInfoEP16VmaAllocHandle_TR24VmaVirtualAllocationInfo(ptr noundef nonnull align 8 dereferenceable(400) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) unnamed_addr #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %9, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_ZNK21VmaBlockMetadata_TLSF5Block6IsFreeEv(ptr noundef nonnull align 8 dereferenceable(48) %10)
  br i1 %11, label %13, label %12

12:                                               ; preds = %3
  br label %13

13:                                               ; preds = %12, %3
  %14 = phi i1 [ false, %3 ], [ true, %12 ]
  br i1 %14, label %15, label %16

15:                                               ; preds = %13
  br label %18

16:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.111, ptr noundef @.str.2, i32 noundef 10681, ptr noundef @__PRETTY_FUNCTION__._ZN21VmaBlockMetadata_TLSF17GetAllocationInfoEP16VmaAllocHandle_TR24VmaVirtualAllocationInfo) #5
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.VmaBlockMetadata_TLSF::Block", ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.VmaVirtualAllocationInfo, ptr %22, i32 0, i32 0
  store i64 %21, ptr %23, align 8, !tbaa !12
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %"class.VmaBlockMetadata_TLSF::Block", ptr %24, i32 0, i32 1
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.VmaVirtualAllocationInfo, ptr %27, i32 0, i32 1
  store i64 %26, ptr %28, align 8, !tbaa !15
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN21VmaBlockMetadata_TLSF5Block8UserDataEv(ptr noundef nonnull align 8 dereferenceable(48) %29)
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.VmaVirtualAllocationInfo, ptr %32, i32 0, i32 2
  store ptr %31, ptr %33, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

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 = { nounwind }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"_ZTSN21VmaBlockMetadata_TLSF5BlockE", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !7, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_ZTS24VmaVirtualAllocationInfo", !11, i64 0, !11, i64 8, !6, i64 16}
!14 = !{!10, !11, i64 8}
!15 = !{!13, !11, i64 8}
!16 = !{!13, !6, i64 16}


; 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.111 = external hidden unnamed_addr constant [65 x i8], align 1
@__PRETTY_FUNCTION__._ZN21VmaBlockMetadata_TLSF17GetAllocationInfoEP16VmaAllocHandle_TR24VmaVirtualAllocationInfo = external hidden unnamed_addr constant [98 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
declare dso_local noundef zeroext i1 @_ZNK21VmaBlockMetadata_TLSF5Block6IsFreeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN21VmaBlockMetadata_TLSF17GetAllocationInfoEP16VmaAllocHandle_TR24VmaVirtualAllocationInfo(ptr nocapture noundef nonnull readnone align 8 dereferenceable(400) %0, ptr noundef nonnull %1, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(24) %2) unnamed_addr #1 align 2 {
  %4 = tail call noundef zeroext i1 @_ZNK21VmaBlockMetadata_TLSF5Block6IsFreeEv(ptr noundef nonnull align 8 dereferenceable(48) %1)
  br i1 %4, label %5, label %6

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.111, ptr noundef nonnull @.str.2, i32 noundef 10681, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN21VmaBlockMetadata_TLSF17GetAllocationInfoEP16VmaAllocHandle_TR24VmaVirtualAllocationInfo) #2
  unreachable

6:                                                ; preds = %3
  %7 = load <2 x i64>, ptr %1, align 8, !tbaa !5
  store <2 x i64> %7, ptr %2, align 8, !tbaa !5
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN21VmaBlockMetadata_TLSF5Block8UserDataEv(ptr noundef nonnull align 8 dereferenceable(48) %1)
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %9, ptr %10, align 8, !tbaa !11
  ret void
}

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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTS24VmaVirtualAllocationInfo", !6, i64 0, !6, i64 8, !10, i64 16}


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