; 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.VmaAllocation_T = type <{ %union.anon, i64, i64, ptr, ptr, i32, i8, i8, i8, i8, i32, [4 x i8] }>
%union.anon = type { %"struct.VmaAllocation_T::DedicatedAllocation" }
%"struct.VmaAllocation_T::DedicatedAllocation" = type { ptr, ptr, ptr, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [153 x i8], align 1
@.str.168 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__._ZN15VmaAllocation_T13BlockAllocMapEv = external hidden unnamed_addr constant [38 x i8], align 1
@.str.169 = external hidden unnamed_addr constant [56 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
declare dso_local noundef i32 @_ZNK15VmaAllocation_T7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(84)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15VmaAllocation_T13BlockAllocMapEv(ptr noundef nonnull align 8 dereferenceable(84) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = call noundef i32 @_ZNK15VmaAllocation_T7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(84) %3)
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  br label %9

7:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.168, ptr noundef @.str.2, i32 noundef 12231, ptr noundef @__PRETTY_FUNCTION__._ZN15VmaAllocation_T13BlockAllocMapEv) #3
  unreachable

8:                                                ; No predecessors!
  br label %9

9:                                                ; preds = %8, %6
  %10 = call noundef zeroext i1 @_ZNK15VmaAllocation_T16IsMappingAllowedEv(ptr noundef nonnull align 8 dereferenceable(84) %3)
  br i1 %10, label %11, label %12

11:                                               ; preds = %9
  br label %12

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

14:                                               ; preds = %12
  br label %17

15:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.160, ptr noundef @.str.2, i32 noundef 12232, ptr noundef @__PRETTY_FUNCTION__._ZN15VmaAllocation_T13BlockAllocMapEv) #3
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  %18 = getelementptr inbounds %struct.VmaAllocation_T, ptr %3, i32 0, i32 8
  %19 = load i8, ptr %18, align 2, !tbaa !9
  %20 = zext i8 %19 to i32
  %21 = icmp slt i32 %20, 255
  br i1 %21, label %22, label %26

22:                                               ; preds = %17
  %23 = getelementptr inbounds %struct.VmaAllocation_T, ptr %3, i32 0, i32 8
  %24 = load i8, ptr %23, align 2, !tbaa !9
  %25 = add i8 %24, 1
  store i8 %25, ptr %23, align 2, !tbaa !9
  br label %27

26:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.169, ptr noundef @.str.2, i32 noundef 12240, ptr noundef @__PRETTY_FUNCTION__._ZN15VmaAllocation_T13BlockAllocMapEv) #3
  unreachable

27:                                               ; preds = %22
  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 = { 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 #3 = { 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, !7, i64 78}
!10 = !{!"_ZTS15VmaAllocation_T", !7, i64 0, !11, i64 40, !11, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !7, i64 76, !7, i64 77, !7, i64 78, !7, i64 79, !12, i64 80}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, 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.160 = external hidden unnamed_addr constant [153 x i8], align 1
@.str.168 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__._ZN15VmaAllocation_T13BlockAllocMapEv = external hidden unnamed_addr constant [38 x i8], align 1
@.str.169 = external hidden unnamed_addr constant [56 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 i32 @_ZNK15VmaAllocation_T7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN15VmaAllocation_T13BlockAllocMapEv(ptr noundef nonnull align 8 dereferenceable(84) %0) local_unnamed_addr #1 align 2 {
  %2 = tail call noundef i32 @_ZNK15VmaAllocation_T7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(84) %0)
  %3 = icmp eq i32 %2, 1
  br i1 %3, label %5, label %4

4:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.168, ptr noundef nonnull @.str.2, i32 noundef 12231, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN15VmaAllocation_T13BlockAllocMapEv) #2
  unreachable

5:                                                ; preds = %1
  %6 = tail call noundef zeroext i1 @_ZNK15VmaAllocation_T16IsMappingAllowedEv(ptr noundef nonnull align 8 dereferenceable(84) %0)
  br i1 %6, label %8, label %7

7:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.160, ptr noundef nonnull @.str.2, i32 noundef 12232, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN15VmaAllocation_T13BlockAllocMapEv) #2
  unreachable

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 78
  %10 = load i8, ptr %9, align 2, !tbaa !5
  %.not = icmp eq i8 %10, -1
  br i1 %.not, label %13, label %11

11:                                               ; preds = %8
  %12 = add nuw i8 %10, 1
  store i8 %12, ptr %9, align 2, !tbaa !5
  ret void

13:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.169, ptr noundef nonnull @.str.2, i32 noundef 12240, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN15VmaAllocation_T13BlockAllocMapEv) #2
  unreachable
}

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 78}
!6 = !{!"_ZTS15VmaAllocation_T", !7, i64 0, !9, i64 40, !9, i64 48, !10, i64 56, !10, i64 64, !11, i64 72, !7, i64 76, !7, i64 77, !7, i64 78, !7, i64 79, !11, i64 80}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"int", !7, i64 0}


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