; LLVM IR from Try/Tempest :: Engine/thirdparty/spirv_cross (spirv_cross_c)

; 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.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::allocator" = type { i8 }
%struct.spvc_resources_s = type { %struct.ScratchMemoryAllocation, ptr, %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.218", %"class.spirv_cross::SmallVector.221", %"class.spirv_cross::SmallVector.221" }
%struct.ScratchMemoryAllocation = type { ptr }
%"class.spirv_cross::SmallVector.218" = type { %"class.spirv_cross::VectorView.219", i64, %"class.spirv_cross::AlignedBuffer.220" }
%"class.spirv_cross::VectorView.219" = type { ptr, i64 }
%"class.spirv_cross::AlignedBuffer.220" = type { [192 x i8] }
%"class.spirv_cross::SmallVector.221" = type { %"class.spirv_cross::VectorView.222", i64, %"class.spirv_cross::AlignedBuffer.223" }
%"class.spirv_cross::VectorView.222" = type { ptr, i64 }
%"class.spirv_cross::AlignedBuffer.223" = type { [256 x i8] }

@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14spvc_context_s12report_errorENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef) #0 align 2

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local i32 @spvc_resources_get_builtin_resource_list_for_type(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 personality ptr @__gxx_personality_v0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %"class.std::__cxx11::basic_string", align 8
  %12 = alloca %"class.std::allocator", align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr null, ptr %10, align 8, !tbaa !5
  %16 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %16, label %23 [
    i32 1, label %17
    i32 2, label %20
  ]

17:                                               ; preds = %4
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.spvc_resources_s, ptr %18, i32 0, i32 16
  store ptr %19, ptr %10, align 8, !tbaa !5
  br label %24

20:                                               ; preds = %4
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.spvc_resources_s, ptr %21, i32 0, i32 17
  store ptr %22, ptr %10, align 8, !tbaa !5
  br label %24

23:                                               ; preds = %4
  br label %24

24:                                               ; preds = %23, %20, %17
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %42, label %27

27:                                               ; preds = %24
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.spvc_resources_s, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #3
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %11, ptr noundef @.str.11, ptr noundef nonnull align 1 dereferenceable(1) %12)
          to label %31 unwind label %33

31:                                               ; preds = %27
  invoke void @_ZN14spvc_context_s12report_errorENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(136) %30, ptr noundef %11)
          to label %32 unwind label %37

32:                                               ; preds = %31
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %11) #3
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  store i32 -4, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %49

33:                                               ; preds = %27
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %13, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %14, align 4
  br label %41

37:                                               ; preds = %31
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %13, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %14, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %11) #3
  br label %41

41:                                               ; preds = %37, %33
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %51

42:                                               ; preds = %24
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = call noundef i64 @_ZNK11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %43) #3
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %44, ptr %45, align 8, !tbaa !21
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = call noundef ptr @_ZNK11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceE4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %46) #3
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %47, ptr %48, align 8, !tbaa !5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %49

49:                                               ; preds = %42, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %50 = load i32, ptr %5, align 4
  ret i32 %50

51:                                               ; preds = %41
  %52 = load ptr, ptr %13, align 8
  %53 = load i32, ptr %14, align 4
  %54 = insertvalue { ptr, i32 } poison, ptr %52, 0
  %55 = insertvalue { ptr, i32 } %54, i32 %53, 1
  resume { ptr, i32 } %55
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceE4dataEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"_ZTS26spvc_builtin_resource_type", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS16spvc_resources_s", !13, i64 0, !6, i64 8, !14, i64 16, !14, i64 232, !14, i64 448, !14, i64 664, !14, i64 880, !14, i64 1096, !14, i64 1312, !14, i64 1528, !14, i64 1744, !14, i64 1960, !14, i64 2176, !14, i64 2392, !14, i64 2608, !14, i64 2824, !18, i64 3040, !18, i64 3320}
!13 = !{!"_ZTS23ScratchMemoryAllocation"}
!14 = !{!"_ZTSN11spirv_cross11SmallVectorI23spvc_reflected_resourceLm8EEE", !15, i64 0, !16, i64 16, !17, i64 24}
!15 = !{!"_ZTSN11spirv_cross10VectorViewI23spvc_reflected_resourceEE", !6, i64 0, !16, i64 8}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN11spirv_cross13AlignedBufferI23spvc_reflected_resourceLm8EEE", !7, i64 0}
!18 = !{!"_ZTSN11spirv_cross11SmallVectorI31spvc_reflected_builtin_resourceLm8EEE", !19, i64 0, !16, i64 16, !20, i64 24}
!19 = !{!"_ZTSN11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceEE", !6, i64 0, !16, i64 8}
!20 = !{!"_ZTSN11spirv_cross13AlignedBufferI31spvc_reflected_builtin_resourceLm8EEE", !7, i64 0}
!21 = !{!16, !16, 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"

%"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::allocator" = type { i8 }

@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14spvc_context_s12report_errorENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef) local_unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local range(i32 -4, 1) i32 @spvc_resources_get_builtin_resource_list_for_type(ptr noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  %6 = alloca %"class.std::allocator", align 1
  switch i32 %1, label %8 [
    i32 1, label %18
    i32 2, label %7
  ]

7:                                                ; preds = %4
  br label %18

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #3
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #3
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull @.str.11, ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %11 unwind label %13

11:                                               ; preds = %8
  invoke void @_ZN14spvc_context_s12report_errorENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(136) %10, ptr noundef nonnull %5)
          to label %12 unwind label %15

12:                                               ; preds = %11
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #3
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  br label %22

13:                                               ; preds = %8
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %17

15:                                               ; preds = %11
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #3
  br label %17

17:                                               ; preds = %15, %13
  %.pn = phi { ptr, i32 } [ %16, %15 ], [ %14, %13 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  resume { ptr, i32 } %.pn

18:                                               ; preds = %4, %7
  %.sink = phi i64 [ 3320, %7 ], [ 3040, %4 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 %.sink
  %20 = tail call noundef i64 @_ZNK11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %19) #3
  store i64 %20, ptr %3, align 8, !tbaa !18
  %21 = tail call noundef ptr @_ZNK11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceE4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %19) #3
  store ptr %21, ptr %2, align 8, !tbaa !19
  br label %22

22:                                               ; preds = %18, %12
  %.013 = phi i32 [ 0, %18 ], [ -4, %12 ]
  ret i32 %.013
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceE4dataEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !8, i64 8}
!6 = !{!"_ZTS16spvc_resources_s", !7, i64 0, !8, i64 8, !11, i64 16, !11, i64 232, !11, i64 448, !11, i64 664, !11, i64 880, !11, i64 1096, !11, i64 1312, !11, i64 1528, !11, i64 1744, !11, i64 1960, !11, i64 2176, !11, i64 2392, !11, i64 2608, !11, i64 2824, !15, i64 3040, !15, i64 3320}
!7 = !{!"_ZTS23ScratchMemoryAllocation"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN11spirv_cross11SmallVectorI23spvc_reflected_resourceLm8EEE", !12, i64 0, !13, i64 16, !14, i64 24}
!12 = !{!"_ZTSN11spirv_cross10VectorViewI23spvc_reflected_resourceEE", !8, i64 0, !13, i64 8}
!13 = !{!"long", !9, i64 0}
!14 = !{!"_ZTSN11spirv_cross13AlignedBufferI23spvc_reflected_resourceLm8EEE", !9, i64 0}
!15 = !{!"_ZTSN11spirv_cross11SmallVectorI31spvc_reflected_builtin_resourceLm8EEE", !16, i64 0, !13, i64 16, !17, i64 24}
!16 = !{!"_ZTSN11spirv_cross10VectorViewI31spvc_reflected_builtin_resourceEE", !8, i64 0, !13, i64 8}
!17 = !{!"_ZTSN11spirv_cross13AlignedBufferI31spvc_reflected_builtin_resourceLm8EEE", !9, i64 0}
!18 = !{!13, !13, i64 0}
!19 = !{!8, !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass