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

; 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.SM4_CTR_CTX = type { %struct.SM4_KEY, [16 x i8], [16 x i8], i64 }
%struct.SM4_KEY = type { [32 x i32] }

@stdin = external global ptr, align 8
@stdout = external global ptr, align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [20 x i8], align 1
@usage = 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 [4 x i8], align 1
@options = external hidden global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [63 x i8], align 1
@__FUNCTION__.sm4_ctr_main = external hidden unnamed_addr constant [13 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [31 x i8], align 1

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

34:                                               ; preds = %2
  %35 = load ptr, ptr @stderr, align 8, !tbaa !9
  %36 = load ptr, ptr %7, align 8, !tbaa !9
  %37 = load ptr, ptr @usage, align 8, !tbaa !9
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str, ptr noundef %36, ptr noundef %37) #6
  store i32 1, ptr %3, align 4
  store i32 1, ptr %22, align 4
  br label %313

39:                                               ; preds = %2
  br label %40

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

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

48:                                               ; preds = %43
  %49 = load ptr, ptr %7, align 8, !tbaa !9
  %50 = load ptr, ptr @usage, align 8, !tbaa !9
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %49, ptr noundef %50)
  %52 = load ptr, ptr @options, align 8, !tbaa !9
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %52)
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %290

54:                                               ; preds = %43
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = call i32 @strcmp(ptr noundef %56, ptr noundef @.str.3) #7
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %60, label %59

59:                                               ; preds = %54
  br label %201

60:                                               ; preds = %54
  %61 = load ptr, ptr %5, align 8, !tbaa !9
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = call i32 @strcmp(ptr noundef %62, ptr noundef @.str.4) #7
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %66, label %65

65:                                               ; preds = %60
  br label %200

66:                                               ; preds = %60
  %67 = load ptr, ptr %5, align 8, !tbaa !9
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = call i32 @strcmp(ptr noundef %68, ptr noundef @.str.5) #7
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %99, label %71

71:                                               ; preds = %66
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = add nsw i32 %72, -1
  store i32 %73, ptr %4, align 4, !tbaa !5
  %74 = icmp slt i32 %73, 1
  br i1 %74, label %75, label %76

75:                                               ; preds = %71
  br label %190

76:                                               ; preds = %71
  %77 = load ptr, ptr %5, align 8, !tbaa !9
  %78 = getelementptr inbounds ptr, ptr %77, i32 1
  store ptr %78, ptr %5, align 8, !tbaa !9
  %79 = load ptr, ptr %78, align 8, !tbaa !9
  store ptr %79, ptr %8, align 8, !tbaa !9
  %80 = load ptr, ptr %8, align 8, !tbaa !9
  %81 = call i64 @strlen(ptr noundef %80) #7
  %82 = icmp ne i64 %81, 32
  br i1 %82, label %83, label %87

83:                                               ; preds = %76
  %84 = load ptr, ptr @stderr, align 8, !tbaa !9
  %85 = load ptr, ptr %7, align 8, !tbaa !9
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef @.str.6, ptr noundef %85) #6
  br label %290

87:                                               ; preds = %76
  %88 = load ptr, ptr %8, align 8, !tbaa !9
  %89 = load ptr, ptr %8, align 8, !tbaa !9
  %90 = call i64 @strlen(ptr noundef %89) #7
  %91 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  %92 = call i32 @hex_to_bytes(ptr noundef %88, i64 noundef %90, ptr noundef %91, ptr noundef %13)
  %93 = icmp ne i32 %92, 1
  br i1 %93, label %94, label %98

94:                                               ; preds = %87
  %95 = load ptr, ptr @stderr, align 8, !tbaa !9
  %96 = load ptr, ptr %7, align 8, !tbaa !9
  %97 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef @.str.7, ptr noundef %96) #6
  br label %290

98:                                               ; preds = %87
  br label %199

99:                                               ; preds = %66
  %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) #7
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %132, 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 %190

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 %9, align 8, !tbaa !9
  %113 = load ptr, ptr %9, align 8, !tbaa !9
  %114 = call i64 @strlen(ptr noundef %113) #7
  %115 = icmp ne i64 %114, 32
  br i1 %115, label %116, label %120

116:                                              ; preds = %109
  %117 = load ptr, ptr @stderr, align 8, !tbaa !9
  %118 = load ptr, ptr %7, align 8, !tbaa !9
  %119 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %117, ptr noundef @.str.9, ptr noundef %118) #6
  br label %290

120:                                              ; preds = %109
  %121 = load ptr, ptr %9, align 8, !tbaa !9
  %122 = load ptr, ptr %9, align 8, !tbaa !9
  %123 = call i64 @strlen(ptr noundef %122) #7
  %124 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 0
  %125 = call i32 @hex_to_bytes(ptr noundef %121, i64 noundef %123, ptr noundef %124, ptr noundef %15)
  %126 = icmp ne i32 %125, 1
  br i1 %126, label %127, label %131

127:                                              ; preds = %120
  %128 = load ptr, ptr @stderr, align 8, !tbaa !9
  %129 = load ptr, ptr %7, align 8, !tbaa !9
  %130 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %128, ptr noundef @.str.10, ptr noundef %129) #6
  br label %290

131:                                              ; preds = %120
  br label %198

132:                                              ; preds = %99
  %133 = load ptr, ptr %5, align 8, !tbaa !9
  %134 = load ptr, ptr %133, align 8, !tbaa !9
  %135 = call i32 @strcmp(ptr noundef %134, ptr noundef @.str.11) #7
  %136 = icmp ne i32 %135, 0
  br i1 %136, label %158, label %137

137:                                              ; preds = %132
  %138 = load i32, ptr %4, align 4, !tbaa !5
  %139 = add nsw i32 %138, -1
  store i32 %139, ptr %4, align 4, !tbaa !5
  %140 = icmp slt i32 %139, 1
  br i1 %140, label %141, label %142

141:                                              ; preds = %137
  br label %190

142:                                              ; preds = %137
  %143 = load ptr, ptr %5, align 8, !tbaa !9
  %144 = getelementptr inbounds ptr, ptr %143, i32 1
  store ptr %144, ptr %5, align 8, !tbaa !9
  %145 = load ptr, ptr %144, align 8, !tbaa !9
  store ptr %145, ptr %10, align 8, !tbaa !9
  %146 = load ptr, ptr %10, align 8, !tbaa !9
  %147 = call noalias ptr @fopen(ptr noundef %146, ptr noundef @.str.12)
  store ptr %147, ptr %16, align 8, !tbaa !9
  %148 = icmp ne ptr %147, null
  br i1 %148, label %157, label %149

149:                                              ; preds = %142
  %150 = load ptr, ptr @stderr, align 8, !tbaa !9
  %151 = load ptr, ptr %7, align 8, !tbaa !9
  %152 = load ptr, ptr %10, align 8, !tbaa !9
  %153 = call ptr @__errno_location() #8
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = call ptr @strerror(i32 noundef %154) #6
  %156 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %150, ptr noundef @.str.13, ptr noundef %151, ptr noundef %152, ptr noundef %155) #6
  br label %290

157:                                              ; preds = %142
  br label %197

158:                                              ; preds = %132
  %159 = load ptr, ptr %5, align 8, !tbaa !9
  %160 = load ptr, ptr %159, align 8, !tbaa !9
  %161 = call i32 @strcmp(ptr noundef %160, ptr noundef @.str.14) #7
  %162 = icmp ne i32 %161, 0
  br i1 %162, label %184, label %163

163:                                              ; preds = %158
  %164 = load i32, ptr %4, align 4, !tbaa !5
  %165 = add nsw i32 %164, -1
  store i32 %165, ptr %4, align 4, !tbaa !5
  %166 = icmp slt i32 %165, 1
  br i1 %166, label %167, label %168

167:                                              ; preds = %163
  br label %190

168:                                              ; preds = %163
  %169 = load ptr, ptr %5, align 8, !tbaa !9
  %170 = getelementptr inbounds ptr, ptr %169, i32 1
  store ptr %170, ptr %5, align 8, !tbaa !9
  %171 = load ptr, ptr %170, align 8, !tbaa !9
  store ptr %171, ptr %11, align 8, !tbaa !9
  %172 = load ptr, ptr %11, align 8, !tbaa !9
  %173 = call noalias ptr @fopen(ptr noundef %172, ptr noundef @.str.15)
  store ptr %173, ptr %17, align 8, !tbaa !9
  %174 = icmp ne ptr %173, null
  br i1 %174, label %183, label %175

175:                                              ; preds = %168
  %176 = load ptr, ptr @stderr, align 8, !tbaa !9
  %177 = load ptr, ptr %7, align 8, !tbaa !9
  %178 = load ptr, ptr %11, align 8, !tbaa !9
  %179 = call ptr @__errno_location() #8
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = call ptr @strerror(i32 noundef %180) #6
  %182 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %176, ptr noundef @.str.13, ptr noundef %177, ptr noundef %178, ptr noundef %181) #6
  br label %290

183:                                              ; preds = %168
  br label %196

184:                                              ; preds = %158
  %185 = load ptr, ptr @stderr, align 8, !tbaa !9
  %186 = load ptr, ptr %7, align 8, !tbaa !9
  %187 = load ptr, ptr %5, align 8, !tbaa !9
  %188 = load ptr, ptr %187, align 8, !tbaa !9
  %189 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %185, ptr noundef @.str.16, ptr noundef %186, ptr noundef %188) #6
  br label %290

190:                                              ; preds = %167, %141, %108, %75
  %191 = load ptr, ptr @stderr, align 8, !tbaa !9
  %192 = load ptr, ptr %7, align 8, !tbaa !9
  %193 = load ptr, ptr %5, align 8, !tbaa !9
  %194 = load ptr, ptr %193, align 8, !tbaa !9
  %195 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %191, ptr noundef @.str.17, ptr noundef %192, ptr noundef %194) #6
  br label %290

196:                                              ; preds = %183
  br label %197

197:                                              ; preds = %196, %157
  br label %198

198:                                              ; preds = %197, %131
  br label %199

199:                                              ; preds = %198, %98
  br label %200

200:                                              ; preds = %199, %65
  br label %201

201:                                              ; preds = %200, %59
  br label %202

202:                                              ; preds = %201
  %203 = load i32, ptr %4, align 4, !tbaa !5
  %204 = add nsw i32 %203, -1
  store i32 %204, ptr %4, align 4, !tbaa !5
  %205 = load ptr, ptr %5, align 8, !tbaa !9
  %206 = getelementptr inbounds ptr, ptr %205, i32 1
  store ptr %206, ptr %5, align 8, !tbaa !9
  br label %40, !llvm.loop !11

207:                                              ; preds = %40
  %208 = load ptr, ptr %8, align 8, !tbaa !9
  %209 = icmp ne ptr %208, null
  br i1 %209, label %214, label %210

210:                                              ; preds = %207
  %211 = load ptr, ptr @stderr, align 8, !tbaa !9
  %212 = load ptr, ptr %7, align 8, !tbaa !9
  %213 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %211, ptr noundef @.str.18, ptr noundef %212) #6
  br label %290

214:                                              ; preds = %207
  %215 = load ptr, ptr %9, align 8, !tbaa !9
  %216 = icmp ne ptr %215, null
  br i1 %216, label %221, label %217

217:                                              ; preds = %214
  %218 = load ptr, ptr @stderr, align 8, !tbaa !9
  %219 = load ptr, ptr %7, align 8, !tbaa !9
  %220 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %218, ptr noundef @.str.19, ptr noundef %219) #6
  br label %290

221:                                              ; preds = %214
  %222 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  %223 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 0
  %224 = call i32 @sm4_ctr_encrypt_init(ptr noundef %18, ptr noundef %222, ptr noundef %223)
  %225 = icmp ne i32 %224, 1
  br i1 %225, label %226, label %232

226:                                              ; preds = %221
  br label %227

227:                                              ; preds = %226
  %228 = load ptr, ptr @stderr, align 8, !tbaa !9
  %229 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %228, ptr noundef @.str.20, ptr noundef @.str.21, i32 noundef 138, ptr noundef @__FUNCTION__.sm4_ctr_main) #6
  br label %230

230:                                              ; preds = %227
  br label %231

231:                                              ; preds = %230
  br label %290

232:                                              ; preds = %221
  br label %233

233:                                              ; preds = %264, %232
  %234 = getelementptr inbounds [4096 x i8], ptr %19, i64 0, i64 0
  %235 = load ptr, ptr %16, align 8, !tbaa !9
  %236 = call i64 @fread(ptr noundef %234, i64 noundef 1, i64 noundef 4096, ptr noundef %235)
  store i64 %236, ptr %20, align 8, !tbaa !13
  %237 = icmp ugt i64 %236, 0
  br i1 %237, label %238, label %265

238:                                              ; preds = %233
  %239 = getelementptr inbounds [4096 x i8], ptr %19, i64 0, i64 0
  %240 = load i64, ptr %20, align 8, !tbaa !13
  %241 = getelementptr inbounds [4096 x i8], ptr %19, i64 0, i64 0
  %242 = call i32 @sm4_ctr_encrypt_update(ptr noundef %18, ptr noundef %239, i64 noundef %240, ptr noundef %241, ptr noundef %21)
  %243 = icmp ne i32 %242, 1
  br i1 %243, label %244, label %250

244:                                              ; preds = %238
  br label %245

245:                                              ; preds = %244
  %246 = load ptr, ptr @stderr, align 8, !tbaa !9
  %247 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %246, ptr noundef @.str.20, ptr noundef @.str.21, i32 noundef 144, ptr noundef @__FUNCTION__.sm4_ctr_main) #6
  br label %248

248:                                              ; preds = %245
  br label %249

249:                                              ; preds = %248
  br label %290

250:                                              ; preds = %238
  %251 = getelementptr inbounds [4096 x i8], ptr %19, i64 0, i64 0
  %252 = load i64, ptr %21, align 8, !tbaa !13
  %253 = load ptr, ptr %17, align 8, !tbaa !9
  %254 = call i64 @fwrite(ptr noundef %251, i64 noundef 1, i64 noundef %252, ptr noundef %253)
  %255 = load i64, ptr %21, align 8, !tbaa !13
  %256 = icmp ne i64 %254, %255
  br i1 %256, label %257, label %264

257:                                              ; preds = %250
  %258 = load ptr, ptr @stderr, align 8, !tbaa !9
  %259 = load ptr, ptr %7, align 8, !tbaa !9
  %260 = call ptr @__errno_location() #8
  %261 = load i32, ptr %260, align 4, !tbaa !5
  %262 = call ptr @strerror(i32 noundef %261) #6
  %263 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %258, ptr noundef @.str.22, ptr noundef %259, ptr noundef %262) #6
  br label %290

264:                                              ; preds = %250
  br label %233, !llvm.loop !15

265:                                              ; preds = %233
  %266 = getelementptr inbounds [4096 x i8], ptr %19, i64 0, i64 0
  %267 = call i32 @sm4_ctr_encrypt_finish(ptr noundef %18, ptr noundef %266, ptr noundef %21)
  %268 = icmp ne i32 %267, 1
  br i1 %268, label %269, label %275

269:                                              ; preds = %265
  br label %270

270:                                              ; preds = %269
  %271 = load ptr, ptr @stderr, align 8, !tbaa !9
  %272 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %271, ptr noundef @.str.20, ptr noundef @.str.21, i32 noundef 154, ptr noundef @__FUNCTION__.sm4_ctr_main) #6
  br label %273

273:                                              ; preds = %270
  br label %274

274:                                              ; preds = %273
  br label %290

275:                                              ; preds = %265
  %276 = getelementptr inbounds [4096 x i8], ptr %19, i64 0, i64 0
  %277 = load i64, ptr %21, align 8, !tbaa !13
  %278 = load ptr, ptr %17, align 8, !tbaa !9
  %279 = call i64 @fwrite(ptr noundef %276, i64 noundef 1, i64 noundef %277, ptr noundef %278)
  %280 = load i64, ptr %21, align 8, !tbaa !13
  %281 = icmp ne i64 %279, %280
  br i1 %281, label %282, label %289

282:                                              ; preds = %275
  %283 = load ptr, ptr @stderr, align 8, !tbaa !9
  %284 = load ptr, ptr %7, align 8, !tbaa !9
  %285 = call ptr @__errno_location() #8
  %286 = load i32, ptr %285, align 4, !tbaa !5
  %287 = call ptr @strerror(i32 noundef %286) #6
  %288 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %283, ptr noundef @.str.22, ptr noundef %284, ptr noundef %287) #6
  br label %290

289:                                              ; preds = %275
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %290

290:                                              ; preds = %289, %282, %274, %257, %249, %231, %217, %210, %190, %184, %175, %149, %127, %116, %94, %83, %48
  %291 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %291, i64 noundef 16)
  %292 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %292, i64 noundef 16)
  call void @gmssl_secure_clear(ptr noundef %18, i64 noundef 168)
  %293 = getelementptr inbounds [4096 x i8], ptr %19, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %293, i64 noundef 4096)
  %294 = load ptr, ptr %10, align 8, !tbaa !9
  %295 = icmp ne ptr %294, null
  br i1 %295, label %296, label %302

296:                                              ; preds = %290
  %297 = load ptr, ptr %16, align 8, !tbaa !9
  %298 = icmp ne ptr %297, null
  br i1 %298, label %299, label %302

299:                                              ; preds = %296
  %300 = load ptr, ptr %16, align 8, !tbaa !9
  %301 = call i32 @fclose(ptr noundef %300)
  br label %302

302:                                              ; preds = %299, %296, %290
  %303 = load ptr, ptr %11, align 8, !tbaa !9
  %304 = icmp ne ptr %303, null
  br i1 %304, label %305, label %311

305:                                              ; preds = %302
  %306 = load ptr, ptr %17, align 8, !tbaa !9
  %307 = icmp ne ptr %306, null
  br i1 %307, label %308, label %311

308:                                              ; preds = %305
  %309 = load ptr, ptr %17, align 8, !tbaa !9
  %310 = call i32 @fclose(ptr noundef %309)
  br label %311

311:                                              ; preds = %308, %305, %302
  %312 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %312, ptr %3, align 4
  store i32 1, ptr %22, align 4
  br label %313

313:                                              ; preds = %311, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4096, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 168, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %314 = load i32, ptr %3, align 4
  ret i32 %314
}

; 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

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

declare i32 @hex_to_bytes(ptr noundef, i64 noundef, ptr noundef, 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 @sm4_ctr_encrypt_init(ptr noundef, ptr noundef, ptr noundef) #4

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

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

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

declare i32 @sm4_ctr_encrypt_finish(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 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 }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { nounwind willreturn memory(none) }

!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}
!15 = distinct !{!15, !12}


; 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.SM4_CTR_CTX = type { %struct.SM4_KEY, [16 x i8], [16 x i8], i64 }
%struct.SM4_KEY = type { [32 x i32] }

@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 [20 x i8], align 1
@usage = 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 [4 x i8], align 1
@options = external hidden local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [63 x i8], align 1
@__FUNCTION__.sm4_ctr_main = external hidden unnamed_addr constant [13 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @sm4_ctr_main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [16 x i8], align 16
  %4 = alloca i64, align 8
  %5 = alloca [16 x i8], align 16
  %6 = alloca i64, align 8
  %7 = alloca %struct.SM4_CTR_CTX, align 8
  %8 = alloca [4096 x i8], align 16
  %9 = alloca i64, align 8
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  %11 = load ptr, ptr @stdin, align 8, !tbaa !5
  %12 = load ptr, ptr @stdout, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 168, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #7
  %13 = icmp slt i32 %0, 2
  br i1 %13, label %14, label %.preheader115

14:                                               ; preds = %2
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = load ptr, ptr @usage, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str, ptr noundef %10, ptr noundef %16) #8
  br label %155

.preheader115:                                    ; preds = %2, %99
  %.064189 = phi ptr [ %.1, %99 ], [ %12, %2 ]
  %.065188 = phi ptr [ %.166, %99 ], [ %11, %2 ]
  %.068187 = phi ptr [ %.169, %99 ], [ null, %2 ]
  %.071186 = phi ptr [ %.172, %99 ], [ null, %2 ]
  %.074185 = phi ptr [ %.175, %99 ], [ null, %2 ]
  %.076184 = phi ptr [ %.177, %99 ], [ null, %2 ]
  %.078.in183 = phi i32 [ %.179, %99 ], [ %0, %2 ]
  %.pn182 = phi ptr [ %.182, %99 ], [ %1, %2 ]
  %.081190 = getelementptr inbounds i8, ptr %.pn182, i64 8
  %.078191 = add nsw i32 %.078.in183, -1
  %18 = load ptr, ptr %.081190, align 8, !tbaa !5
  %19 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) @.str.1) #9
  %.not102 = icmp eq i32 %19, 0
  br i1 %.not102, label %20, label %25

20:                                               ; preds = %.preheader115
  %21 = load ptr, ptr @usage, align 8, !tbaa !5
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %10, ptr noundef %21)
  %23 = load ptr, ptr @options, align 8, !tbaa !5
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %23)
  br label %145

25:                                               ; preds = %.preheader115
  %26 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) @.str.3) #9
  %.not103 = icmp eq i32 %26, 0
  br i1 %.not103, label %99, label %27

27:                                               ; preds = %25
  %28 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) @.str.4) #9
  %.not104 = icmp eq i32 %28, 0
  br i1 %.not104, label %99, label %29

29:                                               ; preds = %27
  %30 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) @.str.5) #9
  %.not105 = icmp eq i32 %30, 0
  br i1 %.not105, label %31, label %46

31:                                               ; preds = %29
  %32 = add nsw i32 %.078.in183, -2
  %33 = icmp eq i32 %.078.in183, 2
  br i1 %33, label %96, label %34

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %.pn182, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %36) #9
  %.not106 = icmp eq i64 %37, 32
  br i1 %.not106, label %41, label %38

38:                                               ; preds = %34
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.6, ptr noundef %10) #8
  br label %145

41:                                               ; preds = %34
  %42 = call i32 @hex_to_bytes(ptr noundef %36, i64 noundef 32, ptr noundef nonnull %3, ptr noundef nonnull %4) #7
  %.not107 = icmp eq i32 %42, 1
  br i1 %.not107, label %99, label %43

43:                                               ; preds = %41
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.7, ptr noundef %10) #8
  br label %145

46:                                               ; preds = %29
  %47 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) @.str.8) #9
  %.not108 = icmp eq i32 %47, 0
  br i1 %.not108, label %48, label %63

48:                                               ; preds = %46
  %49 = add nsw i32 %.078.in183, -2
  %50 = icmp eq i32 %.078.in183, 2
  br i1 %50, label %96, label %51

51:                                               ; preds = %48
  %52 = getelementptr inbounds i8, ptr %.pn182, i64 16
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %53) #9
  %.not109 = icmp eq i64 %54, 32
  br i1 %.not109, label %58, label %55

55:                                               ; preds = %51
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef nonnull @.str.9, ptr noundef %10) #8
  br label %145

58:                                               ; preds = %51
  %59 = call i32 @hex_to_bytes(ptr noundef %53, i64 noundef 32, ptr noundef nonnull %5, ptr noundef nonnull %6) #7
  %.not110 = icmp eq i32 %59, 1
  br i1 %.not110, label %99, label %60

60:                                               ; preds = %58
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef nonnull @.str.10, ptr noundef %10) #8
  br label %145

63:                                               ; preds = %46
  %64 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) @.str.11) #9
  %.not111 = icmp eq i32 %64, 0
  br i1 %.not111, label %65, label %78

65:                                               ; preds = %63
  %66 = icmp eq i32 %.078.in183, 2
  br i1 %66, label %96, label %67

67:                                               ; preds = %65
  %68 = add nsw i32 %.078.in183, -2
  %69 = getelementptr inbounds i8, ptr %.pn182, i64 16
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = call noalias ptr @fopen(ptr noundef %70, ptr noundef nonnull @.str.12)
  %.not112 = icmp eq ptr %71, null
  br i1 %.not112, label %72, label %99

72:                                               ; preds = %67
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = tail call ptr @__errno_location() #10
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = call ptr @strerror(i32 noundef %75) #7
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef nonnull @.str.13, ptr noundef %10, ptr noundef %70, ptr noundef %76) #8
  br label %145

78:                                               ; preds = %63
  %79 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) @.str.14) #9
  %.not113 = icmp eq i32 %79, 0
  br i1 %.not113, label %80, label %93

80:                                               ; preds = %78
  %81 = icmp eq i32 %.078.in183, 2
  br i1 %81, label %96, label %82

82:                                               ; preds = %80
  %83 = add nsw i32 %.078.in183, -2
  %84 = getelementptr inbounds i8, ptr %.pn182, i64 16
  %85 = load ptr, ptr %84, align 8, !tbaa !5
  %86 = call noalias ptr @fopen(ptr noundef %85, ptr noundef nonnull @.str.15)
  %.not114 = icmp eq ptr %86, null
  br i1 %.not114, label %87, label %99

87:                                               ; preds = %82
  %88 = load ptr, ptr @stderr, align 8, !tbaa !5
  %89 = tail call ptr @__errno_location() #10
  %90 = load i32, ptr %89, align 4, !tbaa !9
  %91 = call ptr @strerror(i32 noundef %90) #7
  %92 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef nonnull @.str.13, ptr noundef %10, ptr noundef %85, ptr noundef %91) #8
  br label %145

93:                                               ; preds = %78
  %94 = load ptr, ptr @stderr, align 8, !tbaa !5
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef nonnull @.str.16, ptr noundef %10, ptr noundef %18) #8
  br label %145

96:                                               ; preds = %80, %65, %48, %31
  %97 = load ptr, ptr @stderr, align 8, !tbaa !5
  %98 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %97, ptr noundef nonnull @.str.17, ptr noundef %10, ptr noundef %18) #8
  br label %145

99:                                               ; preds = %25, %41, %67, %82, %58, %27
  %.182 = phi ptr [ %84, %82 ], [ %69, %67 ], [ %52, %58 ], [ %35, %41 ], [ %.081190, %27 ], [ %.081190, %25 ]
  %.179 = phi i32 [ %83, %82 ], [ %68, %67 ], [ %49, %58 ], [ %32, %41 ], [ %.078191, %27 ], [ %.078191, %25 ]
  %.177 = phi ptr [ %.076184, %82 ], [ %.076184, %67 ], [ %.076184, %58 ], [ %36, %41 ], [ %.076184, %27 ], [ %.076184, %25 ]
  %.175 = phi ptr [ %.074185, %82 ], [ %.074185, %67 ], [ %53, %58 ], [ %.074185, %41 ], [ %.074185, %27 ], [ %.074185, %25 ]
  %.172 = phi ptr [ %.071186, %82 ], [ %70, %67 ], [ %.071186, %58 ], [ %.071186, %41 ], [ %.071186, %27 ], [ %.071186, %25 ]
  %.169 = phi ptr [ %85, %82 ], [ %.068187, %67 ], [ %.068187, %58 ], [ %.068187, %41 ], [ %.068187, %27 ], [ %.068187, %25 ]
  %.166 = phi ptr [ %.065188, %82 ], [ %71, %67 ], [ %.065188, %58 ], [ %.065188, %41 ], [ %.065188, %27 ], [ %.065188, %25 ]
  %.1 = phi ptr [ %86, %82 ], [ %.064189, %67 ], [ %.064189, %58 ], [ %.064189, %41 ], [ %.064189, %27 ], [ %.064189, %25 ]
  %100 = icmp sgt i32 %.179, 1
  br i1 %100, label %.preheader115, label %101, !llvm.loop !11

101:                                              ; preds = %99
  %.not = icmp eq ptr %.177, null
  br i1 %.not, label %102, label %105

102:                                              ; preds = %101
  %103 = load ptr, ptr @stderr, align 8, !tbaa !5
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef nonnull @.str.18, ptr noundef %10) #8
  br label %145

105:                                              ; preds = %101
  %.not95 = icmp eq ptr %.175, null
  br i1 %.not95, label %106, label %109

106:                                              ; preds = %105
  %107 = load ptr, ptr @stderr, align 8, !tbaa !5
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef nonnull @.str.19, ptr noundef %10) #8
  br label %145

109:                                              ; preds = %105
  %110 = call i32 @sm4_ctr_encrypt_init(ptr noundef nonnull %7, ptr noundef nonnull %3, ptr noundef nonnull %5) #7
  %.not96 = icmp eq i32 %110, 1
  br i1 %.not96, label %.preheader, label %111

111:                                              ; preds = %109
  %112 = load ptr, ptr @stderr, align 8, !tbaa !5
  %113 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %112, ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.21, i32 noundef 138, ptr noundef nonnull @__FUNCTION__.sm4_ctr_main) #8
  br label %145

.preheader:                                       ; preds = %109, %120
  %114 = call i64 @fread(ptr noundef nonnull %8, i64 noundef 1, i64 noundef 4096, ptr noundef %.166)
  %.not97 = icmp eq i64 %114, 0
  br i1 %.not97, label %130, label %115

115:                                              ; preds = %.preheader
  %116 = call i32 @sm4_ctr_encrypt_update(ptr noundef nonnull %7, ptr noundef nonnull %8, i64 noundef %114, ptr noundef nonnull %8, ptr noundef nonnull %9) #7
  %.not100 = icmp eq i32 %116, 1
  br i1 %.not100, label %120, label %117

117:                                              ; preds = %115
  %118 = load ptr, ptr @stderr, align 8, !tbaa !5
  %119 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %118, ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.21, i32 noundef 144, ptr noundef nonnull @__FUNCTION__.sm4_ctr_main) #8
  br label %145

120:                                              ; preds = %115
  %121 = load i64, ptr %9, align 8, !tbaa !13
  %122 = call i64 @fwrite(ptr noundef nonnull %8, i64 noundef 1, i64 noundef %121, ptr noundef %.1)
  %123 = load i64, ptr %9, align 8, !tbaa !13
  %.not101 = icmp eq i64 %122, %123
  br i1 %.not101, label %.preheader, label %124, !llvm.loop !15

124:                                              ; preds = %120
  %125 = load ptr, ptr @stderr, align 8, !tbaa !5
  %126 = tail call ptr @__errno_location() #10
  %127 = load i32, ptr %126, align 4, !tbaa !9
  %128 = call ptr @strerror(i32 noundef %127) #7
  %129 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %125, ptr noundef nonnull @.str.22, ptr noundef %10, ptr noundef %128) #8
  br label %145

130:                                              ; preds = %.preheader
  %131 = call i32 @sm4_ctr_encrypt_finish(ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9) #7
  %.not98 = icmp eq i32 %131, 1
  br i1 %.not98, label %135, label %132

132:                                              ; preds = %130
  %133 = load ptr, ptr @stderr, align 8, !tbaa !5
  %134 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %133, ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.21, i32 noundef 154, ptr noundef nonnull @__FUNCTION__.sm4_ctr_main) #8
  br label %145

135:                                              ; preds = %130
  %136 = load i64, ptr %9, align 8, !tbaa !13
  %137 = call i64 @fwrite(ptr noundef nonnull %8, i64 noundef 1, i64 noundef %136, ptr noundef %.1)
  %138 = load i64, ptr %9, align 8, !tbaa !13
  %.not99 = icmp eq i64 %137, %138
  br i1 %.not99, label %145, label %139

139:                                              ; preds = %135
  %140 = load ptr, ptr @stderr, align 8, !tbaa !5
  %141 = tail call ptr @__errno_location() #10
  %142 = load i32, ptr %141, align 4, !tbaa !9
  %143 = call ptr @strerror(i32 noundef %142) #7
  %144 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %140, ptr noundef nonnull @.str.22, ptr noundef %10, ptr noundef %143) #8
  br label %145

145:                                              ; preds = %135, %139, %132, %124, %117, %111, %106, %102, %96, %93, %87, %72, %60, %55, %43, %38, %20
  %.080 = phi i32 [ 1, %93 ], [ 1, %96 ], [ 1, %87 ], [ 1, %72 ], [ 1, %55 ], [ 1, %60 ], [ 1, %38 ], [ 1, %43 ], [ 0, %20 ], [ 1, %111 ], [ 1, %117 ], [ 1, %124 ], [ 1, %132 ], [ 1, %139 ], [ 1, %106 ], [ 1, %102 ], [ 0, %135 ]
  %.273 = phi ptr [ %.071186, %93 ], [ %.071186, %96 ], [ %.071186, %87 ], [ %70, %72 ], [ %.071186, %55 ], [ %.071186, %60 ], [ %.071186, %38 ], [ %.071186, %43 ], [ %.071186, %20 ], [ %.172, %111 ], [ %.172, %117 ], [ %.172, %124 ], [ %.172, %132 ], [ %.172, %139 ], [ %.172, %106 ], [ %.172, %102 ], [ %.172, %135 ]
  %.270 = phi ptr [ %.068187, %93 ], [ %.068187, %96 ], [ %85, %87 ], [ %.068187, %72 ], [ %.068187, %55 ], [ %.068187, %60 ], [ %.068187, %38 ], [ %.068187, %43 ], [ %.068187, %20 ], [ %.169, %111 ], [ %.169, %117 ], [ %.169, %124 ], [ %.169, %132 ], [ %.169, %139 ], [ %.169, %106 ], [ %.169, %102 ], [ %.169, %135 ]
  %.267 = phi ptr [ %.065188, %93 ], [ %.065188, %96 ], [ %.065188, %87 ], [ null, %72 ], [ %.065188, %55 ], [ %.065188, %60 ], [ %.065188, %38 ], [ %.065188, %43 ], [ %.065188, %20 ], [ %.166, %111 ], [ %.166, %117 ], [ %.166, %124 ], [ %.166, %132 ], [ %.166, %139 ], [ %.166, %106 ], [ %.166, %102 ], [ %.166, %135 ]
  %.2 = phi ptr [ %.064189, %93 ], [ %.064189, %96 ], [ null, %87 ], [ %.064189, %72 ], [ %.064189, %55 ], [ %.064189, %60 ], [ %.064189, %38 ], [ %.064189, %43 ], [ %.064189, %20 ], [ %.1, %111 ], [ %.1, %117 ], [ %.1, %124 ], [ %.1, %132 ], [ %.1, %139 ], [ %.1, %106 ], [ %.1, %102 ], [ %.1, %135 ]
  call void @gmssl_secure_clear(ptr noundef nonnull %3, i64 noundef 16) #7
  call void @gmssl_secure_clear(ptr noundef nonnull %5, i64 noundef 16) #7
  call void @gmssl_secure_clear(ptr noundef nonnull %7, i64 noundef 168) #7
  call void @gmssl_secure_clear(ptr noundef nonnull %8, i64 noundef 4096) #7
  %146 = icmp ne ptr %.273, null
  %147 = icmp ne ptr %.267, null
  %or.cond = select i1 %146, i1 %147, i1 false
  br i1 %or.cond, label %148, label %150

148:                                              ; preds = %145
  %149 = call i32 @fclose(ptr noundef nonnull %.267)
  br label %150

150:                                              ; preds = %148, %145
  %151 = icmp ne ptr %.270, null
  %152 = icmp ne ptr %.2, null
  %or.cond3 = select i1 %151, i1 %152, i1 false
  br i1 %or.cond3, label %153, label %155

153:                                              ; preds = %150
  %154 = call i32 @fclose(ptr noundef nonnull %.2)
  br label %155

155:                                              ; preds = %150, %153, %14
  %.0 = phi i32 [ 1, %14 ], [ %.080, %153 ], [ %.080, %150 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 168, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  ret i32 %.0
}

; 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

declare i32 @hex_to_bytes(ptr noundef, i64 noundef, ptr noundef, 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

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

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

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

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

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

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

declare i32 @sm4_ctr_encrypt_finish(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 "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 = { 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 #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { nounwind willreturn memory(none) }

!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}
!15 = distinct !{!15, !12}


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