; 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.SM3_CTX = type { [8 x i32], i64, [64 x i8], i64 }
%struct.CMS_CERTS_AND_KEY = type { ptr, i64, ptr }

@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
@__const.cms_signed_data_sign_to_der.digest_algors = external hidden unnamed_addr constant [1 x i32], align 4
@__FUNCTION__.cms_signed_data_sign_to_der = external hidden unnamed_addr constant [28 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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_content_info_to_der(i32 noundef, ptr 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) #3

declare i32 @asn1_type_to_der(i32 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) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare void @sm3_update(ptr noundef, ptr noundef, i64 noundef) #3

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @cms_signed_data_sign_to_der(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, ptr noundef %8) #2 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca [1 x i32], align 4
  %21 = alloca i64, align 8
  %22 = alloca [256 x i8], align 16
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca [512 x i8], align 16
  %26 = alloca i64, align 8
  %27 = alloca %struct.SM3_CTX, 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 i64, align 8
  %34 = alloca i64, align 8
  %35 = alloca i64, align 8
  %36 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i64 %1, ptr %12, align 8, !tbaa !9
  store i32 %2, ptr %13, align 4, !tbaa !11
  store ptr %3, ptr %14, align 8, !tbaa !5
  store i64 %4, ptr %15, align 8, !tbaa !9
  store ptr %5, ptr %16, align 8, !tbaa !5
  store i64 %6, ptr %17, align 8, !tbaa !9
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 @__const.cms_signed_data_sign_to_der.digest_algors, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  store i64 1, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 256, ptr %22) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  store i64 0, ptr %24, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 512, ptr %25) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #5
  store i64 0, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 112, ptr %27) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %32) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #5
  store i64 0, ptr %33, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %34) #5
  %37 = getelementptr inbounds [256 x i8], ptr %22, i64 0, i64 0
  store ptr %37, ptr %32, align 8, !tbaa !5
  store i64 0, ptr %23, align 8, !tbaa !9
  %38 = load i32, ptr %13, align 4, !tbaa !11
  %39 = icmp eq i32 %38, 118
  br i1 %39, label %40, label %64

40:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %35) #5
  store i64 0, ptr %35, align 8, !tbaa !9
  %41 = load ptr, ptr %14, align 8, !tbaa !5
  %42 = load i64, ptr %15, align 8, !tbaa !9
  %43 = call i32 @asn1_type_to_der(i32 noundef 4, ptr noundef %41, i64 noundef %42, ptr noundef null, ptr noundef %35)
  %44 = icmp ne i32 %43, 1
  br i1 %44, label %54, label %45

45:                                               ; preds = %40
  %46 = load i32, ptr %13, align 4, !tbaa !11
  %47 = load i64, ptr %35, align 8, !tbaa !9
  %48 = call i32 @cms_content_info_header_to_der(i32 noundef %46, i64 noundef %47, ptr noundef %32, ptr noundef %23)
  %49 = icmp ne i32 %48, 1
  br i1 %49, label %54, label %50

50:                                               ; preds = %45
  %51 = load i64, ptr %15, align 8, !tbaa !9
  %52 = call i32 @asn1_header_to_der(i32 noundef 4, i64 noundef %51, ptr noundef %32, ptr noundef %23)
  %53 = icmp ne i32 %52, 1
  br i1 %53, label %54, label %60

54:                                               ; preds = %50, %45, %40
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1082, ptr noundef @__FUNCTION__.cms_signed_data_sign_to_der) #5
  br label %58

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58
  store i32 -1, ptr %10, align 4
  store i32 1, ptr %36, align 4
  br label %61

60:                                               ; preds = %50
  store i32 0, ptr %36, align 4
  br label %61

61:                                               ; preds = %60, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %35) #5
  %62 = load i32, ptr %36, align 4
  switch i32 %62, label %202 [
    i32 0, label %63
  ]

63:                                               ; preds = %61
  br label %76

64:                                               ; preds = %9
  %65 = load i32, ptr %13, align 4, !tbaa !11
  %66 = load i64, ptr %15, align 8, !tbaa !9
  %67 = call i32 @cms_content_info_header_to_der(i32 noundef %65, i64 noundef %66, ptr noundef %32, ptr noundef %23)
  %68 = icmp ne i32 %67, 1
  br i1 %68, label %69, label %75

69:                                               ; preds = %64
  br label %70

70:                                               ; preds = %69
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1087, ptr noundef @__FUNCTION__.cms_signed_data_sign_to_der) #5
  br label %73

73:                                               ; preds = %70
  br label %74

74:                                               ; preds = %73
  store i32 -1, ptr %10, align 4
  store i32 1, ptr %36, align 4
  br label %202

75:                                               ; preds = %64
  br label %76

76:                                               ; preds = %75, %63
  call void @sm3_init(ptr noundef %27)
  %77 = getelementptr inbounds [256 x i8], ptr %22, i64 0, i64 0
  %78 = load i64, ptr %23, align 8, !tbaa !9
  call void @sm3_update(ptr noundef %27, ptr noundef %77, i64 noundef %78)
  %79 = load ptr, ptr %14, align 8, !tbaa !5
  %80 = load i64, ptr %15, align 8, !tbaa !9
  call void @sm3_update(ptr noundef %27, ptr noundef %79, i64 noundef %80)
  store i64 0, ptr %34, align 8, !tbaa !9
  br label %81

81:                                               ; preds = %116, %76
  %82 = load i64, ptr %34, align 8, !tbaa !9
  %83 = load i64, ptr %12, align 8, !tbaa !9
  %84 = icmp ult i64 %82, %83
  br i1 %84, label %85, label %119

85:                                               ; preds = %81
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = load i64, ptr %34, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.CMS_CERTS_AND_KEY, ptr %86, i64 %87
  %89 = getelementptr inbounds %struct.CMS_CERTS_AND_KEY, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !13
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  %92 = load i64, ptr %34, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct.CMS_CERTS_AND_KEY, ptr %91, i64 %92
  %94 = getelementptr inbounds %struct.CMS_CERTS_AND_KEY, ptr %93, i32 0, i32 1
  %95 = load i64, ptr %94, align 8, !tbaa !15
  %96 = call i32 @x509_cert_get_issuer_and_serial_number(ptr noundef %90, i64 noundef %95, ptr noundef %28, ptr noundef %29, ptr noundef %30, ptr noundef %31)
  %97 = icmp ne i32 %96, 1
  br i1 %97, label %109, label %98

98:                                               ; preds = %85
  %99 = getelementptr inbounds [512 x i8], ptr %25, i64 0, i64 0
  %100 = load ptr, ptr %11, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.CMS_CERTS_AND_KEY, ptr %100, i32 0, i32 2
  %102 = load ptr, ptr %101, align 8, !tbaa !16
  %103 = load ptr, ptr %28, align 8, !tbaa !5
  %104 = load i64, ptr %29, align 8, !tbaa !9
  %105 = load ptr, ptr %30, align 8, !tbaa !5
  %106 = load i64, ptr %31, align 8, !tbaa !9
  %107 = call i32 @cms_signer_infos_add_signer_info(ptr noundef %99, ptr noundef %26, i64 noundef 512, ptr noundef %27, ptr noundef %102, ptr noundef %103, i64 noundef %104, ptr noundef %105, i64 noundef %106, ptr noundef null, i64 noundef 0, ptr noundef null, i64 noundef 0)
  %108 = icmp ne i32 %107, 1
  br i1 %108, label %109, label %115

109:                                              ; preds = %98, %85
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr @stderr, align 8, !tbaa !5
  %112 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %111, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1105, ptr noundef @__FUNCTION__.cms_signed_data_sign_to_der) #5
  br label %113

113:                                              ; preds = %110
  br label %114

114:                                              ; preds = %113
  store i32 -1, ptr %10, align 4
  store i32 1, ptr %36, align 4
  br label %202

115:                                              ; preds = %98
  br label %116

116:                                              ; preds = %115
  %117 = load i64, ptr %34, align 8, !tbaa !9
  %118 = add i64 %117, 1
  store i64 %118, ptr %34, align 8, !tbaa !9
  br label %81, !llvm.loop !17

119:                                              ; preds = %81
  %120 = call i32 @asn1_int_to_der_ex(i32 noundef 2, i32 noundef 1, ptr noundef null, ptr noundef %33)
  %121 = icmp ne i32 %120, 1
  br i1 %121, label %195, label %122

122:                                              ; preds = %119
  %123 = getelementptr inbounds [1 x i32], ptr %20, i64 0, i64 0
  %124 = load i64, ptr %21, align 8, !tbaa !9
  %125 = call i32 @cms_digest_algors_to_der(ptr noundef %123, i64 noundef %124, ptr noundef null, ptr noundef %33)
  %126 = icmp ne i32 %125, 1
  br i1 %126, label %195, label %127

127:                                              ; preds = %122
  %128 = load i32, ptr %13, align 4, !tbaa !11
  %129 = load ptr, ptr %14, align 8, !tbaa !5
  %130 = load i64, ptr %15, align 8, !tbaa !9
  %131 = call i32 @cms_content_info_to_der(i32 noundef %128, ptr noundef %129, i64 noundef %130, ptr noundef null, ptr noundef %33)
  %132 = icmp ne i32 %131, 1
  br i1 %132, label %195, label %133

133:                                              ; preds = %127
  %134 = load ptr, ptr %11, align 8, !tbaa !5
  %135 = load i64, ptr %12, align 8, !tbaa !9
  %136 = call i32 @cms_implicit_signers_certs_to_der(i32 noundef 0, ptr noundef %134, i64 noundef %135, ptr noundef null, ptr noundef %33)
  %137 = icmp slt i32 %136, 0
  br i1 %137, label %195, label %138

138:                                              ; preds = %133
  %139 = load ptr, ptr %16, align 8, !tbaa !5
  %140 = load i64, ptr %17, align 8, !tbaa !9
  %141 = call i32 @asn1_type_to_der(i32 noundef 161, ptr noundef %139, i64 noundef %140, ptr noundef null, ptr noundef %33)
  %142 = icmp slt i32 %141, 0
  br i1 %142, label %195, label %143

143:                                              ; preds = %138
  %144 = getelementptr inbounds [512 x i8], ptr %25, i64 0, i64 0
  %145 = load i64, ptr %26, align 8, !tbaa !9
  %146 = call i32 @asn1_nonempty_type_to_der(i32 noundef 49, ptr noundef %144, i64 noundef %145, ptr noundef null, ptr noundef %33)
  %147 = icmp ne i32 %146, 1
  br i1 %147, label %195, label %148

148:                                              ; preds = %143
  %149 = load i64, ptr %33, align 8, !tbaa !9
  %150 = load ptr, ptr %18, align 8, !tbaa !5
  %151 = load ptr, ptr %19, align 8, !tbaa !5
  %152 = call i32 @asn1_header_to_der(i32 noundef 48, i64 noundef %149, ptr noundef %150, ptr noundef %151)
  %153 = icmp ne i32 %152, 1
  br i1 %153, label %195, label %154

154:                                              ; preds = %148
  %155 = load ptr, ptr %18, align 8, !tbaa !5
  %156 = load ptr, ptr %19, align 8, !tbaa !5
  %157 = call i32 @asn1_int_to_der_ex(i32 noundef 2, i32 noundef 1, ptr noundef %155, ptr noundef %156)
  %158 = icmp ne i32 %157, 1
  br i1 %158, label %195, label %159

159:                                              ; preds = %154
  %160 = getelementptr inbounds [1 x i32], ptr %20, i64 0, i64 0
  %161 = load i64, ptr %21, align 8, !tbaa !9
  %162 = load ptr, ptr %18, align 8, !tbaa !5
  %163 = load ptr, ptr %19, align 8, !tbaa !5
  %164 = call i32 @cms_digest_algors_to_der(ptr noundef %160, i64 noundef %161, ptr noundef %162, ptr noundef %163)
  %165 = icmp ne i32 %164, 1
  br i1 %165, label %195, label %166

166:                                              ; preds = %159
  %167 = load i32, ptr %13, align 4, !tbaa !11
  %168 = load ptr, ptr %14, align 8, !tbaa !5
  %169 = load i64, ptr %15, align 8, !tbaa !9
  %170 = load ptr, ptr %18, align 8, !tbaa !5
  %171 = load ptr, ptr %19, align 8, !tbaa !5
  %172 = call i32 @cms_content_info_to_der(i32 noundef %167, ptr noundef %168, i64 noundef %169, ptr noundef %170, ptr noundef %171)
  %173 = icmp ne i32 %172, 1
  br i1 %173, label %195, label %174

174:                                              ; preds = %166
  %175 = load ptr, ptr %11, align 8, !tbaa !5
  %176 = load i64, ptr %12, align 8, !tbaa !9
  %177 = load ptr, ptr %18, align 8, !tbaa !5
  %178 = load ptr, ptr %19, align 8, !tbaa !5
  %179 = call i32 @cms_implicit_signers_certs_to_der(i32 noundef 0, ptr noundef %175, i64 noundef %176, ptr noundef %177, ptr noundef %178)
  %180 = icmp slt i32 %179, 0
  br i1 %180, label %195, label %181

181:                                              ; preds = %174
  %182 = load ptr, ptr %16, align 8, !tbaa !5
  %183 = load i64, ptr %17, align 8, !tbaa !9
  %184 = load ptr, ptr %18, align 8, !tbaa !5
  %185 = load ptr, ptr %19, align 8, !tbaa !5
  %186 = call i32 @asn1_type_to_der(i32 noundef 161, ptr noundef %182, i64 noundef %183, ptr noundef %184, ptr noundef %185)
  %187 = icmp slt i32 %186, 0
  br i1 %187, label %195, label %188

188:                                              ; preds = %181
  %189 = getelementptr inbounds [512 x i8], ptr %25, i64 0, i64 0
  %190 = load i64, ptr %26, align 8, !tbaa !9
  %191 = load ptr, ptr %18, align 8, !tbaa !5
  %192 = load ptr, ptr %19, align 8, !tbaa !5
  %193 = call i32 @asn1_nonempty_type_to_der(i32 noundef 49, ptr noundef %189, i64 noundef %190, ptr noundef %191, ptr noundef %192)
  %194 = icmp ne i32 %193, 1
  br i1 %194, label %195, label %201

195:                                              ; preds = %188, %181, %174, %166, %159, %154, %148, %143, %138, %133, %127, %122, %119
  br label %196

196:                                              ; preds = %195
  %197 = load ptr, ptr @stderr, align 8, !tbaa !5
  %198 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %197, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1123, ptr noundef @__FUNCTION__.cms_signed_data_sign_to_der) #5
  br label %199

199:                                              ; preds = %196
  br label %200

200:                                              ; preds = %199
  store i32 -1, ptr %10, align 4
  store i32 1, ptr %36, align 4
  br label %202

201:                                              ; preds = %188
  store i32 1, ptr %10, align 4
  store i32 1, ptr %36, align 4
  br label %202

202:                                              ; preds = %201, %200, %114, %74, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %34) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %33) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %32) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #5
  call void @llvm.lifetime.end.p0(i64 112, ptr %27) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 512, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  %203 = load i32, ptr %10, align 4
  ret i32 %203
}

declare void @sm3_init(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @cms_implicit_signers_certs_to_der(i32 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

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 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !10, i64 8, !6, i64 16}
!15 = !{!14, !10, i64 8}
!16 = !{!14, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"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.SM3_CTX = type { [8 x i32], i64, [64 x i8], i64 }
%struct.CMS_CERTS_AND_KEY = type { ptr, i64, ptr }

@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
@__const.cms_signed_data_sign_to_der.digest_algors = external hidden unnamed_addr constant [1 x i32], align 4
@__FUNCTION__.cms_signed_data_sign_to_der = external hidden unnamed_addr constant [28 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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_content_info_to_der(i32 noundef, ptr 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 #3

declare i32 @asn1_type_to_der(i32 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 #3

declare void @sm3_update(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @cms_signed_data_sign_to_der(ptr noundef %0, i64 noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, ptr noundef %8) local_unnamed_addr #2 {
  %10 = alloca [1 x i32], align 4
  %11 = alloca [256 x i8], align 16
  %12 = alloca i64, align 8
  %13 = alloca [512 x i8], align 16
  %14 = alloca i64, align 8
  %15 = alloca %struct.SM3_CTX, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #4
  %23 = load i32, ptr @__const.cms_signed_data_sign_to_der.digest_algors, align 4
  store i32 %23, ptr %10, align 4
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #4
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #4
  store i64 0, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %17) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %18) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %19) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %20) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %21) #4
  store i64 0, ptr %21, align 8, !tbaa !5
  store ptr %11, ptr %20, align 8, !tbaa !9
  store i64 0, ptr %12, align 8, !tbaa !5
  %24 = icmp eq i32 %2, 118
  br i1 %24, label %25, label %35

25:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %22) #4
  store i64 0, ptr %22, align 8, !tbaa !5
  %26 = call i32 @asn1_type_to_der(i32 noundef 4, ptr noundef %3, i64 noundef %4, ptr noundef null, ptr noundef nonnull %22) #4
  %.not53 = icmp eq i32 %26, 1
  br i1 %.not53, label %27, label %.critedge

27:                                               ; preds = %25
  %28 = load i64, ptr %22, align 8, !tbaa !5
  %29 = call i32 @cms_content_info_header_to_der(i32 noundef 118, i64 noundef %28, ptr noundef nonnull %20, ptr noundef nonnull %12)
  %.not54 = icmp eq i32 %29, 1
  br i1 %.not54, label %30, label %.critedge

30:                                               ; preds = %27
  %31 = call i32 @asn1_header_to_der(i32 noundef 4, i64 noundef %4, ptr noundef nonnull %20, ptr noundef nonnull %12) #4
  %.not55 = icmp eq i32 %31, 1
  br i1 %.not55, label %34, label %.critedge

.critedge:                                        ; preds = %25, %27, %30
  %32 = load ptr, ptr @stderr, align 8, !tbaa !9
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1082, ptr noundef nonnull @__FUNCTION__.cms_signed_data_sign_to_der) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %22) #4
  br label %96

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %22) #4
  br label %40

35:                                               ; preds = %9
  %36 = call i32 @cms_content_info_header_to_der(i32 noundef %2, i64 noundef %4, ptr noundef nonnull %20, ptr noundef nonnull %12)
  %.not = icmp eq i32 %36, 1
  br i1 %.not, label %40, label %37

37:                                               ; preds = %35
  %38 = load ptr, ptr @stderr, align 8, !tbaa !9
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1087, ptr noundef nonnull @__FUNCTION__.cms_signed_data_sign_to_der) #5
  br label %96

40:                                               ; preds = %34, %35
  call void @sm3_init(ptr noundef nonnull %15) #4
  %41 = load i64, ptr %12, align 8, !tbaa !5
  call void @sm3_update(ptr noundef nonnull %15, ptr noundef nonnull %11, i64 noundef %41) #4
  call void @sm3_update(ptr noundef nonnull %15, ptr noundef %3, i64 noundef %4) #4
  %.not68 = icmp eq i64 %1, 0
  br i1 %.not68, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %40
  %42 = getelementptr inbounds i8, ptr %0, i64 16
  br label %45

43:                                               ; preds = %51
  %44 = add nuw i64 %.04867, 1
  %exitcond.not = icmp eq i64 %44, %1
  br i1 %exitcond.not, label %._crit_edge, label %45, !llvm.loop !11

45:                                               ; preds = %.lr.ph, %43
  %.04867 = phi i64 [ 0, %.lr.ph ], [ %44, %43 ]
  %46 = getelementptr inbounds %struct.CMS_CERTS_AND_KEY, ptr %0, i64 %.04867
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %46, i64 8
  %49 = load i64, ptr %48, align 8, !tbaa !15
  %50 = call i32 @x509_cert_get_issuer_and_serial_number(ptr noundef %47, i64 noundef %49, ptr noundef nonnull %16, ptr noundef nonnull %17, ptr noundef nonnull %18, ptr noundef nonnull %19) #4
  %.not65 = icmp eq i32 %50, 1
  br i1 %.not65, label %51, label %58

51:                                               ; preds = %45
  %52 = load ptr, ptr %42, align 8, !tbaa !16
  %53 = load ptr, ptr %16, align 8, !tbaa !9
  %54 = load i64, ptr %17, align 8, !tbaa !5
  %55 = load ptr, ptr %18, align 8, !tbaa !9
  %56 = load i64, ptr %19, align 8, !tbaa !5
  %57 = call i32 @cms_signer_infos_add_signer_info(ptr noundef nonnull %13, ptr noundef nonnull %14, i64 noundef 512, ptr noundef nonnull %15, ptr noundef %52, ptr noundef %53, i64 noundef %54, ptr noundef %55, i64 noundef %56, ptr noundef null, i64 noundef 0, ptr noundef null, i64 noundef 0)
  %.not66 = icmp eq i32 %57, 1
  br i1 %.not66, label %43, label %58

58:                                               ; preds = %45, %51
  %59 = load ptr, ptr @stderr, align 8, !tbaa !9
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1105, ptr noundef nonnull @__FUNCTION__.cms_signed_data_sign_to_der) #5
  br label %96

._crit_edge:                                      ; preds = %43, %40
  %61 = call i32 @asn1_int_to_der_ex(i32 noundef 2, i32 noundef 1, ptr noundef null, ptr noundef nonnull %21) #4
  %.not56 = icmp eq i32 %61, 1
  br i1 %.not56, label %62, label %93

62:                                               ; preds = %._crit_edge
  %63 = call i32 @cms_digest_algors_to_der(ptr noundef nonnull %10, i64 noundef 1, ptr noundef null, ptr noundef nonnull %21)
  %.not57 = icmp eq i32 %63, 1
  br i1 %.not57, label %64, label %93

64:                                               ; preds = %62
  %65 = call i32 @cms_content_info_to_der(i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef null, ptr noundef nonnull %21)
  %.not58 = icmp eq i32 %65, 1
  br i1 %.not58, label %66, label %93

66:                                               ; preds = %64
  %67 = call i32 @cms_implicit_signers_certs_to_der(i32 noundef 0, ptr noundef %0, i64 noundef %1, ptr noundef null, ptr noundef nonnull %21)
  %68 = icmp slt i32 %67, 0
  br i1 %68, label %93, label %69

69:                                               ; preds = %66
  %70 = call i32 @asn1_type_to_der(i32 noundef 161, ptr noundef %5, i64 noundef %6, ptr noundef null, ptr noundef nonnull %21) #4
  %71 = icmp slt i32 %70, 0
  br i1 %71, label %93, label %72

72:                                               ; preds = %69
  %73 = load i64, ptr %14, align 8, !tbaa !5
  %74 = call i32 @asn1_nonempty_type_to_der(i32 noundef 49, ptr noundef nonnull %13, i64 noundef %73, ptr noundef null, ptr noundef nonnull %21) #4
  %.not59 = icmp eq i32 %74, 1
  br i1 %.not59, label %75, label %93

75:                                               ; preds = %72
  %76 = load i64, ptr %21, align 8, !tbaa !5
  %77 = call i32 @asn1_header_to_der(i32 noundef 48, i64 noundef %76, ptr noundef %7, ptr noundef %8) #4
  %.not60 = icmp eq i32 %77, 1
  br i1 %.not60, label %78, label %93

78:                                               ; preds = %75
  %79 = call i32 @asn1_int_to_der_ex(i32 noundef 2, i32 noundef 1, ptr noundef %7, ptr noundef %8) #4
  %.not61 = icmp eq i32 %79, 1
  br i1 %.not61, label %80, label %93

80:                                               ; preds = %78
  %81 = call i32 @cms_digest_algors_to_der(ptr noundef nonnull %10, i64 noundef 1, ptr noundef %7, ptr noundef %8)
  %.not62 = icmp eq i32 %81, 1
  br i1 %.not62, label %82, label %93

82:                                               ; preds = %80
  %83 = call i32 @cms_content_info_to_der(i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %7, ptr noundef %8)
  %.not63 = icmp eq i32 %83, 1
  br i1 %.not63, label %84, label %93

84:                                               ; preds = %82
  %85 = call i32 @cms_implicit_signers_certs_to_der(i32 noundef 0, ptr noundef %0, i64 noundef %1, ptr noundef %7, ptr noundef %8)
  %86 = icmp slt i32 %85, 0
  br i1 %86, label %93, label %87

87:                                               ; preds = %84
  %88 = call i32 @asn1_type_to_der(i32 noundef 161, ptr noundef %5, i64 noundef %6, ptr noundef %7, ptr noundef %8) #4
  %89 = icmp slt i32 %88, 0
  br i1 %89, label %93, label %90

90:                                               ; preds = %87
  %91 = load i64, ptr %14, align 8, !tbaa !5
  %92 = call i32 @asn1_nonempty_type_to_der(i32 noundef 49, ptr noundef nonnull %13, i64 noundef %91, ptr noundef %7, ptr noundef %8) #4
  %.not64 = icmp eq i32 %92, 1
  br i1 %.not64, label %96, label %93

93:                                               ; preds = %._crit_edge, %62, %64, %66, %69, %72, %75, %78, %80, %82, %84, %87, %90
  %94 = load ptr, ptr @stderr, align 8, !tbaa !9
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1123, ptr noundef nonnull @__FUNCTION__.cms_signed_data_sign_to_der) #5
  br label %96

96:                                               ; preds = %90, %.critedge, %93, %58, %37
  %.1 = phi i32 [ -1, %58 ], [ -1, %93 ], [ -1, %37 ], [ -1, %.critedge ], [ 1, %90 ]
  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 8, ptr nonnull %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #4
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #4
  ret i32 %.1
}

declare void @sm3_init(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @cms_implicit_signers_certs_to_der(i32 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { 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 #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 }
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 = !{!"long", !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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16}
!15 = !{!14, !6, i64 8}
!16 = !{!14, !10, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass