; LLVM IR from guanzhi/GmSSL :: src (cms)

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

%struct.SM2_KEY = type { %struct.SM2_Z256_POINT, [4 x i64] }
%struct.SM2_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@__FUNCTION__.cms_enveloped_data_encrypt_to_der = external hidden unnamed_addr constant [34 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_enced_content_info_encrypt_to_der(i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #3

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

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

declare i32 @asn1_length_le(i64 noundef, i64 noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_recipient_info_encrypt_to_der(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @cms_enveloped_data_encrypt_to_der(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, i32 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef %14, ptr noundef %15) #3 {
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca ptr, align 8
  %24 = alloca i64, align 8
  %25 = alloca i32, align 4
  %26 = alloca ptr, align 8
  %27 = alloca i64, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i64, align 8
  %30 = alloca ptr, align 8
  %31 = alloca i64, align 8
  %32 = alloca ptr, align 8
  %33 = alloca ptr, align 8
  %34 = alloca [1024 x i8], align 16
  %35 = alloca i64, align 8
  %36 = alloca ptr, align 8
  %37 = alloca i64, align 8
  %38 = alloca ptr, align 8
  %39 = alloca i64, align 8
  %40 = alloca %struct.SM2_KEY, align 8
  %41 = alloca ptr, align 8
  %42 = alloca i64, align 8
  %43 = alloca ptr, align 8
  %44 = alloca i64, align 8
  %45 = alloca i32, align 4
  store ptr %0, ptr %18, align 8, !tbaa !5
  store i64 %1, ptr %19, align 8, !tbaa !9
  store i32 %2, ptr %20, align 4, !tbaa !11
  store ptr %3, ptr %21, align 8, !tbaa !5
  store i64 %4, ptr %22, align 8, !tbaa !9
  store ptr %5, ptr %23, align 8, !tbaa !5
  store i64 %6, ptr %24, align 8, !tbaa !9
  store i32 %7, ptr %25, align 4, !tbaa !11
  store ptr %8, ptr %26, align 8, !tbaa !5
  store i64 %9, ptr %27, align 8, !tbaa !9
  store ptr %10, ptr %28, align 8, !tbaa !5
  store i64 %11, ptr %29, align 8, !tbaa !9
  store ptr %12, ptr %30, align 8, !tbaa !5
  store i64 %13, ptr %31, align 8, !tbaa !9
  store ptr %14, ptr %32, align 8, !tbaa !5
  store ptr %15, ptr %33, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %34) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %35) #4
  store i64 0, ptr %35, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %36) #4
  %46 = getelementptr inbounds [1024 x i8], ptr %34, i64 0, i64 0
  store ptr %46, ptr %36, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %37) #4
  store i64 0, ptr %37, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %100, %16
  %48 = load i64, ptr %19, align 8, !tbaa !9
  %49 = icmp ne i64 %48, 0
  br i1 %49, label %50, label %101

50:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %38) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %39) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr %40) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %41) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %42) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %43) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %44) #4
  %51 = call i32 @asn1_any_from_der(ptr noundef %38, ptr noundef %39, ptr noundef %18, ptr noundef %19)
  %52 = icmp ne i32 %51, 1
  br i1 %52, label %63, label %53

53:                                               ; preds = %50
  %54 = load ptr, ptr %38, align 8, !tbaa !5
  %55 = load i64, ptr %39, align 8, !tbaa !9
  %56 = call i32 @x509_cert_get_issuer_and_serial_number(ptr noundef %54, i64 noundef %55, ptr noundef %41, ptr noundef %42, ptr noundef %43, ptr noundef %44)
  %57 = icmp ne i32 %56, 1
  br i1 %57, label %63, label %58

58:                                               ; preds = %53
  %59 = load ptr, ptr %38, align 8, !tbaa !5
  %60 = load i64, ptr %39, align 8, !tbaa !9
  %61 = call i32 @x509_cert_get_subject_public_key(ptr noundef %59, i64 noundef %60, ptr noundef %40)
  %62 = icmp ne i32 %61, 1
  br i1 %62, label %63, label %69

63:                                               ; preds = %58, %53, %50
  br label %64

64:                                               ; preds = %63
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1534, ptr noundef @__FUNCTION__.cms_enveloped_data_encrypt_to_der) #4
  br label %67

67:                                               ; preds = %64
  br label %68

68:                                               ; preds = %67
  store i32 -1, ptr %17, align 4
  store i32 1, ptr %45, align 4
  br label %98

69:                                               ; preds = %58
  %70 = load ptr, ptr %41, align 8, !tbaa !5
  %71 = load i64, ptr %42, align 8, !tbaa !9
  %72 = load ptr, ptr %43, align 8, !tbaa !5
  %73 = load i64, ptr %44, align 8, !tbaa !9
  %74 = load ptr, ptr %21, align 8, !tbaa !5
  %75 = load i64, ptr %22, align 8, !tbaa !9
  %76 = call i32 @cms_recipient_info_encrypt_to_der(ptr noundef %40, ptr noundef %70, i64 noundef %71, ptr noundef %72, i64 noundef %73, ptr noundef %74, i64 noundef %75, ptr noundef null, ptr noundef %37)
  %77 = icmp ne i32 %76, 1
  br i1 %77, label %91, label %78

78:                                               ; preds = %69
  %79 = load i64, ptr %37, align 8, !tbaa !9
  %80 = call i32 @asn1_length_le(i64 noundef %79, i64 noundef 1024)
  %81 = icmp ne i32 %80, 1
  br i1 %81, label %91, label %82

82:                                               ; preds = %78
  %83 = load ptr, ptr %41, align 8, !tbaa !5
  %84 = load i64, ptr %42, align 8, !tbaa !9
  %85 = load ptr, ptr %43, align 8, !tbaa !5
  %86 = load i64, ptr %44, align 8, !tbaa !9
  %87 = load ptr, ptr %21, align 8, !tbaa !5
  %88 = load i64, ptr %22, align 8, !tbaa !9
  %89 = call i32 @cms_recipient_info_encrypt_to_der(ptr noundef %40, ptr noundef %83, i64 noundef %84, ptr noundef %85, i64 noundef %86, ptr noundef %87, i64 noundef %88, ptr noundef %36, ptr noundef %35)
  %90 = icmp ne i32 %89, 1
  br i1 %90, label %91, label %97

91:                                               ; preds = %82, %78, %69
  br label %92

92:                                               ; preds = %91
  %93 = load ptr, ptr @stderr, align 8, !tbaa !5
  %94 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %93, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1544, ptr noundef @__FUNCTION__.cms_enveloped_data_encrypt_to_der) #4
  br label %95

95:                                               ; preds = %92
  br label %96

96:                                               ; preds = %95
  store i32 -1, ptr %17, align 4
  store i32 1, ptr %45, align 4
  br label %98

97:                                               ; preds = %82
  store i32 0, ptr %45, align 4
  br label %98

98:                                               ; preds = %97, %96, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %44) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %43) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %42) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %41) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %40) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %39) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %38) #4
  %99 = load i32, ptr %45, align 4
  switch i32 %99, label %166 [
    i32 0, label %100
  ]

100:                                              ; preds = %98
  br label %47, !llvm.loop !13

101:                                              ; preds = %47
  store i64 0, ptr %37, align 8, !tbaa !9
  %102 = call i32 @asn1_int_to_der_ex(i32 noundef 2, i32 noundef 1, ptr noundef null, ptr noundef %37)
  %103 = icmp ne i32 %102, 1
  br i1 %103, label %159, label %104

104:                                              ; preds = %101
  %105 = getelementptr inbounds [1024 x i8], ptr %34, i64 0, i64 0
  %106 = load i64, ptr %35, align 8, !tbaa !9
  %107 = call i32 @asn1_nonempty_type_to_der(i32 noundef 49, ptr noundef %105, i64 noundef %106, ptr noundef null, ptr noundef %37)
  %108 = icmp ne i32 %107, 1
  br i1 %108, label %159, label %109

109:                                              ; preds = %104
  %110 = load i32, ptr %20, align 4, !tbaa !11
  %111 = load ptr, ptr %21, align 8, !tbaa !5
  %112 = load i64, ptr %22, align 8, !tbaa !9
  %113 = load ptr, ptr %23, align 8, !tbaa !5
  %114 = load i64, ptr %24, align 8, !tbaa !9
  %115 = load i32, ptr %25, align 4, !tbaa !11
  %116 = load ptr, ptr %26, align 8, !tbaa !5
  %117 = load i64, ptr %27, align 8, !tbaa !9
  %118 = load ptr, ptr %28, align 8, !tbaa !5
  %119 = load i64, ptr %29, align 8, !tbaa !9
  %120 = load ptr, ptr %30, align 8, !tbaa !5
  %121 = load i64, ptr %31, align 8, !tbaa !9
  %122 = call i32 @cms_enced_content_info_encrypt_to_der(i32 noundef %110, ptr noundef %111, i64 noundef %112, ptr noundef %113, i64 noundef %114, i32 noundef %115, ptr noundef %116, i64 noundef %117, ptr noundef %118, i64 noundef %119, ptr noundef %120, i64 noundef %121, ptr noundef null, ptr noundef %37)
  %123 = icmp ne i32 %122, 1
  br i1 %123, label %159, label %124

124:                                              ; preds = %109
  %125 = load i64, ptr %37, align 8, !tbaa !9
  %126 = load ptr, ptr %32, align 8, !tbaa !5
  %127 = load ptr, ptr %33, align 8, !tbaa !5
  %128 = call i32 @asn1_header_to_der(i32 noundef 48, i64 noundef %125, ptr noundef %126, ptr noundef %127)
  %129 = icmp ne i32 %128, 1
  br i1 %129, label %159, label %130

130:                                              ; preds = %124
  %131 = load ptr, ptr %32, align 8, !tbaa !5
  %132 = load ptr, ptr %33, align 8, !tbaa !5
  %133 = call i32 @asn1_int_to_der_ex(i32 noundef 2, i32 noundef 1, ptr noundef %131, ptr noundef %132)
  %134 = icmp ne i32 %133, 1
  br i1 %134, label %159, label %135

135:                                              ; preds = %130
  %136 = getelementptr inbounds [1024 x i8], ptr %34, i64 0, i64 0
  %137 = load i64, ptr %35, align 8, !tbaa !9
  %138 = load ptr, ptr %32, align 8, !tbaa !5
  %139 = load ptr, ptr %33, align 8, !tbaa !5
  %140 = call i32 @asn1_nonempty_type_to_der(i32 noundef 49, ptr noundef %136, i64 noundef %137, ptr noundef %138, ptr noundef %139)
  %141 = icmp ne i32 %140, 1
  br i1 %141, label %159, label %142

142:                                              ; preds = %135
  %143 = load i32, ptr %20, align 4, !tbaa !11
  %144 = load ptr, ptr %21, align 8, !tbaa !5
  %145 = load i64, ptr %22, align 8, !tbaa !9
  %146 = load ptr, ptr %23, align 8, !tbaa !5
  %147 = load i64, ptr %24, align 8, !tbaa !9
  %148 = load i32, ptr %25, align 4, !tbaa !11
  %149 = load ptr, ptr %26, align 8, !tbaa !5
  %150 = load i64, ptr %27, align 8, !tbaa !9
  %151 = load ptr, ptr %28, align 8, !tbaa !5
  %152 = load i64, ptr %29, align 8, !tbaa !9
  %153 = load ptr, ptr %30, align 8, !tbaa !5
  %154 = load i64, ptr %31, align 8, !tbaa !9
  %155 = load ptr, ptr %32, align 8, !tbaa !5
  %156 = load ptr, ptr %33, align 8, !tbaa !5
  %157 = call i32 @cms_enced_content_info_encrypt_to_der(i32 noundef %143, ptr noundef %144, i64 noundef %145, ptr noundef %146, i64 noundef %147, i32 noundef %148, ptr noundef %149, i64 noundef %150, ptr noundef %151, i64 noundef %152, ptr noundef %153, i64 noundef %154, ptr noundef %155, ptr noundef %156)
  %158 = icmp ne i32 %157, 1
  br i1 %158, label %159, label %165

159:                                              ; preds = %142, %135, %130, %124, %109, %104, %101
  br label %160

160:                                              ; preds = %159
  %161 = load ptr, ptr @stderr, align 8, !tbaa !5
  %162 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %161, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1566, ptr noundef @__FUNCTION__.cms_enveloped_data_encrypt_to_der) #4
  br label %163

163:                                              ; preds = %160
  br label %164

164:                                              ; preds = %163
  store i32 -1, ptr %17, align 4
  store i32 1, ptr %45, align 4
  br label %166

165:                                              ; preds = %142
  store i32 1, ptr %17, align 4
  store i32 1, ptr %45, align 4
  br label %166

166:                                              ; preds = %165, %164, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %37) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %36) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %35) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %34) #4
  %167 = load i32, ptr %17, align 4
  ret i32 %167
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

%struct.SM2_KEY = type { %struct.SM2_Z256_POINT, [4 x i64] }
%struct.SM2_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@__FUNCTION__.cms_enveloped_data_encrypt_to_der = external hidden unnamed_addr constant [34 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_enced_content_info_encrypt_to_der(i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

declare i32 @asn1_length_le(i64 noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_recipient_info_encrypt_to_der(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cms_enveloped_data_encrypt_to_der(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, i32 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef %14, ptr noundef %15) local_unnamed_addr #3 {
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca [1024 x i8], align 16
  %20 = alloca i64, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca ptr, align 8
  %24 = alloca i64, align 8
  %25 = alloca %struct.SM2_KEY, align 8
  %26 = alloca ptr, align 8
  %27 = alloca i64, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i64, align 8
  store ptr %0, ptr %17, align 8, !tbaa !5
  store i64 %1, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %19) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %20) #4
  store i64 0, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %21) #4
  store ptr %19, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %22) #4
  store i64 0, ptr %22, align 8, !tbaa !9
  %.not51 = icmp eq i64 %1, 0
  br i1 %.not51, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %16, %54
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %23) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %24) #4
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %25) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %26) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %27) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %28) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %29) #4
  %30 = call i32 @asn1_any_from_der(ptr noundef nonnull %23, ptr noundef nonnull %24, ptr noundef nonnull %17, ptr noundef nonnull %18) #4
  %.not45 = icmp eq i32 %30, 1
  br i1 %.not45, label %31, label %.critedge

31:                                               ; preds = %.lr.ph
  %32 = load ptr, ptr %23, align 8, !tbaa !5
  %33 = load i64, ptr %24, align 8, !tbaa !9
  %34 = call i32 @x509_cert_get_issuer_and_serial_number(ptr noundef %32, i64 noundef %33, ptr noundef nonnull %26, ptr noundef nonnull %27, ptr noundef nonnull %28, ptr noundef nonnull %29) #4
  %.not46 = icmp eq i32 %34, 1
  br i1 %.not46, label %35, label %.critedge

35:                                               ; preds = %31
  %36 = load ptr, ptr %23, align 8, !tbaa !5
  %37 = load i64, ptr %24, align 8, !tbaa !9
  %38 = call i32 @x509_cert_get_subject_public_key(ptr noundef %36, i64 noundef %37, ptr noundef nonnull %25) #4
  %.not47 = icmp eq i32 %38, 1
  br i1 %.not47, label %39, label %.critedge

39:                                               ; preds = %35
  %40 = load ptr, ptr %26, align 8, !tbaa !5
  %41 = load i64, ptr %27, align 8, !tbaa !9
  %42 = load ptr, ptr %28, align 8, !tbaa !5
  %43 = load i64, ptr %29, align 8, !tbaa !9
  %44 = call i32 @cms_recipient_info_encrypt_to_der(ptr noundef nonnull %25, ptr noundef %40, i64 noundef %41, ptr noundef %42, i64 noundef %43, ptr noundef %3, i64 noundef %4, ptr noundef null, ptr noundef nonnull %22)
  %.not48 = icmp eq i32 %44, 1
  br i1 %.not48, label %45, label %.critedge

45:                                               ; preds = %39
  %46 = load i64, ptr %22, align 8, !tbaa !9
  %47 = call i32 @asn1_length_le(i64 noundef %46, i64 noundef 1024) #4
  %.not49 = icmp eq i32 %47, 1
  br i1 %.not49, label %48, label %.critedge

48:                                               ; preds = %45
  %49 = load ptr, ptr %26, align 8, !tbaa !5
  %50 = load i64, ptr %27, align 8, !tbaa !9
  %51 = load ptr, ptr %28, align 8, !tbaa !5
  %52 = load i64, ptr %29, align 8, !tbaa !9
  %53 = call i32 @cms_recipient_info_encrypt_to_der(ptr noundef nonnull %25, ptr noundef %49, i64 noundef %50, ptr noundef %51, i64 noundef %52, ptr noundef %3, i64 noundef %4, ptr noundef nonnull %21, ptr noundef nonnull %20)
  %.not50 = icmp eq i32 %53, 1
  br i1 %.not50, label %54, label %.critedge

54:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %29) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %28) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %26) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %25) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %23) #4
  %55 = load i64, ptr %18, align 8, !tbaa !9
  %.not = icmp eq i64 %55, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %54, %16
  store i64 0, ptr %22, align 8, !tbaa !9
  %56 = call i32 @asn1_int_to_der_ex(i32 noundef 2, i32 noundef 1, ptr noundef null, ptr noundef nonnull %22) #4
  %.not38 = icmp eq i32 %56, 1
  br i1 %.not38, label %57, label %72

57:                                               ; preds = %._crit_edge
  %58 = load i64, ptr %20, align 8, !tbaa !9
  %59 = call i32 @asn1_nonempty_type_to_der(i32 noundef 49, ptr noundef nonnull %19, i64 noundef %58, ptr noundef null, ptr noundef nonnull %22) #4
  %.not39 = icmp eq i32 %59, 1
  br i1 %.not39, label %60, label %72

60:                                               ; preds = %57
  %61 = call i32 @cms_enced_content_info_encrypt_to_der(i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, i32 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef null, ptr noundef nonnull %22)
  %.not40 = icmp eq i32 %61, 1
  br i1 %.not40, label %62, label %72

62:                                               ; preds = %60
  %63 = load i64, ptr %22, align 8, !tbaa !9
  %64 = call i32 @asn1_header_to_der(i32 noundef 48, i64 noundef %63, ptr noundef %14, ptr noundef %15) #4
  %.not41 = icmp eq i32 %64, 1
  br i1 %.not41, label %65, label %72

65:                                               ; preds = %62
  %66 = call i32 @asn1_int_to_der_ex(i32 noundef 2, i32 noundef 1, ptr noundef %14, ptr noundef %15) #4
  %.not42 = icmp eq i32 %66, 1
  br i1 %.not42, label %67, label %72

67:                                               ; preds = %65
  %68 = load i64, ptr %20, align 8, !tbaa !9
  %69 = call i32 @asn1_nonempty_type_to_der(i32 noundef 49, ptr noundef nonnull %19, i64 noundef %68, ptr noundef %14, ptr noundef %15) #4
  %.not43 = icmp eq i32 %69, 1
  br i1 %.not43, label %70, label %72

70:                                               ; preds = %67
  %71 = call i32 @cms_enced_content_info_encrypt_to_der(i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, i32 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef %14, ptr noundef %15)
  %.not44 = icmp eq i32 %71, 1
  br i1 %.not44, label %77, label %72

72:                                               ; preds = %._crit_edge, %57, %60, %62, %65, %67, %70
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1566, ptr noundef nonnull @__FUNCTION__.cms_enveloped_data_encrypt_to_der) #5
  br label %77

.critedge:                                        ; preds = %48, %45, %39, %35, %31, %.lr.ph
  %.sink52 = phi i32 [ 1534, %.lr.ph ], [ 1534, %31 ], [ 1534, %35 ], [ 1544, %39 ], [ 1544, %45 ], [ 1544, %48 ]
  %75 = load ptr, ptr @stderr, align 8, !tbaa !5
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef %.sink52, ptr noundef nonnull @__FUNCTION__.cms_enveloped_data_encrypt_to_der) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %29) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %28) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %26) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %25) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %23) #4
  br label %77

77:                                               ; preds = %70, %.critedge, %72
  %.2 = phi i32 [ -1, %72 ], [ -1, %.critedge ], [ 1, %70 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %20) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %19) #4
  ret i32 %.2
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass