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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.SM9_ENC_MASTER_KEY = type { %struct.SM9_Z256_POINT, [4 x i64] }
%struct.SM9_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }

@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 [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [66 x i8], align 1
@__FUNCTION__.sm9encrypt_main = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [31 x i8], align 1

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

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

37:                                               ; preds = %2
  br label %38

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

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

46:                                               ; preds = %41
  %47 = load ptr, ptr %7, align 8, !tbaa !9
  %48 = load ptr, ptr @usage, align 8, !tbaa !9
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %47, ptr noundef %48)
  %50 = load ptr, ptr @options, align 8, !tbaa !9
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %50)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %20, align 4
  br label %242

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

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

61:                                               ; preds = %57
  br label %139

62:                                               ; preds = %57
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = getelementptr inbounds ptr, ptr %63, i32 1
  store ptr %64, ptr %5, align 8, !tbaa !9
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  store ptr %65, ptr %8, align 8, !tbaa !9
  %66 = load ptr, ptr %8, align 8, !tbaa !9
  %67 = call noalias ptr @fopen(ptr noundef %66, ptr noundef @.str.4)
  store ptr %67, ptr %12, align 8, !tbaa !9
  %68 = icmp ne ptr %67, null
  br i1 %68, label %75, label %69

69:                                               ; preds = %62
  br label %70

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

73:                                               ; preds = %70
  br label %74

74:                                               ; preds = %73
  br label %216

75:                                               ; preds = %62
  br label %148

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

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

85:                                               ; preds = %81
  br label %139

86:                                               ; preds = %81
  %87 = load ptr, ptr %5, align 8, !tbaa !9
  %88 = getelementptr inbounds ptr, ptr %87, i32 1
  store ptr %88, ptr %5, align 8, !tbaa !9
  %89 = load ptr, ptr %88, align 8, !tbaa !9
  store ptr %89, ptr %9, align 8, !tbaa !9
  br label %147

90:                                               ; preds = %76
  %91 = load ptr, ptr %5, align 8, !tbaa !9
  %92 = load ptr, ptr %91, align 8, !tbaa !9
  %93 = call i32 @strcmp(ptr noundef %92, ptr noundef @.str.8) #6
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %114, label %95

95:                                               ; preds = %90
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = add nsw i32 %96, -1
  store i32 %97, ptr %4, align 4, !tbaa !5
  %98 = icmp slt i32 %97, 1
  br i1 %98, label %99, label %100

99:                                               ; preds = %95
  br label %139

100:                                              ; preds = %95
  %101 = load ptr, ptr %5, align 8, !tbaa !9
  %102 = getelementptr inbounds ptr, ptr %101, i32 1
  store ptr %102, ptr %5, align 8, !tbaa !9
  %103 = load ptr, ptr %102, align 8, !tbaa !9
  store ptr %103, ptr %10, align 8, !tbaa !9
  %104 = load ptr, ptr %10, align 8, !tbaa !9
  %105 = call noalias ptr @fopen(ptr noundef %104, ptr noundef @.str.4)
  store ptr %105, ptr %13, align 8, !tbaa !9
  %106 = icmp ne ptr %105, null
  br i1 %106, label %113, label %107

107:                                              ; preds = %100
  br label %108

108:                                              ; preds = %107
  %109 = load ptr, ptr @stderr, align 8, !tbaa !9
  %110 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %109, ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 80, ptr noundef @__FUNCTION__.sm9encrypt_main) #5
  br label %111

111:                                              ; preds = %108
  br label %112

112:                                              ; preds = %111
  br label %216

113:                                              ; preds = %100
  br label %146

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

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

123:                                              ; preds = %119
  br label %139

124:                                              ; preds = %119
  %125 = load ptr, ptr %5, align 8, !tbaa !9
  %126 = getelementptr inbounds ptr, ptr %125, i32 1
  store ptr %126, ptr %5, align 8, !tbaa !9
  %127 = load ptr, ptr %126, align 8, !tbaa !9
  store ptr %127, ptr %11, align 8, !tbaa !9
  %128 = load ptr, ptr %11, align 8, !tbaa !9
  %129 = call noalias ptr @fopen(ptr noundef %128, ptr noundef @.str.10)
  store ptr %129, ptr %14, align 8, !tbaa !9
  %130 = icmp ne ptr %129, null
  br i1 %130, label %137, label %131

131:                                              ; preds = %124
  br label %132

132:                                              ; preds = %131
  %133 = load ptr, ptr @stderr, align 8, !tbaa !9
  %134 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %133, ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 87, ptr noundef @__FUNCTION__.sm9encrypt_main) #5
  br label %135

135:                                              ; preds = %132
  br label %136

136:                                              ; preds = %135
  br label %216

137:                                              ; preds = %124
  br label %145

138:                                              ; preds = %114
  br label %139

139:                                              ; preds = %138, %123, %99, %85, %61
  %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.11, ptr noundef %141, ptr noundef %143) #5
  store i32 1, ptr %3, align 4
  store i32 1, ptr %20, align 4
  br label %242

145:                                              ; preds = %137
  br label %146

146:                                              ; preds = %145, %113
  br label %147

147:                                              ; preds = %146, %86
  br label %148

148:                                              ; preds = %147, %75
  br label %149

149:                                              ; preds = %148
  %150 = load i32, ptr %4, align 4, !tbaa !5
  %151 = add nsw i32 %150, -1
  store i32 %151, ptr %4, align 4, !tbaa !5
  %152 = load ptr, ptr %5, align 8, !tbaa !9
  %153 = getelementptr inbounds ptr, ptr %152, i32 1
  store ptr %153, ptr %5, align 8, !tbaa !9
  br label %38, !llvm.loop !13

154:                                              ; preds = %38
  %155 = load ptr, ptr %12, align 8, !tbaa !9
  %156 = icmp ne ptr %155, null
  br i1 %156, label %157, label %160

157:                                              ; preds = %154
  %158 = load ptr, ptr %9, align 8, !tbaa !9
  %159 = icmp ne ptr %158, null
  br i1 %159, label %166, label %160

160:                                              ; preds = %157, %154
  br label %161

161:                                              ; preds = %160
  %162 = load ptr, ptr @stderr, align 8, !tbaa !9
  %163 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %162, ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 101, ptr noundef @__FUNCTION__.sm9encrypt_main) #5
  br label %164

164:                                              ; preds = %161
  br label %165

165:                                              ; preds = %164
  br label %216

166:                                              ; preds = %157
  %167 = load ptr, ptr %12, align 8, !tbaa !9
  %168 = call i32 @sm9_enc_master_public_key_from_pem(ptr noundef %15, ptr 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.5, ptr noundef @.str.6, i32 noundef 105, ptr noundef @__FUNCTION__.sm9encrypt_main) #5
  br label %174

174:                                              ; preds = %171
  br label %175

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

176:                                              ; preds = %166
  %177 = getelementptr inbounds [255 x i8], ptr %16, i64 0, i64 0
  %178 = load ptr, ptr %13, align 8, !tbaa !9
  %179 = call i64 @fread(ptr noundef %177, i64 noundef 1, i64 noundef 255, ptr noundef %178)
  store i64 %179, ptr %18, align 8, !tbaa !11
  %180 = icmp ule i64 %179, 0
  br i1 %180, label %181, label %187

181:                                              ; preds = %176
  br label %182

182:                                              ; preds = %181
  %183 = load ptr, ptr @stderr, align 8, !tbaa !9
  %184 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %183, ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 109, ptr noundef @__FUNCTION__.sm9encrypt_main) #5
  br label %185

185:                                              ; preds = %182
  br label %186

186:                                              ; preds = %185
  br label %216

187:                                              ; preds = %176
  %188 = load ptr, ptr %9, align 8, !tbaa !9
  %189 = load ptr, ptr %9, align 8, !tbaa !9
  %190 = call i64 @strlen(ptr noundef %189) #6
  %191 = getelementptr inbounds [255 x i8], ptr %16, i64 0, i64 0
  %192 = load i64, ptr %18, align 8, !tbaa !11
  %193 = getelementptr inbounds [367 x i8], ptr %17, i64 0, i64 0
  %194 = call i32 @sm9_encrypt(ptr noundef %15, ptr noundef %188, i64 noundef %190, ptr noundef %191, i64 noundef %192, ptr noundef %193, ptr noundef %19)
  %195 = icmp ne i32 %194, 1
  br i1 %195, label %196, label %202

196:                                              ; preds = %187
  br label %197

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

200:                                              ; preds = %197
  br label %201

201:                                              ; preds = %200
  br label %216

202:                                              ; preds = %187
  %203 = load i64, ptr %19, align 8, !tbaa !11
  %204 = getelementptr inbounds [367 x i8], ptr %17, i64 0, i64 0
  %205 = load i64, ptr %19, align 8, !tbaa !11
  %206 = load ptr, ptr %14, align 8, !tbaa !9
  %207 = call i64 @fwrite(ptr noundef %204, i64 noundef 1, i64 noundef %205, ptr noundef %206)
  %208 = icmp ne i64 %203, %207
  br i1 %208, label %209, label %215

209:                                              ; preds = %202
  br label %210

210:                                              ; preds = %209
  %211 = load ptr, ptr @stderr, align 8, !tbaa !9
  %212 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %211, ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 117, ptr noundef @__FUNCTION__.sm9encrypt_main) #5
  br label %213

213:                                              ; preds = %210
  br label %214

214:                                              ; preds = %213
  br label %216

215:                                              ; preds = %202
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %216

216:                                              ; preds = %215, %214, %201, %186, %165, %136, %112, %74
  %217 = load ptr, ptr %10, align 8, !tbaa !9
  %218 = icmp ne ptr %217, null
  br i1 %218, label %219, label %225

219:                                              ; preds = %216
  %220 = load ptr, ptr %13, align 8, !tbaa !9
  %221 = icmp ne ptr %220, null
  br i1 %221, label %222, label %225

222:                                              ; preds = %219
  %223 = load ptr, ptr %13, align 8, !tbaa !9
  %224 = call i32 @fclose(ptr noundef %223)
  br label %225

225:                                              ; preds = %222, %219, %216
  %226 = load ptr, ptr %11, align 8, !tbaa !9
  %227 = icmp ne ptr %226, null
  br i1 %227, label %228, label %234

228:                                              ; preds = %225
  %229 = load ptr, ptr %14, align 8, !tbaa !9
  %230 = icmp ne ptr %229, null
  br i1 %230, label %231, label %234

231:                                              ; preds = %228
  %232 = load ptr, ptr %14, align 8, !tbaa !9
  %233 = call i32 @fclose(ptr noundef %232)
  br label %234

234:                                              ; preds = %231, %228, %225
  %235 = load ptr, ptr %12, align 8, !tbaa !9
  %236 = icmp ne ptr %235, null
  br i1 %236, label %237, label %240

237:                                              ; preds = %234
  %238 = load ptr, ptr %12, align 8, !tbaa !9
  %239 = call i32 @fclose(ptr noundef %238)
  br label %240

240:                                              ; preds = %237, %234
  %241 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %241, ptr %3, align 4
  store i32 1, ptr %20, align 4
  br label %242

242:                                              ; preds = %240, %175, %139, %46, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 367, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 255, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %243 = load i32, ptr %3, align 4
  ret i32 %243
}

; 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

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

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

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

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

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

declare i32 @fclose(ptr noundef) #4

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

%struct.SM9_ENC_MASTER_KEY = type { %struct.SM9_Z256_POINT, [4 x i64] }
%struct.SM9_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }

@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 [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [66 x i8], align 1
@__FUNCTION__.sm9encrypt_main = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @sm9encrypt_main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.SM9_ENC_MASTER_KEY, align 8
  %4 = alloca [255 x i8], align 16
  %5 = alloca [367 x i8], align 16
  %6 = alloca i64, align 8
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = load ptr, ptr @stdin, align 8, !tbaa !5
  %9 = load ptr, ptr @stdout, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 255, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 367, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  store i64 367, ptr %6, align 8, !tbaa !9
  %10 = icmp slt i32 %0, 2
  br i1 %10, label %12, label %.preheader.preheader

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

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

.preheader:                                       ; preds = %.preheader.preheader, %64
  %.049148 = phi ptr [ %.1, %64 ], [ %9, %.preheader.preheader ]
  %.050147 = phi ptr [ %.151, %64 ], [ %8, %.preheader.preheader ]
  %.053146 = phi ptr [ %.154, %64 ], [ null, %.preheader.preheader ]
  %.056145 = phi ptr [ %.157, %64 ], [ null, %.preheader.preheader ]
  %.059144 = phi ptr [ %.160, %64 ], [ null, %.preheader.preheader ]
  %.062143 = phi ptr [ %.163, %64 ], [ null, %.preheader.preheader ]
  %.064.in142 = phi i32 [ %.165, %64 ], [ %0, %.preheader.preheader ]
  %.067141 = phi ptr [ %65, %64 ], [ %11, %.preheader.preheader ]
  %16 = load ptr, ptr %.067141, align 8, !tbaa !5
  %17 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.1) #7
  %.not83 = icmp eq i32 %17, 0
  br i1 %.not83, label %18, label %23

18:                                               ; preds = %.preheader
  %19 = load ptr, ptr @usage, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %7, ptr noundef %19)
  %21 = load ptr, ptr @options, align 8, !tbaa !5
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %21)
  br label %109

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

25:                                               ; preds = %23
  %26 = icmp eq i32 %.064.in142, 2
  br i1 %26, label %61, label %27

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %.067141, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = tail call noalias ptr @fopen(ptr noundef %29, ptr noundef nonnull @.str.4)
  %.not85 = icmp eq ptr %30, null
  br i1 %.not85, label %31, label %64

31:                                               ; preds = %27
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 70, ptr noundef nonnull @__FUNCTION__.sm9encrypt_main) #6
  br label %96

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

36:                                               ; preds = %34
  %37 = icmp eq i32 %.064.in142, 2
  br i1 %37, label %61, label %38

38:                                               ; preds = %36
  %39 = getelementptr inbounds i8, ptr %.067141, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  br label %64

41:                                               ; preds = %34
  %42 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.8) #7
  %.not87 = icmp eq i32 %42, 0
  br i1 %.not87, label %43, label %51

43:                                               ; preds = %41
  %44 = icmp eq i32 %.064.in142, 2
  br i1 %44, label %61, label %45

45:                                               ; preds = %43
  %46 = getelementptr inbounds i8, ptr %.067141, i64 8
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = tail call noalias ptr @fopen(ptr noundef %47, ptr noundef nonnull @.str.4)
  %.not88 = icmp eq ptr %48, null
  br i1 %.not88, label %.thread, label %64

.thread:                                          ; preds = %45
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 80, ptr noundef nonnull @__FUNCTION__.sm9encrypt_main) #6
  br label %101

51:                                               ; preds = %41
  %52 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) @.str.9) #7
  %.not89 = icmp ne i32 %52, 0
  %53 = icmp eq i32 %.064.in142, 2
  %or.cond92 = or i1 %53, %.not89
  br i1 %or.cond92, label %61, label %54

54:                                               ; preds = %51
  %55 = getelementptr inbounds i8, ptr %.067141, i64 8
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = tail call noalias ptr @fopen(ptr noundef %56, ptr noundef nonnull @.str.10)
  %.not90 = icmp eq ptr %57, null
  br i1 %.not90, label %58, label %64

58:                                               ; preds = %54
  %59 = load ptr, ptr @stderr, align 8, !tbaa !5
  %60 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 87, ptr noundef nonnull @__FUNCTION__.sm9encrypt_main) #6
  br label %96

61:                                               ; preds = %51, %43, %36, %25
  %62 = load ptr, ptr @stderr, align 8, !tbaa !5
  %63 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef nonnull @.str.11, ptr noundef %7, ptr noundef %16) #6
  br label %109

64:                                               ; preds = %27, %45, %54, %38
  %.163 = phi ptr [ %.062143, %54 ], [ %.062143, %45 ], [ %40, %38 ], [ %.062143, %27 ]
  %.160 = phi ptr [ %.059144, %54 ], [ %47, %45 ], [ %.059144, %38 ], [ %.059144, %27 ]
  %.157 = phi ptr [ %56, %54 ], [ %.056145, %45 ], [ %.056145, %38 ], [ %.056145, %27 ]
  %.154 = phi ptr [ %.053146, %54 ], [ %.053146, %45 ], [ %.053146, %38 ], [ %30, %27 ]
  %.151 = phi ptr [ %.050147, %54 ], [ %48, %45 ], [ %.050147, %38 ], [ %.050147, %27 ]
  %.1 = phi ptr [ %57, %54 ], [ %.049148, %45 ], [ %.049148, %38 ], [ %.049148, %27 ]
  %.165 = add nsw i32 %.064.in142, -2
  %65 = getelementptr inbounds i8, ptr %.067141, i64 16
  %66 = icmp sgt i32 %.064.in142, 3
  br i1 %66, label %.preheader, label %67, !llvm.loop !11

67:                                               ; preds = %64
  %68 = icmp ne ptr %.154, null
  %69 = icmp ne ptr %.163, null
  %or.cond = select i1 %68, i1 %69, i1 false
  br i1 %or.cond, label %73, label %70

70:                                               ; preds = %67
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 101, ptr noundef nonnull @__FUNCTION__.sm9encrypt_main) #6
  br label %96

73:                                               ; preds = %67
  %74 = call i32 @sm9_enc_master_public_key_from_pem(ptr noundef nonnull %3, ptr noundef nonnull %.154) #5
  %.not = icmp eq i32 %74, 1
  br i1 %.not, label %78, label %75

75:                                               ; preds = %73
  %76 = load ptr, ptr @stderr, align 8, !tbaa !5
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 105, ptr noundef nonnull @__FUNCTION__.sm9encrypt_main) #6
  br label %109

78:                                               ; preds = %73
  %79 = call i64 @fread(ptr noundef nonnull %4, i64 noundef 1, i64 noundef 255, ptr noundef %.151)
  %80 = icmp eq i64 %79, 0
  br i1 %80, label %81, label %84

81:                                               ; preds = %78
  %82 = load ptr, ptr @stderr, align 8, !tbaa !5
  %83 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 109, ptr noundef nonnull @__FUNCTION__.sm9encrypt_main) #6
  br label %96

84:                                               ; preds = %78
  %85 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.163) #7
  %86 = call i32 @sm9_encrypt(ptr noundef nonnull %3, ptr noundef nonnull %.163, i64 noundef %85, ptr noundef nonnull %4, i64 noundef %79, ptr noundef nonnull %5, ptr noundef nonnull %6) #5
  %.not81 = icmp eq i32 %86, 1
  br i1 %.not81, label %90, label %87

87:                                               ; preds = %84
  %88 = load ptr, ptr @stderr, align 8, !tbaa !5
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 113, ptr noundef nonnull @__FUNCTION__.sm9encrypt_main) #6
  br label %96

90:                                               ; preds = %84
  %91 = load i64, ptr %6, align 8, !tbaa !9
  %92 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 1, i64 noundef %91, ptr noundef %.1)
  %.not82 = icmp eq i64 %91, %92
  br i1 %.not82, label %96, label %93

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.5, ptr noundef nonnull @.str.6, i32 noundef 117, ptr noundef nonnull @__FUNCTION__.sm9encrypt_main) #6
  br label %96

96:                                               ; preds = %90, %93, %87, %81, %70, %58, %31
  %.059130 = phi ptr [ %.059144, %58 ], [ %.059144, %31 ], [ %.160, %81 ], [ %.160, %87 ], [ %.160, %93 ], [ %.160, %70 ], [ %.160, %90 ]
  %.050114 = phi ptr [ %.050147, %58 ], [ %.050147, %31 ], [ %.151, %81 ], [ %.151, %87 ], [ %.151, %93 ], [ %.151, %70 ], [ %.151, %90 ]
  %.066 = phi i32 [ 1, %58 ], [ 1, %31 ], [ 1, %81 ], [ 1, %87 ], [ 1, %93 ], [ 1, %70 ], [ 0, %90 ]
  %.258 = phi ptr [ %56, %58 ], [ %.056145, %31 ], [ %.157, %81 ], [ %.157, %87 ], [ %.157, %93 ], [ %.157, %70 ], [ %.157, %90 ]
  %.255 = phi ptr [ %.053146, %58 ], [ null, %31 ], [ %.154, %81 ], [ %.154, %87 ], [ %.154, %93 ], [ %.154, %70 ], [ %.154, %90 ]
  %.2 = phi ptr [ null, %58 ], [ %.049148, %31 ], [ %.1, %81 ], [ %.1, %87 ], [ %.1, %93 ], [ %.1, %70 ], [ %.1, %90 ]
  %97 = icmp ne ptr %.059130, null
  %98 = icmp ne ptr %.050114, null
  %or.cond3 = select i1 %97, i1 %98, i1 false
  br i1 %or.cond3, label %99, label %101

99:                                               ; preds = %96
  %100 = call i32 @fclose(ptr noundef nonnull %.050114)
  br label %101

101:                                              ; preds = %.thread, %99, %96
  %.2103 = phi ptr [ %.049148, %.thread ], [ %.2, %99 ], [ %.2, %96 ]
  %.255102 = phi ptr [ %.053146, %.thread ], [ %.255, %99 ], [ %.255, %96 ]
  %.258101 = phi ptr [ %.056145, %.thread ], [ %.258, %99 ], [ %.258, %96 ]
  %.066100 = phi i32 [ 1, %.thread ], [ %.066, %99 ], [ %.066, %96 ]
  %102 = icmp ne ptr %.258101, null
  %103 = icmp ne ptr %.2103, null
  %or.cond5 = select i1 %102, i1 %103, i1 false
  br i1 %or.cond5, label %104, label %106

104:                                              ; preds = %101
  %105 = call i32 @fclose(ptr noundef nonnull %.2103)
  br label %106

106:                                              ; preds = %104, %101
  %.not91 = icmp eq ptr %.255102, null
  br i1 %.not91, label %109, label %107

107:                                              ; preds = %106
  %108 = call i32 @fclose(ptr noundef nonnull %.255102)
  br label %109

109:                                              ; preds = %106, %107, %75, %61, %18, %12
  %.0 = phi i32 [ 1, %12 ], [ 1, %61 ], [ 0, %18 ], [ -1, %75 ], [ %.066100, %107 ], [ %.066100, %106 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 367, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 255, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #5
  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: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

declare i32 @sm9_enc_master_public_key_from_pem(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 @sm9_encrypt(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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

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

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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