; LLVM IR from openssl/openssl :: providers/common (provider_seeding)

; 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.ossl_dispatch_st = type { i32, ptr }

@c_get_entropy = external hidden global ptr, align 8
@c_get_user_entropy = external hidden global ptr, align 8
@c_cleanup_entropy = external hidden global ptr, align 8
@c_cleanup_user_entropy = external hidden global ptr, align 8
@c_get_nonce = external hidden global ptr, align 8
@c_get_user_nonce = external hidden global ptr, align 8
@c_cleanup_nonce = external hidden global ptr, align 8
@c_cleanup_user_nonce = external hidden global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_prov_seeding_from_dispatch(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %142, %1
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.ossl_dispatch_st, ptr %5, i32 0, i32 0
  %7 = load i32, ptr %6, align 8, !tbaa !9
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %9, label %145

9:                                                ; preds = %4
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ossl_dispatch_st, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !9
  switch i32 %12, label %141 [
    i32 101, label %13
    i32 98, label %29
    i32 102, label %45
    i32 96, label %61
    i32 103, label %77
    i32 99, label %93
    i32 104, label %109
    i32 97, label %125
  ]

13:                                               ; preds = %9
  br label %14

14:                                               ; preds = %13
  %15 = load ptr, ptr @c_get_entropy, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %20

17:                                               ; preds = %14
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = call ptr @OSSL_FUNC_get_entropy(ptr noundef %18)
  store ptr %19, ptr @c_get_entropy, align 8, !tbaa !5
  br label %27

20:                                               ; preds = %14
  %21 = load ptr, ptr @c_get_entropy, align 8, !tbaa !5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call ptr @OSSL_FUNC_get_entropy(ptr noundef %22)
  %24 = icmp ne ptr %21, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  store i32 0, ptr %2, align 4
  br label %146

26:                                               ; preds = %20
  br label %27

27:                                               ; preds = %26, %17
  br label %28

28:                                               ; preds = %27
  br label %141

29:                                               ; preds = %9
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr @c_get_user_entropy, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = call ptr @OSSL_FUNC_get_user_entropy(ptr noundef %34)
  store ptr %35, ptr @c_get_user_entropy, align 8, !tbaa !5
  br label %43

36:                                               ; preds = %30
  %37 = load ptr, ptr @c_get_user_entropy, align 8, !tbaa !5
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call ptr @OSSL_FUNC_get_user_entropy(ptr noundef %38)
  %40 = icmp ne ptr %37, %39
  br i1 %40, label %41, label %42

41:                                               ; preds = %36
  store i32 0, ptr %2, align 4
  br label %146

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42, %33
  br label %44

44:                                               ; preds = %43
  br label %141

45:                                               ; preds = %9
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr @c_cleanup_entropy, align 8, !tbaa !5
  %48 = icmp eq ptr %47, null
  br i1 %48, label %49, label %52

49:                                               ; preds = %46
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call ptr @OSSL_FUNC_cleanup_entropy(ptr noundef %50)
  store ptr %51, ptr @c_cleanup_entropy, align 8, !tbaa !5
  br label %59

52:                                               ; preds = %46
  %53 = load ptr, ptr @c_cleanup_entropy, align 8, !tbaa !5
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = call ptr @OSSL_FUNC_cleanup_entropy(ptr noundef %54)
  %56 = icmp ne ptr %53, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %52
  store i32 0, ptr %2, align 4
  br label %146

58:                                               ; preds = %52
  br label %59

59:                                               ; preds = %58, %49
  br label %60

60:                                               ; preds = %59
  br label %141

61:                                               ; preds = %9
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr @c_cleanup_user_entropy, align 8, !tbaa !5
  %64 = icmp eq ptr %63, null
  br i1 %64, label %65, label %68

65:                                               ; preds = %62
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = call ptr @OSSL_FUNC_cleanup_user_entropy(ptr noundef %66)
  store ptr %67, ptr @c_cleanup_user_entropy, align 8, !tbaa !5
  br label %75

68:                                               ; preds = %62
  %69 = load ptr, ptr @c_cleanup_user_entropy, align 8, !tbaa !5
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = call ptr @OSSL_FUNC_cleanup_user_entropy(ptr noundef %70)
  %72 = icmp ne ptr %69, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %68
  store i32 0, ptr %2, align 4
  br label %146

74:                                               ; preds = %68
  br label %75

75:                                               ; preds = %74, %65
  br label %76

76:                                               ; preds = %75
  br label %141

77:                                               ; preds = %9
  br label %78

78:                                               ; preds = %77
  %79 = load ptr, ptr @c_get_nonce, align 8, !tbaa !5
  %80 = icmp eq ptr %79, null
  br i1 %80, label %81, label %84

81:                                               ; preds = %78
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = call ptr @OSSL_FUNC_get_nonce(ptr noundef %82)
  store ptr %83, ptr @c_get_nonce, align 8, !tbaa !5
  br label %91

84:                                               ; preds = %78
  %85 = load ptr, ptr @c_get_nonce, align 8, !tbaa !5
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = call ptr @OSSL_FUNC_get_nonce(ptr noundef %86)
  %88 = icmp ne ptr %85, %87
  br i1 %88, label %89, label %90

89:                                               ; preds = %84
  store i32 0, ptr %2, align 4
  br label %146

90:                                               ; preds = %84
  br label %91

91:                                               ; preds = %90, %81
  br label %92

92:                                               ; preds = %91
  br label %141

93:                                               ; preds = %9
  br label %94

94:                                               ; preds = %93
  %95 = load ptr, ptr @c_get_user_nonce, align 8, !tbaa !5
  %96 = icmp eq ptr %95, null
  br i1 %96, label %97, label %100

97:                                               ; preds = %94
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = call ptr @OSSL_FUNC_get_user_nonce(ptr noundef %98)
  store ptr %99, ptr @c_get_user_nonce, align 8, !tbaa !5
  br label %107

100:                                              ; preds = %94
  %101 = load ptr, ptr @c_get_user_nonce, align 8, !tbaa !5
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = call ptr @OSSL_FUNC_get_user_nonce(ptr noundef %102)
  %104 = icmp ne ptr %101, %103
  br i1 %104, label %105, label %106

105:                                              ; preds = %100
  store i32 0, ptr %2, align 4
  br label %146

106:                                              ; preds = %100
  br label %107

107:                                              ; preds = %106, %97
  br label %108

108:                                              ; preds = %107
  br label %141

109:                                              ; preds = %9
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr @c_cleanup_nonce, align 8, !tbaa !5
  %112 = icmp eq ptr %111, null
  br i1 %112, label %113, label %116

113:                                              ; preds = %110
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = call ptr @OSSL_FUNC_cleanup_nonce(ptr noundef %114)
  store ptr %115, ptr @c_cleanup_nonce, align 8, !tbaa !5
  br label %123

116:                                              ; preds = %110
  %117 = load ptr, ptr @c_cleanup_nonce, align 8, !tbaa !5
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = call ptr @OSSL_FUNC_cleanup_nonce(ptr noundef %118)
  %120 = icmp ne ptr %117, %119
  br i1 %120, label %121, label %122

121:                                              ; preds = %116
  store i32 0, ptr %2, align 4
  br label %146

122:                                              ; preds = %116
  br label %123

123:                                              ; preds = %122, %113
  br label %124

124:                                              ; preds = %123
  br label %141

125:                                              ; preds = %9
  br label %126

126:                                              ; preds = %125
  %127 = load ptr, ptr @c_cleanup_user_nonce, align 8, !tbaa !5
  %128 = icmp eq ptr %127, null
  br i1 %128, label %129, label %132

129:                                              ; preds = %126
  %130 = load ptr, ptr %3, align 8, !tbaa !5
  %131 = call ptr @OSSL_FUNC_cleanup_user_nonce(ptr noundef %130)
  store ptr %131, ptr @c_cleanup_user_nonce, align 8, !tbaa !5
  br label %139

132:                                              ; preds = %126
  %133 = load ptr, ptr @c_cleanup_user_nonce, align 8, !tbaa !5
  %134 = load ptr, ptr %3, align 8, !tbaa !5
  %135 = call ptr @OSSL_FUNC_cleanup_user_nonce(ptr noundef %134)
  %136 = icmp ne ptr %133, %135
  br i1 %136, label %137, label %138

137:                                              ; preds = %132
  store i32 0, ptr %2, align 4
  br label %146

138:                                              ; preds = %132
  br label %139

139:                                              ; preds = %138, %129
  br label %140

140:                                              ; preds = %139
  br label %141

141:                                              ; preds = %140, %124, %108, %92, %76, %60, %44, %28, %9
  br label %142

142:                                              ; preds = %141
  %143 = load ptr, ptr %3, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.ossl_dispatch_st, ptr %143, i32 1
  store ptr %144, ptr %3, align 8, !tbaa !5
  br label %4, !llvm.loop !12

145:                                              ; preds = %4
  store i32 1, ptr %2, align 4
  br label %146

146:                                              ; preds = %145, %137, %121, %105, %89, %73, %57, %41, %25
  %147 = load i32, ptr %2, align 4
  ret i32 %147
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_get_entropy(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_get_user_entropy(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_cleanup_entropy(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_cleanup_user_entropy(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_get_nonce(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_get_user_nonce(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_cleanup_nonce(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_cleanup_user_nonce(ptr noundef) #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" }
attributes #1 = { inlinehint 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"ossl_dispatch_st", !11, i64 0, !6, i64 8}
!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"

@c_get_entropy = external hidden local_unnamed_addr global ptr, align 8
@c_get_user_entropy = external hidden local_unnamed_addr global ptr, align 8
@c_cleanup_entropy = external hidden local_unnamed_addr global ptr, align 8
@c_cleanup_user_entropy = external hidden local_unnamed_addr global ptr, align 8
@c_get_nonce = external hidden local_unnamed_addr global ptr, align 8
@c_get_user_nonce = external hidden local_unnamed_addr global ptr, align 8
@c_cleanup_nonce = external hidden local_unnamed_addr global ptr, align 8
@c_cleanup_user_nonce = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_prov_seeding_from_dispatch(ptr noundef %0) local_unnamed_addr #0 {
  br label %2

2:                                                ; preds = %52, %1
  %.0 = phi ptr [ %0, %1 ], [ %53, %52 ]
  %3 = load i32, ptr %.0, align 8, !tbaa !5
  switch i32 %3, label %52 [
    i32 0, label %54
    i32 101, label %4
    i32 98, label %10
    i32 102, label %16
    i32 96, label %22
    i32 103, label %28
    i32 99, label %34
    i32 104, label %40
    i32 97, label %46
  ]

4:                                                ; preds = %2
  %5 = load ptr, ptr @c_get_entropy, align 8, !tbaa !11
  %6 = icmp eq ptr %5, null
  %7 = tail call ptr @OSSL_FUNC_get_entropy(ptr noundef nonnull %.0)
  br i1 %6, label %8, label %9

8:                                                ; preds = %4
  store ptr %7, ptr @c_get_entropy, align 8, !tbaa !11
  br label %52

9:                                                ; preds = %4
  %.not36 = icmp eq ptr %5, %7
  br i1 %.not36, label %52, label %54

10:                                               ; preds = %2
  %11 = load ptr, ptr @c_get_user_entropy, align 8, !tbaa !11
  %12 = icmp eq ptr %11, null
  %13 = tail call ptr @OSSL_FUNC_get_user_entropy(ptr noundef nonnull %.0)
  br i1 %12, label %14, label %15

14:                                               ; preds = %10
  store ptr %13, ptr @c_get_user_entropy, align 8, !tbaa !11
  br label %52

15:                                               ; preds = %10
  %.not35 = icmp eq ptr %11, %13
  br i1 %.not35, label %52, label %54

16:                                               ; preds = %2
  %17 = load ptr, ptr @c_cleanup_entropy, align 8, !tbaa !11
  %18 = icmp eq ptr %17, null
  %19 = tail call ptr @OSSL_FUNC_cleanup_entropy(ptr noundef nonnull %.0)
  br i1 %18, label %20, label %21

20:                                               ; preds = %16
  store ptr %19, ptr @c_cleanup_entropy, align 8, !tbaa !11
  br label %52

21:                                               ; preds = %16
  %.not34 = icmp eq ptr %17, %19
  br i1 %.not34, label %52, label %54

22:                                               ; preds = %2
  %23 = load ptr, ptr @c_cleanup_user_entropy, align 8, !tbaa !11
  %24 = icmp eq ptr %23, null
  %25 = tail call ptr @OSSL_FUNC_cleanup_user_entropy(ptr noundef nonnull %.0)
  br i1 %24, label %26, label %27

26:                                               ; preds = %22
  store ptr %25, ptr @c_cleanup_user_entropy, align 8, !tbaa !11
  br label %52

27:                                               ; preds = %22
  %.not33 = icmp eq ptr %23, %25
  br i1 %.not33, label %52, label %54

28:                                               ; preds = %2
  %29 = load ptr, ptr @c_get_nonce, align 8, !tbaa !11
  %30 = icmp eq ptr %29, null
  %31 = tail call ptr @OSSL_FUNC_get_nonce(ptr noundef nonnull %.0)
  br i1 %30, label %32, label %33

32:                                               ; preds = %28
  store ptr %31, ptr @c_get_nonce, align 8, !tbaa !11
  br label %52

33:                                               ; preds = %28
  %.not32 = icmp eq ptr %29, %31
  br i1 %.not32, label %52, label %54

34:                                               ; preds = %2
  %35 = load ptr, ptr @c_get_user_nonce, align 8, !tbaa !11
  %36 = icmp eq ptr %35, null
  %37 = tail call ptr @OSSL_FUNC_get_user_nonce(ptr noundef nonnull %.0)
  br i1 %36, label %38, label %39

38:                                               ; preds = %34
  store ptr %37, ptr @c_get_user_nonce, align 8, !tbaa !11
  br label %52

39:                                               ; preds = %34
  %.not31 = icmp eq ptr %35, %37
  br i1 %.not31, label %52, label %54

40:                                               ; preds = %2
  %41 = load ptr, ptr @c_cleanup_nonce, align 8, !tbaa !11
  %42 = icmp eq ptr %41, null
  %43 = tail call ptr @OSSL_FUNC_cleanup_nonce(ptr noundef nonnull %.0)
  br i1 %42, label %44, label %45

44:                                               ; preds = %40
  store ptr %43, ptr @c_cleanup_nonce, align 8, !tbaa !11
  br label %52

45:                                               ; preds = %40
  %.not30 = icmp eq ptr %41, %43
  br i1 %.not30, label %52, label %54

46:                                               ; preds = %2
  %47 = load ptr, ptr @c_cleanup_user_nonce, align 8, !tbaa !11
  %48 = icmp eq ptr %47, null
  %49 = tail call ptr @OSSL_FUNC_cleanup_user_nonce(ptr noundef nonnull %.0)
  br i1 %48, label %50, label %51

50:                                               ; preds = %46
  store ptr %49, ptr @c_cleanup_user_nonce, align 8, !tbaa !11
  br label %52

51:                                               ; preds = %46
  %.not29 = icmp eq ptr %47, %49
  br i1 %.not29, label %52, label %54

52:                                               ; preds = %2, %8, %9, %14, %15, %20, %21, %26, %27, %32, %33, %38, %39, %44, %45, %50, %51
  %53 = getelementptr inbounds i8, ptr %.0, i64 16
  br label %2, !llvm.loop !12

54:                                               ; preds = %2, %51, %45, %39, %33, %27, %21, %15, %9
  %.019 = phi i32 [ 0, %9 ], [ 0, %15 ], [ 0, %21 ], [ 0, %27 ], [ 0, %33 ], [ 0, %39 ], [ 0, %45 ], [ 0, %51 ], [ 1, %2 ]
  ret i32 %.019
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_get_entropy(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_get_user_entropy(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_cleanup_entropy(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_cleanup_user_entropy(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_get_nonce(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_get_user_nonce(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_cleanup_nonce(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_cleanup_user_nonce(ptr noundef) local_unnamed_addr #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" }
attributes #1 = { inlinehint 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 0}
!6 = !{!"ossl_dispatch_st", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass