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

; 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_XMSS_KEY = type { i32, [32 x i8], [32 x i8], [32 x i8], [32 x i8], i32, ptr }

@stdout = external global ptr, align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@help = external hidden global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@usage = external hidden global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [70 x i8], align 1
@__FUNCTION__.sm3xmss_keygen_main = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @sm3xmss_keygen_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 i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca %struct.SM3_XMSS_KEY, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = 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) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds ptr, ptr %20, i64 0
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  store ptr %22, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store ptr null, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store ptr null, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store ptr null, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %23 = load ptr, ptr @stdout, align 8, !tbaa !9
  store ptr %23, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %24 = load ptr, ptr @stdout, align 8, !tbaa !9
  store ptr %24, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 144, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  store ptr null, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  store ptr null, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = add nsw i32 %25, -1
  store i32 %26, ptr %4, align 4, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %27, i32 1
  store ptr %28, ptr %5, align 8, !tbaa !9
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 1
  br i1 %30, label %31, label %36

31:                                               ; preds = %2
  %32 = load ptr, ptr @stderr, align 8, !tbaa !9
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  %34 = load ptr, ptr @help, align 8, !tbaa !9
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str, ptr noundef %33, ptr noundef %34) #7
  store i32 1, ptr %3, align 4
  store i32 1, ptr %19, align 4
  br label %295

36:                                               ; preds = %2
  br label %37

37:                                               ; preds = %154, %36
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %40, label %159

40:                                               ; preds = %37
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = call i32 @strcmp(ptr noundef %42, ptr noundef @.str.1) #8
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %51, label %45

45:                                               ; preds = %40
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = load ptr, ptr @usage, align 8, !tbaa !9
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %46, ptr noundef %47)
  %49 = load ptr, ptr @help, align 8, !tbaa !9
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %49)
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %261

51:                                               ; preds = %40
  %52 = load ptr, ptr %5, align 8, !tbaa !9
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = call i32 @strcmp(ptr noundef %53, ptr noundef @.str.3) #8
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %87, label %56

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

60:                                               ; preds = %56
  br label %145

61:                                               ; preds = %56
  %62 = load ptr, ptr %5, align 8, !tbaa !9
  %63 = getelementptr inbounds ptr, ptr %62, i32 1
  store ptr %63, ptr %5, align 8, !tbaa !9
  %64 = load ptr, ptr %63, align 8, !tbaa !9
  store ptr %64, ptr %8, align 8, !tbaa !9
  %65 = load ptr, ptr %8, align 8, !tbaa !9
  %66 = call i32 @strcmp(ptr noundef %65, ptr noundef @.str.4) #8
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %61
  store i32 268435457, ptr %9, align 4, !tbaa !5
  br label %86

69:                                               ; preds = %61
  %70 = load ptr, ptr %8, align 8, !tbaa !9
  %71 = call i32 @strcmp(ptr noundef %70, ptr noundef @.str.5) #8
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %74

73:                                               ; preds = %69
  store i32 268435458, ptr %9, align 4, !tbaa !5
  br label %85

74:                                               ; preds = %69
  %75 = load ptr, ptr %8, align 8, !tbaa !9
  %76 = call i32 @strcmp(ptr noundef %75, ptr noundef @.str.6) #8
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %79

78:                                               ; preds = %74
  store i32 268435459, ptr %9, align 4, !tbaa !5
  br label %84

79:                                               ; preds = %74
  %80 = load ptr, ptr @stderr, align 8, !tbaa !9
  %81 = load ptr, ptr %7, align 8, !tbaa !9
  %82 = load ptr, ptr %8, align 8, !tbaa !9
  %83 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef @.str.7, ptr noundef %81, ptr noundef %82) #7
  br label %261

84:                                               ; preds = %78
  br label %85

85:                                               ; preds = %84, %73
  br label %86

86:                                               ; preds = %85, %68
  br label %153

87:                                               ; preds = %51
  %88 = load ptr, ptr %5, align 8, !tbaa !9
  %89 = load ptr, ptr %88, align 8, !tbaa !9
  %90 = call i32 @strcmp(ptr noundef %89, ptr noundef @.str.8) #8
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %113, label %92

92:                                               ; preds = %87
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = add nsw i32 %93, -1
  store i32 %94, ptr %4, align 4, !tbaa !5
  %95 = icmp slt i32 %94, 1
  br i1 %95, label %96, label %97

96:                                               ; preds = %92
  br label %145

97:                                               ; preds = %92
  %98 = load ptr, ptr %5, align 8, !tbaa !9
  %99 = getelementptr inbounds ptr, ptr %98, i32 1
  store ptr %99, ptr %5, align 8, !tbaa !9
  %100 = load ptr, ptr %99, align 8, !tbaa !9
  store ptr %100, ptr %10, align 8, !tbaa !9
  %101 = load ptr, ptr %10, align 8, !tbaa !9
  %102 = call noalias ptr @fopen(ptr noundef %101, ptr noundef @.str.9)
  store ptr %102, ptr %12, align 8, !tbaa !9
  %103 = icmp ne ptr %102, null
  br i1 %103, label %112, label %104

104:                                              ; preds = %97
  %105 = load ptr, ptr @stderr, align 8, !tbaa !9
  %106 = load ptr, ptr %7, align 8, !tbaa !9
  %107 = load ptr, ptr %10, align 8, !tbaa !9
  %108 = call ptr @__errno_location() #9
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = call ptr @strerror(i32 noundef %109) #7
  %111 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %105, ptr noundef @.str.10, ptr noundef %106, ptr noundef %107, ptr noundef %110) #7
  br label %261

112:                                              ; preds = %97
  br label %152

113:                                              ; preds = %87
  %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.11) #8
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %139, 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 %145

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
  %127 = load ptr, ptr %11, align 8, !tbaa !9
  %128 = call noalias ptr @fopen(ptr noundef %127, ptr noundef @.str.9)
  store ptr %128, ptr %13, align 8, !tbaa !9
  %129 = icmp ne ptr %128, null
  br i1 %129, label %138, label %130

130:                                              ; preds = %123
  %131 = load ptr, ptr @stderr, align 8, !tbaa !9
  %132 = load ptr, ptr %7, align 8, !tbaa !9
  %133 = load ptr, ptr %10, align 8, !tbaa !9
  %134 = call ptr @__errno_location() #9
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = call ptr @strerror(i32 noundef %135) #7
  %137 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %131, ptr noundef @.str.10, ptr noundef %132, ptr noundef %133, ptr noundef %136) #7
  br label %261

138:                                              ; preds = %123
  br label %151

139:                                              ; preds = %113
  %140 = load ptr, ptr @stderr, align 8, !tbaa !9
  %141 = load ptr, ptr %7, align 8, !tbaa !9
  %142 = load ptr, ptr %5, align 8, !tbaa !9
  %143 = load ptr, ptr %142, align 8, !tbaa !9
  %144 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %140, ptr noundef @.str.12, ptr noundef %141, ptr noundef %143) #7
  br label %261

145:                                              ; preds = %122, %96, %60
  %146 = load ptr, ptr @stderr, align 8, !tbaa !9
  %147 = load ptr, ptr %7, align 8, !tbaa !9
  %148 = load ptr, ptr %5, align 8, !tbaa !9
  %149 = load ptr, ptr %148, align 8, !tbaa !9
  %150 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %146, ptr noundef @.str.13, ptr noundef %147, ptr noundef %149) #7
  br label %261

151:                                              ; preds = %138
  br label %152

152:                                              ; preds = %151, %112
  br label %153

153:                                              ; preds = %152, %86
  br label %154

154:                                              ; preds = %153
  %155 = load i32, ptr %4, align 4, !tbaa !5
  %156 = add nsw i32 %155, -1
  store i32 %156, ptr %4, align 4, !tbaa !5
  %157 = load ptr, ptr %5, align 8, !tbaa !9
  %158 = getelementptr inbounds ptr, ptr %157, i32 1
  store ptr %158, ptr %5, align 8, !tbaa !9
  br label %37, !llvm.loop !11

159:                                              ; preds = %37
  %160 = load ptr, ptr %8, align 8, !tbaa !9
  %161 = icmp ne ptr %160, null
  br i1 %161, label %166, label %162

162:                                              ; preds = %159
  %163 = load ptr, ptr @stderr, align 8, !tbaa !9
  %164 = load ptr, ptr %7, align 8, !tbaa !9
  %165 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %163, ptr noundef @.str.14, ptr noundef %164) #7
  br label %261

166:                                              ; preds = %159
  %167 = load i32, ptr %9, align 4, !tbaa !5
  %168 = call i32 @sm3_xmss_key_generate(ptr noundef %14, i32 noundef %167)
  %169 = icmp ne i32 %168, 1
  br i1 %169, label %170, label %176

170:                                              ; preds = %166
  br label %171

171:                                              ; preds = %170
  %172 = load ptr, ptr @stderr, align 8, !tbaa !9
  %173 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %172, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 107, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %174

174:                                              ; preds = %171
  br label %175

175:                                              ; preds = %174
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %19, align 4
  br label %295

176:                                              ; preds = %166
  %177 = call i32 @sm3_xmss_key_to_bytes(ptr noundef %14, ptr noundef null, ptr noundef %17)
  %178 = icmp ne i32 %177, 1
  br i1 %178, label %179, label %185

179:                                              ; preds = %176
  br label %180

180:                                              ; preds = %179
  %181 = load ptr, ptr @stderr, align 8, !tbaa !9
  %182 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %181, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 112, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %183

183:                                              ; preds = %180
  br label %184

184:                                              ; preds = %183
  br label %261

185:                                              ; preds = %176
  %186 = load i64, ptr %17, align 8, !tbaa !13
  %187 = call noalias ptr @malloc(i64 noundef %186) #10
  store ptr %187, ptr %15, align 8, !tbaa !9
  %188 = icmp ne ptr %187, null
  br i1 %188, label %195, label %189

189:                                              ; preds = %185
  br label %190

190:                                              ; preds = %189
  %191 = load ptr, ptr @stderr, align 8, !tbaa !9
  %192 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %191, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 116, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %193

193:                                              ; preds = %190
  br label %194

194:                                              ; preds = %193
  br label %261

195:                                              ; preds = %185
  %196 = load ptr, ptr %15, align 8, !tbaa !9
  %197 = call i32 @sm3_xmss_key_to_bytes(ptr noundef %14, ptr noundef %196, ptr noundef %17)
  %198 = icmp ne i32 %197, 1
  br i1 %198, label %199, label %205

199:                                              ; preds = %195
  br label %200

200:                                              ; preds = %199
  %201 = load ptr, ptr @stderr, align 8, !tbaa !9
  %202 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %201, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 120, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %203

203:                                              ; preds = %200
  br label %204

204:                                              ; preds = %203
  br label %205

205:                                              ; preds = %204, %195
  %206 = call i32 @sm3_xmss_public_key_to_bytes(ptr noundef %14, ptr noundef null, ptr noundef %18)
  %207 = icmp ne i32 %206, 1
  br i1 %207, label %208, label %214

208:                                              ; preds = %205
  br label %209

209:                                              ; preds = %208
  %210 = load ptr, ptr @stderr, align 8, !tbaa !9
  %211 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %210, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 124, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %212

212:                                              ; preds = %209
  br label %213

213:                                              ; preds = %212
  br label %261

214:                                              ; preds = %205
  %215 = load i64, ptr %18, align 8, !tbaa !13
  %216 = call noalias ptr @malloc(i64 noundef %215) #10
  store ptr %216, ptr %16, align 8, !tbaa !9
  %217 = icmp ne ptr %216, null
  br i1 %217, label %224, label %218

218:                                              ; preds = %214
  br label %219

219:                                              ; preds = %218
  %220 = load ptr, ptr @stderr, align 8, !tbaa !9
  %221 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %220, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 128, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %222

222:                                              ; preds = %219
  br label %223

223:                                              ; preds = %222
  br label %261

224:                                              ; preds = %214
  %225 = load ptr, ptr %16, align 8, !tbaa !9
  %226 = call i32 @sm3_xmss_public_key_to_bytes(ptr noundef %14, ptr noundef %225, ptr noundef %18)
  %227 = icmp ne i32 %226, 1
  br i1 %227, label %228, label %234

228:                                              ; preds = %224
  br label %229

229:                                              ; preds = %228
  %230 = load ptr, ptr @stderr, align 8, !tbaa !9
  %231 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %230, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 132, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %232

232:                                              ; preds = %229
  br label %233

233:                                              ; preds = %232
  br label %261

234:                                              ; preds = %224
  %235 = load ptr, ptr %15, align 8, !tbaa !9
  %236 = load i64, ptr %17, align 8, !tbaa !13
  %237 = load ptr, ptr %12, align 8, !tbaa !9
  %238 = call i64 @fwrite(ptr noundef %235, i64 noundef 1, i64 noundef %236, ptr noundef %237)
  %239 = load i64, ptr %17, align 8, !tbaa !13
  %240 = icmp ne i64 %238, %239
  br i1 %240, label %241, label %247

241:                                              ; preds = %234
  br label %242

242:                                              ; preds = %241
  %243 = load ptr, ptr @stderr, align 8, !tbaa !9
  %244 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %243, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 137, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %245

245:                                              ; preds = %242
  br label %246

246:                                              ; preds = %245
  br label %261

247:                                              ; preds = %234
  %248 = load ptr, ptr %16, align 8, !tbaa !9
  %249 = load i64, ptr %18, align 8, !tbaa !13
  %250 = load ptr, ptr %13, align 8, !tbaa !9
  %251 = call i64 @fwrite(ptr noundef %248, i64 noundef 1, i64 noundef %249, ptr noundef %250)
  %252 = load i64, ptr %18, align 8, !tbaa !13
  %253 = icmp ne i64 %251, %252
  br i1 %253, label %254, label %260

254:                                              ; preds = %247
  br label %255

255:                                              ; preds = %254
  %256 = load ptr, ptr @stderr, align 8, !tbaa !9
  %257 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %256, ptr noundef @.str.15, ptr noundef @.str.16, i32 noundef 141, ptr noundef @__FUNCTION__.sm3xmss_keygen_main) #7
  br label %258

258:                                              ; preds = %255
  br label %259

259:                                              ; preds = %258
  br label %261

260:                                              ; preds = %247
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %261

261:                                              ; preds = %260, %259, %246, %233, %223, %213, %194, %184, %162, %145, %139, %130, %104, %79, %45
  call void @gmssl_secure_clear(ptr noundef %14, i64 noundef 144)
  %262 = load ptr, ptr %15, align 8, !tbaa !9
  %263 = icmp ne ptr %262, null
  br i1 %263, label %264, label %268

264:                                              ; preds = %261
  %265 = load ptr, ptr %15, align 8, !tbaa !9
  %266 = load i64, ptr %17, align 8, !tbaa !13
  call void @gmssl_secure_clear(ptr noundef %265, i64 noundef %266)
  %267 = load ptr, ptr %15, align 8, !tbaa !9
  call void @free(ptr noundef %267) #7
  br label %268

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

271:                                              ; preds = %268
  %272 = load ptr, ptr %16, align 8, !tbaa !9
  %273 = load i64, ptr %18, align 8, !tbaa !13
  call void @gmssl_secure_clear(ptr noundef %272, i64 noundef %273)
  %274 = load ptr, ptr %16, align 8, !tbaa !9
  call void @free(ptr noundef %274) #7
  br label %275

275:                                              ; preds = %271, %268
  %276 = load ptr, ptr %10, align 8, !tbaa !9
  %277 = icmp ne ptr %276, null
  br i1 %277, label %278, label %284

278:                                              ; preds = %275
  %279 = load ptr, ptr %12, align 8, !tbaa !9
  %280 = icmp ne ptr %279, null
  br i1 %280, label %281, label %284

281:                                              ; preds = %278
  %282 = load ptr, ptr %12, align 8, !tbaa !9
  %283 = call i32 @fclose(ptr noundef %282)
  br label %284

284:                                              ; preds = %281, %278, %275
  %285 = load ptr, ptr %11, align 8, !tbaa !9
  %286 = icmp ne ptr %285, null
  br i1 %286, label %287, label %293

287:                                              ; preds = %284
  %288 = load ptr, ptr %13, align 8, !tbaa !9
  %289 = icmp ne ptr %288, null
  br i1 %289, label %290, label %293

290:                                              ; preds = %287
  %291 = load ptr, ptr %13, align 8, !tbaa !9
  %292 = call i32 @fclose(ptr noundef %291)
  br label %293

293:                                              ; preds = %290, %287, %284
  %294 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %294, ptr %3, align 4
  store i32 1, ptr %19, align 4
  br label %295

295:                                              ; preds = %293, %175, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 144, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %296 = load i32, ptr %3, align 4
  ret i32 %296
}

; 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 @printf(ptr noundef, ...) #4

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #5

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #6

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #4

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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 willreturn memory(none) "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 #6 = { nounwind allocsize(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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { nounwind allocsize(0) }

!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"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.SM3_XMSS_KEY = type { i32, [32 x i8], [32 x i8], [32 x i8], [32 x i8], i32, ptr }

@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
@help = external hidden local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@usage = external hidden local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [70 x i8], align 1
@__FUNCTION__.sm3xmss_keygen_main = external hidden unnamed_addr constant [20 x i8], align 1

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

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

10:                                               ; preds = %2
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = load ptr, ptr @help, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str, ptr noundef %6, ptr noundef %12) #10
  br label %132

.preheader:                                       ; preds = %.preheader.preheader, %73
  %.060187 = phi ptr [ %.1, %73 ], [ %7, %.preheader.preheader ]
  %.061186 = phi ptr [ %.162, %73 ], [ %7, %.preheader.preheader ]
  %.064185 = phi ptr [ %.165, %73 ], [ null, %.preheader.preheader ]
  %.067184 = phi ptr [ %.168, %73 ], [ null, %.preheader.preheader ]
  %.070183 = phi i32 [ %.171, %73 ], [ 0, %.preheader.preheader ]
  %.072182 = phi ptr [ %.173, %73 ], [ null, %.preheader.preheader ]
  %.076181 = phi ptr [ %74, %73 ], [ %9, %.preheader.preheader ]
  %.078.in180 = phi i32 [ %.179, %73 ], [ %0, %.preheader.preheader ]
  %14 = load ptr, ptr %.076181, align 8, !tbaa !5
  %15 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) @.str.1) #11
  %.not101 = icmp eq i32 %15, 0
  br i1 %.not101, label %16, label %21

16:                                               ; preds = %.preheader
  %17 = load ptr, ptr @usage, align 8, !tbaa !5
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %6, ptr noundef %17)
  %19 = load ptr, ptr @help, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %19)
  br label %.thread123

21:                                               ; preds = %.preheader
  %22 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) @.str.3) #11
  %.not102 = icmp eq i32 %22, 0
  br i1 %.not102, label %23, label %39

23:                                               ; preds = %21
  %24 = icmp eq i32 %.078.in180, 2
  br i1 %24, label %70, label %25

25:                                               ; preds = %23
  %26 = getelementptr inbounds i8, ptr %.076181, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %27, ptr noundef nonnull dereferenceable(1) @.str.4) #11
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %73, label %30

30:                                               ; preds = %25
  %31 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %27, ptr noundef nonnull dereferenceable(1) @.str.5) #11
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %73, label %33

33:                                               ; preds = %30
  %34 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %27, ptr noundef nonnull dereferenceable(1) @.str.6) #11
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %73, label %36

36:                                               ; preds = %33
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.7, ptr noundef %6, ptr noundef %27) #10
  br label %.thread123

39:                                               ; preds = %21
  %40 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) @.str.8) #11
  %.not103 = icmp eq i32 %40, 0
  br i1 %.not103, label %41, label %53

41:                                               ; preds = %39
  %42 = icmp eq i32 %.078.in180, 2
  br i1 %42, label %70, label %43

43:                                               ; preds = %41
  %44 = getelementptr inbounds i8, ptr %.076181, i64 8
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = tail call noalias ptr @fopen(ptr noundef %45, ptr noundef nonnull @.str.9)
  %.not104 = icmp eq ptr %46, null
  br i1 %.not104, label %47, label %73

47:                                               ; preds = %43
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = tail call ptr @__errno_location() #12
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = tail call ptr @strerror(i32 noundef %50) #9
  %52 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef nonnull @.str.10, ptr noundef %6, ptr noundef %45, ptr noundef %51) #10
  br label %.thread123

53:                                               ; preds = %39
  %54 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) @.str.11) #11
  %.not105 = icmp eq i32 %54, 0
  br i1 %.not105, label %55, label %67

55:                                               ; preds = %53
  %56 = icmp eq i32 %.078.in180, 2
  br i1 %56, label %70, label %57

57:                                               ; preds = %55
  %58 = getelementptr inbounds i8, ptr %.076181, i64 8
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = tail call noalias ptr @fopen(ptr noundef %59, ptr noundef nonnull @.str.9)
  %.not106 = icmp eq ptr %60, null
  br i1 %.not106, label %61, label %73

61:                                               ; preds = %57
  %62 = load ptr, ptr @stderr, align 8, !tbaa !5
  %63 = tail call ptr @__errno_location() #12
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = tail call ptr @strerror(i32 noundef %64) #9
  %66 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef nonnull @.str.10, ptr noundef %6, ptr noundef %.067184, ptr noundef %65) #10
  br label %.thread123

67:                                               ; preds = %53
  %68 = load ptr, ptr @stderr, align 8, !tbaa !5
  %69 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef nonnull @.str.12, ptr noundef %6, ptr noundef %14) #10
  br label %.thread123

70:                                               ; preds = %55, %41, %23
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef nonnull @.str.13, ptr noundef %6, ptr noundef %14) #10
  br label %.thread123

73:                                               ; preds = %33, %30, %25, %57, %43
  %.173 = phi ptr [ %.072182, %57 ], [ %.072182, %43 ], [ %27, %25 ], [ %27, %30 ], [ %27, %33 ]
  %.171 = phi i32 [ %.070183, %57 ], [ %.070183, %43 ], [ 268435457, %25 ], [ 268435458, %30 ], [ 268435459, %33 ]
  %.168 = phi ptr [ %.067184, %57 ], [ %45, %43 ], [ %.067184, %25 ], [ %.067184, %30 ], [ %.067184, %33 ]
  %.165 = phi ptr [ %59, %57 ], [ %.064185, %43 ], [ %.064185, %25 ], [ %.064185, %30 ], [ %.064185, %33 ]
  %.162 = phi ptr [ %.061186, %57 ], [ %46, %43 ], [ %.061186, %25 ], [ %.061186, %30 ], [ %.061186, %33 ]
  %.1 = phi ptr [ %60, %57 ], [ %.060187, %43 ], [ %.060187, %25 ], [ %.060187, %30 ], [ %.060187, %33 ]
  %.179 = add nsw i32 %.078.in180, -2
  %74 = getelementptr inbounds i8, ptr %.076181, i64 16
  %75 = icmp sgt i32 %.078.in180, 3
  br i1 %75, label %.preheader, label %76, !llvm.loop !11

76:                                               ; preds = %73
  %.not = icmp eq ptr %.173, null
  br i1 %.not, label %77, label %80

77:                                               ; preds = %76
  %78 = load ptr, ptr @stderr, align 8, !tbaa !5
  %79 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %78, ptr noundef nonnull @.str.14, ptr noundef %6) #10
  br label %.thread123

80:                                               ; preds = %76
  %81 = call i32 @sm3_xmss_key_generate(ptr noundef nonnull %3, i32 noundef %.171) #9
  %.not92 = icmp eq i32 %81, 1
  br i1 %.not92, label %85, label %82

82:                                               ; preds = %80
  %83 = load ptr, ptr @stderr, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.16, i32 noundef 107, ptr noundef nonnull @__FUNCTION__.sm3xmss_keygen_main) #10
  br label %132

85:                                               ; preds = %80
  %86 = call i32 @sm3_xmss_key_to_bytes(ptr noundef nonnull %3, ptr noundef null, ptr noundef nonnull %4) #9
  %.not93 = icmp eq i32 %86, 1
  br i1 %.not93, label %90, label %87

87:                                               ; preds = %85
  %88 = load ptr, ptr @stderr, align 8, !tbaa !5
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.16, i32 noundef 112, ptr noundef nonnull @__FUNCTION__.sm3xmss_keygen_main) #10
  br label %.thread123

90:                                               ; preds = %85
  %91 = load i64, ptr %4, align 8, !tbaa !13
  %92 = call noalias ptr @malloc(i64 noundef %91) #13
  %.not94 = icmp eq ptr %92, null
  br i1 %.not94, label %93, label %96

93:                                               ; preds = %90
  %94 = load ptr, ptr @stderr, align 8, !tbaa !5
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.16, i32 noundef 116, ptr noundef nonnull @__FUNCTION__.sm3xmss_keygen_main) #10
  br label %.thread123

96:                                               ; preds = %90
  %97 = call i32 @sm3_xmss_key_to_bytes(ptr noundef nonnull %3, ptr noundef nonnull %92, ptr noundef nonnull %4) #9
  %.not95 = icmp eq i32 %97, 1
  br i1 %.not95, label %101, label %98

98:                                               ; preds = %96
  %99 = load ptr, ptr @stderr, align 8, !tbaa !5
  %100 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %99, ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.16, i32 noundef 120, ptr noundef nonnull @__FUNCTION__.sm3xmss_keygen_main) #10
  br label %101

101:                                              ; preds = %98, %96
  %102 = call i32 @sm3_xmss_public_key_to_bytes(ptr noundef nonnull %3, ptr noundef null, ptr noundef nonnull %5) #9
  %.not96 = icmp eq i32 %102, 1
  br i1 %.not96, label %103, label %.sink.split

103:                                              ; preds = %101
  %104 = load i64, ptr %5, align 8, !tbaa !13
  %105 = call noalias ptr @malloc(i64 noundef %104) #13
  %.not97 = icmp eq ptr %105, null
  br i1 %.not97, label %.sink.split, label %106

106:                                              ; preds = %103
  %107 = call i32 @sm3_xmss_public_key_to_bytes(ptr noundef nonnull %3, ptr noundef nonnull %105, ptr noundef nonnull %5) #9
  %.not98 = icmp eq i32 %107, 1
  br i1 %.not98, label %108, label %.sink.split

108:                                              ; preds = %106
  %109 = load i64, ptr %4, align 8, !tbaa !13
  %110 = call i64 @fwrite(ptr noundef nonnull %92, i64 noundef 1, i64 noundef %109, ptr noundef %.162)
  %111 = load i64, ptr %4, align 8, !tbaa !13
  %.not99 = icmp eq i64 %110, %111
  br i1 %.not99, label %112, label %.sink.split

112:                                              ; preds = %108
  %113 = load i64, ptr %5, align 8, !tbaa !13
  %114 = call i64 @fwrite(ptr noundef nonnull %105, i64 noundef 1, i64 noundef %113, ptr noundef %.1)
  %115 = load i64, ptr %5, align 8, !tbaa !13
  %.not100 = icmp eq i64 %114, %115
  br i1 %.not100, label %118, label %.sink.split

.thread123:                                       ; preds = %77, %93, %87, %16, %36, %47, %61, %70, %67
  %.075.ph = phi i32 [ 1, %77 ], [ 1, %93 ], [ 1, %87 ], [ 0, %16 ], [ 1, %36 ], [ 1, %47 ], [ 1, %61 ], [ 1, %70 ], [ 1, %67 ]
  %.269.ph = phi ptr [ %.168, %77 ], [ %.168, %93 ], [ %.168, %87 ], [ %.067184, %16 ], [ %.067184, %36 ], [ %45, %47 ], [ %.067184, %61 ], [ %.067184, %70 ], [ %.067184, %67 ]
  %.266.ph = phi ptr [ %.165, %77 ], [ %.165, %93 ], [ %.165, %87 ], [ %.064185, %16 ], [ %.064185, %36 ], [ %.064185, %47 ], [ %59, %61 ], [ %.064185, %70 ], [ %.064185, %67 ]
  %.263.ph = phi ptr [ %.162, %77 ], [ %.162, %93 ], [ %.162, %87 ], [ %.061186, %16 ], [ %.061186, %36 ], [ null, %47 ], [ %.061186, %61 ], [ %.061186, %70 ], [ %.061186, %67 ]
  %.2.ph = phi ptr [ %.1, %77 ], [ %.1, %93 ], [ %.1, %87 ], [ %.060187, %16 ], [ %.060187, %36 ], [ %.060187, %47 ], [ null, %61 ], [ %.060187, %70 ], [ %.060187, %67 ]
  call void @gmssl_secure_clear(ptr noundef nonnull %3, i64 noundef 144) #9
  br label %122

.sink.split:                                      ; preds = %112, %108, %106, %103, %101
  %.sink254 = phi i32 [ 124, %101 ], [ 128, %103 ], [ 132, %106 ], [ 137, %108 ], [ 141, %112 ]
  %.0.ph = phi ptr [ null, %101 ], [ null, %103 ], [ %105, %106 ], [ %105, %108 ], [ %105, %112 ]
  %116 = load ptr, ptr @stderr, align 8, !tbaa !5
  %117 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %116, ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.16, i32 noundef %.sink254, ptr noundef nonnull @__FUNCTION__.sm3xmss_keygen_main) #10
  br label %118

118:                                              ; preds = %.sink.split, %112
  %.075 = phi i32 [ 0, %112 ], [ 1, %.sink.split ]
  %.0 = phi ptr [ %105, %112 ], [ %.0.ph, %.sink.split ]
  call void @gmssl_secure_clear(ptr noundef nonnull %3, i64 noundef 144) #9
  %119 = load i64, ptr %4, align 8, !tbaa !13
  call void @gmssl_secure_clear(ptr noundef nonnull %92, i64 noundef %119) #9
  call void @free(ptr noundef nonnull %92) #9
  %.not108 = icmp eq ptr %.0, null
  br i1 %.not108, label %122, label %120

120:                                              ; preds = %118
  %121 = load i64, ptr %5, align 8, !tbaa !13
  call void @gmssl_secure_clear(ptr noundef nonnull %.0, i64 noundef %121) #9
  call void @free(ptr noundef nonnull %.0) #9
  br label %122

122:                                              ; preds = %.thread123, %120, %118
  %.075117135 = phi i32 [ %.075.ph, %.thread123 ], [ %.075, %120 ], [ %.075, %118 ]
  %.269118134 = phi ptr [ %.269.ph, %.thread123 ], [ %.168, %120 ], [ %.168, %118 ]
  %.266119133 = phi ptr [ %.266.ph, %.thread123 ], [ %.165, %120 ], [ %.165, %118 ]
  %.263120132 = phi ptr [ %.263.ph, %.thread123 ], [ %.162, %120 ], [ %.162, %118 ]
  %.2121131 = phi ptr [ %.2.ph, %.thread123 ], [ %.1, %120 ], [ %.1, %118 ]
  %123 = icmp ne ptr %.269118134, null
  %124 = icmp ne ptr %.263120132, null
  %or.cond = select i1 %123, i1 %124, i1 false
  br i1 %or.cond, label %125, label %127

125:                                              ; preds = %122
  %126 = call i32 @fclose(ptr noundef nonnull %.263120132)
  br label %127

127:                                              ; preds = %125, %122
  %128 = icmp ne ptr %.266119133, null
  %129 = icmp ne ptr %.2121131, null
  %or.cond3 = select i1 %128, i1 %129, i1 false
  br i1 %or.cond3, label %130, label %132

130:                                              ; preds = %127
  %131 = call i32 @fclose(ptr noundef nonnull %.2121131)
  br label %132

132:                                              ; preds = %127, %130, %82, %10
  %.074 = phi i32 [ 1, %10 ], [ -1, %82 ], [ %.075117135, %130 ], [ %.075117135, %127 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %3) #9
  ret i32 %.074
}

; 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

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

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #5

declare i32 @sm3_xmss_key_generate(ptr noundef, i32 noundef) local_unnamed_addr #6

declare i32 @sm3_xmss_key_to_bytes(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #7

declare i32 @sm3_xmss_public_key_to_bytes(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #8

; 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 = { 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 #5 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 #6 = { "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 #7 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #8 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #9 = { nounwind }
attributes #10 = { cold nounwind }
attributes #11 = { nounwind willreturn memory(read) }
attributes #12 = { nounwind willreturn memory(none) }
attributes #13 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}


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