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

; 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.spirv_cross::CompilerMSL::OpCodePreprocessor" = type <{ %"struct.spirv_cross::Compiler::OpcodeHandler", ptr, %"class.std::unordered_map.213", %"class.std::unordered_map.213", i8, i8, i8, i8, i8, i8, i8, i8, i8, [7 x i8] }>
%"struct.spirv_cross::Compiler::OpcodeHandler" = type { ptr }
%"class.std::unordered_map.213" = type { %"class.std::_Hashtable.214" }
%"class.std::_Hashtable.214" = 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 }
%"struct.spirv_cross::SPIRVariable" = type { %"struct.spirv_cross::IVariant.base", %"class.spirv_cross::TypedID.414", i32, i32, %"class.spirv_cross::TypedID.413", %"class.spirv_cross::TypedID.350", %"class.spirv_cross::SmallVector.92", i8, i8, %"class.spirv_cross::TypedID.413", %"class.spirv_cross::SmallVector.7", i8, i8, i8, i8, i32, %"class.spirv_cross::TypedID.415", i8, i8, i8, ptr }
%"struct.spirv_cross::IVariant.base" = type <{ ptr, %"class.spirv_cross::TypedID.413" }>
%"class.spirv_cross::TypedID.414" = type { i32 }
%"class.spirv_cross::TypedID.350" = type { i32 }
%"class.spirv_cross::SmallVector.92" = type { %"class.spirv_cross::VectorView.93", i64, %"class.spirv_cross::AlignedBuffer.94" }
%"class.spirv_cross::VectorView.93" = type { ptr, i64 }
%"class.spirv_cross::AlignedBuffer.94" = type { [32 x i8] }
%"class.spirv_cross::TypedID.413" = type { i32 }
%"class.spirv_cross::SmallVector.7" = type { %"class.spirv_cross::VectorView.8", i64, %"class.spirv_cross::AlignedBuffer.9" }
%"class.spirv_cross::VectorView.8" = type { ptr, i64 }
%"class.spirv_cross::AlignedBuffer.9" = type { [32 x i8] }
%"class.spirv_cross::TypedID.415" = type { i32 }

; 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

declare noundef ptr @_ZN11spirv_cross8Compiler26maybe_get_backing_variableEj(ptr noundef nonnull align 8 dereferenceable(3176), i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11spirv_cross11CompilerMSL18OpCodePreprocessor20check_resource_writeEj(ptr noundef nonnull align 8 dereferenceable(137) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %8 = getelementptr inbounds %"struct.spirv_cross::CompilerMSL::OpCodePreprocessor", ptr %7, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = call noundef ptr @_ZN11spirv_cross8Compiler26maybe_get_backing_variableEj(ptr noundef nonnull align 8 dereferenceable(3176) %9, i32 noundef %10)
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %18

14:                                               ; preds = %2
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.spirv_cross::SPIRVariable", ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !21
  br label %19

18:                                               ; preds = %2
  br label %19

19:                                               ; preds = %18, %14
  %20 = phi i32 [ %17, %14 ], [ 2147483647, %18 ]
  store i32 %20, ptr %6, align 4, !tbaa !35
  %21 = load i32, ptr %6, align 4, !tbaa !35
  %22 = icmp eq i32 %21, 2
  br i1 %22, label %26, label %23

23:                                               ; preds = %19
  %24 = load i32, ptr %6, align 4, !tbaa !35
  %25 = icmp eq i32 %24, 12
  br i1 %25, label %26, label %28

26:                                               ; preds = %23, %19
  %27 = getelementptr inbounds %"struct.spirv_cross::CompilerMSL::OpCodePreprocessor", ptr %7, i32 0, i32 7
  store i8 1, ptr %27, align 1, !tbaa !36
  br label %28

28:                                               ; preds = %26, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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, !6, i64 8}
!12 = !{!"_ZTSN11spirv_cross11CompilerMSL18OpCodePreprocessorE", !13, i64 0, !6, i64 8, !14, i64 16, !14, i64 72, !20, i64 128, !20, i64 129, !20, i64 130, !20, i64 131, !20, i64 132, !20, i64 133, !20, i64 134, !20, i64 135, !20, i64 136}
!13 = !{!"_ZTSN11spirv_cross8Compiler13OpcodeHandlerE"}
!14 = !{!"_ZTSSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE", !15, i64 0}
!15 = !{!"_ZTSSt10_HashtableIjSt4pairIKjjESaIS2_ENSt8__detail10_Select1stESt8equal_toIjESt4hashIjENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE", !6, i64 0, !16, i64 8, !17, i64 16, !16, i64 24, !18, i64 32, !6, i64 48}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!18 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !19, i64 0, !16, i64 8}
!19 = !{!"float", !7, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{!22, !26, i64 16}
!22 = !{!"_ZTSN11spirv_cross12SPIRVariableE", !23, i64 0, !25, i64 12, !26, i64 16, !10, i64 20, !24, i64 24, !27, i64 28, !28, i64 32, !20, i64 88, !20, i64 89, !24, i64 92, !31, i64 96, !20, i64 152, !20, i64 153, !20, i64 154, !20, i64 155, !10, i64 156, !34, i64 160, !20, i64 164, !20, i64 165, !20, i64 166, !6, i64 168}
!23 = !{!"_ZTSN11spirv_cross8IVariantE", !24, i64 8}
!24 = !{!"_ZTSN11spirv_cross7TypedIDILNS_5TypesE0EEE", !10, i64 0}
!25 = !{!"_ZTSN11spirv_cross7TypedIDILNS_5TypesE1EEE", !10, i64 0}
!26 = !{!"_ZTSN3spv12StorageClassE", !7, i64 0}
!27 = !{!"_ZTSN11spirv_cross7TypedIDILNS_5TypesE2EEE", !10, i64 0}
!28 = !{!"_ZTSN11spirv_cross11SmallVectorIjLm8EEE", !29, i64 0, !16, i64 16, !30, i64 24}
!29 = !{!"_ZTSN11spirv_cross10VectorViewIjEE", !6, i64 0, !16, i64 8}
!30 = !{!"_ZTSN11spirv_cross13AlignedBufferIjLm8EEE", !7, i64 0}
!31 = !{!"_ZTSN11spirv_cross11SmallVectorINS_7TypedIDILNS_5TypesE0EEELm8EEE", !32, i64 0, !16, i64 16, !33, i64 24}
!32 = !{!"_ZTSN11spirv_cross10VectorViewINS_7TypedIDILNS_5TypesE0EEEEE", !6, i64 0, !16, i64 8}
!33 = !{!"_ZTSN11spirv_cross13AlignedBufferINS_7TypedIDILNS_5TypesE0EEELm8EEE", !7, i64 0}
!34 = !{!"_ZTSN11spirv_cross7TypedIDILNS_5TypesE6EEE", !10, i64 0}
!35 = !{!26, !26, i64 0}
!36 = !{!12, !20, i64 131}


; 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 noundef ptr @_ZN11spirv_cross8Compiler26maybe_get_backing_variableEj(ptr noundef nonnull align 8 dereferenceable(3176), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11spirv_cross11CompilerMSL18OpCodePreprocessor20check_resource_writeEj(ptr nocapture noundef nonnull align 8 dereferenceable(137) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call noundef ptr @_ZN11spirv_cross8Compiler26maybe_get_backing_variableEj(ptr noundef nonnull align 8 dereferenceable(3176) %4, i32 noundef %1)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.thread, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %5, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !18
  switch i32 %8, label %.thread [
    i32 12, label %9
    i32 2, label %9
  ]

9:                                                ; preds = %6, %6
  %10 = getelementptr inbounds i8, ptr %0, i64 131
  store i8 1, ptr %10, align 1, !tbaa !33
  br label %.thread

.thread:                                          ; preds = %2, %6, %9
  ret void
}

attributes #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)"}
!5 = !{!6, !8, i64 8}
!6 = !{!"_ZTSN11spirv_cross11CompilerMSL18OpCodePreprocessorE", !7, i64 0, !8, i64 8, !11, i64 16, !11, i64 72, !17, i64 128, !17, i64 129, !17, i64 130, !17, i64 131, !17, i64 132, !17, i64 133, !17, i64 134, !17, i64 135, !17, i64 136}
!7 = !{!"_ZTSN11spirv_cross8Compiler13OpcodeHandlerE"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE", !12, i64 0}
!12 = !{!"_ZTSSt10_HashtableIjSt4pairIKjjESaIS2_ENSt8__detail10_Select1stESt8equal_toIjESt4hashIjENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE", !8, i64 0, !13, i64 8, !14, i64 16, !13, i64 24, !15, i64 32, !8, i64 48}
!13 = !{!"long", !9, i64 0}
!14 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !8, i64 0}
!15 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !16, i64 0, !13, i64 8}
!16 = !{!"float", !9, i64 0}
!17 = !{!"bool", !9, i64 0}
!18 = !{!19, !24, i64 16}
!19 = !{!"_ZTSN11spirv_cross12SPIRVariableE", !20, i64 0, !23, i64 12, !24, i64 16, !22, i64 20, !21, i64 24, !25, i64 28, !26, i64 32, !17, i64 88, !17, i64 89, !21, i64 92, !29, i64 96, !17, i64 152, !17, i64 153, !17, i64 154, !17, i64 155, !22, i64 156, !32, i64 160, !17, i64 164, !17, i64 165, !17, i64 166, !8, i64 168}
!20 = !{!"_ZTSN11spirv_cross8IVariantE", !21, i64 8}
!21 = !{!"_ZTSN11spirv_cross7TypedIDILNS_5TypesE0EEE", !22, i64 0}
!22 = !{!"int", !9, i64 0}
!23 = !{!"_ZTSN11spirv_cross7TypedIDILNS_5TypesE1EEE", !22, i64 0}
!24 = !{!"_ZTSN3spv12StorageClassE", !9, i64 0}
!25 = !{!"_ZTSN11spirv_cross7TypedIDILNS_5TypesE2EEE", !22, i64 0}
!26 = !{!"_ZTSN11spirv_cross11SmallVectorIjLm8EEE", !27, i64 0, !13, i64 16, !28, i64 24}
!27 = !{!"_ZTSN11spirv_cross10VectorViewIjEE", !8, i64 0, !13, i64 8}
!28 = !{!"_ZTSN11spirv_cross13AlignedBufferIjLm8EEE", !9, i64 0}
!29 = !{!"_ZTSN11spirv_cross11SmallVectorINS_7TypedIDILNS_5TypesE0EEELm8EEE", !30, i64 0, !13, i64 16, !31, i64 24}
!30 = !{!"_ZTSN11spirv_cross10VectorViewINS_7TypedIDILNS_5TypesE0EEEEE", !8, i64 0, !13, i64 8}
!31 = !{!"_ZTSN11spirv_cross13AlignedBufferINS_7TypedIDILNS_5TypesE0EEELm8EEE", !9, i64 0}
!32 = !{!"_ZTSN11spirv_cross7TypedIDILNS_5TypesE6EEE", !22, i64 0}
!33 = !{!6, !17, i64 131}


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