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

@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_signed_and_enveloped_data_decipher_from_der = external hidden unnamed_addr constant [48 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

declare i32 @asn1_check(i32 noundef) #4

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

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

declare void @sm3_init(ptr noundef) #4

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @cms_signed_and_enveloped_data_decipher_from_der(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13, ptr noundef %14, ptr noundef %15, ptr noundef %16, ptr noundef %17, ptr noundef %18, ptr noundef %19, ptr noundef %20, i64 noundef %21, ptr noundef %22, i64 noundef %23, ptr noundef %24, ptr noundef %25) #2 {
  %27 = alloca i32, align 4
  %28 = alloca ptr, align 8
  %29 = alloca ptr, align 8
  %30 = alloca i64, align 8
  %31 = alloca ptr, align 8
  %32 = alloca i64, align 8
  %33 = alloca ptr, align 8
  %34 = alloca ptr, align 8
  %35 = alloca ptr, align 8
  %36 = alloca ptr, align 8
  %37 = alloca ptr, align 8
  %38 = alloca ptr, align 8
  %39 = alloca ptr, align 8
  %40 = alloca ptr, align 8
  %41 = alloca ptr, align 8
  %42 = alloca ptr, align 8
  %43 = alloca ptr, align 8
  %44 = alloca ptr, align 8
  %45 = alloca ptr, align 8
  %46 = alloca ptr, align 8
  %47 = alloca ptr, align 8
  %48 = alloca ptr, align 8
  %49 = alloca i64, align 8
  %50 = alloca ptr, align 8
  %51 = alloca i64, align 8
  %52 = alloca ptr, align 8
  %53 = alloca ptr, align 8
  %54 = alloca i32, align 4
  %55 = alloca i32, align 4
  %56 = alloca ptr, align 8
  %57 = alloca i64, align 8
  %58 = alloca [4 x i32], align 16
  %59 = alloca i64, align 8
  %60 = alloca ptr, align 8
  %61 = alloca i64, align 8
  %62 = alloca ptr, align 8
  %63 = alloca i64, align 8
  %64 = alloca i32, align 4
  %65 = alloca [32 x i8], align 16
  %66 = alloca i64, align 8
  %67 = alloca %struct.SM3_CTX, align 8
  %68 = alloca [128 x i8], align 16
  %69 = alloca i64, align 8
  %70 = alloca ptr, align 8
  %71 = alloca i32, align 4
  %72 = alloca ptr, align 8
  %73 = alloca i64, align 8
  %74 = alloca ptr, align 8
  %75 = alloca i64, align 8
  %76 = alloca ptr, align 8
  %77 = alloca i64, align 8
  %78 = alloca ptr, align 8
  %79 = alloca i64, align 8
  %80 = alloca ptr, align 8
  %81 = alloca i64, align 8
  store ptr %0, ptr %28, align 8, !tbaa !5
  store ptr %1, ptr %29, align 8, !tbaa !5
  store i64 %2, ptr %30, align 8, !tbaa !9
  store ptr %3, ptr %31, align 8, !tbaa !5
  store i64 %4, ptr %32, align 8, !tbaa !9
  store ptr %5, ptr %33, align 8, !tbaa !5
  store ptr %6, ptr %34, align 8, !tbaa !5
  store ptr %7, ptr %35, align 8, !tbaa !5
  store ptr %8, ptr %36, align 8, !tbaa !5
  store ptr %9, ptr %37, align 8, !tbaa !5
  store ptr %10, ptr %38, align 8, !tbaa !5
  store ptr %11, ptr %39, align 8, !tbaa !5
  store ptr %12, ptr %40, align 8, !tbaa !5
  store ptr %13, ptr %41, align 8, !tbaa !5
  store ptr %14, ptr %42, align 8, !tbaa !5
  store ptr %15, ptr %43, align 8, !tbaa !5
  store ptr %16, ptr %44, align 8, !tbaa !5
  store ptr %17, ptr %45, align 8, !tbaa !5
  store ptr %18, ptr %46, align 8, !tbaa !5
  store ptr %19, ptr %47, align 8, !tbaa !5
  store ptr %20, ptr %48, align 8, !tbaa !5
  store i64 %21, ptr %49, align 8, !tbaa !9
  store ptr %22, ptr %50, align 8, !tbaa !5
  store i64 %23, ptr %51, align 8, !tbaa !9
  store ptr %24, ptr %52, align 8, !tbaa !5
  store ptr %25, ptr %53, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %54) #5
  store i32 0, ptr %54, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %55) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %56) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %57) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %58) #5
  call void @llvm.memset.p0.i64(ptr align 16 %58, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %59) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %60) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %61) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %62) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %63) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %64) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %65) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %66) #5
  call void @llvm.lifetime.start.p0(i64 112, ptr %67) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr %68) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %69) #5
  store i64 0, ptr %69, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %70) #5
  %82 = getelementptr inbounds [128 x i8], ptr %68, i64 0, i64 0
  store ptr %82, ptr %70, align 8, !tbaa !5
  %83 = getelementptr inbounds [4 x i32], ptr %58, i64 0, i64 0
  %84 = load ptr, ptr %42, align 8, !tbaa !5
  %85 = load ptr, ptr %43, align 8, !tbaa !5
  %86 = load ptr, ptr %44, align 8, !tbaa !5
  %87 = load ptr, ptr %45, align 8, !tbaa !5
  %88 = load ptr, ptr %52, align 8, !tbaa !5
  %89 = load ptr, ptr %53, align 8, !tbaa !5
  %90 = call i32 @cms_signed_and_enveloped_data_from_der(ptr noundef %55, ptr noundef %56, ptr noundef %57, ptr noundef %83, ptr noundef %59, i64 noundef 4, ptr noundef %60, ptr noundef %61, ptr noundef %84, ptr noundef %85, ptr noundef %86, ptr noundef %87, ptr noundef %62, ptr noundef %63, ptr noundef %88, ptr noundef %89)
  %91 = icmp ne i32 %90, 1
  br i1 %91, label %105, label %92

92:                                               ; preds = %26
  %93 = load i32, ptr %55, align 4, !tbaa !11
  %94 = icmp eq i32 %93, 1
  %95 = zext i1 %94 to i32
  %96 = call i32 @asn1_check(i32 noundef %95)
  %97 = icmp ne i32 %96, 1
  br i1 %97, label %105, label %98

98:                                               ; preds = %92
  %99 = getelementptr inbounds [4 x i32], ptr %58, i64 0, i64 0
  %100 = load i32, ptr %99, align 16, !tbaa !11
  %101 = icmp eq i32 %100, 13
  %102 = zext i1 %101 to i32
  %103 = call i32 @asn1_check(i32 noundef %102)
  %104 = icmp ne i32 %103, 1
  br i1 %104, label %105, label %111

105:                                              ; preds = %98, %92, %26
  br label %106

106:                                              ; preds = %105
  %107 = load ptr, ptr @stderr, align 8, !tbaa !5
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1889, ptr noundef @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #5
  br label %109

109:                                              ; preds = %106
  br label %110

110:                                              ; preds = %109
  store i32 -1, ptr %27, align 4
  store i32 1, ptr %71, align 4
  br label %211

111:                                              ; preds = %98
  %112 = load ptr, ptr %56, align 8, !tbaa !5
  %113 = load ptr, ptr %36, align 8, !tbaa !5
  store ptr %112, ptr %113, align 8, !tbaa !5
  %114 = load i64, ptr %57, align 8, !tbaa !9
  %115 = load ptr, ptr %37, align 8, !tbaa !5
  store i64 %114, ptr %115, align 8, !tbaa !9
  %116 = load ptr, ptr %62, align 8, !tbaa !5
  %117 = load ptr, ptr %46, align 8, !tbaa !5
  store ptr %116, ptr %117, align 8, !tbaa !5
  %118 = load i64, ptr %63, align 8, !tbaa !9
  %119 = load ptr, ptr %47, align 8, !tbaa !5
  store i64 %118, ptr %119, align 8, !tbaa !9
  br label %120

120:                                              ; preds = %143, %111
  %121 = load i64, ptr %57, align 8, !tbaa !9
  %122 = icmp ne i64 %121, 0
  br i1 %122, label %123, label %144

123:                                              ; preds = %120
  %124 = load ptr, ptr %28, align 8, !tbaa !5
  %125 = load ptr, ptr %29, align 8, !tbaa !5
  %126 = load i64, ptr %30, align 8, !tbaa !9
  %127 = load ptr, ptr %31, align 8, !tbaa !5
  %128 = load i64, ptr %32, align 8, !tbaa !9
  %129 = getelementptr inbounds [32 x i8], ptr %65, i64 0, i64 0
  %130 = call i32 @cms_recipient_info_decrypt_from_der(ptr noundef %124, ptr noundef %125, i64 noundef %126, ptr noundef %127, i64 noundef %128, ptr noundef %129, ptr noundef %66, i64 noundef 32, ptr noundef %56, ptr noundef %57)
  store i32 %130, ptr %54, align 4, !tbaa !11
  %131 = icmp slt i32 %130, 0
  br i1 %131, label %132, label %138

132:                                              ; preds = %123
  br label %133

133:                                              ; preds = %132
  %134 = load ptr, ptr @stderr, align 8, !tbaa !5
  %135 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %134, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1904, ptr noundef @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #5
  br label %136

136:                                              ; preds = %133
  br label %137

137:                                              ; preds = %136
  store i32 -1, ptr %27, align 4
  store i32 1, ptr %71, align 4
  br label %211

138:                                              ; preds = %123
  %139 = load i32, ptr %54, align 4, !tbaa !11
  %140 = icmp ne i32 %139, 0
  br i1 %140, label %141, label %142

141:                                              ; preds = %138
  br label %144

142:                                              ; preds = %138
  br label %143

143:                                              ; preds = %142
  br label %120, !llvm.loop !13

144:                                              ; preds = %141, %120
  %145 = load i32, ptr %54, align 4, !tbaa !11
  %146 = icmp ne i32 %145, 0
  br i1 %146, label %153, label %147

147:                                              ; preds = %144
  br label %148

148:                                              ; preds = %147
  %149 = load ptr, ptr @stderr, align 8, !tbaa !5
  %150 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %149, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1911, ptr noundef @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #5
  br label %151

151:                                              ; preds = %148
  br label %152

152:                                              ; preds = %151
  store i32 -1, ptr %27, align 4
  store i32 1, ptr %71, align 4
  br label %211

153:                                              ; preds = %144
  %154 = getelementptr inbounds [32 x i8], ptr %65, i64 0, i64 0
  %155 = load i64, ptr %66, align 8, !tbaa !9
  %156 = load ptr, ptr %33, align 8, !tbaa !5
  %157 = load ptr, ptr %34, align 8, !tbaa !5
  %158 = load ptr, ptr %35, align 8, !tbaa !5
  %159 = load ptr, ptr %38, align 8, !tbaa !5
  %160 = load ptr, ptr %39, align 8, !tbaa !5
  %161 = load ptr, ptr %40, align 8, !tbaa !5
  %162 = load ptr, ptr %41, align 8, !tbaa !5
  %163 = call i32 @cms_enced_content_info_decrypt_from_der(ptr noundef %64, ptr noundef %154, i64 noundef %155, ptr noundef %156, ptr noundef %157, ptr noundef %158, ptr noundef %159, ptr noundef %160, ptr noundef %161, ptr noundef %162, ptr noundef %60, ptr noundef %61)
  %164 = icmp ne i32 %163, 1
  br i1 %164, label %165, label %171

165:                                              ; preds = %153
  br label %166

166:                                              ; preds = %165
  %167 = load ptr, ptr @stderr, align 8, !tbaa !5
  %168 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %167, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1921, ptr noundef @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #5
  br label %169

169:                                              ; preds = %166
  br label %170

170:                                              ; preds = %169
  store i32 -1, ptr %27, align 4
  store i32 1, ptr %71, align 4
  br label %211

171:                                              ; preds = %153
  %172 = load ptr, ptr %33, align 8, !tbaa !5
  %173 = load i32, ptr %172, align 4, !tbaa !11
  %174 = load ptr, ptr %35, align 8, !tbaa !5
  %175 = load i64, ptr %174, align 8, !tbaa !9
  %176 = call i32 @cms_content_info_header_to_der(i32 noundef %173, i64 noundef %175, ptr noundef %70, ptr noundef %69)
  %177 = icmp ne i32 %176, 1
  br i1 %177, label %178, label %184

178:                                              ; preds = %171
  br label %179

179:                                              ; preds = %178
  %180 = load ptr, ptr @stderr, align 8, !tbaa !5
  %181 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %180, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1927, ptr noundef @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #5
  br label %182

182:                                              ; preds = %179
  br label %183

183:                                              ; preds = %182
  store i32 -1, ptr %27, align 4
  store i32 1, ptr %71, align 4
  br label %211

184:                                              ; preds = %171
  call void @sm3_init(ptr noundef %67)
  %185 = getelementptr inbounds [128 x i8], ptr %68, i64 0, i64 0
  %186 = load i64, ptr %69, align 8, !tbaa !9
  call void @sm3_update(ptr noundef %67, ptr noundef %185, i64 noundef %186)
  %187 = load ptr, ptr %34, align 8, !tbaa !5
  %188 = load ptr, ptr %35, align 8, !tbaa !5
  %189 = load i64, ptr %188, align 8, !tbaa !9
  call void @sm3_update(ptr noundef %67, ptr noundef %187, i64 noundef %189)
  br label %190

190:                                              ; preds = %209, %184
  %191 = load i64, ptr %63, align 8, !tbaa !9
  %192 = icmp ne i64 %191, 0
  br i1 %192, label %193, label %210

193:                                              ; preds = %190
  call void @llvm.lifetime.start.p0(i64 8, ptr %72) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %73) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %74) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %75) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %76) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %77) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %78) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %79) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %80) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %81) #5
  %194 = load ptr, ptr %42, align 8, !tbaa !5
  %195 = load ptr, ptr %194, align 8, !tbaa !5
  %196 = load ptr, ptr %43, align 8, !tbaa !5
  %197 = load i64, ptr %196, align 8, !tbaa !9
  %198 = call i32 @cms_signer_info_verify_from_der(ptr noundef %67, ptr noundef %195, i64 noundef %197, ptr noundef %72, ptr noundef %73, ptr noundef %74, ptr noundef %75, ptr noundef %76, ptr noundef %77, ptr noundef %78, ptr noundef %79, ptr noundef %80, ptr noundef %81, ptr noundef %62, ptr noundef %63)
  %199 = icmp ne i32 %198, 1
  br i1 %199, label %200, label %206

200:                                              ; preds = %193
  br label %201

201:                                              ; preds = %200
  %202 = load ptr, ptr @stderr, align 8, !tbaa !5
  %203 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %202, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1954, ptr noundef @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #5
  br label %204

204:                                              ; preds = %201
  br label %205

205:                                              ; preds = %204
  store i32 -1, ptr %27, align 4
  store i32 1, ptr %71, align 4
  br label %207

206:                                              ; preds = %193
  store i32 0, ptr %71, align 4
  br label %207

207:                                              ; preds = %206, %205
  call void @llvm.lifetime.end.p0(i64 8, ptr %81) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %80) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %79) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %78) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %77) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %76) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %75) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %74) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %73) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %72) #5
  %208 = load i32, ptr %71, align 4
  switch i32 %208, label %211 [
    i32 0, label %209
  ]

209:                                              ; preds = %207
  br label %190, !llvm.loop !15

210:                                              ; preds = %190
  store i32 1, ptr %27, align 4
  store i32 1, ptr %71, align 4
  br label %211

211:                                              ; preds = %210, %207, %183, %170, %152, %137, %110
  call void @llvm.lifetime.end.p0(i64 8, ptr %70) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %69) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr %68) #5
  call void @llvm.lifetime.end.p0(i64 112, ptr %67) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %66) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %65) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %64) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %63) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %62) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %61) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %60) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %59) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %58) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %57) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %56) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %55) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %54) #5
  %212 = load i32, ptr %27, align 4
  ret i32 %212
}

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 #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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@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_signed_and_enveloped_data_decipher_from_der = external hidden unnamed_addr constant [48 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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

declare i32 @asn1_check(i32 noundef) local_unnamed_addr #4

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

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

declare void @sm3_init(ptr noundef) local_unnamed_addr #4

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cms_signed_and_enveloped_data_decipher_from_der(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr nocapture noundef writeonly %8, ptr nocapture noundef writeonly %9, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13, ptr noundef %14, ptr noundef %15, ptr noundef %16, ptr noundef %17, ptr nocapture noundef writeonly %18, ptr nocapture noundef writeonly %19, ptr nocapture noundef readnone %20, i64 noundef %21, ptr nocapture noundef readnone %22, i64 noundef %23, ptr noundef %24, ptr noundef %25) local_unnamed_addr #2 {
  %27 = alloca i32, align 4
  %28 = alloca ptr, align 8
  %29 = alloca i64, align 8
  %30 = alloca [4 x i32], align 16
  %31 = alloca i64, align 8
  %32 = alloca ptr, align 8
  %33 = alloca i64, align 8
  %34 = alloca ptr, align 8
  %35 = alloca i64, align 8
  %36 = alloca i32, align 4
  %37 = alloca [32 x i8], align 16
  %38 = alloca i64, align 8
  %39 = alloca %struct.SM3_CTX, align 8
  %40 = alloca [128 x i8], align 16
  %41 = alloca i64, align 8
  %42 = alloca ptr, align 8
  %43 = alloca ptr, align 8
  %44 = alloca i64, align 8
  %45 = alloca ptr, align 8
  %46 = alloca i64, align 8
  %47 = alloca ptr, align 8
  %48 = alloca i64, align 8
  %49 = alloca ptr, align 8
  %50 = alloca i64, align 8
  %51 = alloca ptr, align 8
  %52 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %27) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %28) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %29) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %30) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %30, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %31) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %32) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %33) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %34) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %35) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %36) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %37) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %38) #5
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %39) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %40) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %41) #5
  store i64 0, ptr %41, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %42) #5
  store ptr %40, ptr %42, align 8, !tbaa !9
  %53 = call i32 @cms_signed_and_enveloped_data_from_der(ptr noundef nonnull %27, ptr noundef nonnull %28, ptr noundef nonnull %29, ptr noundef nonnull %30, ptr noundef nonnull %31, i64 noundef 4, ptr noundef nonnull %32, ptr noundef nonnull %33, ptr noundef %14, ptr noundef %15, ptr noundef %16, ptr noundef %17, ptr noundef nonnull %34, ptr noundef nonnull %35, ptr noundef %24, ptr noundef %25)
  %.not = icmp eq i32 %53, 1
  br i1 %.not, label %54, label %64

54:                                               ; preds = %26
  %55 = load i32, ptr %27, align 4, !tbaa !11
  %56 = icmp eq i32 %55, 1
  %57 = zext i1 %56 to i32
  %58 = call i32 @asn1_check(i32 noundef %57) #5
  %.not35 = icmp eq i32 %58, 1
  br i1 %.not35, label %59, label %64

59:                                               ; preds = %54
  %60 = load i32, ptr %30, align 16, !tbaa !11
  %61 = icmp eq i32 %60, 13
  %62 = zext i1 %61 to i32
  %63 = call i32 @asn1_check(i32 noundef %62) #5
  %.not36 = icmp eq i32 %63, 1
  br i1 %.not36, label %67, label %64

64:                                               ; preds = %26, %54, %59
  %65 = load ptr, ptr @stderr, align 8, !tbaa !9
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1889, ptr noundef nonnull @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #6
  br label %.loopexit

67:                                               ; preds = %59
  %68 = load ptr, ptr %28, align 8, !tbaa !9
  store ptr %68, ptr %8, align 8, !tbaa !9
  %69 = load i64, ptr %29, align 8, !tbaa !5
  store i64 %69, ptr %9, align 8, !tbaa !5
  %70 = load ptr, ptr %34, align 8, !tbaa !9
  store ptr %70, ptr %18, align 8, !tbaa !9
  %71 = load i64, ptr %35, align 8, !tbaa !5
  store i64 %71, ptr %19, align 8, !tbaa !5
  %.old1.not = icmp eq i64 %69, 0
  br i1 %.old1.not, label %.thread, label %.preheader

.preheader:                                       ; preds = %67, %77
  %72 = call i32 @cms_recipient_info_decrypt_from_der(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef nonnull %37, ptr noundef nonnull %38, i64 noundef 32, ptr noundef nonnull %28, ptr noundef nonnull %29)
  %73 = icmp slt i32 %72, 0
  br i1 %73, label %74, label %77

74:                                               ; preds = %.preheader
  %75 = load ptr, ptr @stderr, align 8, !tbaa !9
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1904, ptr noundef nonnull @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #6
  br label %.loopexit

77:                                               ; preds = %.preheader
  %78 = icmp eq i32 %72, 0
  %79 = load i64, ptr %29, align 8
  %80 = icmp ne i64 %79, 0
  %or.cond = select i1 %78, i1 %80, i1 false
  br i1 %or.cond, label %.preheader, label %81, !llvm.loop !13

81:                                               ; preds = %77
  br i1 %78, label %.thread, label %84

.thread:                                          ; preds = %67, %81
  %82 = load ptr, ptr @stderr, align 8, !tbaa !9
  %83 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1911, ptr noundef nonnull @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #6
  br label %.loopexit

84:                                               ; preds = %81
  %85 = load i64, ptr %38, align 8, !tbaa !5
  %86 = call i32 @cms_enced_content_info_decrypt_from_der(ptr noundef nonnull %36, ptr noundef nonnull %37, i64 noundef %85, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13, ptr noundef nonnull %32, ptr noundef nonnull %33)
  %.not38 = icmp eq i32 %86, 1
  br i1 %.not38, label %90, label %87

87:                                               ; preds = %84
  %88 = load ptr, ptr @stderr, align 8, !tbaa !9
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1921, ptr noundef nonnull @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #6
  br label %.loopexit

90:                                               ; preds = %84
  %91 = load i32, ptr %5, align 4, !tbaa !11
  %92 = load i64, ptr %7, align 8, !tbaa !5
  %93 = call i32 @cms_content_info_header_to_der(i32 noundef %91, i64 noundef %92, ptr noundef nonnull %42, ptr noundef nonnull %41)
  %.not39 = icmp eq i32 %93, 1
  br i1 %.not39, label %97, label %94

94:                                               ; preds = %90
  %95 = load ptr, ptr @stderr, align 8, !tbaa !9
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1927, ptr noundef nonnull @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #6
  br label %.loopexit

97:                                               ; preds = %90
  call void @sm3_init(ptr noundef nonnull %39) #5
  %98 = load i64, ptr %41, align 8, !tbaa !5
  call void @sm3_update(ptr noundef nonnull %39, ptr noundef nonnull %40, i64 noundef %98) #5
  %99 = load i64, ptr %7, align 8, !tbaa !5
  call void @sm3_update(ptr noundef nonnull %39, ptr noundef %6, i64 noundef %99) #5
  %100 = load i64, ptr %35, align 8, !tbaa !5
  %.not4045 = icmp eq i64 %100, 0
  br i1 %.not4045, label %.loopexit, label %.lr.ph

.critedge:                                        ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %52) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %51) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %50) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %49) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %48) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %47) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %46) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %45) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %44) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %43) #5
  %101 = load i64, ptr %35, align 8, !tbaa !5
  %.not40 = icmp eq i64 %101, 0
  br i1 %.not40, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %97, %.critedge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %43) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %44) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %45) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %46) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %47) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %48) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %49) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %50) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %51) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %52) #5
  %102 = load ptr, ptr %14, align 8, !tbaa !9
  %103 = load i64, ptr %15, align 8, !tbaa !5
  %104 = call i32 @cms_signer_info_verify_from_der(ptr noundef nonnull %39, ptr noundef %102, i64 noundef %103, ptr noundef nonnull %43, ptr noundef nonnull %44, ptr noundef nonnull %45, ptr noundef nonnull %46, ptr noundef nonnull %47, ptr noundef nonnull %48, ptr noundef nonnull %49, ptr noundef nonnull %50, ptr noundef nonnull %51, ptr noundef nonnull %52, ptr noundef nonnull %34, ptr noundef nonnull %35)
  %.not41 = icmp eq i32 %104, 1
  br i1 %.not41, label %.critedge, label %105

105:                                              ; preds = %.lr.ph
  %106 = load ptr, ptr @stderr, align 8, !tbaa !9
  %107 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %106, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1954, ptr noundef nonnull @__FUNCTION__.cms_signed_and_enveloped_data_decipher_from_der) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %52) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %51) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %50) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %49) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %48) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %47) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %46) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %45) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %44) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %43) #5
  br label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %.critedge, %97, %105, %94, %87, %.thread, %74, %64
  %.2 = phi i32 [ -1, %64 ], [ -1, %74 ], [ -1, %87 ], [ -1, %94 ], [ -1, %105 ], [ -1, %.thread ], [ 1, %97 ], [ 1, %.critedge ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %42) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %41) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %40) #5
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %39) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %38) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %37) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %36) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %35) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %34) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %33) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %32) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %31) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %30) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %29) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %28) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %27) #5
  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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 #5 = { nounwind }
attributes #6 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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