; LLVM IR from openanolis/openssl :: demos/cms (cms_ddec)

; 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 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stderr = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [23 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 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 ptr, align 8
  %13 = alloca i32, align 4
  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 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !9
  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 4, ptr %13) #4
  store i32 1, ptr %13, align 4, !tbaa !5
  %14 = call i32 @OPENSSL_init_crypto(i64 noundef 12, ptr noundef null)
  %15 = call i32 @OPENSSL_init_crypto(i64 noundef 2, ptr noundef null)
  %16 = call ptr @BIO_new_file(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %16, ptr %8, align 8, !tbaa !9
  %17 = load ptr, ptr %8, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %2
  br label %65

20:                                               ; preds = %2
  %21 = load ptr, ptr %8, align 8, !tbaa !9
  %22 = call ptr @PEM_read_bio_X509(ptr noundef %21, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %22, ptr %10, align 8, !tbaa !9
  %23 = load ptr, ptr %8, align 8, !tbaa !9
  %24 = call i64 @BIO_ctrl(ptr noundef %23, i32 noundef 1, i64 noundef 0, ptr noundef null)
  %25 = trunc i64 %24 to i32
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  %27 = call ptr @PEM_read_bio_PrivateKey(ptr noundef %26, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %27, ptr %11, align 8, !tbaa !9
  %28 = load ptr, ptr %10, align 8, !tbaa !9
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %33

30:                                               ; preds = %20
  %31 = load ptr, ptr %11, align 8, !tbaa !9
  %32 = icmp ne ptr %31, null
  br i1 %32, label %34, label %33

33:                                               ; preds = %30, %20
  br label %65

34:                                               ; preds = %30
  %35 = call ptr @BIO_new_file(ptr noundef @.str.2, ptr noundef @.str.1)
  store ptr %35, ptr %6, align 8, !tbaa !9
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = icmp ne ptr %36, null
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  br label %65

39:                                               ; preds = %34
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = call ptr @PEM_read_bio_CMS(ptr noundef %40, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %41, ptr %12, align 8, !tbaa !9
  %42 = load ptr, ptr %12, align 8, !tbaa !9
  %43 = icmp ne ptr %42, null
  br i1 %43, label %45, label %44

44:                                               ; preds = %39
  br label %65

45:                                               ; preds = %39
  %46 = call ptr @BIO_new_file(ptr noundef @.str.3, ptr noundef @.str.4)
  store ptr %46, ptr %9, align 8, !tbaa !9
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = icmp ne ptr %47, null
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  br label %65

50:                                               ; preds = %45
  %51 = call ptr @BIO_new_file(ptr noundef @.str.5, ptr noundef @.str.6)
  store ptr %51, ptr %7, align 8, !tbaa !9
  %52 = load ptr, ptr %7, align 8, !tbaa !9
  %53 = icmp ne ptr %52, null
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  br label %65

55:                                               ; preds = %50
  %56 = load ptr, ptr %12, align 8, !tbaa !9
  %57 = load ptr, ptr %11, align 8, !tbaa !9
  %58 = load ptr, ptr %10, align 8, !tbaa !9
  %59 = load ptr, ptr %9, align 8, !tbaa !9
  %60 = load ptr, ptr %7, align 8, !tbaa !9
  %61 = call i32 @CMS_decrypt(ptr noundef %56, ptr noundef %57, ptr noundef %58, ptr noundef %59, ptr noundef %60, i32 noundef 0)
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %64, label %63

63:                                               ; preds = %55
  br label %65

64:                                               ; preds = %55
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %64, %63, %54, %49, %44, %38, %33, %19
  %66 = load i32, ptr %13, align 4, !tbaa !5
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %72

68:                                               ; preds = %65
  %69 = load ptr, ptr @stderr, align 8, !tbaa !9
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef @.str.7) #4
  %71 = load ptr, ptr @stderr, align 8, !tbaa !9
  call void @ERR_print_errors_fp(ptr noundef %71)
  br label %72

72:                                               ; preds = %68, %65
  %73 = load ptr, ptr %12, align 8, !tbaa !9
  call void @CMS_ContentInfo_free(ptr noundef %73)
  %74 = load ptr, ptr %10, align 8, !tbaa !9
  call void @X509_free(ptr noundef %74)
  %75 = load ptr, ptr %11, align 8, !tbaa !9
  call void @EVP_PKEY_free(ptr noundef %75)
  %76 = load ptr, ptr %6, align 8, !tbaa !9
  %77 = call i32 @BIO_free(ptr noundef %76)
  %78 = load ptr, ptr %7, align 8, !tbaa !9
  %79 = call i32 @BIO_free(ptr noundef %78)
  %80 = load ptr, ptr %8, align 8, !tbaa !9
  %81 = call i32 @BIO_free(ptr noundef %80)
  %82 = load ptr, ptr %9, align 8, !tbaa !9
  %83 = call i32 @BIO_free(ptr noundef %82)
  %84 = load i32, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, 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 8, ptr %6) #4
  ret i32 %84
}

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

declare i32 @OPENSSL_init_crypto(i64 noundef, ptr noundef) #2

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

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

declare i64 @BIO_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) #2

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

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

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

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

declare void @ERR_print_errors_fp(ptr noundef) #2

declare void @CMS_ContentInfo_free(ptr noundef) #2

declare void @X509_free(ptr noundef) #2

declare void @EVP_PKEY_free(ptr noundef) #2

declare i32 @BIO_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"

@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [23 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 = tail call i32 @OPENSSL_init_crypto(i64 noundef 12, ptr noundef null) #3
  %4 = tail call i32 @OPENSSL_init_crypto(i64 noundef 2, ptr noundef null) #3
  %5 = tail call ptr @BIO_new_file(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1) #3
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.thread, label %6

6:                                                ; preds = %2
  %7 = tail call ptr @PEM_read_bio_X509(ptr noundef nonnull %5, ptr noundef null, ptr noundef null, ptr noundef null) #3
  %8 = tail call i64 @BIO_ctrl(ptr noundef nonnull %5, i32 noundef 1, i64 noundef 0, ptr noundef null) #3
  %9 = tail call ptr @PEM_read_bio_PrivateKey(ptr noundef nonnull %5, ptr noundef null, ptr noundef null, ptr noundef null) #3
  %10 = icmp ne ptr %7, null
  %11 = icmp ne ptr %9, null
  %or.cond = select i1 %10, i1 %11, i1 false
  br i1 %or.cond, label %12, label %.thread

12:                                               ; preds = %6
  %13 = tail call ptr @BIO_new_file(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1) #3
  %.not39 = icmp eq ptr %13, null
  br i1 %.not39, label %.thread, label %14

14:                                               ; preds = %12
  %15 = tail call ptr @PEM_read_bio_CMS(ptr noundef nonnull %13, ptr noundef null, ptr noundef null, ptr noundef null) #3
  %.not40 = icmp eq ptr %15, null
  br i1 %.not40, label %.thread, label %16

16:                                               ; preds = %14
  %17 = tail call ptr @BIO_new_file(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4) #3
  %18 = tail call ptr @BIO_new_file(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6) #3
  %.not41 = icmp eq ptr %18, null
  br i1 %.not41, label %.thread, label %19

19:                                               ; preds = %16
  %20 = tail call i32 @CMS_decrypt(ptr noundef nonnull %15, ptr noundef nonnull %9, ptr noundef nonnull %7, ptr noundef %17, ptr noundef nonnull %18, i32 noundef 0) #3
  %.not42.not = icmp eq i32 %20, 0
  br i1 %.not42.not, label %.thread, label %24

.thread:                                          ; preds = %2, %6, %12, %14, %16, %19
  %.02563 = phi ptr [ %15, %19 ], [ %15, %16 ], [ null, %14 ], [ null, %12 ], [ null, %6 ], [ null, %2 ]
  %.02661 = phi ptr [ %9, %19 ], [ %9, %16 ], [ %9, %14 ], [ %9, %12 ], [ %9, %6 ], [ null, %2 ]
  %.02759 = phi ptr [ %7, %19 ], [ %7, %16 ], [ %7, %14 ], [ %7, %12 ], [ %7, %6 ], [ null, %2 ]
  %.02857 = phi ptr [ %17, %19 ], [ %17, %16 ], [ null, %14 ], [ null, %12 ], [ null, %6 ], [ null, %2 ]
  %.02955 = phi ptr [ %18, %19 ], [ null, %16 ], [ null, %14 ], [ null, %12 ], [ null, %6 ], [ null, %2 ]
  %.03053 = phi ptr [ %13, %19 ], [ %13, %16 ], [ %13, %14 ], [ null, %12 ], [ null, %6 ], [ null, %2 ]
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.7) #4
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void @ERR_print_errors_fp(ptr noundef %23) #3
  br label %24

24:                                               ; preds = %.thread, %19
  %.066 = phi i32 [ 1, %.thread ], [ 0, %19 ]
  %.02564 = phi ptr [ %.02563, %.thread ], [ %15, %19 ]
  %.02662 = phi ptr [ %.02661, %.thread ], [ %9, %19 ]
  %.02760 = phi ptr [ %.02759, %.thread ], [ %7, %19 ]
  %.02858 = phi ptr [ %.02857, %.thread ], [ %17, %19 ]
  %.02956 = phi ptr [ %.02955, %.thread ], [ %18, %19 ]
  %.03054 = phi ptr [ %.03053, %.thread ], [ %13, %19 ]
  tail call void @CMS_ContentInfo_free(ptr noundef %.02564) #3
  tail call void @X509_free(ptr noundef %.02760) #3
  tail call void @EVP_PKEY_free(ptr noundef %.02662) #3
  %25 = tail call i32 @BIO_free(ptr noundef %.03054) #3
  %26 = tail call i32 @BIO_free(ptr noundef %.02956) #3
  %27 = tail call i32 @BIO_free(ptr noundef %5) #3
  %28 = tail call i32 @BIO_free(ptr noundef %.02858) #3
  ret i32 %.066
}

declare i32 @OPENSSL_init_crypto(i64 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @BIO_new_file(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @PEM_read_bio_X509(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i64 @BIO_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @PEM_read_bio_PrivateKey(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @PEM_read_bio_CMS(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @CMS_decrypt(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

declare void @ERR_print_errors_fp(ptr noundef) local_unnamed_addr #1

declare void @CMS_ContentInfo_free(ptr noundef) local_unnamed_addr #1

declare void @X509_free(ptr noundef) local_unnamed_addr #1

declare void @EVP_PKEY_free(ptr noundef) local_unnamed_addr #1

declare i32 @BIO_free(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 = { 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 #3 = { nounwind }
attributes #4 = { 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: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass