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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK30VmaBlockBufferImageGranularity19RoundupAllocRequestE20VmaSuballocationTypeRmS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8
  %10 = getelementptr inbounds %class.VmaBlockBufferImageGranularity, ptr %9, i32 0, i32 0
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = icmp ugt i64 %11, 1
  br i1 %12, label %13, label %39

13:                                               ; preds = %4
  %14 = getelementptr inbounds %class.VmaBlockBufferImageGranularity, ptr %9, i32 0, i32 0
  %15 = load i64, ptr %14, align 8, !tbaa !11
  %16 = icmp ule i64 %15, 256
  br i1 %16, label %17, label %39

17:                                               ; preds = %13
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %26, label %20

20:                                               ; preds = %17
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = icmp eq i32 %21, 3
  br i1 %22, label %26, label %23

23:                                               ; preds = %20
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp eq i32 %24, 5
  br i1 %25, label %26, label %38

26:                                               ; preds = %23, %20, %17
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.VmaBlockBufferImageGranularity, ptr %9, i32 0, i32 0
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %27, ptr noundef nonnull align 8 dereferenceable(8) %28)
  %30 = load i64, ptr %29, align 8, !tbaa !15
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %30, ptr %31, align 8, !tbaa !15
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load i64, ptr %32, align 8, !tbaa !15
  %34 = getelementptr inbounds %class.VmaBlockBufferImageGranularity, ptr %9, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !11
  %36 = call noundef i64 @_ZL10VmaAlignUpImET_S0_S0_(i64 noundef %33, i64 noundef %35)
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %36, ptr %37, align 8, !tbaa !15
  br label %38

38:                                               ; preds = %26, %23
  br label %39

39:                                               ; preds = %38, %13, %4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL10VmaAlignUpImET_S0_S0_(i64 noundef, i64 noundef) #1

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 = { inlinehint 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, !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 = !{!"_ZTS20VmaSuballocationType", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS30VmaBlockBufferImageGranularity", !13, i64 0, !14, i64 8, !6, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !13, 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZNK30VmaBlockBufferImageGranularity19RoundupAllocRequestE20VmaSuballocationTypeRmS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, ptr nocapture noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) local_unnamed_addr #0 align 2 {
  %5 = load i64, ptr %0, align 8, !tbaa !5
  %6 = add i64 %5, -2
  %or.cond10 = icmp ult i64 %6, 255
  br i1 %or.cond10, label %7, label %14

7:                                                ; preds = %4
  switch i32 %1, label %14 [
    i32 5, label %8
    i32 3, label %8
    i32 1, label %8
  ]

8:                                                ; preds = %7, %7, %7
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %0)
  %10 = load i64, ptr %9, align 8, !tbaa !12
  store i64 %10, ptr %3, align 8, !tbaa !12
  %11 = load i64, ptr %2, align 8, !tbaa !12
  %12 = load i64, ptr %0, align 8, !tbaa !5
  %13 = tail call noundef i64 @_ZL10VmaAlignUpImET_S0_S0_(i64 noundef %11, i64 noundef %12)
  store i64 %13, ptr %2, align 8, !tbaa !12
  br label %14

14:                                               ; preds = %7, %8, %4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL10VmaAlignUpImET_S0_S0_(i64 noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { inlinehint 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, !7, i64 0}
!6 = !{!"_ZTS30VmaBlockBufferImageGranularity", !7, i64 0, !10, i64 8, !11, i64 16}
!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 = !{!7, !7, i64 0}


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