; 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.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 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5shift3gfx10AttachmentC2E8VkFormatNS1_4TypeEj(ptr noundef nonnull align 4 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  store i32 %3, ptr %8, align 4, !tbaa !13
  %9 = load ptr, ptr %5, align 8
  %10 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 0
  store i32 0, ptr %11, align 4, !tbaa !15
  %12 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 1
  store i32 0, ptr %12, align 4, !tbaa !21
  %13 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 2
  store i32 0, ptr %13, align 4, !tbaa !22
  %14 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 3
  store i32 0, ptr %14, align 4, !tbaa !23
  %15 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 4
  store i32 0, ptr %15, align 4, !tbaa !24
  %16 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 5
  store i32 0, ptr %16, align 4, !tbaa !25
  %17 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 6
  store i32 0, ptr %17, align 4, !tbaa !26
  %18 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 7
  store i32 0, ptr %18, align 4, !tbaa !27
  %19 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %10, i32 0, i32 8
  store i32 0, ptr %19, align 4, !tbaa !28
  %20 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 1
  %21 = getelementptr inbounds %struct.VkAttachmentReference, ptr %20, i32 0, i32 0
  store i32 0, ptr %21, align 4, !tbaa !29
  %22 = getelementptr inbounds %struct.VkAttachmentReference, ptr %20, i32 0, i32 1
  store i32 0, ptr %22, align 4, !tbaa !31
  %23 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 2
  %24 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %24, ptr %23, align 4, !tbaa !32
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %27 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %26, i32 0, i32 1
  store i32 %25, ptr %27, align 4, !tbaa !34
  %28 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %29 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %28, i32 0, i32 2
  store i32 1, ptr %29, align 4, !tbaa !35
  %30 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %31 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %30, i32 0, i32 3
  store i32 1, ptr %31, align 4, !tbaa !36
  %32 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %33 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %32, i32 0, i32 4
  store i32 0, ptr %33, align 4, !tbaa !37
  %34 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %35 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %34, i32 0, i32 5
  store i32 2, ptr %35, align 4, !tbaa !38
  %36 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %37 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %36, i32 0, i32 6
  store i32 1, ptr %37, align 4, !tbaa !39
  %38 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %39 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %38, i32 0, i32 7
  store i32 0, ptr %39, align 4, !tbaa !40
  %40 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 2
  %41 = load i32, ptr %40, align 4, !tbaa !32
  switch i32 %41, label %51 [
    i32 0, label %42
    i32 1, label %45
    i32 2, label %48
  ]

42:                                               ; preds = %4
  %43 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %44 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %43, i32 0, i32 8
  store i32 2, ptr %44, align 4, !tbaa !41
  br label %51

45:                                               ; preds = %4
  %46 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %47 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %46, i32 0, i32 8
  store i32 3, ptr %47, align 4, !tbaa !41
  br label %51

48:                                               ; preds = %4
  %49 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 0
  %50 = getelementptr inbounds %struct.VkAttachmentDescription, ptr %49, i32 0, i32 8
  store i32 1000001002, ptr %50, align 4, !tbaa !41
  br label %51

51:                                               ; preds = %48, %45, %42, %4
  %52 = load i32, ptr %8, align 4, !tbaa !13
  %53 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 1
  %54 = getelementptr inbounds %struct.VkAttachmentReference, ptr %53, i32 0, i32 0
  store i32 %52, ptr %54, align 4, !tbaa !42
  %55 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 2
  %56 = load i32, ptr %55, align 4, !tbaa !32
  switch i32 %56, label %60 [
    i32 1, label %57
  ]

57:                                               ; preds = %51
  %58 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 1
  %59 = getelementptr inbounds %struct.VkAttachmentReference, ptr %58, i32 0, i32 1
  store i32 3, ptr %59, align 4, !tbaa !43
  br label %63

60:                                               ; preds = %51
  %61 = getelementptr inbounds %"struct.shift::gfx::Attachment", ptr %9, i32 0, i32 1
  %62 = getelementptr inbounds %struct.VkAttachmentReference, ptr %61, i32 0, i32 1
  store i32 2, ptr %62, align 4, !tbaa !43
  br label %63

63:                                               ; preds = %60, %57
  ret void
}

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" }

!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 = !{!"_ZTS8VkFormat", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN5shift3gfx10Attachment4TypeE", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"_ZTS23VkAttachmentDescription", !14, i64 0, !10, i64 4, !17, i64 8, !18, i64 12, !19, i64 16, !18, i64 20, !19, i64 24, !20, i64 28, !20, i64 32}
!17 = !{!"_ZTS21VkSampleCountFlagBits", !7, i64 0}
!18 = !{!"_ZTS18VkAttachmentLoadOp", !7, i64 0}
!19 = !{!"_ZTS19VkAttachmentStoreOp", !7, i64 0}
!20 = !{!"_ZTS13VkImageLayout", !7, i64 0}
!21 = !{!16, !10, i64 4}
!22 = !{!16, !17, i64 8}
!23 = !{!16, !18, i64 12}
!24 = !{!16, !19, i64 16}
!25 = !{!16, !18, i64 20}
!26 = !{!16, !19, i64 24}
!27 = !{!16, !20, i64 28}
!28 = !{!16, !20, i64 32}
!29 = !{!30, !14, i64 0}
!30 = !{!"_ZTS21VkAttachmentReference", !14, i64 0, !20, i64 4}
!31 = !{!30, !20, i64 4}
!32 = !{!33, !12, i64 44}
!33 = !{!"_ZTSN5shift3gfx10AttachmentE", !16, i64 0, !30, i64 36, !12, i64 44}
!34 = !{!33, !10, i64 4}
!35 = !{!33, !17, i64 8}
!36 = !{!33, !18, i64 12}
!37 = !{!33, !19, i64 16}
!38 = !{!33, !18, i64 20}
!39 = !{!33, !19, i64 24}
!40 = !{!33, !20, i64 28}
!41 = !{!33, !20, i64 32}
!42 = !{!33, !14, i64 36}
!43 = !{!33, !20, i64 40}


; 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"

@switch.table._ZN5shift3gfx10AttachmentC2E8VkFormatNS1_4TypeEj = private unnamed_addr constant [3 x i32] [i32 2, i32 3, i32 1000001002], align 4

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_ZN5shift3gfx10AttachmentC2E8VkFormatNS1_4TypeEj(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  %8 = getelementptr inbounds i8, ptr %0, i64 20
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = getelementptr inbounds i8, ptr %0, i64 44
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(36) %0, i8 0, i64 36, i1 false)
  store i32 %2, ptr %10, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !18
  store i32 1, ptr %6, align 4, !tbaa !19
  store i32 1, ptr %7, align 4, !tbaa !20
  store i32 2, ptr %8, align 4, !tbaa !21
  store i32 1, ptr %9, align 4, !tbaa !22
  %11 = icmp ult i32 %2, 3
  br i1 %11, label %switch.lookup, label %14

switch.lookup:                                    ; preds = %4
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = zext nneg i32 %2 to i64
  %switch.gep = getelementptr inbounds [3 x i32], ptr @switch.table._ZN5shift3gfx10AttachmentC2E8VkFormatNS1_4TypeEj, i64 0, i64 %13
  %switch.load = load i32, ptr %switch.gep, align 4
  store i32 %switch.load, ptr %12, align 4, !tbaa !23
  br label %14

14:                                               ; preds = %4, %switch.lookup
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %16 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 %3, ptr %16, align 4, !tbaa !24
  %cond = icmp eq i32 %2, 1
  %. = select i1 %cond, i32 3, i32 2
  store i32 %., ptr %15, align 4, !tbaa !25
  ret void
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 nounwind willreturn memory(argmem: write) }

!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, !17, i64 44}
!6 = !{!"_ZTSN5shift3gfx10AttachmentE", !7, i64 0, !16, i64 36, !17, i64 44}
!7 = !{!"_ZTS23VkAttachmentDescription", !8, i64 0, !11, i64 4, !12, i64 8, !13, i64 12, !14, i64 16, !13, i64 20, !14, i64 24, !15, i64 28, !15, i64 32}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS8VkFormat", !9, i64 0}
!12 = !{!"_ZTS21VkSampleCountFlagBits", !9, i64 0}
!13 = !{!"_ZTS18VkAttachmentLoadOp", !9, i64 0}
!14 = !{!"_ZTS19VkAttachmentStoreOp", !9, i64 0}
!15 = !{!"_ZTS13VkImageLayout", !9, i64 0}
!16 = !{!"_ZTS21VkAttachmentReference", !8, i64 0, !15, i64 4}
!17 = !{!"_ZTSN5shift3gfx10Attachment4TypeE", !9, i64 0}
!18 = !{!6, !11, i64 4}
!19 = !{!6, !12, i64 8}
!20 = !{!6, !13, i64 12}
!21 = !{!6, !13, i64 20}
!22 = !{!6, !14, i64 24}
!23 = !{!6, !15, i64 32}
!24 = !{!6, !8, i64 36}
!25 = !{!6, !15, i64 40}


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