; LLVM IR from openssl/openssl :: crypto (provider)

; 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"

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

18:                                               ; preds = %4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = call ptr @ossl_provider_new(ptr noundef %19, ptr noundef %20, ptr noundef null, ptr noundef %21, i32 noundef 0)
  store ptr %22, ptr %10, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %18
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %58

25:                                               ; preds = %18
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %25, %4
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = call i32 @ossl_provider_activate(ptr noundef %27, i32 noundef 1, i32 noundef 0)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %32, label %30

30:                                               ; preds = %26
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ossl_provider_free(ptr noundef %31)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %58

32:                                               ; preds = %26
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %33, ptr %11, align 8, !tbaa !5
  %34 = load i32, ptr %12, align 4, !tbaa !9
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %45

36:                                               ; preds = %32
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = call i32 @ossl_provider_add_to_store(ptr noundef %37, ptr noundef %11, i32 noundef %38)
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %45, label %41

41:                                               ; preds = %36
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = call i32 @ossl_provider_deactivate(ptr noundef %42, i32 noundef 1)
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ossl_provider_free(ptr noundef %44)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %58

45:                                               ; preds = %36, %32
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = icmp ne ptr %46, %47
  br i1 %48, label %49, label %56

49:                                               ; preds = %45
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = call i32 @ossl_provider_activate(ptr noundef %50, i32 noundef 1, i32 noundef 0)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %55, label %53

53:                                               ; preds = %49
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  call void @ossl_provider_free(ptr noundef %54)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %58

55:                                               ; preds = %49
  br label %56

56:                                               ; preds = %55, %45
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %57, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %58

58:                                               ; preds = %56, %53, %41, %30, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %59 = load ptr, ptr %5, align 8
  ret ptr %59
}

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

declare ptr @ossl_provider_find(ptr noundef, ptr noundef, i32 noundef) #2

declare ptr @ossl_provider_new(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @ossl_provider_activate(ptr noundef, i32 noundef, i32 noundef) #2

declare void @ossl_provider_free(ptr noundef) #2

declare i32 @ossl_provider_add_to_store(ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @ossl_provider_deactivate(ptr noundef, i32 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 = { 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}


; 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"

; Function Attrs: nounwind uwtable
define dso_local ptr @OSSL_PROVIDER_try_load_ex(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = tail call ptr @ossl_provider_find(ptr noundef %0, ptr noundef %1, i32 noundef 0) #3
  %.not20 = icmp eq ptr %6, null
  br i1 %.not20, label %7, label %.thread

7:                                                ; preds = %4
  %8 = tail call ptr @ossl_provider_new(ptr noundef %0, ptr noundef %1, ptr noundef null, ptr noundef %2, i32 noundef 0) #3
  %9 = icmp eq ptr %8, null
  br i1 %9, label %.thread32, label %10

10:                                               ; preds = %7
  %11 = tail call i32 @ossl_provider_activate(ptr noundef nonnull %8, i32 noundef 1, i32 noundef 0) #3
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %13, label %14

.thread:                                          ; preds = %4
  %12 = tail call i32 @ossl_provider_activate(ptr noundef nonnull %6, i32 noundef 1, i32 noundef 0) #3
  %.not25 = icmp eq i32 %12, 0
  br i1 %.not25, label %13, label %.thread32

13:                                               ; preds = %.thread, %10
  %.01427 = phi ptr [ %6, %.thread ], [ %8, %10 ]
  tail call void @ossl_provider_free(ptr noundef nonnull %.01427) #3
  br label %.thread32

14:                                               ; preds = %10
  store ptr %8, ptr %5, align 8, !tbaa !5
  %15 = call i32 @ossl_provider_add_to_store(ptr noundef nonnull %8, ptr noundef nonnull %5, i32 noundef %3) #3
  %.not21 = icmp eq i32 %15, 0
  br i1 %.not21, label %16, label %18

16:                                               ; preds = %14
  %17 = call i32 @ossl_provider_deactivate(ptr noundef nonnull %8, i32 noundef 1) #3
  call void @ossl_provider_free(ptr noundef nonnull %8) #3
  br label %.thread32

18:                                               ; preds = %14
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  %.not22 = icmp eq ptr %.pre, %8
  br i1 %.not22, label %.thread32, label %19

19:                                               ; preds = %18
  %20 = call i32 @ossl_provider_activate(ptr noundef %.pre, i32 noundef 1, i32 noundef 0) #3
  %.not23 = icmp eq i32 %20, 0
  %.pre31 = load ptr, ptr %5, align 8, !tbaa !5
  br i1 %.not23, label %21, label %.thread32

21:                                               ; preds = %19
  call void @ossl_provider_free(ptr noundef %.pre31) #3
  br label %.thread32

.thread32:                                        ; preds = %.thread, %18, %19, %7, %21, %16, %13
  %.015 = phi ptr [ null, %21 ], [ null, %16 ], [ null, %13 ], [ null, %7 ], [ %.pre31, %19 ], [ %.pre, %18 ], [ %6, %.thread ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret ptr %.015
}

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

declare ptr @ossl_provider_find(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @ossl_provider_new(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @ossl_provider_activate(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @ossl_provider_free(ptr noundef) local_unnamed_addr #2

declare i32 @ossl_provider_add_to_store(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @ossl_provider_deactivate(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress 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 = { 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass