; LLVM IR from devicehive/esp8266-firmware :: esp-utils/esp-flasher.ll (Z10flash_fileP10SerialPortPcjS1_)

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

@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [52 x i8], align 1

declare i32 @printf(ptr noundef, ...) #0

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z9flash_memP10SerialPortPhjj(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #3

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z10flash_fileP10SerialPortPcjS1_(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #3 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca i8, align 1
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 4096, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = call noalias ptr @fopen(ptr noundef %27, ptr noundef @.str.11)
  store ptr %28, ptr %11, align 8, !tbaa !5
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %34, label %31

31:                                               ; preds = %4
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, ptr noundef %32)
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %324

34:                                               ; preds = %4
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = call i32 @fseek(ptr noundef %35, i64 noundef 0, i32 noundef 2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = call i64 @ftell(ptr noundef %37)
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr %13, align 4, !tbaa !9
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = call i32 @fseek(ptr noundef %40, i64 noundef 0, i32 noundef 0)
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, ptr noundef %42, i32 noundef %43)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %45 = load i32, ptr %13, align 4, !tbaa !9
  %46 = uitofp i32 %45 to double
  %47 = fdiv double %46, 4.096000e+03
  %48 = call double @llvm.ceil.f64(double %47)
  %49 = fptoui double %48 to i32
  %50 = mul i32 4096, %49
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = sub i32 %50, %51
  store i32 %52, ptr %14, align 4, !tbaa !9
  %53 = load i32, ptr %14, align 4, !tbaa !9
  %54 = load i32, ptr %14, align 4, !tbaa !9
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = add i32 %54, %55
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i32 noundef %53, i32 noundef %56)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = load i32, ptr %14, align 4, !tbaa !9
  %60 = add i32 %58, %59
  %61 = zext i32 %60 to i64
  %62 = call noalias noundef nonnull ptr @_Znam(i64 noundef %61) #9
  store ptr %62, ptr %15, align 8, !tbaa !5
  %63 = load ptr, ptr %15, align 8, !tbaa !5
  %64 = load i32, ptr %13, align 4, !tbaa !9
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %63, i64 %65
  %67 = load i32, ptr %14, align 4, !tbaa !9
  %68 = zext i32 %67 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %66, i8 -1, i64 %68, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = load i32, ptr %13, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = call i64 @fread(ptr noundef %69, i64 noundef 1, i64 noundef %71, ptr noundef %72)
  %74 = trunc i64 %73 to i32
  store i32 %74, ptr %17, align 4, !tbaa !9
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = call i32 @fclose(ptr noundef %75)
  %77 = load i32, ptr %17, align 4, !tbaa !9
  %78 = load i32, ptr %13, align 4, !tbaa !9
  %79 = icmp ne i32 %77, %78
  br i1 %79, label %80, label %86

80:                                               ; preds = %34
  %81 = load ptr, ptr %15, align 8, !tbaa !5
  %82 = icmp eq ptr %81, null
  br i1 %82, label %84, label %83

83:                                               ; preds = %80
  call void @_ZdaPv(ptr noundef %81) #10
  br label %84

84:                                               ; preds = %83, %80
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %323

86:                                               ; preds = %34
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = icmp ne ptr %87, null
  br i1 %88, label %89, label %163

89:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = call noalias ptr @fopen(ptr noundef %90, ptr noundef @.str.11)
  store ptr %91, ptr %18, align 8, !tbaa !5
  %92 = load ptr, ptr %18, align 8, !tbaa !5
  %93 = icmp ne ptr %92, null
  br i1 %93, label %94, label %143

94:                                               ; preds = %89
  %95 = load i32, ptr %13, align 4, !tbaa !9
  %96 = load i32, ptr %14, align 4, !tbaa !9
  %97 = add i32 %95, %96
  %98 = zext i32 %97 to i64
  %99 = call noalias noundef nonnull ptr @_Znam(i64 noundef %98) #9
  store ptr %99, ptr %16, align 8, !tbaa !5
  %100 = load ptr, ptr %16, align 8, !tbaa !5
  %101 = load i32, ptr %13, align 4, !tbaa !9
  %102 = zext i32 %101 to i64
  %103 = getelementptr inbounds i8, ptr %100, i64 %102
  %104 = load i32, ptr %14, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %103, i8 -1, i64 %105, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  %106 = load ptr, ptr %16, align 8, !tbaa !5
  %107 = load i32, ptr %13, align 4, !tbaa !9
  %108 = zext i32 %107 to i64
  %109 = load ptr, ptr %18, align 8, !tbaa !5
  %110 = call i64 @fread(ptr noundef %106, i64 noundef 1, i64 noundef %108, ptr noundef %109)
  %111 = trunc i64 %110 to i32
  store i32 %111, ptr %19, align 4, !tbaa !9
  %112 = load i32, ptr %19, align 4, !tbaa !9
  %113 = icmp ne i32 %112, 0
  br i1 %113, label %114, label %135

114:                                              ; preds = %94
  br label %115

115:                                              ; preds = %119, %114
  %116 = load i32, ptr %19, align 4, !tbaa !9
  %117 = load i32, ptr %13, align 4, !tbaa !9
  %118 = icmp ult i32 %116, %117
  br i1 %118, label %119, label %134

119:                                              ; preds = %115
  %120 = load ptr, ptr %15, align 8, !tbaa !5
  %121 = load i32, ptr %19, align 4, !tbaa !9
  %122 = zext i32 %121 to i64
  %123 = getelementptr inbounds i8, ptr %120, i64 %122
  %124 = load i8, ptr %123, align 1, !tbaa !11
  %125 = zext i8 %124 to i32
  %126 = xor i32 %125, -1
  %127 = trunc i32 %126 to i8
  %128 = load ptr, ptr %16, align 8, !tbaa !5
  %129 = load i32, ptr %19, align 4, !tbaa !9
  %130 = zext i32 %129 to i64
  %131 = getelementptr inbounds i8, ptr %128, i64 %130
  store i8 %127, ptr %131, align 1, !tbaa !11
  %132 = load i32, ptr %19, align 4, !tbaa !9
  %133 = add i32 %132, 1
  store i32 %133, ptr %19, align 4, !tbaa !9
  br label %115, !llvm.loop !12

134:                                              ; preds = %115
  br label %140

135:                                              ; preds = %94
  %136 = load ptr, ptr %16, align 8, !tbaa !5
  %137 = icmp eq ptr %136, null
  br i1 %137, label %139, label %138

138:                                              ; preds = %135
  call void @_ZdaPv(ptr noundef %136) #10
  br label %139

139:                                              ; preds = %138, %135
  store ptr null, ptr %16, align 8, !tbaa !5
  br label %140

140:                                              ; preds = %139, %134
  %141 = load ptr, ptr %18, align 8, !tbaa !5
  %142 = call i32 @fclose(ptr noundef %141)
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  br label %143

143:                                              ; preds = %140, %89
  %144 = load ptr, ptr %16, align 8, !tbaa !5
  %145 = icmp eq ptr %144, null
  br i1 %145, label %146, label %148

146:                                              ; preds = %143
  %147 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  br label %159

148:                                              ; preds = %143
  %149 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  %150 = load ptr, ptr %15, align 8, !tbaa !5
  %151 = load ptr, ptr %16, align 8, !tbaa !5
  %152 = load i32, ptr %13, align 4, !tbaa !9
  %153 = zext i32 %152 to i64
  %154 = call i32 @memcmp(ptr noundef %150, ptr noundef %151, i64 noundef %153) #11
  %155 = icmp eq i32 %154, 0
  br i1 %155, label %156, label %158

156:                                              ; preds = %148
  %157 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %160

158:                                              ; preds = %148
  br label %159

159:                                              ; preds = %158, %146
  store i32 0, ptr %12, align 4
  br label %160

160:                                              ; preds = %159, %156
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  %161 = load i32, ptr %12, align 4
  switch i32 %161, label %323 [
    i32 0, label %162
  ]

162:                                              ; preds = %160
  br label %163

163:                                              ; preds = %162, %86
  %164 = load i32, ptr %14, align 4, !tbaa !9
  %165 = load i32, ptr %13, align 4, !tbaa !9
  %166 = add i32 %165, %164
  store i32 %166, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #8
  store i8 0, ptr %20, align 1, !tbaa !14
  %167 = load ptr, ptr %16, align 8, !tbaa !5
  %168 = icmp ne ptr %167, null
  br i1 %168, label %169, label %300

169:                                              ; preds = %163
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %170

170:                                              ; preds = %294, %169
  %171 = load i32, ptr %21, align 4, !tbaa !9
  %172 = icmp slt i32 %171, 2
  br i1 %172, label %174, label %173

173:                                              ; preds = %170
  store i32 4, ptr %12, align 4
  br label %297

174:                                              ; preds = %170
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #8
  store i32 0, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #8
  store i32 0, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #8
  store i32 16384, ptr %24, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #8
  store i32 0, ptr %25, align 4, !tbaa !9
  br label %175

175:                                              ; preds = %262, %174
  %176 = load i32, ptr %25, align 4, !tbaa !9
  %177 = load i32, ptr %13, align 4, !tbaa !9
  %178 = icmp ult i32 %176, %177
  br i1 %178, label %180, label %179

179:                                              ; preds = %175
  store i32 7, ptr %12, align 4
  br label %265

180:                                              ; preds = %175
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #8
  store i32 0, ptr %26, align 4, !tbaa !9
  br label %181

181:                                              ; preds = %203, %180
  %182 = load i32, ptr %25, align 4, !tbaa !9
  %183 = load i32, ptr %26, align 4, !tbaa !9
  %184 = add i32 %182, %183
  %185 = load i32, ptr %13, align 4, !tbaa !9
  %186 = icmp ult i32 %184, %185
  br i1 %186, label %187, label %206

187:                                              ; preds = %181
  %188 = load ptr, ptr %15, align 8, !tbaa !5
  %189 = load i32, ptr %25, align 4, !tbaa !9
  %190 = load i32, ptr %26, align 4, !tbaa !9
  %191 = add i32 %189, %190
  %192 = zext i32 %191 to i64
  %193 = getelementptr inbounds i8, ptr %188, i64 %192
  %194 = load ptr, ptr %16, align 8, !tbaa !5
  %195 = load i32, ptr %25, align 4, !tbaa !9
  %196 = load i32, ptr %26, align 4, !tbaa !9
  %197 = add i32 %195, %196
  %198 = zext i32 %197 to i64
  %199 = getelementptr inbounds i8, ptr %194, i64 %198
  %200 = call i32 @memcmp(ptr noundef %193, ptr noundef %199, i64 noundef 4096) #11
  %201 = icmp eq i32 %200, 0
  br i1 %201, label %202, label %203

202:                                              ; preds = %187
  br label %206

203:                                              ; preds = %187
  %204 = load i32, ptr %26, align 4, !tbaa !9
  %205 = add i32 %204, 4096
  store i32 %205, ptr %26, align 4, !tbaa !9
  br label %181, !llvm.loop !16

206:                                              ; preds = %202, %181
  %207 = load i32, ptr %26, align 4, !tbaa !9
  %208 = icmp ne i32 %207, 0
  br i1 %208, label %209, label %258

209:                                              ; preds = %206
  %210 = load i32, ptr %26, align 4, !tbaa !9
  %211 = urem i32 %210, 16384
  %212 = icmp ne i32 %211, 0
  br i1 %212, label %213, label %218

213:                                              ; preds = %209
  %214 = load i32, ptr %26, align 4, !tbaa !9
  %215 = udiv i32 %214, 16384
  %216 = add i32 %215, 1
  %217 = mul i32 %216, 16384
  store i32 %217, ptr %26, align 4, !tbaa !9
  br label %218

218:                                              ; preds = %213, %209
  %219 = load i32, ptr %26, align 4, !tbaa !9
  %220 = load i32, ptr %25, align 4, !tbaa !9
  %221 = add i32 %219, %220
  %222 = load i32, ptr %13, align 4, !tbaa !9
  %223 = icmp ugt i32 %221, %222
  br i1 %223, label %224, label %228

224:                                              ; preds = %218
  %225 = load i32, ptr %13, align 4, !tbaa !9
  %226 = load i32, ptr %25, align 4, !tbaa !9
  %227 = sub i32 %225, %226
  store i32 %227, ptr %26, align 4, !tbaa !9
  br label %228

228:                                              ; preds = %224, %218
  %229 = load i32, ptr %23, align 4, !tbaa !9
  %230 = add i32 %229, 1
  store i32 %230, ptr %23, align 4, !tbaa !9
  %231 = load i32, ptr %21, align 4, !tbaa !9
  %232 = icmp ne i32 %231, 0
  br i1 %232, label %233, label %251

233:                                              ; preds = %228
  %234 = load ptr, ptr %6, align 8, !tbaa !5
  %235 = load ptr, ptr %15, align 8, !tbaa !5
  %236 = load i32, ptr %25, align 4, !tbaa !9
  %237 = zext i32 %236 to i64
  %238 = getelementptr inbounds i8, ptr %235, i64 %237
  %239 = load i32, ptr %26, align 4, !tbaa !9
  %240 = load i32, ptr %8, align 4, !tbaa !9
  %241 = load i32, ptr %25, align 4, !tbaa !9
  %242 = add i32 %240, %241
  %243 = call noundef zeroext i1 @_Z9flash_memP10SerialPortPhjj(ptr noundef %234, ptr noundef %238, i32 noundef %239, i32 noundef %242)
  %244 = zext i1 %243 to i8
  store i8 %244, ptr %20, align 1, !tbaa !14
  %245 = load i8, ptr %20, align 1, !tbaa !14, !range !17, !noundef !18
  %246 = trunc i8 %245 to i1
  br i1 %246, label %250, label %247

247:                                              ; preds = %233
  %248 = load i8, ptr %20, align 1, !tbaa !14, !range !17, !noundef !18
  %249 = trunc i8 %248 to i1
  store i1 %249, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %259

250:                                              ; preds = %233
  br label %251

251:                                              ; preds = %250, %228
  %252 = load i32, ptr %26, align 4, !tbaa !9
  %253 = load i32, ptr %25, align 4, !tbaa !9
  %254 = add i32 %253, %252
  store i32 %254, ptr %25, align 4, !tbaa !9
  %255 = load i32, ptr %26, align 4, !tbaa !9
  %256 = load i32, ptr %22, align 4, !tbaa !9
  %257 = add i32 %256, %255
  store i32 %257, ptr %22, align 4, !tbaa !9
  br label %258

258:                                              ; preds = %251, %206
  store i32 0, ptr %12, align 4
  br label %259

259:                                              ; preds = %258, %247
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #8
  %260 = load i32, ptr %12, align 4
  switch i32 %260, label %265 [
    i32 0, label %261
  ]

261:                                              ; preds = %259
  br label %262

262:                                              ; preds = %261
  %263 = load i32, ptr %25, align 4, !tbaa !9
  %264 = add i32 %263, 4096
  store i32 %264, ptr %25, align 4, !tbaa !9
  br label %175, !llvm.loop !19

265:                                              ; preds = %259, %179
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  %266 = load i32, ptr %12, align 4
  switch i32 %266, label %291 [
    i32 7, label %267
  ]

267:                                              ; preds = %265
  %268 = load i32, ptr %21, align 4, !tbaa !9
  %269 = icmp eq i32 %268, 0
  br i1 %269, label %270, label %281

270:                                              ; preds = %267
  %271 = load i32, ptr %23, align 4, !tbaa !9
  %272 = icmp ugt i32 %271, 3
  br i1 %272, label %273, label %281

273:                                              ; preds = %270
  %274 = call i32 (ptr, ...) @printf(ptr noundef @.str.19)
  %275 = load ptr, ptr %6, align 8, !tbaa !5
  %276 = load ptr, ptr %15, align 8, !tbaa !5
  %277 = load i32, ptr %13, align 4, !tbaa !9
  %278 = load i32, ptr %8, align 4, !tbaa !9
  %279 = call noundef zeroext i1 @_Z9flash_memP10SerialPortPhjj(ptr noundef %275, ptr noundef %276, i32 noundef %277, i32 noundef %278)
  %280 = zext i1 %279 to i8
  store i8 %280, ptr %20, align 1, !tbaa !14
  store i32 4, ptr %12, align 4
  br label %291

281:                                              ; preds = %270, %267
  %282 = load i32, ptr %23, align 4, !tbaa !9
  %283 = icmp ugt i32 %282, 3
  br i1 %283, label %284, label %289

284:                                              ; preds = %281
  %285 = load i32, ptr %22, align 4, !tbaa !9
  %286 = load i32, ptr %13, align 4, !tbaa !9
  %287 = load i32, ptr %23, align 4, !tbaa !9
  %288 = call i32 (ptr, ...) @printf(ptr noundef @.str.20, i32 noundef %285, i32 noundef %286, i32 noundef %287)
  br label %289

289:                                              ; preds = %284, %281
  br label %290

290:                                              ; preds = %289
  store i32 0, ptr %12, align 4
  br label %291

291:                                              ; preds = %290, %273, %265
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  %292 = load i32, ptr %12, align 4
  switch i32 %292, label %297 [
    i32 0, label %293
  ]

293:                                              ; preds = %291
  br label %294

294:                                              ; preds = %293
  %295 = load i32, ptr %21, align 4, !tbaa !9
  %296 = add nsw i32 %295, 1
  store i32 %296, ptr %21, align 4, !tbaa !9
  br label %170, !llvm.loop !20

297:                                              ; preds = %291, %173
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  %298 = load i32, ptr %12, align 4
  switch i32 %298, label %322 [
    i32 4, label %299
  ]

299:                                              ; preds = %297
  br label %307

300:                                              ; preds = %163
  %301 = load ptr, ptr %6, align 8, !tbaa !5
  %302 = load ptr, ptr %15, align 8, !tbaa !5
  %303 = load i32, ptr %13, align 4, !tbaa !9
  %304 = load i32, ptr %8, align 4, !tbaa !9
  %305 = call noundef zeroext i1 @_Z9flash_memP10SerialPortPhjj(ptr noundef %301, ptr noundef %302, i32 noundef %303, i32 noundef %304)
  %306 = zext i1 %305 to i8
  store i8 %306, ptr %20, align 1, !tbaa !14
  br label %307

307:                                              ; preds = %300, %299
  %308 = load ptr, ptr %15, align 8, !tbaa !5
  %309 = icmp eq ptr %308, null
  br i1 %309, label %311, label %310

310:                                              ; preds = %307
  call void @_ZdaPv(ptr noundef %308) #10
  br label %311

311:                                              ; preds = %310, %307
  %312 = load ptr, ptr %16, align 8, !tbaa !5
  %313 = icmp ne ptr %312, null
  br i1 %313, label %314, label %319

314:                                              ; preds = %311
  %315 = load ptr, ptr %16, align 8, !tbaa !5
  %316 = icmp eq ptr %315, null
  br i1 %316, label %318, label %317

317:                                              ; preds = %314
  call void @_ZdaPv(ptr noundef %315) #10
  br label %318

318:                                              ; preds = %317, %314
  br label %319

319:                                              ; preds = %318, %311
  %320 = load i8, ptr %20, align 1, !tbaa !14, !range !17, !noundef !18
  %321 = trunc i8 %320 to i1
  store i1 %321, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %322

322:                                              ; preds = %319, %297
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #8
  br label %323

323:                                              ; preds = %322, %160, %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %324

324:                                              ; preds = %323, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  %325 = load i1, ptr %5, align 1
  ret i1 %325
}

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

declare i32 @fseek(ptr noundef, i64 noundef, i32 noundef) #0

declare i64 @ftell(ptr noundef) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #5

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

declare i32 @fclose(ptr noundef) #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #6

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #7

attributes #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nobuiltin 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin nounwind }
attributes #11 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = distinct !{!16, !13}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !13}
!20 = distinct !{!20, !13}


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

@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [52 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z9flash_memP10SerialPortPhjj(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z10flash_fileP10SerialPortPcjS1_(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef readonly %3) local_unnamed_addr #2 {
  %5 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.11)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %8

6:                                                ; preds = %4
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %1)
  br label %.loopexit239

8:                                                ; preds = %4
  %9 = tail call i32 @fseek(ptr noundef nonnull %5, i64 noundef 0, i32 noundef 2)
  %10 = tail call i64 @ftell(ptr noundef nonnull %5)
  %11 = trunc i64 %10 to i32
  %12 = tail call i32 @fseek(ptr noundef nonnull %5, i64 noundef 0, i32 noundef 0)
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, ptr noundef %1, i32 noundef %2)
  %14 = uitofp i32 %11 to double
  %15 = fmul double %14, 0x3F30000000000000
  %16 = tail call double @llvm.ceil.f64(double %15)
  %17 = fptoui double %16 to i32
  %18 = shl i32 %17, 12
  %19 = sub i32 %18, %11
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %19, i32 noundef %18)
  %21 = zext i32 %18 to i64
  %22 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %21) #7
  %23 = and i64 %10, 4294967295
  %24 = getelementptr inbounds i8, ptr %22, i64 %23
  %25 = zext i32 %19 to i64
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %24, i8 -1, i64 %25, i1 false)
  %26 = tail call i64 @fread(ptr noundef nonnull %22, i64 noundef 1, i64 noundef %23, ptr noundef nonnull %5)
  %27 = trunc i64 %26 to i32
  %28 = tail call i32 @fclose(ptr noundef nonnull %5)
  %.not159 = icmp eq i32 %27, %11
  br i1 %.not159, label %31, label %29

29:                                               ; preds = %8
  tail call void @_ZdaPv(ptr noundef nonnull %22) #8
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  br label %.loopexit239

31:                                               ; preds = %8
  %.not160 = icmp eq ptr %3, null
  br i1 %.not160, label %.thread232, label %32

32:                                               ; preds = %31
  %33 = tail call noalias ptr @fopen(ptr noundef nonnull %3, ptr noundef nonnull @.str.11)
  %.not161 = icmp eq ptr %33, null
  br i1 %.not161, label %.thread, label %34

34:                                               ; preds = %32
  %35 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %21) #7
  %36 = getelementptr inbounds i8, ptr %35, i64 %23
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %36, i8 -1, i64 %25, i1 false)
  %37 = tail call i64 @fread(ptr noundef nonnull %35, i64 noundef 1, i64 noundef %23, ptr noundef nonnull %33)
  %38 = trunc i64 %37 to i32
  %.not162 = icmp eq i32 %38, 0
  br i1 %.not162, label %.thread171, label %.preheader240

.preheader240:                                    ; preds = %34
  %39 = icmp ult i32 %38, %11
  br i1 %39, label %iter.check, label %._crit_edge

iter.check:                                       ; preds = %.preheader240
  %40 = and i64 %37, 4294967295
  %wide.trip.count = and i64 %10, 4294967295
  %41 = sub nsw i64 %wide.trip.count, %40
  %min.iters.check = icmp ult i64 %41, 8
  br i1 %min.iters.check, label %.lr.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check295 = icmp ult i64 %41, 32
  br i1 %min.iters.check295, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %41, -32
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %40, %index
  %42 = getelementptr inbounds i8, ptr %22, i64 %offset.idx
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  %wide.load = load <16 x i8>, ptr %42, align 1, !tbaa !5
  %wide.load296 = load <16 x i8>, ptr %43, align 1, !tbaa !5
  %44 = xor <16 x i8> %wide.load, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
  %45 = xor <16 x i8> %wide.load296, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
  %46 = getelementptr inbounds i8, ptr %35, i64 %offset.idx
  %47 = getelementptr inbounds i8, ptr %46, i64 16
  store <16 x i8> %44, ptr %46, align 1, !tbaa !5
  store <16 x i8> %45, ptr %47, align 1, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %48 = icmp eq i64 %index.next, %n.vec
  br i1 %48, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %41, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end299 = add nsw i64 %40, %n.vec
  %n.vec.remaining = and i64 %41, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %.lr.ph.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec298 = and i64 %41, -8
  %ind.end = add nsw i64 %40, %n.vec298
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index300 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next303, %vec.epilog.vector.body ]
  %offset.idx301 = add i64 %40, %index300
  %49 = getelementptr inbounds i8, ptr %22, i64 %offset.idx301
  %wide.load302 = load <8 x i8>, ptr %49, align 1, !tbaa !5
  %50 = xor <8 x i8> %wide.load302, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
  %51 = getelementptr inbounds i8, ptr %35, i64 %offset.idx301
  store <8 x i8> %50, ptr %51, align 1, !tbaa !5
  %index.next303 = add nuw i64 %index300, 8
  %52 = icmp eq i64 %index.next303, %n.vec298
  br i1 %52, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !12

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n304 = icmp eq i64 %41, %n.vec298
  br i1 %cmp.n304, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %indvars.iv.ph = phi i64 [ %40, %iter.check ], [ %ind.end299, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader ]
  %53 = getelementptr inbounds i8, ptr %22, i64 %indvars.iv
  %54 = load i8, ptr %53, align 1, !tbaa !5
  %55 = xor i8 %54, -1
  %56 = getelementptr inbounds i8, ptr %35, i64 %indvars.iv
  store i8 %55, ptr %56, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

.thread171:                                       ; preds = %34
  tail call void @_ZdaPv(ptr noundef nonnull %35) #8
  %57 = tail call i32 @fclose(ptr noundef nonnull %33)
  br label %.thread

.thread:                                          ; preds = %32, %.thread171
  %58 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  br label %.thread232

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %vec.epilog.middle.block, %.preheader240
  %59 = tail call i32 @fclose(ptr noundef nonnull %33)
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  %bcmp = tail call i32 @bcmp(ptr nonnull %22, ptr nonnull %35, i64 %23)
  %61 = icmp eq i32 %bcmp, 0
  br i1 %61, label %.critedge, label %.preheader238

.preheader238:                                    ; preds = %._crit_edge
  %.not168249.not = icmp eq i32 %18, 0
  br i1 %.not168249.not, label %.loopexit, label %.preheader.us.us

.preheader.us273.1:                               ; preds = %._crit_edge254.us, %88
  %.0118253.us274.1 = phi i32 [ %89, %88 ], [ 0, %._crit_edge254.us ]
  %.0124252.us275.1 = phi i32 [ %.2126.ph.us270.1, %88 ], [ 0, %._crit_edge254.us ]
  %.0128251.us276.1 = phi i32 [ %.2130.ph.us269.1, %88 ], [ 0, %._crit_edge254.us ]
  %.1134250.us.1 = phi i1 [ %.4137.ph.us.1, %88 ], [ false, %._crit_edge254.us ]
  br label %62

62:                                               ; preds = %69, %.preheader.us273.1
  %indvars.iv286.1 = phi i64 [ 0, %.preheader.us273.1 ], [ %indvars.iv.next287.1, %69 ]
  %63 = trunc nuw i64 %indvars.iv286.1 to i32
  %64 = add i32 %.0118253.us274.1, %63
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %22, i64 %65
  %67 = getelementptr inbounds i8, ptr %35, i64 %65
  %bcmp164.us263.1 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(4096) %66, ptr noundef nonnull dereferenceable(4096) %67, i64 4096)
  %68 = icmp eq i32 %bcmp164.us263.1, 0
  br i1 %68, label %72, label %69

69:                                               ; preds = %62
  %indvars.iv.next287.1 = add nuw nsw i64 %indvars.iv286.1, 4096
  %indvars.1 = trunc i64 %indvars.iv.next287.1 to i32
  %70 = add i32 %.0118253.us274.1, %indvars.1
  %71 = icmp ult i32 %70, %18
  br i1 %71, label %62, label %72, !llvm.loop !14

72:                                               ; preds = %69, %62
  %.0.lcssa.us264.1 = phi i32 [ %63, %62 ], [ %indvars.1, %69 ]
  %.not165.us265.1 = icmp eq i32 %.0.lcssa.us264.1, 0
  br i1 %.not165.us265.1, label %88, label %73

73:                                               ; preds = %72
  %74 = and i32 %.0.lcssa.us264.1, 12288
  %.not166.us266.1 = icmp eq i32 %74, 0
  %75 = and i32 %.0.lcssa.us264.1, -16384
  %76 = add i32 %75, 16384
  %.1.us267.1 = select i1 %.not166.us266.1, i32 %.0.lcssa.us264.1, i32 %76
  %77 = add i32 %.1.us267.1, %.0118253.us274.1
  %78 = icmp ugt i32 %77, %18
  %79 = sub i32 %18, %.0118253.us274.1
  %.2.us268.1 = select i1 %78, i32 %79, i32 %.1.us267.1
  %80 = zext i32 %.0118253.us274.1 to i64
  %81 = getelementptr inbounds i8, ptr %22, i64 %80
  %82 = add i32 %.0118253.us274.1, %2
  %83 = tail call noundef zeroext i1 @_Z9flash_memP10SerialPortPhjj(ptr noundef %0, ptr noundef nonnull %81, i32 noundef %.2.us268.1, i32 noundef %82)
  br i1 %83, label %84, label %.loopexit239

84:                                               ; preds = %73
  %85 = add i32 %.0124252.us275.1, 1
  %86 = add i32 %.2.us268.1, %.0118253.us274.1
  %87 = add i32 %.2.us268.1, %.0128251.us276.1
  br label %88

88:                                               ; preds = %84, %72
  %.4137.ph.us.1 = phi i1 [ %.1134250.us.1, %72 ], [ true, %84 ]
  %.2130.ph.us269.1 = phi i32 [ %.0128251.us276.1, %72 ], [ %87, %84 ]
  %.2126.ph.us270.1 = phi i32 [ %.0124252.us275.1, %72 ], [ %85, %84 ]
  %.2120.ph.us271.1 = phi i32 [ %.0118253.us274.1, %72 ], [ %86, %84 ]
  %89 = add i32 %.2120.ph.us271.1, 4096
  %.not168.us272.1 = icmp ult i32 %89, %18
  br i1 %.not168.us272.1, label %.preheader.us273.1, label %._crit_edge254.us.1, !llvm.loop !15

._crit_edge254.us.1:                              ; preds = %88
  %90 = icmp ugt i32 %.2126.ph.us270.1, 3
  br i1 %90, label %91, label %.loopexit

91:                                               ; preds = %._crit_edge254.us.1
  %92 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef %.2130.ph.us269.1, i32 noundef %18, i32 noundef %.2126.ph.us270.1)
  br label %.loopexit

._crit_edge254.us:                                ; preds = %114
  %93 = icmp ugt i32 %.2126.ph.us.us, 3
  br i1 %93, label %.split.us, label %.preheader.us273.1

.preheader.us.us:                                 ; preds = %.preheader238, %114
  %.0118253.us.us = phi i32 [ %115, %114 ], [ 0, %.preheader238 ]
  %.0124252.us.us = phi i32 [ %.2126.ph.us.us, %114 ], [ 0, %.preheader238 ]
  br label %94

94:                                               ; preds = %101, %.preheader.us.us
  %indvars.iv289 = phi i64 [ %indvars.iv.next290, %101 ], [ 0, %.preheader.us.us ]
  %95 = trunc nuw i64 %indvars.iv289 to i32
  %96 = add i32 %.0118253.us.us, %95
  %97 = zext i32 %96 to i64
  %98 = getelementptr inbounds i8, ptr %22, i64 %97
  %99 = getelementptr inbounds i8, ptr %35, i64 %97
  %bcmp164.us.us = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(4096) %98, ptr noundef nonnull dereferenceable(4096) %99, i64 4096)
  %100 = icmp eq i32 %bcmp164.us.us, 0
  br i1 %100, label %104, label %101

101:                                              ; preds = %94
  %indvars.iv.next290 = add nuw nsw i64 %indvars.iv289, 4096
  %indvars291 = trunc i64 %indvars.iv.next290 to i32
  %102 = add i32 %.0118253.us.us, %indvars291
  %103 = icmp ult i32 %102, %18
  br i1 %103, label %94, label %104, !llvm.loop !14

104:                                              ; preds = %101, %94
  %.0.lcssa.us.us = phi i32 [ %95, %94 ], [ %indvars291, %101 ]
  %.not165.us.us = icmp eq i32 %.0.lcssa.us.us, 0
  br i1 %.not165.us.us, label %114, label %105

105:                                              ; preds = %104
  %106 = and i32 %.0.lcssa.us.us, 12288
  %.not166.us.us = icmp eq i32 %106, 0
  %107 = and i32 %.0.lcssa.us.us, -16384
  %108 = add i32 %107, 16384
  %.1.us.us = select i1 %.not166.us.us, i32 %.0.lcssa.us.us, i32 %108
  %109 = add i32 %.1.us.us, %.0118253.us.us
  %110 = icmp ugt i32 %109, %18
  %111 = sub i32 %18, %.0118253.us.us
  %.2.us.us = select i1 %110, i32 %111, i32 %.1.us.us
  %112 = add i32 %.0124252.us.us, 1
  %113 = add i32 %.2.us.us, %.0118253.us.us
  br label %114

114:                                              ; preds = %105, %104
  %.2126.ph.us.us = phi i32 [ %.0124252.us.us, %104 ], [ %112, %105 ]
  %.2120.ph.us.us = phi i32 [ %.0118253.us.us, %104 ], [ %113, %105 ]
  %115 = add i32 %.2120.ph.us.us, 4096
  %.not168.us.us = icmp ult i32 %115, %18
  br i1 %.not168.us.us, label %.preheader.us.us, label %._crit_edge254.us, !llvm.loop !15

.critedge:                                        ; preds = %._crit_edge
  %116 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18)
  br label %.loopexit239

.split.us:                                        ; preds = %._crit_edge254.us
  %117 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19)
  %118 = tail call noundef zeroext i1 @_Z9flash_memP10SerialPortPhjj(ptr noundef %0, ptr noundef nonnull %22, i32 noundef %18, i32 noundef %2)
  br label %.loopexit

.thread232:                                       ; preds = %.thread, %31
  %119 = tail call noundef zeroext i1 @_Z9flash_memP10SerialPortPhjj(ptr noundef %0, ptr noundef nonnull %22, i32 noundef %18, i32 noundef %2)
  tail call void @_ZdaPv(ptr noundef nonnull %22) #8
  br label %.loopexit239

.loopexit:                                        ; preds = %._crit_edge254.us.1, %91, %.preheader238, %.split.us
  %.7140.ph = phi i1 [ %118, %.split.us ], [ false, %.preheader238 ], [ %.4137.ph.us.1, %91 ], [ %.4137.ph.us.1, %._crit_edge254.us.1 ]
  tail call void @_ZdaPv(ptr noundef nonnull %22) #8
  tail call void @_ZdaPv(ptr noundef nonnull %35) #8
  br label %.loopexit239

.loopexit239:                                     ; preds = %73, %.loopexit, %.thread232, %29, %.critedge, %6
  %.9 = phi i1 [ false, %6 ], [ false, %29 ], [ true, %.critedge ], [ %119, %.thread232 ], [ %.7140.ph, %.loopexit ], [ false, %73 ]
  ret i1 %.9
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @fseek(ptr nocapture noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i64 @ftell(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 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 #0

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #6

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

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

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


; Effective O3 passes: AggressiveInstCombinePass,BDCEPass,ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass