; 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.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.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 uwtable
declare dso_local ptr @spvReflectGetEntryPoint(ptr noundef, ptr noundef) #1

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

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

17:                                               ; preds = %4
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 5, ptr %21, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %20, %17
  store ptr null, ptr %5, align 8
  br label %104

23:                                               ; preds = %4
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 0
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %35

29:                                               ; preds = %23
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %34

32:                                               ; preds = %29
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 8, ptr %33, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %32, %29
  store ptr null, ptr %5, align 8
  br label %104

35:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr null, ptr %10, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %86

38:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = call ptr @spvReflectGetEntryPoint(ptr noundef %39, ptr noundef %40)
  store ptr %41, ptr %11, align 8, !tbaa !5
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %50

44:                                               ; preds = %38
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %49

47:                                               ; preds = %44
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 8, ptr %48, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %47, %44
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %83

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

51:                                               ; preds = %79, %50
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.SpvReflectEntryPoint, ptr %53, i32 0, i32 4
  %55 = load i32, ptr %54, align 4, !tbaa !12
  %56 = icmp ult i32 %52, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %51
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %82

58:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.SpvReflectEntryPoint, ptr %59, i32 0, i32 5
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds %struct.SpvReflectInterfaceVariable, ptr %61, i64 %63
  store ptr %64, ptr %14, align 8, !tbaa !5
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.SpvReflectInterfaceVariable, ptr %65, i32 0, i32 4
  %67 = load ptr, ptr %66, align 8, !tbaa !16
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %78

69:                                               ; preds = %58
  %70 = load ptr, ptr %14, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.SpvReflectInterfaceVariable, ptr %70, i32 0, i32 4
  %72 = load ptr, ptr %71, align 8, !tbaa !16
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = call i32 @strcmp(ptr noundef %72, ptr noundef %73) #4
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %78

76:                                               ; preds = %69
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %77, ptr %10, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %76, %69, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %13, align 4, !tbaa !9
  %81 = add i32 %80, 1
  store i32 %81, ptr %13, align 4, !tbaa !9
  br label %51, !llvm.loop !24

82:                                               ; preds = %57
  store i32 0, ptr %12, align 4
  br label %83

83:                                               ; preds = %82, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %84 = load i32, ptr %12, align 4
  switch i32 %84, label %103 [
    i32 0, label %85
  ]

85:                                               ; preds = %83
  br label %86

86:                                               ; preds = %85, %35
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = icmp ne ptr %87, null
  br i1 %88, label %89, label %101

89:                                               ; preds = %86
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = icmp ne ptr %90, null
  br i1 %91, label %92, label %93

92:                                               ; preds = %89
  br label %98

93:                                               ; preds = %89
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = icmp eq ptr %94, null
  %96 = zext i1 %95 to i64
  %97 = select i1 %95, i32 5, i32 8
  br label %98

98:                                               ; preds = %93, %92
  %99 = phi i32 [ 0, %92 ], [ %97, %93 ]
  %100 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %99, ptr %100, align 4, !tbaa !9
  br label %101

101:                                              ; preds = %98, %86
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %102, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %103

103:                                              ; preds = %101, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %104

104:                                              ; preds = %103, %34, %22
  %105 = load ptr, ptr %5, align 8
  ret ptr %105
}

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 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 #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 20}
!13 = !{!"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, !14, i64 96, !10, i64 108, !10, i64 112}
!14 = !{!"LocalSize", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!13, !6, i64 24}
!16 = !{!17, !6, i64 24}
!17 = !{!"SpvReflectInterfaceVariable", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !10, i64 32, !10, i64 36, !18, i64 40, !22, i64 64, !10, i64 200, !6, i64 208, !10, i64 216, !6, i64 224, !23, i64 232}
!18 = !{!"SpvReflectNumericTraits", !19, i64 0, !20, i64 8, !21, i64 12}
!19 = !{!"Scalar", !10, i64 0, !10, i64 4}
!20 = !{!"Vector", !10, i64 0}
!21 = !{!"Matrix", !10, i64 0, !10, i64 4, !10, i64 8}
!22 = !{!"SpvReflectArrayTraits", !10, i64 0, !7, i64 4, !10, i64 132}
!23 = !{!"", !10, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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: nounwind uwtable
declare dso_local ptr @spvReflectGetEntryPoint(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @spvReflectGetEntryPointInputVariableBySemantic(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2, ptr noundef writeonly %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %2, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %4
  %.not45 = icmp eq ptr %3, null
  br i1 %.not45, label %.thread, label %.thread.sink.split

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

10:                                               ; preds = %7
  %.not44 = icmp eq ptr %3, null
  br i1 %.not44, label %.thread, label %.thread.sink.split

11:                                               ; preds = %7
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.loopexit, label %12

12:                                               ; preds = %11
  %13 = tail call ptr @spvReflectGetEntryPoint(ptr noundef nonnull %0, ptr noundef %1)
  %.not41 = icmp eq ptr %13, null
  br i1 %.not41, label %18, label %.preheader

.preheader:                                       ; preds = %12
  %14 = getelementptr inbounds i8, ptr %13, i64 20
  %15 = load i32, ptr %14, align 4, !tbaa !8
  %.not49 = icmp eq i32 %15, 0
  br i1 %.not49, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %16 = getelementptr inbounds i8, ptr %13, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %wide.trip.count = zext i32 %15 to i64
  br label %19

18:                                               ; preds = %12
  %.not40 = icmp eq ptr %3, null
  br i1 %.not40, label %.thread, label %.thread.sink.split

19:                                               ; preds = %.lr.ph, %26
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %.02947 = phi ptr [ null, %.lr.ph ], [ %.130, %26 ]
  %20 = getelementptr inbounds %struct.SpvReflectInterfaceVariable, ptr %17, i64 %indvars.iv
  %21 = getelementptr inbounds i8, ptr %20, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %.not39 = icmp eq ptr %22, null
  br i1 %.not39, label %26, label %23

23:                                               ; preds = %19
  %24 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %22, ptr noundef nonnull dereferenceable(1) %2) #2
  %25 = icmp eq i32 %24, 0
  %spec.select = select i1 %25, ptr %20, ptr %.02947
  br label %26

26:                                               ; preds = %23, %19
  %.130 = phi ptr [ %.02947, %19 ], [ %spec.select, %23 ]
  %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 %19, !llvm.loop !22

.loopexit:                                        ; preds = %26, %.preheader, %11
  %.3 = phi ptr [ null, %11 ], [ null, %.preheader ], [ %.130, %26 ]
  %.not42 = icmp eq ptr %3, null
  br i1 %.not42, label %.thread, label %27

27:                                               ; preds = %.loopexit
  %.not43 = icmp eq ptr %.3, null
  %28 = select i1 %.not, i32 5, i32 8
  %29 = select i1 %.not43, i32 %28, i32 0
  br label %.thread.sink.split

.thread.sink.split:                               ; preds = %18, %10, %6, %27
  %.sink = phi i32 [ %29, %27 ], [ 5, %6 ], [ 8, %10 ], [ 8, %18 ]
  %.2.ph = phi ptr [ %.3, %27 ], [ null, %6 ], [ null, %10 ], [ null, %18 ]
  store i32 %.sink, ptr %3, align 4, !tbaa !24
  br label %.thread

.thread:                                          ; preds = %.thread.sink.split, %18, %.loopexit, %10, %6
  %.2 = phi ptr [ null, %6 ], [ null, %10 ], [ %.3, %.loopexit ], [ null, %18 ], [ %.2.ph, %.thread.sink.split ]
  ret ptr %.2
}

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" }
attributes #1 = { 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 #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, !11, i64 20}
!9 = !{!"SpvReflectEntryPoint", !10, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !10, i64 24, !11, i64 32, !10, i64 40, !11, i64 48, !10, i64 56, !11, i64 64, !10, i64 72, !11, i64 80, !10, i64 88, !12, i64 96, !11, i64 108, !11, i64 112}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"LocalSize", !11, i64 0, !11, i64 4, !11, i64 8}
!13 = !{!9, !10, i64 24}
!14 = !{!15, !10, i64 24}
!15 = !{!"SpvReflectInterfaceVariable", !11, i64 0, !10, i64 8, !11, i64 16, !11, i64 20, !10, i64 24, !11, i64 32, !11, i64 36, !16, i64 40, !20, i64 64, !11, i64 200, !10, i64 208, !11, i64 216, !10, i64 224, !21, i64 232}
!16 = !{!"SpvReflectNumericTraits", !17, i64 0, !18, i64 8, !19, i64 12}
!17 = !{!"Scalar", !11, i64 0, !11, i64 4}
!18 = !{!"Vector", !11, i64 0}
!19 = !{!"Matrix", !11, i64 0, !11, i64 4, !11, i64 8}
!20 = !{!"SpvReflectArrayTraits", !11, i64 0, !6, i64 4, !11, i64 132}
!21 = !{!"", !11, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!11, !11, i64 0}


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