; LLVM IR from guanzhi/GmSSL :: tools (sm9keygen)

; 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.SM9_SIGN_MASTER_KEY = type { %struct.SM9_Z256_TWIST_POINT, [4 x i64] }
%struct.SM9_Z256_TWIST_POINT = type { [2 x [4 x i64]], [2 x [4 x i64]], [2 x [4 x i64]] }
%struct.SM9_ENC_MASTER_KEY = type { %struct.SM9_Z256_POINT, [4 x i64] }
%struct.SM9_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }
%struct.SM9_SIGN_KEY = type { %struct.SM9_Z256_TWIST_POINT, %struct.SM9_Z256_POINT }
%struct.SM9_ENC_KEY = type { %struct.SM9_Z256_POINT, %struct.SM9_Z256_TWIST_POINT }

@stdin = external global ptr, align 8
@stdout = external global ptr, align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@options = external hidden global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [65 x i8], align 1
@__FUNCTION__.sm9keygen_main = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @sm9keygen_main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca %struct.SM9_SIGN_MASTER_KEY, align 8
  %18 = alloca %struct.SM9_ENC_MASTER_KEY, align 8
  %19 = alloca %struct.SM9_SIGN_KEY, align 8
  %20 = alloca %struct.SM9_ENC_KEY, align 8
  %21 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 -1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = getelementptr inbounds ptr, ptr %22, i64 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  store ptr %24, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store ptr null, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store ptr null, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store ptr null, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store ptr null, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store ptr null, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %25 = load ptr, ptr @stdin, align 8, !tbaa !9
  store ptr %25, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %26 = load ptr, ptr @stdout, align 8, !tbaa !9
  store ptr %26, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 224, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 288, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 288, ptr %20) #5
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = add nsw i32 %27, -1
  store i32 %28, ptr %4, align 4, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = getelementptr inbounds ptr, ptr %29, i32 1
  store ptr %30, ptr %5, align 8, !tbaa !9
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = icmp slt i32 %31, 1
  br i1 %32, label %33, label %38

33:                                               ; preds = %2
  %34 = load ptr, ptr @stderr, align 8, !tbaa !9
  %35 = load ptr, ptr %7, align 8, !tbaa !9
  %36 = load ptr, ptr @options, align 8, !tbaa !9
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str, ptr noundef %35, ptr noundef %36) #5
  store i32 1, ptr %3, align 4
  store i32 1, ptr %21, align 4
  br label %276

38:                                               ; preds = %2
  br label %39

39:                                               ; preds = %178, %38
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %42, label %183

42:                                               ; preds = %39
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = call i32 @strcmp(ptr noundef %44, ptr noundef @.str.1) #6
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %52, label %47

47:                                               ; preds = %42
  %48 = load ptr, ptr @stdout, align 8, !tbaa !9
  %49 = load ptr, ptr %7, align 8, !tbaa !9
  %50 = load ptr, ptr @options, align 8, !tbaa !9
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str, ptr noundef %49, ptr noundef %50) #5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %21, align 4
  br label %276

52:                                               ; preds = %42
  %53 = load ptr, ptr %5, align 8, !tbaa !9
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = call i32 @strcmp(ptr noundef %54, ptr noundef @.str.2) #6
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %75, label %57

57:                                               ; preds = %52
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = add nsw i32 %58, -1
  store i32 %59, ptr %4, align 4, !tbaa !5
  %60 = icmp slt i32 %59, 1
  br i1 %60, label %61, label %62

61:                                               ; preds = %57
  br label %166

62:                                               ; preds = %57
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = getelementptr inbounds ptr, ptr %63, i32 1
  store ptr %64, ptr %5, align 8, !tbaa !9
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  store ptr %65, ptr %8, align 8, !tbaa !9
  %66 = load ptr, ptr %8, align 8, !tbaa !9
  %67 = call i32 @sm9_oid_from_name(ptr noundef %66)
  store i32 %67, ptr %14, align 4, !tbaa !5
  %68 = icmp slt i32 %67, 1
  br i1 %68, label %69, label %74

69:                                               ; preds = %62
  %70 = load ptr, ptr @stdout, align 8, !tbaa !9
  %71 = load ptr, ptr %7, align 8, !tbaa !9
  %72 = load ptr, ptr %8, align 8, !tbaa !9
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef @.str.3, ptr noundef %71, ptr noundef %72) #5
  br label %257

74:                                               ; preds = %62
  br label %177

75:                                               ; preds = %52
  %76 = load ptr, ptr %5, align 8, !tbaa !9
  %77 = load ptr, ptr %76, align 8, !tbaa !9
  %78 = call i32 @strcmp(ptr noundef %77, ptr noundef @.str.4) #6
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %99, label %80

80:                                               ; preds = %75
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = add nsw i32 %81, -1
  store i32 %82, ptr %4, align 4, !tbaa !5
  %83 = icmp slt i32 %82, 1
  br i1 %83, label %84, label %85

84:                                               ; preds = %80
  br label %166

85:                                               ; preds = %80
  %86 = load ptr, ptr %5, align 8, !tbaa !9
  %87 = getelementptr inbounds ptr, ptr %86, i32 1
  store ptr %87, ptr %5, align 8, !tbaa !9
  %88 = load ptr, ptr %87, align 8, !tbaa !9
  store ptr %88, ptr %9, align 8, !tbaa !9
  %89 = load ptr, ptr %9, align 8, !tbaa !9
  %90 = call noalias ptr @fopen(ptr noundef %89, ptr noundef @.str.5)
  store ptr %90, ptr %15, align 8, !tbaa !9
  %91 = icmp ne ptr %90, null
  br i1 %91, label %98, label %92

92:                                               ; preds = %85
  br label %93

93:                                               ; preds = %92
  %94 = load ptr, ptr @stderr, align 8, !tbaa !9
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef @.str.6, ptr noundef @.str.7, i32 noundef 80, ptr noundef @__FUNCTION__.sm9keygen_main) #5
  br label %96

96:                                               ; preds = %93
  br label %97

97:                                               ; preds = %96
  br label %257

98:                                               ; preds = %85
  br label %176

99:                                               ; preds = %75
  %100 = load ptr, ptr %5, align 8, !tbaa !9
  %101 = load ptr, ptr %100, align 8, !tbaa !9
  %102 = call i32 @strcmp(ptr noundef %101, ptr noundef @.str.8) #6
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %113, label %104

104:                                              ; preds = %99
  %105 = load i32, ptr %4, align 4, !tbaa !5
  %106 = add nsw i32 %105, -1
  store i32 %106, ptr %4, align 4, !tbaa !5
  %107 = icmp slt i32 %106, 1
  br i1 %107, label %108, label %109

108:                                              ; preds = %104
  br label %166

109:                                              ; preds = %104
  %110 = load ptr, ptr %5, align 8, !tbaa !9
  %111 = getelementptr inbounds ptr, ptr %110, i32 1
  store ptr %111, ptr %5, align 8, !tbaa !9
  %112 = load ptr, ptr %111, align 8, !tbaa !9
  store ptr %112, ptr %10, align 8, !tbaa !9
  br label %175

113:                                              ; preds = %99
  %114 = load ptr, ptr %5, align 8, !tbaa !9
  %115 = load ptr, ptr %114, align 8, !tbaa !9
  %116 = call i32 @strcmp(ptr noundef %115, ptr noundef @.str.9) #6
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %127, label %118

118:                                              ; preds = %113
  %119 = load i32, ptr %4, align 4, !tbaa !5
  %120 = add nsw i32 %119, -1
  store i32 %120, ptr %4, align 4, !tbaa !5
  %121 = icmp slt i32 %120, 1
  br i1 %121, label %122, label %123

122:                                              ; preds = %118
  br label %166

123:                                              ; preds = %118
  %124 = load ptr, ptr %5, align 8, !tbaa !9
  %125 = getelementptr inbounds ptr, ptr %124, i32 1
  store ptr %125, ptr %5, align 8, !tbaa !9
  %126 = load ptr, ptr %125, align 8, !tbaa !9
  store ptr %126, ptr %11, align 8, !tbaa !9
  br label %174

127:                                              ; preds = %113
  %128 = load ptr, ptr %5, align 8, !tbaa !9
  %129 = load ptr, ptr %128, align 8, !tbaa !9
  %130 = call i32 @strcmp(ptr noundef %129, ptr noundef @.str.10) #6
  %131 = icmp ne i32 %130, 0
  br i1 %131, label %151, label %132

132:                                              ; preds = %127
  %133 = load i32, ptr %4, align 4, !tbaa !5
  %134 = add nsw i32 %133, -1
  store i32 %134, ptr %4, align 4, !tbaa !5
  %135 = icmp slt i32 %134, 1
  br i1 %135, label %136, label %137

136:                                              ; preds = %132
  br label %166

137:                                              ; preds = %132
  %138 = load ptr, ptr %5, align 8, !tbaa !9
  %139 = getelementptr inbounds ptr, ptr %138, i32 1
  store ptr %139, ptr %5, align 8, !tbaa !9
  %140 = load ptr, ptr %139, align 8, !tbaa !9
  store ptr %140, ptr %12, align 8, !tbaa !9
  %141 = load ptr, ptr %12, align 8, !tbaa !9
  %142 = call noalias ptr @fopen(ptr noundef %141, ptr noundef @.str.11)
  store ptr %142, ptr %16, align 8, !tbaa !9
  %143 = icmp ne ptr %142, null
  br i1 %143, label %150, label %144

144:                                              ; preds = %137
  br label %145

145:                                              ; preds = %144
  %146 = load ptr, ptr @stderr, align 8, !tbaa !9
  %147 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %146, ptr noundef @.str.6, ptr noundef @.str.7, i32 noundef 93, ptr noundef @__FUNCTION__.sm9keygen_main) #5
  br label %148

148:                                              ; preds = %145
  br label %149

149:                                              ; preds = %148
  br label %257

150:                                              ; preds = %137
  br label %173

151:                                              ; preds = %127
  %152 = load ptr, ptr %5, align 8, !tbaa !9
  %153 = load ptr, ptr %152, align 8, !tbaa !9
  %154 = call i32 @strcmp(ptr noundef %153, ptr noundef @.str.12) #6
  %155 = icmp ne i32 %154, 0
  br i1 %155, label %165, label %156

156:                                              ; preds = %151
  %157 = load i32, ptr %4, align 4, !tbaa !5
  %158 = add nsw i32 %157, -1
  store i32 %158, ptr %4, align 4, !tbaa !5
  %159 = icmp slt i32 %158, 1
  br i1 %159, label %160, label %161

160:                                              ; preds = %156
  br label %166

161:                                              ; preds = %156
  %162 = load ptr, ptr %5, align 8, !tbaa !9
  %163 = getelementptr inbounds ptr, ptr %162, i32 1
  store ptr %163, ptr %5, align 8, !tbaa !9
  %164 = load ptr, ptr %163, align 8, !tbaa !9
  store ptr %164, ptr %13, align 8, !tbaa !9
  br label %172

165:                                              ; preds = %151
  br label %166

166:                                              ; preds = %165, %160, %136, %122, %108, %84, %61
  %167 = load ptr, ptr @stderr, align 8, !tbaa !9
  %168 = load ptr, ptr %7, align 8, !tbaa !9
  %169 = load ptr, ptr %5, align 8, !tbaa !9
  %170 = load ptr, ptr %169, align 8, !tbaa !9
  %171 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %167, ptr noundef @.str.13, ptr noundef %168, ptr noundef %170) #5
  store i32 1, ptr %3, align 4
  store i32 1, ptr %21, align 4
  br label %276

172:                                              ; preds = %161
  br label %173

173:                                              ; preds = %172, %150
  br label %174

174:                                              ; preds = %173, %123
  br label %175

175:                                              ; preds = %174, %109
  br label %176

176:                                              ; preds = %175, %98
  br label %177

177:                                              ; preds = %176, %74
  br label %178

178:                                              ; preds = %177
  %179 = load i32, ptr %4, align 4, !tbaa !5
  %180 = add nsw i32 %179, -1
  store i32 %180, ptr %4, align 4, !tbaa !5
  %181 = load ptr, ptr %5, align 8, !tbaa !9
  %182 = getelementptr inbounds ptr, ptr %181, i32 1
  store ptr %182, ptr %5, align 8, !tbaa !9
  br label %39, !llvm.loop !11

183:                                              ; preds = %39
  %184 = load ptr, ptr %11, align 8, !tbaa !9
  %185 = icmp ne ptr %184, null
  br i1 %185, label %190, label %186

186:                                              ; preds = %183
  %187 = load ptr, ptr @stderr, align 8, !tbaa !9
  %188 = load ptr, ptr %7, align 8, !tbaa !9
  %189 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %187, ptr noundef @.str.14, ptr noundef %188) #5
  br label %257

190:                                              ; preds = %183
  %191 = load ptr, ptr %10, align 8, !tbaa !9
  %192 = icmp ne ptr %191, null
  br i1 %192, label %193, label %196

193:                                              ; preds = %190
  %194 = load ptr, ptr %13, align 8, !tbaa !9
  %195 = icmp ne ptr %194, null
  br i1 %195, label %202, label %196

196:                                              ; preds = %193, %190
  br label %197

197:                                              ; preds = %196
  %198 = load ptr, ptr @stderr, align 8, !tbaa !9
  %199 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %198, ptr noundef @.str.6, ptr noundef @.str.7, i32 noundef 115, ptr noundef @__FUNCTION__.sm9keygen_main) #5
  br label %200

200:                                              ; preds = %197
  br label %201

201:                                              ; preds = %200
  br label %257

202:                                              ; preds = %193
  %203 = load i32, ptr %14, align 4, !tbaa !5
  switch i32 %203, label %250 [
    i32 10, label %204
    i32 12, label %227
  ]

204:                                              ; preds = %202
  %205 = load ptr, ptr %10, align 8, !tbaa !9
  %206 = load ptr, ptr %15, align 8, !tbaa !9
  %207 = call i32 @sm9_sign_master_key_info_decrypt_from_pem(ptr noundef %17, ptr noundef %205, ptr noundef %206)
  %208 = icmp ne i32 %207, 1
  br i1 %208, label %220, label %209

209:                                              ; preds = %204
  %210 = load ptr, ptr %11, align 8, !tbaa !9
  %211 = load ptr, ptr %11, align 8, !tbaa !9
  %212 = call i64 @strlen(ptr noundef %211) #6
  %213 = call i32 @sm9_sign_master_key_extract_key(ptr noundef %17, ptr noundef %210, i64 noundef %212, ptr noundef %19)
  %214 = icmp ne i32 %213, 1
  br i1 %214, label %220, label %215

215:                                              ; preds = %209
  %216 = load ptr, ptr %13, align 8, !tbaa !9
  %217 = load ptr, ptr %16, align 8, !tbaa !9
  %218 = call i32 @sm9_sign_key_info_encrypt_to_pem(ptr noundef %19, ptr noundef %216, ptr noundef %217)
  %219 = icmp ne i32 %218, 1
  br i1 %219, label %220, label %226

220:                                              ; preds = %215, %209, %204
  br label %221

221:                                              ; preds = %220
  %222 = load ptr, ptr @stderr, align 8, !tbaa !9
  %223 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %222, ptr noundef @.str.6, ptr noundef @.str.7, i32 noundef 124, ptr noundef @__FUNCTION__.sm9keygen_main) #5
  br label %224

224:                                              ; preds = %221
  br label %225

225:                                              ; preds = %224
  br label %257

226:                                              ; preds = %215
  br label %256

227:                                              ; preds = %202
  %228 = load ptr, ptr %10, align 8, !tbaa !9
  %229 = load ptr, ptr %15, align 8, !tbaa !9
  %230 = call i32 @sm9_enc_master_key_info_decrypt_from_pem(ptr noundef %18, ptr noundef %228, ptr noundef %229)
  %231 = icmp ne i32 %230, 1
  br i1 %231, label %243, label %232

232:                                              ; preds = %227
  %233 = load ptr, ptr %11, align 8, !tbaa !9
  %234 = load ptr, ptr %11, align 8, !tbaa !9
  %235 = call i64 @strlen(ptr noundef %234) #6
  %236 = call i32 @sm9_enc_master_key_extract_key(ptr noundef %18, ptr noundef %233, i64 noundef %235, ptr noundef %20)
  %237 = icmp ne i32 %236, 1
  br i1 %237, label %243, label %238

238:                                              ; preds = %232
  %239 = load ptr, ptr %13, align 8, !tbaa !9
  %240 = load ptr, ptr %16, align 8, !tbaa !9
  %241 = call i32 @sm9_enc_key_info_encrypt_to_pem(ptr noundef %20, ptr noundef %239, ptr noundef %240)
  %242 = icmp ne i32 %241, 1
  br i1 %242, label %243, label %249

243:                                              ; preds = %238, %232, %227
  br label %244

244:                                              ; preds = %243
  %245 = load ptr, ptr @stderr, align 8, !tbaa !9
  %246 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %245, ptr noundef @.str.6, ptr noundef @.str.7, i32 noundef 132, ptr noundef @__FUNCTION__.sm9keygen_main) #5
  br label %247

247:                                              ; preds = %244
  br label %248

248:                                              ; preds = %247
  br label %257

249:                                              ; preds = %238
  br label %256

250:                                              ; preds = %202
  br label %251

251:                                              ; preds = %250
  %252 = load ptr, ptr @stderr, align 8, !tbaa !9
  %253 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %252, ptr noundef @.str.6, ptr noundef @.str.7, i32 noundef 137, ptr noundef @__FUNCTION__.sm9keygen_main) #5
  br label %254

254:                                              ; preds = %251
  br label %255

255:                                              ; preds = %254
  br label %257

256:                                              ; preds = %249, %226
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %257

257:                                              ; preds = %256, %255, %248, %225, %201, %186, %149, %97, %69
  call void @gmssl_secure_clear(ptr noundef %17, i64 noundef 224)
  call void @gmssl_secure_clear(ptr noundef %18, i64 noundef 128)
  call void @gmssl_secure_clear(ptr noundef %19, i64 noundef 288)
  call void @gmssl_secure_clear(ptr noundef %20, i64 noundef 288)
  %258 = load ptr, ptr %9, align 8, !tbaa !9
  %259 = icmp ne ptr %258, null
  br i1 %259, label %260, label %266

260:                                              ; preds = %257
  %261 = load ptr, ptr %15, align 8, !tbaa !9
  %262 = icmp ne ptr %261, null
  br i1 %262, label %263, label %266

263:                                              ; preds = %260
  %264 = load ptr, ptr %15, align 8, !tbaa !9
  %265 = call i32 @fclose(ptr noundef %264)
  br label %266

266:                                              ; preds = %263, %260, %257
  %267 = load ptr, ptr %12, align 8, !tbaa !9
  %268 = icmp ne ptr %267, null
  br i1 %268, label %269, label %275

269:                                              ; preds = %266
  %270 = load ptr, ptr %16, align 8, !tbaa !9
  %271 = icmp ne ptr %270, null
  br i1 %271, label %272, label %275

272:                                              ; preds = %269
  %273 = load ptr, ptr %16, align 8, !tbaa !9
  %274 = call i32 @fclose(ptr noundef %273)
  br label %275

275:                                              ; preds = %272, %269, %266
  store i32 1, ptr %3, align 4
  store i32 1, ptr %21, align 4
  br label %276

276:                                              ; preds = %275, %166, %47, %33
  call void @llvm.lifetime.end.p0(i64 288, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 288, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 224, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %277 = load i32, ptr %3, align 4
  ret i32 %277
}

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

declare i32 @sm9_oid_from_name(ptr noundef) #4

declare noalias ptr @fopen(ptr noundef, ptr noundef) #4

declare i32 @sm9_sign_master_key_info_decrypt_from_pem(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @sm9_sign_master_key_extract_key(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

declare i32 @sm9_sign_key_info_encrypt_to_pem(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @sm9_enc_master_key_info_decrypt_from_pem(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @sm9_enc_master_key_extract_key(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #4

declare i32 @sm9_enc_key_info_encrypt_to_pem(ptr noundef, ptr noundef, ptr noundef) #4

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

declare i32 @fclose(ptr noundef) #4

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind willreturn memory(read) "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 = { "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 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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.SM9_SIGN_MASTER_KEY = type { %struct.SM9_Z256_TWIST_POINT, [4 x i64] }
%struct.SM9_Z256_TWIST_POINT = type { [2 x [4 x i64]], [2 x [4 x i64]], [2 x [4 x i64]] }
%struct.SM9_ENC_MASTER_KEY = type { %struct.SM9_Z256_POINT, [4 x i64] }
%struct.SM9_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }
%struct.SM9_SIGN_KEY = type { %struct.SM9_Z256_TWIST_POINT, %struct.SM9_Z256_POINT }
%struct.SM9_ENC_KEY = type { %struct.SM9_Z256_POINT, %struct.SM9_Z256_TWIST_POINT }

@stdin = external local_unnamed_addr global ptr, align 8
@stdout = external local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@options = external hidden local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [65 x i8], align 1
@__FUNCTION__.sm9keygen_main = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @sm9keygen_main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.SM9_SIGN_MASTER_KEY, align 8
  %4 = alloca %struct.SM9_ENC_MASTER_KEY, align 8
  %5 = alloca %struct.SM9_SIGN_KEY, align 8
  %6 = alloca %struct.SM9_ENC_KEY, align 8
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = load ptr, ptr @stdin, align 8, !tbaa !5
  %9 = load ptr, ptr @stdout, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 224, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 288, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 288, ptr nonnull %6) #5
  %10 = icmp slt i32 %0, 2
  br i1 %10, label %12, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  br label %.preheader

12:                                               ; preds = %2
  %13 = load ptr, ptr @stderr, align 8, !tbaa !5
  %14 = load ptr, ptr @options, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str, ptr noundef %7, ptr noundef %14) #6
  br label %126

.preheader:                                       ; preds = %.preheader.preheader, %79
  %.0169 = phi ptr [ %.1, %79 ], [ %9, %.preheader.preheader ]
  %.063168 = phi ptr [ %.164, %79 ], [ %8, %.preheader.preheader ]
  %.066167 = phi i32 [ %.167, %79 ], [ 0, %.preheader.preheader ]
  %.068166 = phi ptr [ %.169, %79 ], [ null, %.preheader.preheader ]
  %.070165 = phi ptr [ %.171, %79 ], [ null, %.preheader.preheader ]
  %.073164 = phi ptr [ %.174, %79 ], [ null, %.preheader.preheader ]
  %.075163 = phi ptr [ %.176, %79 ], [ null, %.preheader.preheader ]
  %.077162 = phi ptr [ %.178, %79 ], [ null, %.preheader.preheader ]
  %.081161 = phi ptr [ %80, %79 ], [ %11, %.preheader.preheader ]
  %.083.in160 = phi i32 [ %.184, %79 ], [ %0, %.preheader.preheader ]
  %16 = load ptr, ptr %.081161, align 8, !tbaa !5
  %17 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.1) #7
  %.not103 = icmp eq i32 %17, 0
  br i1 %.not103, label %18, label %22

18:                                               ; preds = %.preheader
  %19 = load ptr, ptr @stdout, align 8, !tbaa !5
  %20 = load ptr, ptr @options, align 8, !tbaa !5
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str, ptr noundef %7, ptr noundef %20) #5
  br label %126

22:                                               ; preds = %.preheader
  %23 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.2) #7
  %.not104 = icmp eq i32 %23, 0
  br i1 %.not104, label %24, label %34

24:                                               ; preds = %22
  %25 = icmp eq i32 %.083.in160, 2
  br i1 %25, label %76, label %26

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %.081161, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = tail call i32 @sm9_oid_from_name(ptr noundef %28) #5
  %30 = icmp slt i32 %29, 1
  br i1 %30, label %31, label %79

31:                                               ; preds = %26
  %32 = load ptr, ptr @stdout, align 8, !tbaa !5
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.3, ptr noundef %7, ptr noundef %28) #5
  br label %116

34:                                               ; preds = %22
  %35 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.4) #7
  %.not105 = icmp eq i32 %35, 0
  br i1 %.not105, label %36, label %45

36:                                               ; preds = %34
  %37 = icmp eq i32 %.083.in160, 2
  br i1 %37, label %76, label %38

38:                                               ; preds = %36
  %39 = getelementptr inbounds i8, ptr %.081161, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = tail call noalias ptr @fopen(ptr noundef %40, ptr noundef nonnull @.str.5)
  %.not106 = icmp eq ptr %41, null
  br i1 %.not106, label %42, label %79

42:                                               ; preds = %38
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7, i32 noundef 80, ptr noundef nonnull @__FUNCTION__.sm9keygen_main) #6
  br label %116

45:                                               ; preds = %34
  %46 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.8) #7
  %.not107 = icmp eq i32 %46, 0
  br i1 %.not107, label %47, label %52

47:                                               ; preds = %45
  %48 = icmp eq i32 %.083.in160, 2
  br i1 %48, label %76, label %49

49:                                               ; preds = %47
  %50 = getelementptr inbounds i8, ptr %.081161, i64 8
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  br label %79

52:                                               ; preds = %45
  %53 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.9) #7
  %.not108 = icmp eq i32 %53, 0
  br i1 %.not108, label %54, label %59

54:                                               ; preds = %52
  %55 = icmp eq i32 %.083.in160, 2
  br i1 %55, label %76, label %56

56:                                               ; preds = %54
  %57 = getelementptr inbounds i8, ptr %.081161, i64 8
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  br label %79

59:                                               ; preds = %52
  %60 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.10) #7
  %.not109 = icmp eq i32 %60, 0
  br i1 %.not109, label %61, label %70

61:                                               ; preds = %59
  %62 = icmp eq i32 %.083.in160, 2
  br i1 %62, label %76, label %63

63:                                               ; preds = %61
  %64 = getelementptr inbounds i8, ptr %.081161, i64 8
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = tail call noalias ptr @fopen(ptr noundef %65, ptr noundef nonnull @.str.11)
  %.not110 = icmp eq ptr %66, null
  br i1 %.not110, label %67, label %79

67:                                               ; preds = %63
  %68 = load ptr, ptr @stderr, align 8, !tbaa !5
  %69 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7, i32 noundef 93, ptr noundef nonnull @__FUNCTION__.sm9keygen_main) #6
  br label %116

70:                                               ; preds = %59
  %71 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.12) #7
  %.not111 = icmp ne i32 %71, 0
  %72 = icmp eq i32 %.083.in160, 2
  %or.cond112 = or i1 %72, %.not111
  br i1 %or.cond112, label %76, label %73

73:                                               ; preds = %70
  %74 = getelementptr inbounds i8, ptr %.081161, i64 8
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  br label %79

76:                                               ; preds = %70, %61, %54, %47, %36, %24
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef nonnull @.str.13, ptr noundef %7, ptr noundef %16) #6
  br label %126

79:                                               ; preds = %26, %49, %73, %63, %56, %38
  %.178 = phi ptr [ %.077162, %73 ], [ %.077162, %63 ], [ %.077162, %56 ], [ %.077162, %49 ], [ %40, %38 ], [ %.077162, %26 ]
  %.176 = phi ptr [ %.075163, %73 ], [ %.075163, %63 ], [ %.075163, %56 ], [ %51, %49 ], [ %.075163, %38 ], [ %.075163, %26 ]
  %.174 = phi ptr [ %.073164, %73 ], [ %.073164, %63 ], [ %58, %56 ], [ %.073164, %49 ], [ %.073164, %38 ], [ %.073164, %26 ]
  %.171 = phi ptr [ %.070165, %73 ], [ %65, %63 ], [ %.070165, %56 ], [ %.070165, %49 ], [ %.070165, %38 ], [ %.070165, %26 ]
  %.169 = phi ptr [ %75, %73 ], [ %.068166, %63 ], [ %.068166, %56 ], [ %.068166, %49 ], [ %.068166, %38 ], [ %.068166, %26 ]
  %.167 = phi i32 [ %.066167, %73 ], [ %.066167, %63 ], [ %.066167, %56 ], [ %.066167, %49 ], [ %.066167, %38 ], [ %29, %26 ]
  %.164 = phi ptr [ %.063168, %73 ], [ %.063168, %63 ], [ %.063168, %56 ], [ %.063168, %49 ], [ %41, %38 ], [ %.063168, %26 ]
  %.1 = phi ptr [ %.0169, %73 ], [ %66, %63 ], [ %.0169, %56 ], [ %.0169, %49 ], [ %.0169, %38 ], [ %.0169, %26 ]
  %.184 = add nsw i32 %.083.in160, -2
  %80 = getelementptr inbounds i8, ptr %.081161, i64 16
  %81 = icmp sgt i32 %.083.in160, 3
  br i1 %81, label %.preheader, label %82, !llvm.loop !9

82:                                               ; preds = %79
  %.not = icmp eq ptr %.174, null
  br i1 %.not, label %83, label %86

83:                                               ; preds = %82
  %84 = load ptr, ptr @stderr, align 8, !tbaa !5
  %85 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef nonnull @.str.14, ptr noundef %7) #6
  br label %116

86:                                               ; preds = %82
  %87 = icmp ne ptr %.176, null
  %88 = icmp ne ptr %.169, null
  %or.cond = select i1 %87, i1 %88, i1 false
  br i1 %or.cond, label %92, label %89

89:                                               ; preds = %86
  %90 = load ptr, ptr @stderr, align 8, !tbaa !5
  %91 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %90, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7, i32 noundef 115, ptr noundef nonnull @__FUNCTION__.sm9keygen_main) #6
  br label %116

92:                                               ; preds = %86
  switch i32 %.167, label %113 [
    i32 10, label %93
    i32 12, label %103
  ]

93:                                               ; preds = %92
  %94 = call i32 @sm9_sign_master_key_info_decrypt_from_pem(ptr noundef nonnull %3, ptr noundef nonnull %.176, ptr noundef %.164) #5
  %.not100 = icmp eq i32 %94, 1
  br i1 %.not100, label %95, label %100

95:                                               ; preds = %93
  %96 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.174) #7
  %97 = call i32 @sm9_sign_master_key_extract_key(ptr noundef nonnull %3, ptr noundef nonnull %.174, i64 noundef %96, ptr noundef nonnull %5) #5
  %.not101 = icmp eq i32 %97, 1
  br i1 %.not101, label %98, label %100

98:                                               ; preds = %95
  %99 = call i32 @sm9_sign_key_info_encrypt_to_pem(ptr noundef nonnull %5, ptr noundef nonnull %.169, ptr noundef %.1) #5
  %.not102 = icmp eq i32 %99, 1
  br i1 %.not102, label %116, label %100

100:                                              ; preds = %93, %95, %98
  %101 = load ptr, ptr @stderr, align 8, !tbaa !5
  %102 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7, i32 noundef 124, ptr noundef nonnull @__FUNCTION__.sm9keygen_main) #6
  br label %116

103:                                              ; preds = %92
  %104 = call i32 @sm9_enc_master_key_info_decrypt_from_pem(ptr noundef nonnull %4, ptr noundef nonnull %.176, ptr noundef %.164) #5
  %.not97 = icmp eq i32 %104, 1
  br i1 %.not97, label %105, label %110

105:                                              ; preds = %103
  %106 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.174) #7
  %107 = call i32 @sm9_enc_master_key_extract_key(ptr noundef nonnull %4, ptr noundef nonnull %.174, i64 noundef %106, ptr noundef nonnull %6) #5
  %.not98 = icmp eq i32 %107, 1
  br i1 %.not98, label %108, label %110

108:                                              ; preds = %105
  %109 = call i32 @sm9_enc_key_info_encrypt_to_pem(ptr noundef nonnull %6, ptr noundef nonnull %.169, ptr noundef %.1) #5
  %.not99 = icmp eq i32 %109, 1
  br i1 %.not99, label %116, label %110

110:                                              ; preds = %103, %105, %108
  %111 = load ptr, ptr @stderr, align 8, !tbaa !5
  %112 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %111, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7, i32 noundef 132, ptr noundef nonnull @__FUNCTION__.sm9keygen_main) #6
  br label %116

113:                                              ; preds = %92
  %114 = load ptr, ptr @stderr, align 8, !tbaa !5
  %115 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %114, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7, i32 noundef 137, ptr noundef nonnull @__FUNCTION__.sm9keygen_main) #6
  br label %116

116:                                              ; preds = %98, %108, %113, %110, %100, %89, %83, %67, %42, %31
  %.279 = phi ptr [ %.077162, %67 ], [ %40, %42 ], [ %.077162, %31 ], [ %.178, %113 ], [ %.178, %110 ], [ %.178, %100 ], [ %.178, %89 ], [ %.178, %83 ], [ %.178, %108 ], [ %.178, %98 ]
  %.272 = phi ptr [ %65, %67 ], [ %.070165, %42 ], [ %.070165, %31 ], [ %.171, %113 ], [ %.171, %110 ], [ %.171, %100 ], [ %.171, %89 ], [ %.171, %83 ], [ %.171, %108 ], [ %.171, %98 ]
  %.265 = phi ptr [ %.063168, %67 ], [ null, %42 ], [ %.063168, %31 ], [ %.164, %113 ], [ %.164, %110 ], [ %.164, %100 ], [ %.164, %89 ], [ %.164, %83 ], [ %.164, %108 ], [ %.164, %98 ]
  %.2 = phi ptr [ null, %67 ], [ %.0169, %42 ], [ %.0169, %31 ], [ %.1, %113 ], [ %.1, %110 ], [ %.1, %100 ], [ %.1, %89 ], [ %.1, %83 ], [ %.1, %108 ], [ %.1, %98 ]
  call void @gmssl_secure_clear(ptr noundef nonnull %3, i64 noundef 224) #5
  call void @gmssl_secure_clear(ptr noundef nonnull %4, i64 noundef 128) #5
  call void @gmssl_secure_clear(ptr noundef nonnull %5, i64 noundef 288) #5
  call void @gmssl_secure_clear(ptr noundef nonnull %6, i64 noundef 288) #5
  %117 = icmp ne ptr %.279, null
  %118 = icmp ne ptr %.265, null
  %or.cond3 = select i1 %117, i1 %118, i1 false
  br i1 %or.cond3, label %119, label %121

119:                                              ; preds = %116
  %120 = call i32 @fclose(ptr noundef nonnull %.265)
  br label %121

121:                                              ; preds = %119, %116
  %122 = icmp ne ptr %.272, null
  %123 = icmp ne ptr %.2, null
  %or.cond5 = select i1 %122, i1 %123, i1 false
  br i1 %or.cond5, label %124, label %126

124:                                              ; preds = %121
  %125 = call i32 @fclose(ptr noundef nonnull %.2)
  br label %126

126:                                              ; preds = %121, %124, %76, %18, %12
  %.080 = phi i32 [ 1, %12 ], [ 1, %76 ], [ 0, %18 ], [ 1, %124 ], [ 1, %121 ]
  call void @llvm.lifetime.end.p0(i64 288, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 288, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 224, ptr nonnull %3) #5
  ret i32 %.080
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

declare i32 @sm9_oid_from_name(ptr noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

declare i32 @sm9_sign_master_key_info_decrypt_from_pem(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @sm9_sign_master_key_extract_key(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

declare i32 @sm9_sign_key_info_encrypt_to_pem(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @sm9_enc_master_key_info_decrypt_from_pem(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @sm9_enc_master_key_extract_key(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

declare i32 @sm9_enc_key_info_encrypt_to_pem(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { "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 }
attributes #7 = { nounwind willreturn memory(read) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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