; LLVM IR from hbatagelo/abcg :: abcg/external/glslang/SPIRV (SpvBuilder)

; 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.spv::Builder" = type { ptr, i32, i32, i32, i32, %"class.std::__cxx11::basic_string", i32, ptr, i8, %"class.std::set", %"class.std::vector", %"class.std::vector", i32, i32, %"class.std::set.6", i32, %"class.spv::Module", ptr, i32, ptr, i8, [7 x i8], %"struct.spv::Builder::AccessChain", %"class.std::vector.27", %"class.std::vector.27", %"class.std::vector.27", %"class.std::vector.27", %"class.std::vector.27", %"class.std::vector.27", %"class.std::vector.27", %"class.std::vector.27", %"class.std::vector.32", %"class.std::unordered_map", %"class.std::unordered_map", %"class.std::unordered_map", %"class.std::vector.17", %"class.std::stack", %"class.std::stack.45", %"class.std::unordered_map.52", %"class.std::map", ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, std::_Identity<std::__cxx11::basic_string<char>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, std::_Identity<std::__cxx11::basic_string<char>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<const char *, std::allocator<const char *>>::_Vector_impl" }
%"struct.std::_Vector_base<const char *, std::allocator<const char *>>::_Vector_impl" = type { %"struct.std::_Vector_base<const char *, std::allocator<const char *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<const char *, std::allocator<const char *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::set.6" = type { %"class.std::_Rb_tree.7" }
%"class.std::_Rb_tree.7" = type { %"struct.std::_Rb_tree<spv::Capability, spv::Capability, std::_Identity<spv::Capability>, std::less<spv::Capability>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<spv::Capability, spv::Capability, std::_Identity<spv::Capability>, std::less<spv::Capability>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"class.spv::Module" = type { ptr, %"class.std::vector.12", %"class.std::vector.17" }
%"class.std::vector.12" = type { %"struct.std::_Vector_base.13" }
%"struct.std::_Vector_base.13" = type { %"struct.std::_Vector_base<spv::Function *, std::allocator<spv::Function *>>::_Vector_impl" }
%"struct.std::_Vector_base<spv::Function *, std::allocator<spv::Function *>>::_Vector_impl" = type { %"struct.std::_Vector_base<spv::Function *, std::allocator<spv::Function *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<spv::Function *, std::allocator<spv::Function *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.spv::Builder::AccessChain" = type <{ i32, [4 x i8], %"class.std::vector.22", i32, [4 x i8], %"class.std::vector.22", i32, i32, i8, [3 x i8], i32, %"struct.spv::Builder::AccessChain::CoherentFlags", [4 x i8] }>
%"class.std::vector.22" = type { %"struct.std::_Vector_base.23" }
%"struct.std::_Vector_base.23" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.spv::Builder::AccessChain::CoherentFlags" = type { i16, [2 x i8] }
%"class.std::vector.27" = type { %"struct.std::_Vector_base.28" }
%"struct.std::_Vector_base.28" = type { %"struct.std::_Vector_base<std::unique_ptr<spv::Instruction>, std::allocator<std::unique_ptr<spv::Instruction>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::unique_ptr<spv::Instruction>, std::allocator<std::unique_ptr<spv::Instruction>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::unique_ptr<spv::Instruction>, std::allocator<std::unique_ptr<spv::Instruction>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::unique_ptr<spv::Instruction>, std::allocator<std::unique_ptr<spv::Instruction>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.32" = type { %"struct.std::_Vector_base.33" }
%"struct.std::_Vector_base.33" = type { %"struct.std::_Vector_base<std::unique_ptr<spv::Function>, std::allocator<std::unique_ptr<spv::Function>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::unique_ptr<spv::Function>, std::allocator<std::unique_ptr<spv::Function>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::unique_ptr<spv::Function>, std::allocator<std::unique_ptr<spv::Function>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::unique_ptr<spv::Function>, std::allocator<std::unique_ptr<spv::Function>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::vector.17" = type { %"struct.std::_Vector_base.18" }
%"struct.std::_Vector_base.18" = type { %"struct.std::_Vector_base<spv::Instruction *, std::allocator<spv::Instruction *>>::_Vector_impl" }
%"struct.std::_Vector_base<spv::Instruction *, std::allocator<spv::Instruction *>>::_Vector_impl" = type { %"struct.std::_Vector_base<spv::Instruction *, std::allocator<spv::Instruction *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<spv::Instruction *, std::allocator<spv::Instruction *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<spv::Block *, std::allocator<spv::Block *>>::_Deque_impl" }
%"struct.std::_Deque_base<spv::Block *, std::allocator<spv::Block *>>::_Deque_impl" = type { %"struct.std::_Deque_base<spv::Block *, std::allocator<spv::Block *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<spv::Block *, std::allocator<spv::Block *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::stack.45" = type { %"class.std::deque.46" }
%"class.std::deque.46" = type { %"class.std::_Deque_base.47" }
%"class.std::_Deque_base.47" = type { %"struct.std::_Deque_base<spv::Builder::LoopBlocks, std::allocator<spv::Builder::LoopBlocks>>::_Deque_impl" }
%"struct.std::_Deque_base<spv::Builder::LoopBlocks, std::allocator<spv::Builder::LoopBlocks>>::_Deque_impl" = type { %"struct.std::_Deque_base<spv::Builder::LoopBlocks, std::allocator<spv::Builder::LoopBlocks>>::_Deque_impl_data" }
%"struct.std::_Deque_base<spv::Builder::LoopBlocks, std::allocator<spv::Builder::LoopBlocks>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator.51", %"struct.std::_Deque_iterator.51" }
%"struct.std::_Deque_iterator.51" = type { ptr, ptr, ptr, ptr }
%"class.std::unordered_map.52" = type { %"class.std::_Hashtable.53" }
%"class.std::_Hashtable.53" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"class.std::map" = type { %"class.std::_Rb_tree.72" }
%"class.std::_Rb_tree.72" = type { %"struct.std::_Rb_tree<unsigned int, std::pair<const unsigned int, const std::__cxx11::basic_string<char> *>, std::_Select1st<std::pair<const unsigned int, const std::__cxx11::basic_string<char> *>>, std::less<unsigned int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned int, std::pair<const unsigned int, const std::__cxx11::basic_string<char> *>, std::_Select1st<std::pair<const unsigned int, const std::__cxx11::basic_string<char> *>>, std::less<unsigned int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }

; 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: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3spv6Module14getInstructionEj(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3spv11Instruction9getOpCodeEv(ptr noundef nonnull align 8 dereferenceable(96)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3spv7Builder18getContainedTypeIdEj(ptr noundef nonnull align 8 dereferenceable(1096), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3spv7Builder36containsPhysicalStorageBufferOrArrayEj(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %10 = getelementptr inbounds %"class.spv::Builder", ptr %9, i32 0, i32 16
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = call noundef ptr @_ZNK3spv6Module14getInstructionEj(ptr noundef nonnull align 8 dereferenceable(56) %10, i32 noundef %11)
  store ptr %12, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = call noundef i32 @_ZNK3spv11Instruction9getOpCodeEv(ptr noundef nonnull align 8 dereferenceable(96) %13)
  store i32 %14, ptr %7, align 4, !tbaa !11
  %15 = load i32, ptr %7, align 4, !tbaa !11
  switch i32 %15, label %24 [
    i32 32, label %16
    i32 28, label %20
  ]

16:                                               ; preds = %2
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = call noundef i32 @_ZNK3spv7Builder19getTypeStorageClassEj(ptr noundef nonnull align 8 dereferenceable(1096) %9, i32 noundef %17)
  %19 = icmp eq i32 %18, 5349
  store i1 %19, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %25

20:                                               ; preds = %2
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = call noundef i32 @_ZNK3spv7Builder18getContainedTypeIdEj(ptr noundef nonnull align 8 dereferenceable(1096) %9, i32 noundef %21)
  %23 = call noundef zeroext i1 @_ZNK3spv7Builder36containsPhysicalStorageBufferOrArrayEj(ptr noundef nonnull align 8 dereferenceable(1096) %9, i32 noundef %22)
  store i1 %23, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %25

24:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %25

25:                                               ; preds = %24, %20, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %26 = load i1, ptr %3, align 1
  ret i1 %26
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3spv7Builder19getTypeStorageClassEj(ptr noundef nonnull align 8 dereferenceable(1096), i32 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !12, i64 0}
!12 = !{!"_ZTSN3spv2OpE", !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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3spv6Module14getInstructionEj(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3spv11Instruction9getOpCodeEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3spv7Builder18getContainedTypeIdEj(ptr noundef nonnull align 8 dereferenceable(1096), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3spv7Builder36containsPhysicalStorageBufferOrArrayEj(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 240
  br label %tailrecurse

tailrecurse:                                      ; preds = %9, %2
  %.tr6 = phi i32 [ %1, %2 ], [ %10, %9 ]
  %4 = tail call noundef ptr @_ZNK3spv6Module14getInstructionEj(ptr noundef nonnull align 8 dereferenceable(56) %3, i32 noundef %.tr6)
  %5 = tail call noundef i32 @_ZNK3spv11Instruction9getOpCodeEv(ptr noundef nonnull align 8 dereferenceable(96) %4)
  switch i32 %5, label %.loopexit [
    i32 32, label %6
    i32 28, label %9
  ]

6:                                                ; preds = %tailrecurse
  %7 = tail call noundef i32 @_ZNK3spv7Builder19getTypeStorageClassEj(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %.tr6)
  %8 = icmp eq i32 %7, 5349
  br label %.loopexit

9:                                                ; preds = %tailrecurse
  %10 = tail call noundef i32 @_ZNK3spv7Builder18getContainedTypeIdEj(ptr noundef nonnull align 8 dereferenceable(1096) %0, i32 noundef %.tr6)
  br label %tailrecurse

.loopexit:                                        ; preds = %tailrecurse, %6
  %.0 = phi i1 [ %8, %6 ], [ false, %tailrecurse ]
  ret i1 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3spv7Builder19getTypeStorageClassEj(ptr noundef nonnull align 8 dereferenceable(1096), i32 noundef) local_unnamed_addr #1 align 2

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

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


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass