; LLVM IR from openssl/openssl :: providers (defltprov)

; 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 }
%struct.ag_capable_st = type { %struct.ossl_algorithm_st, ptr }
%struct.ossl_algorithm_st = type { ptr, ptr, ptr, ptr }

@c_gettable_params = external hidden global ptr, align 8
@c_get_params = external hidden global ptr, align 8
@deflt_dispatch_table = external hidden constant [6 x %struct.ossl_dispatch_st], align 16
@deflt_ciphers = external hidden constant [140 x %struct.ag_capable_st], align 16
@exported_ciphers = external hidden global [140 x %struct.ossl_algorithm_st], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_default_provider_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %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
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = call i32 @ossl_prov_bio_from_dispatch(ptr noundef %13)
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %20

16:                                               ; preds = %4
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = call i32 @ossl_prov_seeding_from_dispatch(ptr noundef %17)
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %16, %4
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %76

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %42, %21
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ossl_dispatch_st, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !9
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %45

27:                                               ; preds = %22
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ossl_dispatch_st, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !9
  switch i32 %30, label %40 [
    i32 1, label %31
    i32 2, label %34
    i32 4, label %37
  ]

31:                                               ; preds = %27
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = call ptr @OSSL_FUNC_core_gettable_params(ptr noundef %32)
  store ptr %33, ptr @c_gettable_params, align 8, !tbaa !5
  br label %41

34:                                               ; preds = %27
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call ptr @OSSL_FUNC_core_get_params(ptr noundef %35)
  store ptr %36, ptr @c_get_params, align 8, !tbaa !5
  br label %41

37:                                               ; preds = %27
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = call ptr @OSSL_FUNC_core_get_libctx(ptr noundef %38)
  store ptr %39, ptr %10, align 8, !tbaa !5
  br label %41

40:                                               ; preds = %27
  br label %41

41:                                               ; preds = %40, %37, %34, %31
  br label %42

42:                                               ; preds = %41
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ossl_dispatch_st, ptr %43, i32 1
  store ptr %44, ptr %7, align 8, !tbaa !5
  br label %22, !llvm.loop !12

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

48:                                               ; preds = %45
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %76

49:                                               ; preds = %45
  %50 = call ptr @ossl_prov_ctx_new()
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %50, ptr %51, align 8, !tbaa !5
  %52 = icmp eq ptr %50, null
  br i1 %52, label %56, label %53

53:                                               ; preds = %49
  %54 = call ptr @ossl_bio_prov_init_bio_method()
  store ptr %54, ptr %11, align 8, !tbaa !5
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %60

56:                                               ; preds = %53, %49
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  call void @ossl_prov_ctx_free(ptr noundef %58)
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr null, ptr %59, align 8, !tbaa !5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %76

60:                                               ; preds = %53
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = call ptr %63(ptr noundef %64)
  call void @ossl_prov_ctx_set0_libctx(ptr noundef %62, ptr noundef %65)
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ossl_prov_ctx_set0_handle(ptr noundef %67, ptr noundef %68)
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  call void @ossl_prov_ctx_set0_core_bio_method(ptr noundef %70, ptr noundef %71)
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load ptr, ptr @c_get_params, align 8, !tbaa !5
  call void @ossl_prov_ctx_set0_core_get_params(ptr noundef %73, ptr noundef %74)
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr @deflt_dispatch_table, ptr %75, align 8, !tbaa !5
  call void @ossl_prov_cache_exported_algorithms(ptr noundef @deflt_ciphers, ptr noundef @exported_ciphers)
  store i32 1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %76

76:                                               ; preds = %60, %56, %48, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %77 = load i32, ptr %5, align 4
  ret i32 %77
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i32 @ossl_prov_bio_from_dispatch(ptr noundef) #2

declare i32 @ossl_prov_seeding_from_dispatch(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_core_gettable_params(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_core_get_params(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @OSSL_FUNC_core_get_libctx(ptr noundef) #3

declare ptr @ossl_prov_ctx_new() #2

declare ptr @ossl_bio_prov_init_bio_method() #2

declare void @ossl_prov_ctx_free(ptr noundef) #2

declare void @ossl_prov_ctx_set0_libctx(ptr noundef, ptr noundef) #2

declare void @ossl_prov_ctx_set0_handle(ptr noundef, ptr noundef) #2

declare void @ossl_prov_ctx_set0_core_bio_method(ptr noundef, ptr noundef) #2

declare void @ossl_prov_ctx_set0_core_get_params(ptr noundef, ptr noundef) #2

declare void @ossl_prov_cache_exported_algorithms(ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync 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 = { 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" }
attributes #4 = { 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, !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"

%struct.ossl_dispatch_st = type { i32, ptr }
%struct.ag_capable_st = type { %struct.ossl_algorithm_st, ptr }
%struct.ossl_algorithm_st = type { ptr, ptr, ptr, ptr }

@c_gettable_params = external hidden local_unnamed_addr global ptr, align 8
@c_get_params = external hidden local_unnamed_addr global ptr, align 8
@deflt_dispatch_table = external hidden constant [6 x %struct.ossl_dispatch_st], align 16
@deflt_ciphers = external hidden constant [140 x %struct.ag_capable_st], align 16
@exported_ciphers = external hidden global [140 x %struct.ossl_algorithm_st], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_default_provider_init(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef %3) local_unnamed_addr #0 {
  %5 = tail call i32 @ossl_prov_bio_from_dispatch(ptr noundef %1) #3
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %33, label %6

6:                                                ; preds = %4
  %7 = tail call i32 @ossl_prov_seeding_from_dispatch(ptr noundef %1) #3
  %.not25 = icmp eq i32 %7, 0
  br i1 %.not25, label %33, label %.preheader

.preheader:                                       ; preds = %6, %15
  %.022 = phi ptr [ %16, %15 ], [ %1, %6 ]
  %.021 = phi ptr [ %.1, %15 ], [ null, %6 ]
  %8 = load i32, ptr %.022, align 8, !tbaa !5
  switch i32 %8, label %15 [
    i32 0, label %17
    i32 1, label %9
    i32 2, label %11
    i32 4, label %13
  ]

9:                                                ; preds = %.preheader
  %10 = tail call ptr @OSSL_FUNC_core_gettable_params(ptr noundef nonnull %.022)
  store ptr %10, ptr @c_gettable_params, align 8, !tbaa !11
  br label %15

11:                                               ; preds = %.preheader
  %12 = tail call ptr @OSSL_FUNC_core_get_params(ptr noundef nonnull %.022)
  store ptr %12, ptr @c_get_params, align 8, !tbaa !11
  br label %15

13:                                               ; preds = %.preheader
  %14 = tail call ptr @OSSL_FUNC_core_get_libctx(ptr noundef nonnull %.022)
  br label %15

15:                                               ; preds = %.preheader, %9, %11, %13
  %.1 = phi ptr [ %14, %13 ], [ %.021, %11 ], [ %.021, %9 ], [ %.021, %.preheader ]
  %16 = getelementptr inbounds i8, ptr %.022, i64 16
  br label %.preheader, !llvm.loop !12

17:                                               ; preds = %.preheader
  %18 = icmp eq ptr %.021, null
  br i1 %18, label %33, label %19

19:                                               ; preds = %17
  %20 = tail call ptr @ossl_prov_ctx_new() #3
  store ptr %20, ptr %3, align 8, !tbaa !11
  %21 = icmp eq ptr %20, null
  br i1 %21, label %25, label %22

22:                                               ; preds = %19
  %23 = tail call ptr @ossl_bio_prov_init_bio_method() #3
  %24 = icmp eq ptr %23, null
  %.pre = load ptr, ptr %3, align 8, !tbaa !11
  br i1 %24, label %25, label %27

25:                                               ; preds = %22, %19
  %26 = phi ptr [ %.pre, %22 ], [ null, %19 ]
  tail call void @ossl_prov_ctx_free(ptr noundef %26) #3
  store ptr null, ptr %3, align 8, !tbaa !11
  br label %33

27:                                               ; preds = %22
  %28 = tail call ptr %.021(ptr noundef %0) #3
  tail call void @ossl_prov_ctx_set0_libctx(ptr noundef %.pre, ptr noundef %28) #3
  %29 = load ptr, ptr %3, align 8, !tbaa !11
  tail call void @ossl_prov_ctx_set0_handle(ptr noundef %29, ptr noundef %0) #3
  %30 = load ptr, ptr %3, align 8, !tbaa !11
  tail call void @ossl_prov_ctx_set0_core_bio_method(ptr noundef %30, ptr noundef nonnull %23) #3
  %31 = load ptr, ptr %3, align 8, !tbaa !11
  %32 = load ptr, ptr @c_get_params, align 8, !tbaa !11
  tail call void @ossl_prov_ctx_set0_core_get_params(ptr noundef %31, ptr noundef %32) #3
  store ptr @deflt_dispatch_table, ptr %2, align 8, !tbaa !11
  tail call void @ossl_prov_cache_exported_algorithms(ptr noundef nonnull @deflt_ciphers, ptr noundef nonnull @exported_ciphers) #3
  br label %33

33:                                               ; preds = %17, %4, %6, %27, %25
  %.0 = phi i32 [ 0, %25 ], [ 1, %27 ], [ 0, %6 ], [ 0, %4 ], [ 0, %17 ]
  ret i32 %.0
}

declare i32 @ossl_prov_bio_from_dispatch(ptr noundef) local_unnamed_addr #1

declare i32 @ossl_prov_seeding_from_dispatch(ptr noundef) local_unnamed_addr #1

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

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

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

declare ptr @ossl_prov_ctx_new() local_unnamed_addr #1

declare ptr @ossl_bio_prov_init_bio_method() local_unnamed_addr #1

declare void @ossl_prov_ctx_free(ptr noundef) local_unnamed_addr #1

declare void @ossl_prov_ctx_set0_libctx(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @ossl_prov_ctx_set0_handle(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @ossl_prov_ctx_set0_core_bio_method(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @ossl_prov_ctx_set0_core_get_params(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @ossl_prov_cache_exported_algorithms(ptr noundef, 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 = { "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 = { 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" }
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, !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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass