; 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.SpvReflectInterfaceVariable = type { i32, ptr, i32, i32, ptr, i32, i32, %struct.SpvReflectNumericTraits, %struct.SpvReflectArrayTraits, i32, ptr, i32, ptr, %struct.anon.0 }
%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 }
%struct.anon.0 = 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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @spvReflectGetInputVariableBySemantic(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %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 i32, align 4
  %10 = alloca ptr, align 8
  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
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %19

13:                                               ; preds = %3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 5, ptr %17, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %16, %13
  store ptr null, ptr %4, align 8
  br label %84

19:                                               ; preds = %3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 0
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %31

25:                                               ; preds = %19
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %30

28:                                               ; preds = %25
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 8, ptr %29, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %28, %25
  store ptr null, ptr %4, align 8
  br label %84

31:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %67

34:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %63, %34
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.SpvReflectShaderModule, ptr %37, i32 0, i32 15
  %39 = load i32, ptr %38, align 8, !tbaa !12
  %40 = icmp ult i32 %36, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %66

42:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.SpvReflectShaderModule, ptr %43, i32 0, i32 16
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds %struct.SpvReflectInterfaceVariable, ptr %45, i64 %47
  store ptr %48, ptr %10, align 8, !tbaa !5
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.SpvReflectInterfaceVariable, ptr %49, i32 0, i32 4
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %62

53:                                               ; preds = %42
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.SpvReflectInterfaceVariable, ptr %54, i32 0, i32 4
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = call i32 @strcmp(ptr noundef %56, ptr noundef %57) #4
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %62

60:                                               ; preds = %53
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %61, ptr %8, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %60, %53, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = add i32 %64, 1
  store i32 %65, ptr %9, align 4, !tbaa !9
  br label %35, !llvm.loop !23

66:                                               ; preds = %41
  br label %67

67:                                               ; preds = %66, %31
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %82

70:                                               ; preds = %67
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = icmp ne ptr %71, null
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  br label %79

74:                                               ; preds = %70
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = icmp eq ptr %75, null
  %77 = zext i1 %76 to i64
  %78 = select i1 %76, i32 5, i32 8
  br label %79

79:                                               ; preds = %74, %73
  %80 = phi i32 [ 0, %73 ], [ %78, %74 ]
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %80, ptr %81, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %79, %67
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %83, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %84

84:                                               ; preds = %82, %30, %18
  %85 = load ptr, ptr %4, align 8
  ret ptr %85
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 1112}
!13 = !{!"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}
!14 = !{!13, !6, i64 1120}
!15 = !{!16, !6, i64 24}
!16 = !{!"SpvReflectInterfaceVariable", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !10, i64 32, !10, i64 36, !17, i64 40, !21, i64 64, !10, i64 200, !6, i64 208, !10, i64 216, !6, i64 224, !22, i64 232}
!17 = !{!"SpvReflectNumericTraits", !18, i64 0, !19, i64 8, !20, i64 12}
!18 = !{!"Scalar", !10, i64 0, !10, i64 4}
!19 = !{!"Vector", !10, i64 0}
!20 = !{!"Matrix", !10, i64 0, !10, i64 4, !10, i64 8}
!21 = !{!"SpvReflectArrayTraits", !10, i64 0, !7, i64 4, !10, i64 132}
!22 = !{!"", !10, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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.SpvReflectInterfaceVariable = type { i32, ptr, i32, i32, ptr, i32, i32, %struct.SpvReflectNumericTraits, %struct.SpvReflectArrayTraits, i32, ptr, i32, ptr, %struct.anon.0 }
%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 }
%struct.anon.0 = type { i32 }

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local ptr @spvReflectGetInputVariableBySemantic(ptr noundef readonly %0, ptr noundef readonly %1, ptr noundef writeonly %2) local_unnamed_addr #1 {
  %4 = icmp eq ptr %1, null
  br i1 %4, label %5, label %6

5:                                                ; preds = %3
  %.not33 = icmp eq ptr %2, null
  br i1 %.not33, label %26, label %.sink.split

6:                                                ; preds = %3
  %7 = load i8, ptr %1, align 1, !tbaa !5
  %8 = icmp eq i8 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  %.not32 = icmp eq ptr %2, null
  br i1 %.not32, label %26, label %.sink.split

10:                                               ; preds = %6
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %10
  %11 = getelementptr inbounds i8, ptr %0, i64 1112
  %12 = load i32, ptr %11, align 8, !tbaa !8
  %.not36 = icmp eq i32 %12, 0
  br i1 %.not36, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %13 = getelementptr inbounds i8, ptr %0, i64 1120
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %wide.trip.count = zext i32 %12 to i64
  br label %15

15:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %.02234 = phi ptr [ null, %.lr.ph ], [ %.1, %22 ]
  %16 = getelementptr inbounds %struct.SpvReflectInterfaceVariable, ptr %14, i64 %indvars.iv
  %17 = getelementptr inbounds i8, ptr %16, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %.not31 = icmp eq ptr %18, null
  br i1 %.not31, label %22, label %19

19:                                               ; preds = %15
  %20 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %1) #2
  %21 = icmp eq i32 %20, 0
  %spec.select = select i1 %21, ptr %16, ptr %.02234
  br label %22

22:                                               ; preds = %19, %15
  %.1 = phi ptr [ %.02234, %15 ], [ %spec.select, %19 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %15, !llvm.loop !21

.loopexit:                                        ; preds = %22, %.preheader, %10
  %.2 = phi ptr [ null, %10 ], [ null, %.preheader ], [ %.1, %22 ]
  %.not29 = icmp eq ptr %2, null
  br i1 %.not29, label %26, label %23

23:                                               ; preds = %.loopexit
  %.not30 = icmp eq ptr %.2, null
  %24 = select i1 %.not, i32 5, i32 8
  %25 = select i1 %.not30, i32 %24, i32 0
  br label %.sink.split

.sink.split:                                      ; preds = %9, %5, %23
  %.sink = phi i32 [ %25, %23 ], [ 5, %5 ], [ 8, %9 ]
  %.0.ph = phi ptr [ %.2, %23 ], [ null, %5 ], [ null, %9 ]
  store i32 %.sink, ptr %2, align 4, !tbaa !23
  br label %26

26:                                               ; preds = %.sink.split, %.loopexit, %9, %5
  %.0 = phi ptr [ null, %5 ], [ null, %9 ], [ %.2, %.loopexit ], [ %.0.ph, %.sink.split ]
  ret ptr %.0
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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 willreturn memory(read) }

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


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