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

%"class.spirv_cross::TypedID.413" = type { i32 }
%"class.spirv_cross::TypedID.414" = type { i32 }
%"struct.spirv_cross::IVariant" = type <{ ptr, %"class.spirv_cross::TypedID.413", [4 x i8] }>
%"struct.spirv_cross::SPIRType" = type { %"struct.spirv_cross::IVariant.base", i32, i32, i32, i32, i32, %"class.spirv_cross::SmallVector.92", %"class.spirv_cross::SmallVector.416", i32, i8, i8, i32, %"class.spirv_cross::SmallVector.227", %"class.spirv_cross::SmallVector.92", %"struct.spirv_cross::SPIRType::ImageType", %"class.spirv_cross::TypedID.414", %"class.spirv_cross::TypedID.414", %"class.std::unordered_set.165" }
%"struct.spirv_cross::IVariant.base" = type <{ ptr, %"class.spirv_cross::TypedID.413" }>
%"class.spirv_cross::SmallVector.416" = type { %"class.spirv_cross::VectorView.417", i64, %"class.spirv_cross::AlignedBuffer.418" }
%"class.spirv_cross::VectorView.417" = type { ptr, i64 }
%"class.spirv_cross::AlignedBuffer.418" = type { [8 x i8] }
%"class.spirv_cross::SmallVector.227" = type { %"class.spirv_cross::VectorView.228", i64, %"class.spirv_cross::AlignedBuffer.229" }
%"class.spirv_cross::VectorView.228" = type { ptr, i64 }
%"class.spirv_cross::AlignedBuffer.229" = type { [32 x i8] }
%"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] }
%"struct.spirv_cross::SPIRType::ImageType" = type { %"class.spirv_cross::TypedID.414", i32, i8, i8, i8, i32, i32, i32 }
%"class.std::unordered_set.165" = type { %"class.std::_Hashtable.166" }
%"class.std::_Hashtable.166" = 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 }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare noundef zeroext i1 @_ZNK11spirv_cross8Compiler14has_decorationENS_7TypedIDILNS_5TypesE0EEEN3spv10DecorationE(ptr noundef nonnull align 8 dereferenceable(3176), i32, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN11spirv_cross11CompilerMSL14is_patch_blockERKNS_8SPIRTypeE(ptr noundef nonnull align 8 dereferenceable(12482) %0, ptr noundef nonnull align 8 dereferenceable(336) %1) #3 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"class.spirv_cross::TypedID.413", align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"class.spirv_cross::TypedID.414", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.spirv_cross::IVariant", ptr %11, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %12, i64 4, i1 false), !tbaa.struct !9
  %13 = getelementptr inbounds %"class.spirv_cross::TypedID.413", ptr %6, i32 0, i32 0
  %14 = load i32, ptr %13, align 4
  %15 = call noundef zeroext i1 @_ZNK11spirv_cross8Compiler14has_decorationENS_7TypedIDILNS_5TypesE0EEEN3spv10DecorationE(ptr noundef nonnull align 8 dereferenceable(3176) %10, i32 %14, i32 noundef 2)
  br i1 %15, label %17, label %16

16:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %43

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !10
  br label %18

18:                                               ; preds = %37, %17
  %19 = load i32, ptr %7, align 4, !tbaa !10
  %20 = zext i32 %19 to i64
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.spirv_cross::SPIRType", ptr %21, i32 0, i32 12
  %23 = call noundef i64 @_ZNK11spirv_cross10VectorViewINS_7TypedIDILNS_5TypesE1EEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %22) #5
  %24 = icmp ult i64 %20, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %18
  store i32 2, ptr %8, align 4
  br label %40

26:                                               ; preds = %18
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.spirv_cross::IVariant", ptr %27, i32 0, i32 1
  %29 = call i32 @_ZNK11spirv_cross7TypedIDILNS_5TypesE0EEcvNS0_IXT_EEEILS1_1EEEv(ptr noundef nonnull align 4 dereferenceable(4) %28)
  %30 = getelementptr inbounds %"class.spirv_cross::TypedID.414", ptr %9, i32 0, i32 0
  store i32 %29, ptr %30, align 4
  %31 = load i32, ptr %7, align 4, !tbaa !10
  %32 = getelementptr inbounds %"class.spirv_cross::TypedID.414", ptr %9, i32 0, i32 0
  %33 = load i32, ptr %32, align 4
  %34 = call noundef zeroext i1 @_ZNK11spirv_cross8Compiler21has_member_decorationENS_7TypedIDILNS_5TypesE1EEEjN3spv10DecorationE(ptr noundef nonnull align 8 dereferenceable(3176) %10, i32 %33, i32 noundef %31, i32 noundef 15)
  br i1 %34, label %36, label %35

35:                                               ; preds = %26
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %40

36:                                               ; preds = %26
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %7, align 4, !tbaa !10
  %39 = add i32 %38, 1
  store i32 %39, ptr %7, align 4, !tbaa !10
  br label %18, !llvm.loop !12

40:                                               ; preds = %35, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  %41 = load i32, ptr %8, align 4
  switch i32 %41, label %45 [
    i32 2, label %42
    i32 1, label %43
  ]

42:                                               ; preds = %40
  store i1 true, ptr %3, align 1
  br label %43

43:                                               ; preds = %42, %40, %16
  %44 = load i1, ptr %3, align 1
  ret i1 %44

45:                                               ; preds = %40
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZNK11spirv_cross7TypedIDILNS_5TypesE0EEcvNS0_IXT_EEEILS1_1EEEv(ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

declare noundef zeroext i1 @_ZNK11spirv_cross8Compiler21has_member_decorationENS_7TypedIDILNS_5TypesE1EEEjN3spv10DecorationE(ptr noundef nonnull align 8 dereferenceable(3176), i32, i32 noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #4 = { 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 #5 = { 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 = !{i64 0, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN11spirv_cross11CompilerMSL14is_patch_blockERKNS_8SPIRTypeE(ptr noundef nonnull align 8 dereferenceable(12482) %0, ptr noundef nonnull align 8 dereferenceable(336) %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %.sroa.04.0.copyload = load i32, ptr %3, align 8, !tbaa !5
  %4 = tail call noundef zeroext i1 @_ZNK11spirv_cross8Compiler14has_decorationENS_7TypedIDILNS_5TypesE0EEEN3spv10DecorationE(ptr noundef nonnull align 8 dereferenceable(3176) %0, i32 %.sroa.04.0.copyload, i32 noundef 2)
  br i1 %4, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 136
  %6 = tail call noundef i64 @_ZNK11spirv_cross10VectorViewINS_7TypedIDILNS_5TypesE1EEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #3
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %.loopexit, label %.lr.ph

8:                                                ; preds = %.lr.ph
  %9 = add i32 %.01011, 1
  %10 = zext i32 %9 to i64
  %11 = tail call noundef i64 @_ZNK11spirv_cross10VectorViewINS_7TypedIDILNS_5TypesE1EEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #3
  %.not = icmp ugt i64 %11, %10
  br i1 %.not, label %.lr.ph, label %.loopexit, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader, %8
  %.01011 = phi i32 [ %9, %8 ], [ 0, %.preheader ]
  %12 = tail call i32 @_ZNK11spirv_cross7TypedIDILNS_5TypesE0EEcvNS0_IXT_EEEILS1_1EEEv(ptr noundef nonnull align 4 dereferenceable(4) %3)
  %13 = tail call noundef zeroext i1 @_ZNK11spirv_cross8Compiler21has_member_decorationENS_7TypedIDILNS_5TypesE1EEEjN3spv10DecorationE(ptr noundef nonnull align 8 dereferenceable(3176) %0, i32 %12, i32 noundef %.01011, i32 noundef 15)
  br i1 %13, label %8, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %8, %.preheader, %2
  %.1 = phi i1 [ false, %2 ], [ true, %.preheader ], [ %13, %8 ], [ %13, %.lr.ph ]
  ret i1 %.1
}

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZNK11spirv_cross7TypedIDILNS_5TypesE0EEcvNS0_IXT_EEEILS1_1EEEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZNK11spirv_cross8Compiler21has_member_decorationENS_7TypedIDILNS_5TypesE1EEEjN3spv10DecorationE(ptr noundef nonnull align 8 dereferenceable(3176), i32, i32 noundef, i32 noundef) local_unnamed_addr #0

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" }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass