; LLVM IR from intel/QAT_Engine :: kpt/apps (kpt_swk)

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

@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1

; 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
define dso_local i32 @encrypt_swk_with_per_part_key(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca [1024 x i8], align 16
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i32 %5, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 -1, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store ptr null, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  store i64 384, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1024, ptr %19) #4
  call void @llvm.memset.p0.i64(ptr align 16 %19, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  store ptr null, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  store ptr null, ptr %21, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %34

25:                                               ; preds = %6
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %34

28:                                               ; preds = %25
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %34

31:                                               ; preds = %28
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %35, label %34

34:                                               ; preds = %31, %28, %25, %6
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %22, align 4
  br label %90

35:                                               ; preds = %31
  %36 = call ptr @EVP_PKEY_new()
  store ptr %36, ptr %20, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  br label %78

39:                                               ; preds = %35
  %40 = call ptr @RSA_new()
  store ptr %40, ptr %21, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  br label %78

43:                                               ; preds = %39
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = call ptr @BN_bin2bn(ptr noundef %44, i32 noundef %45, ptr noundef null)
  store ptr %46, ptr %15, align 8, !tbaa !5
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = call ptr @BN_bin2bn(ptr noundef %47, i32 noundef %48, ptr noundef null)
  store ptr %49, ptr %16, align 8, !tbaa !5
  %50 = load ptr, ptr %21, align 8, !tbaa !5
  %51 = load ptr, ptr %15, align 8, !tbaa !5
  %52 = load ptr, ptr %16, align 8, !tbaa !5
  %53 = call i32 @RSA_set0_key(ptr noundef %50, ptr noundef %51, ptr noundef %52, ptr noundef null)
  %54 = load ptr, ptr %20, align 8, !tbaa !5
  %55 = load ptr, ptr %21, align 8, !tbaa !5
  %56 = call i32 @EVP_PKEY_assign(ptr noundef %54, i32 noundef 6, ptr noundef %55)
  %57 = load ptr, ptr %20, align 8, !tbaa !5
  %58 = call ptr @EVP_PKEY_CTX_new(ptr noundef %57, ptr noundef null)
  store ptr %58, ptr %17, align 8, !tbaa !5
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %77

61:                                               ; preds = %43
  %62 = load ptr, ptr %17, align 8, !tbaa !5
  %63 = call i32 @EVP_PKEY_encrypt_init(ptr noundef %62)
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %65, label %76

65:                                               ; preds = %61
  %66 = load ptr, ptr %17, align 8, !tbaa !5
  %67 = call i32 @EVP_PKEY_CTX_ctrl_str(ptr noundef %66, ptr noundef @.str.2, ptr noundef @.str.3)
  %68 = load ptr, ptr %17, align 8, !tbaa !5
  %69 = call i32 @EVP_PKEY_CTX_ctrl_str(ptr noundef %68, ptr noundef @.str.4, ptr noundef @.str.5)
  %70 = load ptr, ptr %17, align 8, !tbaa !5
  %71 = call i32 @EVP_PKEY_CTX_ctrl_str(ptr noundef %70, ptr noundef @.str.6, ptr noundef @.str.5)
  %72 = load ptr, ptr %17, align 8, !tbaa !5
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = call i32 @EVP_PKEY_encrypt(ptr noundef %72, ptr noundef %73, ptr noundef %18, ptr noundef %74, i64 noundef 32)
  store i32 %75, ptr %14, align 4, !tbaa !9
  br label %76

76:                                               ; preds = %65, %61
  br label %77

77:                                               ; preds = %76, %43
  br label %78

78:                                               ; preds = %77, %42, %38
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = icmp ne ptr %79, null
  br i1 %80, label %81, label %83

81:                                               ; preds = %78
  %82 = load ptr, ptr %17, align 8, !tbaa !5
  call void @EVP_PKEY_CTX_free(ptr noundef %82)
  br label %83

83:                                               ; preds = %81, %78
  %84 = load ptr, ptr %20, align 8, !tbaa !5
  %85 = icmp ne ptr %84, null
  br i1 %85, label %86, label %88

86:                                               ; preds = %83
  %87 = load ptr, ptr %20, align 8, !tbaa !5
  call void @EVP_PKEY_free(ptr noundef %87)
  br label %88

88:                                               ; preds = %86, %83
  %89 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %89, ptr %7, align 4
  store i32 1, ptr %22, align 4
  br label %90

90:                                               ; preds = %88, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %91 = load i32, ptr %7, align 4
  ret i32 %91
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare ptr @EVP_PKEY_new() #3

declare ptr @RSA_new() #3

declare ptr @BN_bin2bn(ptr noundef, i32 noundef, ptr noundef) #3

declare i32 @RSA_set0_key(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @EVP_PKEY_assign(ptr noundef, i32 noundef, ptr noundef) #3

declare ptr @EVP_PKEY_CTX_new(ptr noundef, ptr noundef) #3

declare i32 @EVP_PKEY_encrypt_init(ptr noundef) #3

declare i32 @EVP_PKEY_CTX_ctrl_str(ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @EVP_PKEY_encrypt(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #3

declare void @EVP_PKEY_CTX_free(ptr noundef) #3

declare void @EVP_PKEY_free(ptr noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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"

@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @encrypt_swk_with_per_part_key(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  store i64 384, ptr %7, align 8, !tbaa !5
  %8 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %9 = insertelement <4 x ptr> %8, ptr %1, i64 1
  %10 = insertelement <4 x ptr> %9, ptr %2, i64 2
  %11 = insertelement <4 x ptr> %10, ptr %4, i64 3
  %12 = icmp eq <4 x ptr> %11, zeroinitializer
  %13 = bitcast <4 x i1> %12 to i4
  %14 = icmp eq i4 %13, 0
  br i1 %14, label %15, label %35

15:                                               ; preds = %6
  %16 = tail call ptr @EVP_PKEY_new() #3
  %17 = icmp eq ptr %16, null
  br i1 %17, label %35, label %18

18:                                               ; preds = %15
  %19 = tail call ptr @RSA_new() #3
  %20 = icmp eq ptr %19, null
  br i1 %20, label %.thread52, label %21

21:                                               ; preds = %18
  %22 = tail call ptr @BN_bin2bn(ptr noundef nonnull %2, i32 noundef %3, ptr noundef null) #3
  %23 = tail call ptr @BN_bin2bn(ptr noundef nonnull %4, i32 noundef %5, ptr noundef null) #3
  %24 = tail call i32 @RSA_set0_key(ptr noundef nonnull %19, ptr noundef %22, ptr noundef %23, ptr noundef null) #3
  %25 = tail call i32 @EVP_PKEY_assign(ptr noundef nonnull %16, i32 noundef 6, ptr noundef nonnull %19) #3
  %26 = tail call ptr @EVP_PKEY_CTX_new(ptr noundef nonnull %16, ptr noundef null) #3
  %.not = icmp eq ptr %26, null
  br i1 %.not, label %.thread52, label %27

27:                                               ; preds = %21
  %28 = tail call i32 @EVP_PKEY_encrypt_init(ptr noundef nonnull %26) #3
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %30, label %.thread48

30:                                               ; preds = %27
  %31 = tail call i32 @EVP_PKEY_CTX_ctrl_str(ptr noundef nonnull %26, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3) #3
  %32 = tail call i32 @EVP_PKEY_CTX_ctrl_str(ptr noundef nonnull %26, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5) #3
  %33 = tail call i32 @EVP_PKEY_CTX_ctrl_str(ptr noundef nonnull %26, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.5) #3
  %34 = call i32 @EVP_PKEY_encrypt(ptr noundef nonnull %26, ptr noundef nonnull %1, ptr noundef nonnull %7, ptr noundef nonnull %0, i64 noundef 32) #3
  br label %.thread48

.thread48:                                        ; preds = %30, %27
  %.032 = phi i32 [ %34, %30 ], [ -1, %27 ]
  call void @EVP_PKEY_CTX_free(ptr noundef nonnull %26) #3
  br label %.thread52

.thread52:                                        ; preds = %21, %18, %.thread48
  %.0324750 = phi i32 [ %.032, %.thread48 ], [ -1, %18 ], [ -1, %21 ]
  call void @EVP_PKEY_free(ptr noundef nonnull %16) #3
  br label %35

35:                                               ; preds = %15, %.thread52, %6
  %.033 = phi i32 [ -1, %6 ], [ %.0324750, %.thread52 ], [ -1, %15 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  ret i32 %.033
}

declare ptr @EVP_PKEY_new() local_unnamed_addr #2

declare ptr @RSA_new() local_unnamed_addr #2

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

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

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

declare ptr @EVP_PKEY_CTX_new(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @EVP_PKEY_encrypt_init(ptr noundef) local_unnamed_addr #2

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

declare i32 @EVP_PKEY_encrypt(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare void @EVP_PKEY_CTX_free(ptr noundef) local_unnamed_addr #2

declare void @EVP_PKEY_free(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { "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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass