; 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.VmaBlockBufferImageGranularity::ValidationContext" = type { ptr, ptr }
%class.VmaBlockBufferImageGranularity = type { i64, i32, ptr }
%"struct.VmaBlockBufferImageGranularity::RegionInfo" = type { i8, i16 }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [64 x i8], align 1
@__PRETTY_FUNCTION__._ZNK30VmaBlockBufferImageGranularity8ValidateERNS_17ValidationContextEmm = external hidden unnamed_addr constant [101 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [62 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 @_ZNK30VmaBlockBufferImageGranularity9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK30VmaBlockBufferImageGranularity8ValidateERNS_17ValidationContextEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 noundef %2, i64 noundef %3) #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  %12 = call noundef zeroext i1 @_ZNK30VmaBlockBufferImageGranularity9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  br i1 %12, label %13, label %68

13:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %14 = load i64, ptr %7, align 8, !tbaa !9
  %15 = call noundef i32 @_ZNK30VmaBlockBufferImageGranularity12GetStartPageEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %14)
  store i32 %15, ptr %9, align 4, !tbaa !11
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.VmaBlockBufferImageGranularity::ValidationContext", ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i32, ptr %9, align 4, !tbaa !11
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i16, ptr %18, i64 %20
  %22 = load i16, ptr %21, align 2, !tbaa !15
  %23 = add i16 %22, 1
  store i16 %23, ptr %21, align 2, !tbaa !15
  br label %24

24:                                               ; preds = %13
  %25 = getelementptr inbounds %class.VmaBlockBufferImageGranularity, ptr %11, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = load i32, ptr %9, align 4, !tbaa !11
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds %"struct.VmaBlockBufferImageGranularity::RegionInfo", ptr %26, i64 %28
  %30 = getelementptr inbounds %"struct.VmaBlockBufferImageGranularity::RegionInfo", ptr %29, i32 0, i32 1
  %31 = load i16, ptr %30, align 2, !tbaa !19
  %32 = zext i16 %31 to i32
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %35, label %34

34:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.35, ptr noundef @.str.2, i32 noundef 6797, ptr noundef @__PRETTY_FUNCTION__._ZNK30VmaBlockBufferImageGranularity8ValidateERNS_17ValidationContextEmm) #5
  unreachable

35:                                               ; preds = %24
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %38 = load i64, ptr %7, align 8, !tbaa !9
  %39 = load i64, ptr %8, align 8, !tbaa !9
  %40 = call noundef i32 @_ZNK30VmaBlockBufferImageGranularity10GetEndPageEmm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %38, i64 noundef %39)
  store i32 %40, ptr %10, align 4, !tbaa !11
  %41 = load i32, ptr %9, align 4, !tbaa !11
  %42 = load i32, ptr %10, align 4, !tbaa !11
  %43 = icmp ne i32 %41, %42
  br i1 %43, label %44, label %67

44:                                               ; preds = %37
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.VmaBlockBufferImageGranularity::ValidationContext", ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load i32, ptr %10, align 4, !tbaa !11
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i16, ptr %47, i64 %49
  %51 = load i16, ptr %50, align 2, !tbaa !15
  %52 = add i16 %51, 1
  store i16 %52, ptr %50, align 2, !tbaa !15
  br label %53

53:                                               ; preds = %44
  %54 = getelementptr inbounds %class.VmaBlockBufferImageGranularity, ptr %11, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load i32, ptr %10, align 4, !tbaa !11
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds %"struct.VmaBlockBufferImageGranularity::RegionInfo", ptr %55, i64 %57
  %59 = getelementptr inbounds %"struct.VmaBlockBufferImageGranularity::RegionInfo", ptr %58, i32 0, i32 1
  %60 = load i16, ptr %59, align 2, !tbaa !19
  %61 = zext i16 %60 to i32
  %62 = icmp sgt i32 %61, 0
  br i1 %62, label %64, label %63

63:                                               ; preds = %53
  call void @__assert_fail(ptr noundef @.str.36, ptr noundef @.str.2, i32 noundef 6803, ptr noundef @__PRETTY_FUNCTION__._ZNK30VmaBlockBufferImageGranularity8ValidateERNS_17ValidationContextEmm) #5
  unreachable

64:                                               ; preds = %53
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %68

68:                                               ; preds = %67, %4
  ret i1 true
}

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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTSN30VmaBlockBufferImageGranularity17ValidationContextE", !6, i64 0, !6, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = !{!18, !6, i64 16}
!18 = !{!"_ZTS30VmaBlockBufferImageGranularity", !10, i64 0, !12, i64 8, !6, i64 16}
!19 = !{!20, !16, i64 2}
!20 = !{!"_ZTSN30VmaBlockBufferImageGranularity10RegionInfoE", !7, i64 0, !16, i64 2}


; 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.VmaBlockBufferImageGranularity::RegionInfo" = type { i8, i16 }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [64 x i8], align 1
@__PRETTY_FUNCTION__._ZNK30VmaBlockBufferImageGranularity8ValidateERNS_17ValidationContextEmm = external hidden unnamed_addr constant [101 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [62 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 @_ZNK30VmaBlockBufferImageGranularity9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK30VmaBlockBufferImageGranularity12GetStartPageEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK30VmaBlockBufferImageGranularity10GetEndPageEmm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK30VmaBlockBufferImageGranularity8ValidateERNS_17ValidationContextEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #2 align 2 {
  %5 = tail call noundef zeroext i1 @_ZNK30VmaBlockBufferImageGranularity9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  br i1 %5, label %6, label %31

6:                                                ; preds = %4
  %7 = tail call noundef i32 @_ZNK30VmaBlockBufferImageGranularity12GetStartPageEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %2)
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = zext i32 %7 to i64
  %11 = getelementptr inbounds i16, ptr %9, i64 %10
  %12 = load i16, ptr %11, align 2, !tbaa !10
  %13 = add i16 %12, 1
  store i16 %13, ptr %11, align 2, !tbaa !10
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = getelementptr inbounds %"struct.VmaBlockBufferImageGranularity::RegionInfo", ptr %15, i64 %10, i32 1
  %17 = load i16, ptr %16, align 2, !tbaa !16
  %.not = icmp eq i16 %17, 0
  br i1 %.not, label %18, label %19

18:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.35, ptr noundef nonnull @.str.2, i32 noundef 6797, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK30VmaBlockBufferImageGranularity8ValidateERNS_17ValidationContextEmm) #3
  unreachable

19:                                               ; preds = %6
  %20 = tail call noundef i32 @_ZNK30VmaBlockBufferImageGranularity10GetEndPageEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %2, i64 noundef %3)
  %.not11 = icmp eq i32 %7, %20
  br i1 %.not11, label %31, label %21

21:                                               ; preds = %19
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = zext i32 %20 to i64
  %24 = getelementptr inbounds i16, ptr %22, i64 %23
  %25 = load i16, ptr %24, align 2, !tbaa !10
  %26 = add i16 %25, 1
  store i16 %26, ptr %24, align 2, !tbaa !10
  %27 = load ptr, ptr %14, align 8, !tbaa !12
  %28 = getelementptr inbounds %"struct.VmaBlockBufferImageGranularity::RegionInfo", ptr %27, i64 %23, i32 1
  %29 = load i16, ptr %28, align 2, !tbaa !16
  %.not12 = icmp eq i16 %29, 0
  br i1 %.not12, label %30, label %31

30:                                               ; preds = %21
  tail call void @__assert_fail(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.2, i32 noundef 6803, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK30VmaBlockBufferImageGranularity8ValidateERNS_17ValidationContextEmm) #3
  unreachable

31:                                               ; preds = %19, %21, %4
  ret i1 true
}

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, !7, i64 8}
!6 = !{!"_ZTSN30VmaBlockBufferImageGranularity17ValidationContextE", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!13, !7, i64 16}
!13 = !{!"_ZTS30VmaBlockBufferImageGranularity", !14, i64 0, !15, i64 8, !7, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!17, !11, i64 2}
!17 = !{!"_ZTSN30VmaBlockBufferImageGranularity10RegionInfoE", !8, i64 0, !11, i64 2}


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