; LLVM IR from Dragons-Lake/REI :: sources/REI/3rdParty/spirv_reflect (spirv_reflect)

; 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.SpvReflectShaderModule = type { i32, ptr, i32, i32, ptr, i32, i32, ptr, ptr, i32, i32, i32, ptr, i32, [64 x %struct.SpvReflectDescriptorSet], i32, ptr, i32, ptr, i32, ptr, ptr }
%struct.SpvReflectDescriptorSet = type { i32, i32, ptr }
%struct.SpvReflectEntryPoint = type { ptr, i32, i32, i32, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, %struct.LocalSize, i32, i32 }
%struct.LocalSize = type { i32, i32, i32 }
%struct.SpvReflectBlockVariable = type { i32, ptr, i32, i32, i32, i32, i32, %struct.SpvReflectNumericTraits, %struct.SpvReflectArrayTraits, i32, i32, ptr, ptr }
%struct.SpvReflectNumericTraits = type { %struct.Scalar, %struct.Vector, %struct.Matrix }
%struct.Scalar = type { i32, i32 }
%struct.Vector = type { i32 }
%struct.Matrix = type { i32, i32, i32 }
%struct.SpvReflectArrayTraits = type { i32, [32 x i32], 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

; Function Attrs: nounwind uwtable
declare dso_local ptr @spvReflectGetEntryPoint(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @SearchSortedUint32(ptr noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @spvReflectGetEntryPointPushConstantBlock(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store ptr null, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %74

15:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call ptr @spvReflectGetEntryPoint(ptr noundef %16, ptr noundef %17)
  store ptr %18, ptr %9, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %27

21:                                               ; preds = %15
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 8, ptr %25, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %24, %21
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %71

27:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %66, %27
  %29 = load i32, ptr %11, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.SpvReflectShaderModule, ptr %30, i32 0, i32 19
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = icmp ult i32 %29, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store i32 2, ptr %10, align 4
  br label %69

35:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #2
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.SpvReflectEntryPoint, ptr %36, i32 0, i32 13
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.SpvReflectEntryPoint, ptr %39, i32 0, i32 12
  %41 = load i32, ptr %40, align 8, !tbaa !16
  %42 = zext i32 %41 to i64
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.SpvReflectShaderModule, ptr %43, i32 0, i32 20
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds %struct.SpvReflectBlockVariable, ptr %45, i64 %47
  %49 = getelementptr inbounds %struct.SpvReflectBlockVariable, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !18
  %51 = call zeroext i1 @SearchSortedUint32(ptr noundef %38, i64 noundef %42, i32 noundef %50)
  %52 = zext i1 %51 to i8
  store i8 %52, ptr %12, align 1, !tbaa !25
  %53 = load i8, ptr %12, align 1, !tbaa !25, !range !27, !noundef !28
  %54 = trunc i8 %53 to i1
  br i1 %54, label %55, label %62

55:                                               ; preds = %35
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.SpvReflectShaderModule, ptr %56, i32 0, i32 20
  %58 = load ptr, ptr %57, align 8, !tbaa !17
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds %struct.SpvReflectBlockVariable, ptr %58, i64 %60
  store ptr %61, ptr %8, align 8, !tbaa !5
  store i32 2, ptr %10, align 4
  br label %63

62:                                               ; preds = %35
  store i32 0, ptr %10, align 4
  br label %63

63:                                               ; preds = %62, %55
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #2
  %64 = load i32, ptr %10, align 4
  switch i32 %64, label %69 [
    i32 0, label %65
  ]

65:                                               ; preds = %63
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = add i32 %67, 1
  store i32 %68, ptr %11, align 4, !tbaa !9
  br label %28, !llvm.loop !29

69:                                               ; preds = %63, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %70

70:                                               ; preds = %69
  store i32 0, ptr %10, align 4
  br label %71

71:                                               ; preds = %70, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  %72 = load i32, ptr %10, align 4
  switch i32 %72, label %91 [
    i32 0, label %73
  ]

73:                                               ; preds = %71
  br label %74

74:                                               ; preds = %73, %3
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %89

77:                                               ; preds = %74
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = icmp ne ptr %78, null
  br i1 %79, label %80, label %81

80:                                               ; preds = %77
  br label %86

81:                                               ; preds = %77
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = icmp eq ptr %82, null
  %84 = zext i1 %83 to i64
  %85 = select i1 %83, i32 5, i32 8
  br label %86

86:                                               ; preds = %81, %80
  %87 = phi i32 [ 0, %80 ], [ %85, %81 ]
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %87, ptr %88, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %86, %74
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %90, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %91

91:                                               ; preds = %89, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %92 = load ptr, ptr %4, align 8
  ret ptr %92
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 1144}
!12 = !{!"SpvReflectShaderModule", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !6, i64 72, !10, i64 80, !7, i64 88, !10, i64 1112, !6, i64 1120, !10, i64 1128, !6, i64 1136, !10, i64 1144, !6, i64 1152, !6, i64 1160}
!13 = !{!14, !6, i64 88}
!14 = !{!"SpvReflectEntryPoint", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !10, i64 80, !6, i64 88, !15, i64 96, !10, i64 108, !10, i64 112}
!15 = !{!"LocalSize", !10, i64 0, !10, i64 4, !10, i64 8}
!16 = !{!14, !10, i64 80}
!17 = !{!12, !6, i64 1152}
!18 = !{!19, !10, i64 0}
!19 = !{!"SpvReflectBlockVariable", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !20, i64 36, !24, i64 60, !10, i64 196, !10, i64 200, !6, i64 208, !6, i64 216}
!20 = !{!"SpvReflectNumericTraits", !21, i64 0, !22, i64 8, !23, i64 12}
!21 = !{!"Scalar", !10, i64 0, !10, i64 4}
!22 = !{!"Vector", !10, i64 0}
!23 = !{!"Matrix", !10, i64 0, !10, i64 4, !10, i64 8}
!24 = !{!"SpvReflectArrayTraits", !10, i64 0, !7, i64 4, !10, i64 132}
!25 = !{!26, !26, i64 0}
!26 = !{!"_Bool", !7, i64 0}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = distinct !{!29, !30}
!30 = !{!"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"

%struct.SpvReflectBlockVariable = type { i32, ptr, i32, i32, i32, i32, i32, %struct.SpvReflectNumericTraits, %struct.SpvReflectArrayTraits, i32, i32, ptr, ptr }
%struct.SpvReflectNumericTraits = type { %struct.Scalar, %struct.Vector, %struct.Matrix }
%struct.Scalar = type { i32, i32 }
%struct.Vector = type { i32 }
%struct.Matrix = type { i32, i32, i32 }
%struct.SpvReflectArrayTraits = type { i32, [32 x i32], i32 }

; Function Attrs: nounwind uwtable
declare dso_local ptr @spvReflectGetEntryPoint(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @SearchSortedUint32(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @spvReflectGetEntryPointPushConstantBlock(ptr noundef %0, ptr noundef %1, ptr noundef writeonly %2) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %._crit_edge, label %4

4:                                                ; preds = %3
  %5 = tail call ptr @spvReflectGetEntryPoint(ptr noundef nonnull %0, ptr noundef %1)
  %.not33 = icmp eq ptr %5, null
  br i1 %.not33, label %11, label %.preheader

.preheader:                                       ; preds = %4
  %6 = getelementptr inbounds i8, ptr %0, i64 1144
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not43 = icmp eq i32 %7, 0
  br i1 %.not43, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %8 = getelementptr inbounds i8, ptr %5, i64 88
  %9 = getelementptr inbounds i8, ptr %5, i64 80
  %10 = getelementptr inbounds i8, ptr %0, i64 1152
  br label %16

11:                                               ; preds = %4
  %.not32 = icmp eq ptr %2, null
  br i1 %.not32, label %.thread37, label %.thread37.sink.split

12:                                               ; preds = %16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr %6, align 8, !tbaa !5
  %14 = zext i32 %13 to i64
  %15 = icmp ult i64 %indvars.iv.next, %14
  br i1 %15, label %16, label %._crit_edge, !llvm.loop !11

16:                                               ; preds = %.lr.ph, %12
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %12 ]
  %17 = load ptr, ptr %8, align 8, !tbaa !13
  %18 = load i32, ptr %9, align 8, !tbaa !16
  %19 = zext i32 %18 to i64
  %20 = load ptr, ptr %10, align 8, !tbaa !17
  %21 = getelementptr inbounds %struct.SpvReflectBlockVariable, ptr %20, i64 %indvars.iv
  %22 = load i32, ptr %21, align 8, !tbaa !18
  %23 = tail call zeroext i1 @SearchSortedUint32(ptr noundef %17, i64 noundef %19, i32 noundef %22)
  br i1 %23, label %.thread39, label %12

.thread39:                                        ; preds = %16
  %24 = load ptr, ptr %10, align 8, !tbaa !17
  %25 = getelementptr inbounds %struct.SpvReflectBlockVariable, ptr %24, i64 %indvars.iv
  br label %._crit_edge

._crit_edge:                                      ; preds = %12, %.preheader, %.thread39, %3
  %.4 = phi ptr [ null, %3 ], [ %25, %.thread39 ], [ null, %.preheader ], [ null, %12 ]
  %.not34 = icmp eq ptr %2, null
  br i1 %.not34, label %.thread37, label %26

26:                                               ; preds = %._crit_edge
  %.not35 = icmp eq ptr %.4, null
  %27 = select i1 %.not, i32 5, i32 8
  %28 = select i1 %.not35, i32 %27, i32 0
  br label %.thread37.sink.split

.thread37.sink.split:                             ; preds = %11, %26
  %.sink = phi i32 [ %28, %26 ], [ 8, %11 ]
  %.1.ph = phi ptr [ %.4, %26 ], [ null, %11 ]
  store i32 %.sink, ptr %2, align 4, !tbaa !25
  br label %.thread37

.thread37:                                        ; preds = %.thread37.sink.split, %11, %._crit_edge
  %.1 = phi ptr [ %.4, %._crit_edge ], [ null, %11 ], [ %.1.ph, %.thread37.sink.split ]
  ret ptr %.1
}

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

!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, !7, i64 1144}
!6 = !{!"SpvReflectShaderModule", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !10, i64 24, !7, i64 32, !7, i64 36, !10, i64 40, !10, i64 48, !7, i64 56, !7, i64 60, !7, i64 64, !10, i64 72, !7, i64 80, !8, i64 88, !7, i64 1112, !10, i64 1120, !7, i64 1128, !10, i64 1136, !7, i64 1144, !10, i64 1152, !10, i64 1160}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 88}
!14 = !{!"SpvReflectEntryPoint", !10, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !10, i64 56, !7, i64 64, !10, i64 72, !7, i64 80, !10, i64 88, !15, i64 96, !7, i64 108, !7, i64 112}
!15 = !{!"LocalSize", !7, i64 0, !7, i64 4, !7, i64 8}
!16 = !{!14, !7, i64 80}
!17 = !{!6, !10, i64 1152}
!18 = !{!19, !7, i64 0}
!19 = !{!"SpvReflectBlockVariable", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !20, i64 36, !24, i64 60, !7, i64 196, !7, i64 200, !10, i64 208, !10, i64 216}
!20 = !{!"SpvReflectNumericTraits", !21, i64 0, !22, i64 8, !23, i64 12}
!21 = !{!"Scalar", !7, i64 0, !7, i64 4}
!22 = !{!"Vector", !7, i64 0}
!23 = !{!"Matrix", !7, i64 0, !7, i64 4, !7, i64 8}
!24 = !{!"SpvReflectArrayTraits", !7, i64 0, !8, i64 4, !7, i64 132}
!25 = !{!7, !7, i64 0}


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