; LLVM IR from Adeon18/Shift :: Source/Graphics/Abstraction/RenderPass (PassPrimitives)

; 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.VkSubpassDependency = type { i32, i32, i32, i32, i32, i32, i32 }
%"struct.shift::gfx::Attachment" = type { %struct.VkAttachmentDescription, %struct.VkAttachmentReference, i32 }
%struct.VkAttachmentDescription = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.VkAttachmentReference = type { i32, i32 }
%"struct.shift::gfx::Subpass" = type { %"class.std::vector", %struct.VkAttachmentReference, %"class.std::vector.0", %struct.VkSubpassDescription }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<VkAttachmentReference, std::allocator<VkAttachmentReference>>::_Vector_impl" }
%"struct.std::_Vector_base<VkAttachmentReference, std::allocator<VkAttachmentReference>>::_Vector_impl" = type { %"struct.std::_Vector_base<VkAttachmentReference, std::allocator<VkAttachmentReference>>::_Vector_impl_data" }
%"struct.std::_Vector_base<VkAttachmentReference, std::allocator<VkAttachmentReference>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<VkSubpassDependency, std::allocator<VkSubpassDependency>>::_Vector_impl" }
%"struct.std::_Vector_base<VkSubpassDependency, std::allocator<VkSubpassDependency>>::_Vector_impl" = type { %"struct.std::_Vector_base<VkSubpassDependency, std::allocator<VkSubpassDependency>>::_Vector_impl_data" }
%"struct.std::_Vector_base<VkSubpassDependency, std::allocator<VkSubpassDependency>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.VkSubpassDescription = type { i32, i32, i32, ptr, i32, ptr, ptr, ptr, i32, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5shift3gfx7Subpass13AddDependencyERKNS0_10AttachmentEjj(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull align 4 dereferenceable(48) %1, i32 noundef %2, i32 noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.VkSubpassDependency, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 28, ptr %9) #4
  call void @llvm.memset.p0.i64(ptr align 4 %9, i8 0, i64 28, i1 false)
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 0
  store i32 %11, ptr %12, align 4, !tbaa !11
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 1
  store i32 %13, ptr %14, align 4, !tbaa !13
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 4, !tbaa !14
  switch i32 %17, label %36 [
    i32 0, label %18
    i32 1, label %24
    i32 2, label %30
  ]

18:                                               ; preds = %4
  %19 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 2
  store i32 1024, ptr %19, align 4, !tbaa !24
  %20 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 3
  store i32 128, ptr %20, align 4, !tbaa !25
  %21 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 4
  store i32 256, ptr %21, align 4, !tbaa !26
  %22 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 5
  store i32 16, ptr %22, align 4, !tbaa !27
  %23 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 6
  store i32 1, ptr %23, align 4, !tbaa !28
  br label %24

24:                                               ; preds = %18, %4
  %25 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 2
  store i32 768, ptr %25, align 4, !tbaa !24
  %26 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 3
  store i32 768, ptr %26, align 4, !tbaa !25
  %27 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 4
  store i32 0, ptr %27, align 4, !tbaa !26
  %28 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 5
  store i32 1024, ptr %28, align 4, !tbaa !27
  %29 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 6
  store i32 0, ptr %29, align 4, !tbaa !28
  br label %36

30:                                               ; preds = %4
  %31 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 2
  store i32 1024, ptr %31, align 4, !tbaa !24
  %32 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 3
  store i32 1024, ptr %32, align 4, !tbaa !25
  %33 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 4
  store i32 0, ptr %33, align 4, !tbaa !26
  %34 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 5
  store i32 256, ptr %34, align 4, !tbaa !27
  %35 = getelementptr inbounds %struct.VkSubpassDependency, ptr %9, i32 0, i32 6
  store i32 0, ptr %35, align 4, !tbaa !28
  br label %36

36:                                               ; preds = %30, %24, %4
  %37 = getelementptr inbounds %"struct.shift::gfx::Subpass", ptr %10, i32 0, i32 2
  %38 = call noundef nonnull align 4 dereferenceable(28) ptr @_ZNSt6vectorI19VkSubpassDependencySaIS0_EE12emplace_backIJRS0_EEES4_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %37, ptr noundef nonnull align 4 dereferenceable(28) %9)
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 4, !tbaa !14
  switch i32 %41, label %56 [
    i32 0, label %42
    i32 1, label %47
    i32 2, label %51
  ]

42:                                               ; preds = %36
  %43 = getelementptr inbounds %"struct.shift::gfx::Subpass", ptr %10, i32 0, i32 0
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %44, i32 0, i32 1
  %46 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI21VkAttachmentReferenceSaIS0_EE12emplace_backIJRKS0_EEERS0_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %43, ptr noundef nonnull align 4 dereferenceable(8) %45)
  br label %47

47:                                               ; preds = %42, %36
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %48, i32 0, i32 1
  %50 = getelementptr inbounds %"struct.shift::gfx::Subpass", ptr %10, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %50, ptr align 4 %49, i64 8, i1 false), !tbaa.struct !29
  br label %56

51:                                               ; preds = %36
  %52 = getelementptr inbounds %"struct.shift::gfx::Subpass", ptr %10, i32 0, i32 0
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %53, i32 0, i32 1
  %55 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI21VkAttachmentReferenceSaIS0_EE12emplace_backIJRKS0_EEERS0_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %52, ptr noundef nonnull align 4 dereferenceable(8) %54)
  br label %56

56:                                               ; preds = %51, %47, %36
  call void @llvm.lifetime.end.p0(i64 28, ptr %9) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(28) ptr @_ZNSt6vectorI19VkSubpassDependencySaIS0_EE12emplace_backIJRS0_EEES4_DpOT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(28)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI21VkAttachmentReferenceSaIS0_EE12emplace_backIJRKS0_EEERS0_DpOT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS19VkSubpassDependency", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!13 = !{!12, !10, i64 4}
!14 = !{!15, !23, i64 44}
!15 = !{!"_ZTSN5shift3gfx10AttachmentE", !16, i64 0, !22, i64 36, !23, i64 44}
!16 = !{!"_ZTS23VkAttachmentDescription", !10, i64 0, !17, i64 4, !18, i64 8, !19, i64 12, !20, i64 16, !19, i64 20, !20, i64 24, !21, i64 28, !21, i64 32}
!17 = !{!"_ZTS8VkFormat", !7, i64 0}
!18 = !{!"_ZTS21VkSampleCountFlagBits", !7, i64 0}
!19 = !{!"_ZTS18VkAttachmentLoadOp", !7, i64 0}
!20 = !{!"_ZTS19VkAttachmentStoreOp", !7, i64 0}
!21 = !{!"_ZTS13VkImageLayout", !7, i64 0}
!22 = !{!"_ZTS21VkAttachmentReference", !10, i64 0, !21, i64 4}
!23 = !{!"_ZTSN5shift3gfx10Attachment4TypeE", !7, i64 0}
!24 = !{!12, !10, i64 8}
!25 = !{!12, !10, i64 12}
!26 = !{!12, !10, i64 16}
!27 = !{!12, !10, i64 20}
!28 = !{!12, !10, i64 24}
!29 = !{i64 0, i64 4, !9, i64 4, i64 4, !30}
!30 = !{!21, !21, 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"

%struct.VkSubpassDependency = type { i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5shift3gfx7Subpass13AddDependencyERKNS0_10AttachmentEjj(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull align 4 dereferenceable(48) %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %5 = alloca %struct.VkSubpassDependency, align 4
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %5) #3
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(28) %6, i8 0, i64 20, i1 false)
  store i32 %2, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %3, ptr %7, align 4, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %1, i64 44
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %.sink8.sroa.gep14 = getelementptr inbounds i8, ptr %5, i64 20
  %.sink10.sroa.gep15 = getelementptr inbounds i8, ptr %5, i64 12
  %.sink13.sroa.gep16 = getelementptr inbounds i8, ptr %5, i64 8
  switch i32 %9, label %13 [
    i32 0, label %10
    i32 1, label %10
    i32 2, label %.sink.split
  ]

10:                                               ; preds = %4, %4
  %.sink13.sroa.gep = getelementptr inbounds i8, ptr %5, i64 16
  %.sink10.sroa.gep = getelementptr inbounds i8, ptr %5, i64 20
  %.sink8.sroa.gep = getelementptr inbounds i8, ptr %5, i64 24
  %11 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 768, ptr %11, align 4, !tbaa !21
  %12 = getelementptr inbounds i8, ptr %5, i64 12
  store i32 768, ptr %12, align 4, !tbaa !22
  br label %.sink.split

.sink.split:                                      ; preds = %4, %10
  %.sink13.sroa.phi = phi ptr [ %.sink13.sroa.gep, %10 ], [ %.sink13.sroa.gep16, %4 ]
  %.sink11 = phi i32 [ 0, %10 ], [ 1024, %4 ]
  %.sink10.sroa.phi = phi ptr [ %.sink10.sroa.gep, %10 ], [ %.sink10.sroa.gep15, %4 ]
  %.sink8.sroa.phi = phi ptr [ %.sink8.sroa.gep, %10 ], [ %.sink8.sroa.gep14, %4 ]
  %.sink = phi i32 [ 0, %10 ], [ 256, %4 ]
  store i32 %.sink11, ptr %.sink13.sroa.phi, align 4, !tbaa !23
  store i32 1024, ptr %.sink10.sroa.phi, align 4, !tbaa !23
  store i32 %.sink, ptr %.sink8.sroa.phi, align 4, !tbaa !23
  br label %13

13:                                               ; preds = %.sink.split, %4
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = call noundef nonnull align 4 dereferenceable(28) ptr @_ZNSt6vectorI19VkSubpassDependencySaIS0_EE12emplace_backIJRS0_EEES4_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 4 dereferenceable(28) %5)
  %16 = load i32, ptr %8, align 4, !tbaa !11
  switch i32 %16, label %27 [
    i32 0, label %17
    i32 1, label %20
    i32 2, label %24
  ]

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %1, i64 36
  %19 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI21VkAttachmentReferenceSaIS0_EE12emplace_backIJRKS0_EEERS0_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(8) %18)
  br label %20

20:                                               ; preds = %17, %13
  %21 = getelementptr inbounds i8, ptr %1, i64 36
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load i64, ptr %21, align 4
  store i64 %23, ptr %22, align 8
  br label %27

24:                                               ; preds = %13
  %25 = getelementptr inbounds i8, ptr %1, i64 36
  %26 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI21VkAttachmentReferenceSaIS0_EE12emplace_backIJRKS0_EEERS0_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(8) %25)
  br label %27

27:                                               ; preds = %24, %20, %13
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %5) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(28) ptr @_ZNSt6vectorI19VkSubpassDependencySaIS0_EE12emplace_backIJRS0_EEES4_DpOT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(28)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI21VkAttachmentReferenceSaIS0_EE12emplace_backIJRKS0_EEERS0_DpOT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"_ZTS19VkSubpassDependency", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !20, i64 44}
!12 = !{!"_ZTSN5shift3gfx10AttachmentE", !13, i64 0, !19, i64 36, !20, i64 44}
!13 = !{!"_ZTS23VkAttachmentDescription", !7, i64 0, !14, i64 4, !15, i64 8, !16, i64 12, !17, i64 16, !16, i64 20, !17, i64 24, !18, i64 28, !18, i64 32}
!14 = !{!"_ZTS8VkFormat", !8, i64 0}
!15 = !{!"_ZTS21VkSampleCountFlagBits", !8, i64 0}
!16 = !{!"_ZTS18VkAttachmentLoadOp", !8, i64 0}
!17 = !{!"_ZTS19VkAttachmentStoreOp", !8, i64 0}
!18 = !{!"_ZTS13VkImageLayout", !8, i64 0}
!19 = !{!"_ZTS21VkAttachmentReference", !7, i64 0, !18, i64 4}
!20 = !{!"_ZTSN5shift3gfx10Attachment4TypeE", !8, i64 0}
!21 = !{!6, !7, i64 8}
!22 = !{!6, !7, i64 12}
!23 = !{!7, !7, i64 0}


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