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

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

18:                                               ; preds = %2
  br label %58

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

29:                                               ; preds = %19
  %30 = load ptr, ptr %10, align 8, !tbaa !9
  %31 = icmp ne ptr %30, null
  br i1 %31, label %33, label %32

32:                                               ; preds = %29, %19
  br label %58

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

37:                                               ; preds = %33
  br label %58

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

43:                                               ; preds = %38
  br label %58

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

48:                                               ; preds = %44
  br label %58

49:                                               ; preds = %44
  %50 = load ptr, ptr %11, align 8, !tbaa !9
  %51 = load ptr, ptr %10, align 8, !tbaa !9
  %52 = load ptr, ptr %9, align 8, !tbaa !9
  %53 = load ptr, ptr %7, align 8, !tbaa !9
  %54 = call i32 @CMS_decrypt(ptr noundef %50, ptr noundef %51, ptr noundef %52, ptr noundef null, ptr noundef %53, i32 noundef 0)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %57, label %56

56:                                               ; preds = %49
  br label %58

57:                                               ; preds = %49
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %57, %56, %48, %43, %37, %32, %18
  %59 = load i32, ptr %12, align 4, !tbaa !5
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %65

61:                                               ; preds = %58
  %62 = load ptr, ptr @stderr, align 8, !tbaa !9
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.5) #4
  %64 = load ptr, ptr @stderr, align 8, !tbaa !9
  call void @ERR_print_errors_fp(ptr noundef %64)
  br label %65

65:                                               ; preds = %61, %58
  %66 = load ptr, ptr %11, align 8, !tbaa !9
  call void @CMS_ContentInfo_free(ptr noundef %66)
  %67 = load ptr, ptr %9, align 8, !tbaa !9
  call void @X509_free(ptr noundef %67)
  %68 = load ptr, ptr %10, align 8, !tbaa !9
  call void @EVP_PKEY_free(ptr noundef %68)
  %69 = load ptr, ptr %6, align 8, !tbaa !9
  %70 = call i32 @BIO_free(ptr noundef %69)
  %71 = load ptr, ptr %7, align 8, !tbaa !9
  %72 = call i32 @BIO_free(ptr noundef %71)
  %73 = load ptr, ptr %8, align 8, !tbaa !9
  %74 = call i32 @BIO_free(ptr noundef %73)
  %75 = load i32, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, 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 %75
}

; 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 @SMIME_read_CMS(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 [2 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.5 = 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
  %.not35 = icmp eq ptr %13, null
  br i1 %.not35, label %.thread, label %14

14:                                               ; preds = %12
  %15 = tail call ptr @SMIME_read_CMS(ptr noundef nonnull %13, ptr noundef null) #3
  %.not36 = icmp eq ptr %15, null
  br i1 %.not36, 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
  %.not37 = icmp eq ptr %17, null
  br i1 %.not37, label %.thread, label %18

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

.thread:                                          ; preds = %2, %6, %12, %14, %16, %18
  %.02256 = phi ptr [ %15, %18 ], [ %15, %16 ], [ null, %14 ], [ null, %12 ], [ null, %6 ], [ null, %2 ]
  %.02354 = phi ptr [ %9, %18 ], [ %9, %16 ], [ %9, %14 ], [ %9, %12 ], [ %9, %6 ], [ null, %2 ]
  %.02452 = phi ptr [ %7, %18 ], [ %7, %16 ], [ %7, %14 ], [ %7, %12 ], [ %7, %6 ], [ null, %2 ]
  %.02550 = phi ptr [ %17, %18 ], [ null, %16 ], [ null, %14 ], [ null, %12 ], [ null, %6 ], [ null, %2 ]
  %.02648 = phi ptr [ %13, %18 ], [ %13, %16 ], [ %13, %14 ], [ null, %12 ], [ null, %6 ], [ null, %2 ]
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.5) #4
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void @ERR_print_errors_fp(ptr noundef %22) #3
  br label %23

23:                                               ; preds = %.thread, %18
  %.059 = phi i32 [ 1, %.thread ], [ 0, %18 ]
  %.02257 = phi ptr [ %.02256, %.thread ], [ %15, %18 ]
  %.02355 = phi ptr [ %.02354, %.thread ], [ %9, %18 ]
  %.02453 = phi ptr [ %.02452, %.thread ], [ %7, %18 ]
  %.02551 = phi ptr [ %.02550, %.thread ], [ %17, %18 ]
  %.02649 = phi ptr [ %.02648, %.thread ], [ %13, %18 ]
  tail call void @CMS_ContentInfo_free(ptr noundef %.02257) #3
  tail call void @X509_free(ptr noundef %.02453) #3
  tail call void @EVP_PKEY_free(ptr noundef %.02355) #3
  %24 = tail call i32 @BIO_free(ptr noundef %.02649) #3
  %25 = tail call i32 @BIO_free(ptr noundef %.02551) #3
  %26 = tail call i32 @BIO_free(ptr noundef %5) #3
  ret i32 %.059
}

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 @SMIME_read_CMS(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