; LLVM IR from openanolis/openssl :: demos/pkey (EVP_PKEY_DSA_paramfromdata)

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

@dsa_p = external hidden constant [256 x i8], align 16
@dsa_q = external hidden constant [28 x i8], align 16
@dsa_g = external hidden constant [256 x i8], align 16
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1

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

21:                                               ; preds = %2
  %22 = load ptr, ptr %14, align 8, !tbaa !9
  %23 = icmp eq ptr %22, null
  br i1 %23, label %27, label %24

24:                                               ; preds = %21
  %25 = load ptr, ptr %15, align 8, !tbaa !9
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %24, %21, %2
  br label %84

28:                                               ; preds = %24
  %29 = call ptr @OSSL_PARAM_BLD_new()
  store ptr %29, ptr %11, align 8, !tbaa !9
  %30 = load ptr, ptr %11, align 8, !tbaa !9
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  br label %84

33:                                               ; preds = %28
  %34 = load ptr, ptr %11, align 8, !tbaa !9
  %35 = load ptr, ptr %13, align 8, !tbaa !9
  %36 = call i32 @OSSL_PARAM_BLD_push_BN(ptr noundef %34, ptr noundef @.str, ptr noundef %35)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %48

38:                                               ; preds = %33
  %39 = load ptr, ptr %11, align 8, !tbaa !9
  %40 = load ptr, ptr %14, align 8, !tbaa !9
  %41 = call i32 @OSSL_PARAM_BLD_push_BN(ptr noundef %39, ptr noundef @.str.1, ptr noundef %40)
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %48

43:                                               ; preds = %38
  %44 = load ptr, ptr %11, align 8, !tbaa !9
  %45 = load ptr, ptr %15, align 8, !tbaa !9
  %46 = call i32 @OSSL_PARAM_BLD_push_BN(ptr noundef %44, ptr noundef @.str.2, ptr noundef %45)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %49, label %48

48:                                               ; preds = %43, %38, %33
  br label %84

49:                                               ; preds = %43
  %50 = load ptr, ptr %11, align 8, !tbaa !9
  %51 = call ptr @OSSL_PARAM_BLD_to_param(ptr noundef %50)
  store ptr %51, ptr %12, align 8, !tbaa !9
  %52 = load ptr, ptr %12, align 8, !tbaa !9
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  br label %84

55:                                               ; preds = %49
  %56 = load ptr, ptr %7, align 8, !tbaa !9
  %57 = load ptr, ptr %8, align 8, !tbaa !9
  %58 = call ptr @EVP_PKEY_CTX_new_from_name(ptr noundef %56, ptr noundef @.str.3, ptr noundef %57)
  store ptr %58, ptr %9, align 8, !tbaa !9
  %59 = load ptr, ptr %9, align 8, !tbaa !9
  %60 = icmp eq ptr %59, null
  br i1 %60, label %61, label %64

61:                                               ; preds = %55
  %62 = load ptr, ptr @stderr, align 8, !tbaa !9
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.4) #4
  br label %84

64:                                               ; preds = %55
  %65 = load ptr, ptr %9, align 8, !tbaa !9
  %66 = call i32 @EVP_PKEY_fromdata_init(ptr noundef %65)
  %67 = icmp sle i32 %66, 0
  br i1 %67, label %73, label %68

68:                                               ; preds = %64
  %69 = load ptr, ptr %9, align 8, !tbaa !9
  %70 = load ptr, ptr %12, align 8, !tbaa !9
  %71 = call i32 @EVP_PKEY_fromdata(ptr noundef %69, ptr noundef %10, i32 noundef 132, ptr noundef %70)
  %72 = icmp sle i32 %71, 0
  br i1 %72, label %73, label %76

73:                                               ; preds = %68, %64
  %74 = load ptr, ptr @stderr, align 8, !tbaa !9
  %75 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %74, ptr noundef @.str.5) #4
  br label %84

76:                                               ; preds = %68
  %77 = load ptr, ptr %10, align 8, !tbaa !9
  %78 = load ptr, ptr %7, align 8, !tbaa !9
  %79 = load ptr, ptr %8, align 8, !tbaa !9
  %80 = call i32 @dsa_print_key(ptr noundef %77, i32 noundef 0, ptr noundef %78, ptr noundef %79)
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %83, label %82

82:                                               ; preds = %76
  br label %84

83:                                               ; preds = %76
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %83, %82, %73, %61, %54, %48, %32, %27
  %85 = load ptr, ptr %10, align 8, !tbaa !9
  call void @EVP_PKEY_free(ptr noundef %85)
  %86 = load ptr, ptr %9, align 8, !tbaa !9
  call void @EVP_PKEY_CTX_free(ptr noundef %86)
  %87 = load ptr, ptr %12, align 8, !tbaa !9
  call void @OSSL_PARAM_free(ptr noundef %87)
  %88 = load ptr, ptr %11, align 8, !tbaa !9
  call void @OSSL_PARAM_BLD_free(ptr noundef %88)
  %89 = load ptr, ptr %15, align 8, !tbaa !9
  call void @BN_free(ptr noundef %89)
  %90 = load ptr, ptr %14, align 8, !tbaa !9
  call void @BN_free(ptr noundef %90)
  %91 = load ptr, ptr %13, align 8, !tbaa !9
  call void @BN_free(ptr noundef %91)
  %92 = load i32, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret i32 %92
}

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

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

declare ptr @OSSL_PARAM_BLD_new() #2

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

declare ptr @OSSL_PARAM_BLD_to_param(ptr noundef) #2

declare ptr @EVP_PKEY_CTX_new_from_name(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare i32 @EVP_PKEY_fromdata_init(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @dsa_print_key(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

declare void @EVP_PKEY_free(ptr noundef) #2

declare void @EVP_PKEY_CTX_free(ptr noundef) #2

declare void @OSSL_PARAM_free(ptr noundef) #2

declare void @OSSL_PARAM_BLD_free(ptr noundef) #2

declare void @BN_free(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 = { nounwind "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

@dsa_p = external hidden constant [256 x i8], align 16
@dsa_q = external hidden constant [28 x i8], align 16
@dsa_g = external hidden constant [256 x i8], align 16
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store ptr null, ptr %3, align 8, !tbaa !5
  %4 = tail call ptr @BN_bin2bn(ptr noundef nonnull @dsa_p, i32 noundef 256, ptr noundef null) #4
  %5 = tail call ptr @BN_bin2bn(ptr noundef nonnull @dsa_q, i32 noundef 28, ptr noundef null) #4
  %6 = tail call ptr @BN_bin2bn(ptr noundef nonnull @dsa_g, i32 noundef 256, ptr noundef null) #4
  %7 = icmp eq ptr %4, null
  %8 = icmp eq ptr %5, null
  %or.cond = select i1 %7, i1 true, i1 %8
  %9 = icmp eq ptr %6, null
  %or.cond3 = select i1 %or.cond, i1 true, i1 %9
  br i1 %or.cond3, label %40, label %10

10:                                               ; preds = %2
  %11 = tail call ptr @OSSL_PARAM_BLD_new() #4
  %12 = icmp eq ptr %11, null
  br i1 %12, label %40, label %13

13:                                               ; preds = %10
  %14 = tail call i32 @OSSL_PARAM_BLD_push_BN(ptr noundef nonnull %11, ptr noundef nonnull @.str, ptr noundef nonnull %4) #4
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %40, label %15

15:                                               ; preds = %13
  %16 = tail call i32 @OSSL_PARAM_BLD_push_BN(ptr noundef nonnull %11, ptr noundef nonnull @.str.1, ptr noundef nonnull %5) #4
  %.not40 = icmp eq i32 %16, 0
  br i1 %.not40, label %40, label %17

17:                                               ; preds = %15
  %18 = tail call i32 @OSSL_PARAM_BLD_push_BN(ptr noundef nonnull %11, ptr noundef nonnull @.str.2, ptr noundef nonnull %6) #4
  %.not41 = icmp eq i32 %18, 0
  br i1 %.not41, label %40, label %19

19:                                               ; preds = %17
  %20 = tail call ptr @OSSL_PARAM_BLD_to_param(ptr noundef nonnull %11) #4
  %21 = icmp eq ptr %20, null
  br i1 %21, label %40, label %22

22:                                               ; preds = %19
  %23 = tail call ptr @EVP_PKEY_CTX_new_from_name(ptr noundef null, ptr noundef nonnull @.str.3, ptr noundef null) #4
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.4) #5
  br label %40

28:                                               ; preds = %22
  %29 = tail call i32 @EVP_PKEY_fromdata_init(ptr noundef nonnull %23) #4
  %30 = icmp slt i32 %29, 1
  br i1 %30, label %34, label %31

31:                                               ; preds = %28
  %32 = call i32 @EVP_PKEY_fromdata(ptr noundef nonnull %23, ptr noundef nonnull %3, i32 noundef 132, ptr noundef nonnull %20) #4
  %33 = icmp slt i32 %32, 1
  br i1 %33, label %34, label %37

34:                                               ; preds = %31, %28
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str.5) #5
  br label %40

37:                                               ; preds = %31
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call i32 @dsa_print_key(ptr noundef %38, i32 noundef 0, ptr noundef null, ptr noundef null)
  %.not42 = icmp eq i32 %39, 0
  %spec.select = zext i1 %.not42 to i32
  br label %40

40:                                               ; preds = %37, %19, %13, %15, %17, %10, %2, %34, %25
  %.031 = phi i32 [ 1, %2 ], [ 1, %10 ], [ 1, %19 ], [ 1, %25 ], [ 1, %34 ], [ 1, %17 ], [ 1, %15 ], [ 1, %13 ], [ %spec.select, %37 ]
  %.030 = phi ptr [ null, %2 ], [ null, %10 ], [ null, %19 ], [ null, %25 ], [ %23, %34 ], [ null, %17 ], [ null, %15 ], [ null, %13 ], [ %23, %37 ]
  %.029 = phi ptr [ null, %2 ], [ null, %10 ], [ %11, %19 ], [ %11, %25 ], [ %11, %34 ], [ %11, %17 ], [ %11, %15 ], [ %11, %13 ], [ %11, %37 ]
  %.0 = phi ptr [ null, %2 ], [ null, %10 ], [ null, %19 ], [ %20, %25 ], [ %20, %34 ], [ null, %17 ], [ null, %15 ], [ null, %13 ], [ %20, %37 ]
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  call void @EVP_PKEY_free(ptr noundef %41) #4
  call void @EVP_PKEY_CTX_free(ptr noundef %.030) #4
  call void @OSSL_PARAM_free(ptr noundef %.0) #4
  call void @OSSL_PARAM_BLD_free(ptr noundef %.029) #4
  call void @BN_free(ptr noundef %6) #4
  call void @BN_free(ptr noundef %5) #4
  call void @BN_free(ptr noundef %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret i32 %.031
}

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

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

declare ptr @OSSL_PARAM_BLD_new() local_unnamed_addr #2

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

declare ptr @OSSL_PARAM_BLD_to_param(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare i32 @EVP_PKEY_fromdata_init(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @dsa_print_key(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @EVP_PKEY_free(ptr noundef) local_unnamed_addr #2

declare void @EVP_PKEY_CTX_free(ptr noundef) local_unnamed_addr #2

declare void @OSSL_PARAM_free(ptr noundef) local_unnamed_addr #2

declare void @OSSL_PARAM_BLD_free(ptr noundef) local_unnamed_addr #2

declare void @BN_free(ptr 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 = { nofree nounwind "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 }
attributes #5 = { cold 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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass