; LLVM IR from intel/QAT_Engine :: qat_evp (qat_x448_pmeth)

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

@sw_x448_pmeth = external dso_local global ptr, align 8
@qat_reload_algo = external global i32, align 4
@.str = external hidden unnamed_addr constant [60 x i8], align 1
@qat_hw_ecx_offload = external global i32, align 4
@_hidden_x448_pmeth = external hidden global ptr, align 8

declare void @EVP_PKEY_meth_free(ptr noundef) #0

declare ptr @EVP_PKEY_meth_new(i32 noundef, i32 noundef) #0

declare void @ERR_QAT_error(i32 noundef, i32 noundef, ptr noundef, i32 noundef) #0

declare ptr @EVP_PKEY_meth_find(i32 noundef) #0

declare void @EVP_PKEY_meth_copy(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @qat_x448_pmeth() #1 {
  %1 = alloca ptr, align 8
  %2 = load ptr, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  %3 = icmp ne ptr %2, null
  br i1 %3, label %4, label %11

4:                                                ; preds = %0
  %5 = load i32, ptr @qat_reload_algo, align 4, !tbaa !9
  %6 = icmp ne i32 %5, 0
  br i1 %6, label %9, label %7

7:                                                ; preds = %4
  %8 = load ptr, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  store ptr %8, ptr %1, align 8
  br label %27

9:                                                ; preds = %4
  %10 = load ptr, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  call void @EVP_PKEY_meth_free(ptr noundef %10)
  store ptr null, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %9, %0
  %12 = call ptr @EVP_PKEY_meth_new(i32 noundef 1035, i32 noundef 0)
  store ptr %12, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  call void @ERR_QAT_error(i32 noundef 0, i32 noundef 112, ptr noundef @.str, i32 noundef 671)
  store ptr null, ptr %1, align 8
  br label %27

15:                                               ; preds = %11
  %16 = call ptr @EVP_PKEY_meth_find(i32 noundef 1035)
  store ptr %16, ptr @sw_x448_pmeth, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  call void @ERR_QAT_error(i32 noundef 0, i32 noundef 786691, ptr noundef @.str, i32 noundef 678)
  store ptr null, ptr %1, align 8
  br label %27

19:                                               ; preds = %15
  store i32 0, ptr @qat_hw_ecx_offload, align 4, !tbaa !9
  %20 = load i32, ptr @qat_hw_ecx_offload, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %25, label %22

22:                                               ; preds = %19
  %23 = load ptr, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  %24 = load ptr, ptr @sw_x448_pmeth, align 8, !tbaa !5
  call void @EVP_PKEY_meth_copy(ptr noundef %23, ptr noundef %24)
  br label %25

25:                                               ; preds = %22, %19
  %26 = load ptr, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  store ptr %26, ptr %1, align 8
  br label %27

27:                                               ; preds = %25, %18, %14, %7
  %28 = load ptr, ptr %1, align 8
  ret ptr %28
}

attributes #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 = { 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, !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"

@sw_x448_pmeth = external dso_local local_unnamed_addr global ptr, align 8
@qat_reload_algo = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [60 x i8], align 1
@qat_hw_ecx_offload = external local_unnamed_addr global i32, align 4
@_hidden_x448_pmeth = external hidden local_unnamed_addr global ptr, align 8

declare void @EVP_PKEY_meth_free(ptr noundef) local_unnamed_addr #0

declare ptr @EVP_PKEY_meth_new(i32 noundef, i32 noundef) local_unnamed_addr #0

declare void @ERR_QAT_error(i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare ptr @EVP_PKEY_meth_find(i32 noundef) local_unnamed_addr #0

declare void @EVP_PKEY_meth_copy(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @qat_x448_pmeth() local_unnamed_addr #1 {
  %1 = load ptr, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %5, label %2

2:                                                ; preds = %0
  %3 = load i32, ptr @qat_reload_algo, align 4, !tbaa !9
  %.not2 = icmp eq i32 %3, 0
  br i1 %.not2, label %16, label %4

4:                                                ; preds = %2
  tail call void @EVP_PKEY_meth_free(ptr noundef nonnull %1) #2
  store ptr null, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %4, %0
  %6 = tail call ptr @EVP_PKEY_meth_new(i32 noundef 1035, i32 noundef 0) #2
  store ptr %6, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %5
  tail call void @ERR_QAT_error(i32 noundef 0, i32 noundef 112, ptr noundef nonnull @.str, i32 noundef 671) #2
  br label %16

9:                                                ; preds = %5
  %10 = tail call ptr @EVP_PKEY_meth_find(i32 noundef 1035) #2
  store ptr %10, ptr @sw_x448_pmeth, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  tail call void @ERR_QAT_error(i32 noundef 0, i32 noundef 786691, ptr noundef nonnull @.str, i32 noundef 678) #2
  br label %16

13:                                               ; preds = %9
  store i32 0, ptr @qat_hw_ecx_offload, align 4, !tbaa !9
  %14 = load ptr, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  tail call void @EVP_PKEY_meth_copy(ptr noundef %14, ptr noundef nonnull %10) #2
  %15 = load ptr, ptr @_hidden_x448_pmeth, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %2, %13, %12, %8
  %.0 = phi ptr [ null, %8 ], [ null, %12 ], [ %15, %13 ], [ %1, %2 ]
  ret ptr %.0
}

attributes #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 = { 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 }

!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}


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