; LLVM IR from hbatagelo/abcg :: abcg/external/glslang/glslang/MachineIndependent (SpirvIntrinsics)

; 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.glslang::TPublicType" = type { i32, %"struct.glslang::TSampler", %"class.glslang::TQualifier", %"struct.glslang::TShaderQualifiers", i16, ptr, ptr, %"struct.glslang::TSourceLoc", ptr, ptr }
%"struct.glslang::TSampler" = type { i32 }
%"class.glslang::TQualifier" = type <{ ptr, i64, i8, [3 x i8], i32, i32, i64, i64, i8, i8, i8, i8, i8, [3 x i8], i32, i8, [3 x i8], i32, ptr }>
%"struct.glslang::TShaderQualifiers" = type { i32, i8, i8, i32, i32, i32, i32, i8, [3 x i32], [3 x i8], [3 x i32], i8, i8, i32, i8, i32, i32, i8, i8, i8, i32, i8 }
%"struct.glslang::TSourceLoc" = type { ptr, i32, i32, i32 }
%"struct.glslang::TSpirvType" = type { %"struct.glslang::TSpirvInstruction", %"class.glslang::TVector.190" }
%"struct.glslang::TSpirvInstruction" = type <{ %"class.std::__cxx11::basic_string", i32, [4 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char, std::char_traits<char>, glslang::pool_allocator<char>>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char, std::char_traits<char>, glslang::pool_allocator<char>>::_Alloc_hider" = type { %"class.glslang::pool_allocator.5", ptr }
%"class.glslang::pool_allocator.5" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.glslang::TVector.190" = type { %"class.std::vector.191" }
%"class.std::vector.191" = type { %"struct.std::_Vector_base.192" }
%"struct.std::_Vector_base.192" = type { %"struct.std::_Vector_base<glslang::TSpirvTypeParameter, glslang::pool_allocator<glslang::TSpirvTypeParameter>>::_Vector_impl" }
%"struct.std::_Vector_base<glslang::TSpirvTypeParameter, glslang::pool_allocator<glslang::TSpirvTypeParameter>>::_Vector_impl" = type { %"class.glslang::pool_allocator.193", %"struct.std::_Vector_base<glslang::TSpirvTypeParameter, glslang::pool_allocator<glslang::TSpirvTypeParameter>>::_Vector_impl_data" }
%"class.glslang::pool_allocator.193" = type { ptr }
%"struct.std::_Vector_base<glslang::TSpirvTypeParameter, glslang::pool_allocator<glslang::TSpirvTypeParameter>>::_Vector_impl_data" = type { ptr, ptr, ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7glslang11TPublicType12setSpirvTypeERKNS_17TSpirvInstructionEPKNS_7TVectorINS_19TSpirvTypeParameterEEE(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef nonnull align 8 dereferenceable(44) %1, ptr noundef %2) #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  %10 = getelementptr inbounds %"class.glslang::TPublicType", ptr %9, i32 0, i32 9
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = icmp ne ptr %11, null
  br i1 %12, label %21, label %13

13:                                               ; preds = %3
  %14 = call noundef ptr @_ZN7glslang10TSpirvTypenwEm(i64 noundef 80)
  invoke void @_ZN7glslang10TSpirvTypeC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %14)
          to label %15 unwind label %17

15:                                               ; preds = %13
  %16 = getelementptr inbounds %"class.glslang::TPublicType", ptr %9, i32 0, i32 9
  store ptr %14, ptr %16, align 8, !tbaa !9
  br label %21

17:                                               ; preds = %13
  %18 = landingpad { ptr, i32 }
          cleanup
  %19 = extractvalue { ptr, i32 } %18, 0
  store ptr %19, ptr %7, align 8
  %20 = extractvalue { ptr, i32 } %18, 1
  store i32 %20, ptr %8, align 4
  call void @_ZN7glslang10TSpirvTypedlEPv(ptr noundef %14) #3
  br label %37

21:                                               ; preds = %15, %3
  %22 = getelementptr inbounds %"class.glslang::TPublicType", ptr %9, i32 0, i32 0
  store i32 20, ptr %22, align 8, !tbaa !30
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.glslang::TPublicType", ptr %9, i32 0, i32 9
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds %"struct.glslang::TSpirvType", ptr %25, i32 0, i32 0
  %27 = call noundef nonnull align 8 dereferenceable(44) ptr @_ZN7glslang17TSpirvInstructionaSERKS0_(ptr noundef nonnull align 8 dereferenceable(44) %26, ptr noundef nonnull align 8 dereferenceable(44) %23)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %36

30:                                               ; preds = %21
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.glslang::TPublicType", ptr %9, i32 0, i32 9
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds %"struct.glslang::TSpirvType", ptr %33, i32 0, i32 1
  %35 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN7glslang7TVectorINS_19TSpirvTypeParameterEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(32) %34, ptr noundef nonnull align 8 dereferenceable(32) %31)
  br label %36

36:                                               ; preds = %30, %21
  ret void

37:                                               ; preds = %17
  %38 = load ptr, ptr %7, align 8
  %39 = load i32, ptr %8, align 4
  %40 = insertvalue { ptr, i32 } poison, ptr %38, 0
  %41 = insertvalue { ptr, i32 } %40, i32 %39, 1
  resume { ptr, i32 } %41
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN7glslang10TSpirvTypenwEm(i64 noundef) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7glslang10TSpirvTypeC2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7glslang10TSpirvTypedlEPv(ptr noundef) #2 align 2

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

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

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 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 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 = { 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, !6, i64 224}
!10 = !{!"_ZTSN7glslang11TPublicTypeE", !11, i64 0, !12, i64 4, !16, i64 8, !23, i64 80, !15, i64 168, !15, i64 168, !15, i64 169, !14, i64 169, !6, i64 176, !6, i64 184, !29, i64 192, !6, i64 216, !6, i64 224}
!11 = !{!"_ZTSN7glslang10TBasicTypeE", !7, i64 0}
!12 = !{!"_ZTSN7glslang8TSamplerE", !11, i64 0, !13, i64 1, !14, i64 2, !14, i64 2, !14, i64 2, !14, i64 2, !14, i64 2, !14, i64 2, !15, i64 2, !15, i64 3, !14, i64 3, !14, i64 3}
!13 = !{!"_ZTSN7glslang11TSamplerDimE", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN7glslang10TQualifierE", !6, i64 0, !17, i64 8, !18, i64 8, !18, i64 9, !19, i64 11, !14, i64 11, !14, i64 11, !14, i64 11, !14, i64 11, !14, i64 11, !14, i64 12, !14, i64 12, !14, i64 12, !14, i64 12, !14, i64 12, !14, i64 12, !14, i64 12, !14, i64 12, !14, i64 13, !14, i64 13, !14, i64 13, !14, i64 13, !14, i64 13, !14, i64 13, !14, i64 13, !14, i64 13, !14, i64 14, !14, i64 14, !14, i64 14, !14, i64 14, !14, i64 14, !14, i64 14, !14, i64 14, !14, i64 14, !14, i64 15, !14, i64 15, !14, i64 15, !20, i64 15, !21, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !15, i64 29, !15, i64 29, !15, i64 32, !15, i64 34, !15, i64 35, !15, i64 36, !15, i64 36, !15, i64 38, !15, i64 40, !15, i64 41, !15, i64 42, !22, i64 44, !14, i64 45, !14, i64 46, !14, i64 47, !14, i64 48, !15, i64 52, !14, i64 56, !15, i64 60, !6, i64 64}
!17 = !{!"_ZTSN7glslang17TStorageQualifierE", !7, i64 0}
!18 = !{!"_ZTSN7glslang16TBuiltInVariableE", !7, i64 0}
!19 = !{!"_ZTSN7glslang19TPrecisionQualifierE", !7, i64 0}
!20 = !{!"_ZTSN7glslang13TLayoutMatrixE", !7, i64 0}
!21 = !{!"_ZTSN7glslang14TLayoutPackingE", !7, i64 0}
!22 = !{!"_ZTSN7glslang13TLayoutFormatE", !7, i64 0}
!23 = !{!"_ZTSN7glslang17TShaderQualifiersE", !24, i64 0, !14, i64 4, !14, i64 5, !15, i64 8, !15, i64 12, !25, i64 16, !26, i64 20, !14, i64 24, !7, i64 28, !7, i64 40, !7, i64 44, !14, i64 56, !14, i64 57, !27, i64 60, !14, i64 64, !15, i64 68, !28, i64 72, !14, i64 76, !14, i64 77, !14, i64 78, !15, i64 80, !14, i64 84}
!24 = !{!"_ZTSN7glslang15TLayoutGeometryE", !7, i64 0}
!25 = !{!"_ZTSN7glslang14TVertexSpacingE", !7, i64 0}
!26 = !{!"_ZTSN7glslang12TVertexOrderE", !7, i64 0}
!27 = !{!"_ZTSN7glslang12TLayoutDepthE", !7, i64 0}
!28 = !{!"_ZTSN7glslang18TInterlockOrderingE", !7, i64 0}
!29 = !{!"_ZTSN7glslang10TSourceLocE", !6, i64 0, !15, i64 8, !15, i64 12, !15, i64 16}
!30 = !{!10, !11, 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"

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7glslang11TPublicType12setSpirvTypeERKNS_17TSpirvInstructionEPKNS_7TVectorINS_19TSpirvTypeParameterEEE(ptr nocapture noundef nonnull align 8 dereferenceable(232) %0, ptr noundef nonnull align 8 dereferenceable(44) %1, ptr noundef %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 224
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %11

6:                                                ; preds = %3
  %7 = tail call noundef ptr @_ZN7glslang10TSpirvTypenwEm(i64 noundef 80)
  invoke void @_ZN7glslang10TSpirvTypeC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %7)
          to label %8 unwind label %9

8:                                                ; preds = %6
  store ptr %7, ptr %4, align 8, !tbaa !5
  br label %11

9:                                                ; preds = %6
  %10 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN7glslang10TSpirvTypedlEPv(ptr noundef %7) #3
  resume { ptr, i32 } %10

11:                                               ; preds = %8, %3
  %12 = phi ptr [ %7, %8 ], [ %5, %3 ]
  store i32 20, ptr %0, align 8, !tbaa !29
  %13 = tail call noundef nonnull align 8 dereferenceable(44) ptr @_ZN7glslang17TSpirvInstructionaSERKS0_(ptr noundef nonnull align 8 dereferenceable(44) %12, ptr noundef nonnull align 8 dereferenceable(44) %1)
  %.not5 = icmp eq ptr %2, null
  br i1 %.not5, label %18, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 48
  %17 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN7glslang7TVectorINS_19TSpirvTypeParameterEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(32) %16, ptr noundef nonnull align 8 dereferenceable(32) %2)
  br label %18

18:                                               ; preds = %14, %11
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN7glslang10TSpirvTypenwEm(i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7glslang10TSpirvTypeC2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7glslang10TSpirvTypedlEPv(ptr noundef) local_unnamed_addr #2 align 2

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

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

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 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 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 = { 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, !15, i64 224}
!6 = !{!"_ZTSN7glslang11TPublicTypeE", !7, i64 0, !10, i64 4, !14, i64 8, !22, i64 80, !13, i64 168, !13, i64 168, !13, i64 169, !12, i64 169, !15, i64 176, !15, i64 184, !28, i64 192, !15, i64 216, !15, i64 224}
!7 = !{!"_ZTSN7glslang10TBasicTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN7glslang8TSamplerE", !7, i64 0, !11, i64 1, !12, i64 2, !12, i64 2, !12, i64 2, !12, i64 2, !12, i64 2, !12, i64 2, !13, i64 2, !13, i64 3, !12, i64 3, !12, i64 3}
!11 = !{!"_ZTSN7glslang11TSamplerDimE", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!"_ZTSN7glslang10TQualifierE", !15, i64 0, !16, i64 8, !17, i64 8, !17, i64 9, !18, i64 11, !12, i64 11, !12, i64 11, !12, i64 11, !12, i64 11, !12, i64 11, !12, i64 12, !12, i64 12, !12, i64 12, !12, i64 12, !12, i64 12, !12, i64 12, !12, i64 12, !12, i64 12, !12, i64 13, !12, i64 13, !12, i64 13, !12, i64 13, !12, i64 13, !12, i64 13, !12, i64 13, !12, i64 13, !12, i64 14, !12, i64 14, !12, i64 14, !12, i64 14, !12, i64 14, !12, i64 14, !12, i64 14, !12, i64 14, !12, i64 15, !12, i64 15, !12, i64 15, !19, i64 15, !20, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 29, !13, i64 29, !13, i64 32, !13, i64 34, !13, i64 35, !13, i64 36, !13, i64 36, !13, i64 38, !13, i64 40, !13, i64 41, !13, i64 42, !21, i64 44, !12, i64 45, !12, i64 46, !12, i64 47, !12, i64 48, !13, i64 52, !12, i64 56, !13, i64 60, !15, i64 64}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"_ZTSN7glslang17TStorageQualifierE", !8, i64 0}
!17 = !{!"_ZTSN7glslang16TBuiltInVariableE", !8, i64 0}
!18 = !{!"_ZTSN7glslang19TPrecisionQualifierE", !8, i64 0}
!19 = !{!"_ZTSN7glslang13TLayoutMatrixE", !8, i64 0}
!20 = !{!"_ZTSN7glslang14TLayoutPackingE", !8, i64 0}
!21 = !{!"_ZTSN7glslang13TLayoutFormatE", !8, i64 0}
!22 = !{!"_ZTSN7glslang17TShaderQualifiersE", !23, i64 0, !12, i64 4, !12, i64 5, !13, i64 8, !13, i64 12, !24, i64 16, !25, i64 20, !12, i64 24, !8, i64 28, !8, i64 40, !8, i64 44, !12, i64 56, !12, i64 57, !26, i64 60, !12, i64 64, !13, i64 68, !27, i64 72, !12, i64 76, !12, i64 77, !12, i64 78, !13, i64 80, !12, i64 84}
!23 = !{!"_ZTSN7glslang15TLayoutGeometryE", !8, i64 0}
!24 = !{!"_ZTSN7glslang14TVertexSpacingE", !8, i64 0}
!25 = !{!"_ZTSN7glslang12TVertexOrderE", !8, i64 0}
!26 = !{!"_ZTSN7glslang12TLayoutDepthE", !8, i64 0}
!27 = !{!"_ZTSN7glslang18TInterlockOrderingE", !8, i64 0}
!28 = !{!"_ZTSN7glslang10TSourceLocE", !15, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!29 = !{!6, !7, i64 0}


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