; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/228 Division 1/Problem B (B)

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

@k = external dso_local global i32, align 4
@g = external dso_local global [2001 x [2001 x i32]], align 16
@cur = external dso_local global i32, align 4
@up = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @k)
  %14 = load i32, ptr @k, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %19

16:                                               ; preds = %0
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  br label %295

19:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 29, ptr %2, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %131, %19
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = icmp sge i32 %21, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %134

24:                                               ; preds = %20
  %25 = load i32, ptr @k, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = shl i32 1, %26
  %28 = and i32 %25, %27
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %30, label %130

30:                                               ; preds = %24
  %31 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %31, ptr @up, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %32 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr @cur, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %35
  %37 = getelementptr inbounds [2001 x i32], ptr %36, i64 0, i64 1
  store i32 1, ptr %37, align 4, !tbaa !5
  %38 = load i32, ptr @cur, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %39
  %41 = getelementptr inbounds [2001 x i32], ptr %40, i64 0, i64 1
  store i32 1, ptr %41, align 4, !tbaa !5
  %42 = load i32, ptr @cur, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds ([2001 x [2001 x i32]], ptr @g, i64 0, i64 1), i64 0, i64 %44
  store i32 1, ptr %45, align 4, !tbaa !5
  %46 = load i32, ptr @cur, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds ([2001 x [2001 x i32]], ptr @g, i64 0, i64 1), i64 0, i64 %47
  store i32 1, ptr %48, align 4, !tbaa !5
  %49 = load i32, ptr @cur, align 4, !tbaa !5
  %50 = add nsw i32 %49, 2
  store i32 %50, ptr @cur, align 4, !tbaa !5
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr %2, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %57, %30
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr %2, align 4, !tbaa !5
  %56 = icmp ne i32 %54, 0
  br i1 %56, label %57, label %90

57:                                               ; preds = %53
  %58 = load i32, ptr @cur, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %59
  %61 = load i32, ptr @cur, align 4, !tbaa !5
  %62 = sub nsw i32 %61, 2
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [2001 x i32], ptr %60, i64 0, i64 %63
  store i32 1, ptr %64, align 4, !tbaa !5
  %65 = load i32, ptr @cur, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %66
  %68 = load i32, ptr @cur, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [2001 x i32], ptr %67, i64 0, i64 %70
  store i32 1, ptr %71, align 4, !tbaa !5
  %72 = load i32, ptr @cur, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %74
  %76 = load i32, ptr @cur, align 4, !tbaa !5
  %77 = sub nsw i32 %76, 2
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [2001 x i32], ptr %75, i64 0, i64 %78
  store i32 1, ptr %79, align 4, !tbaa !5
  %80 = load i32, ptr @cur, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %82
  %84 = load i32, ptr @cur, align 4, !tbaa !5
  %85 = sub nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2001 x i32], ptr %83, i64 0, i64 %86
  store i32 1, ptr %87, align 4, !tbaa !5
  %88 = load i32, ptr @cur, align 4, !tbaa !5
  %89 = add nsw i32 %88, 2
  store i32 %89, ptr @cur, align 4, !tbaa !5
  br label %53, !llvm.loop !9

90:                                               ; preds = %53
  %91 = load i32, ptr @cur, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %92
  %94 = load i32, ptr @cur, align 4, !tbaa !5
  %95 = sub nsw i32 %94, 2
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2001 x i32], ptr %93, i64 0, i64 %96
  store i32 1, ptr %97, align 4, !tbaa !5
  %98 = load i32, ptr @cur, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %99
  %101 = load i32, ptr @cur, align 4, !tbaa !5
  %102 = sub nsw i32 %101, 1
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [2001 x i32], ptr %100, i64 0, i64 %103
  store i32 1, ptr %104, align 4, !tbaa !5
  %105 = load i32, ptr @cur, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr @cur, align 4, !tbaa !5
  %107 = load i32, ptr %3, align 4, !tbaa !5
  %108 = sub nsw i32 30, %107
  store i32 %108, ptr %3, align 4, !tbaa !5
  %109 = load i32, ptr %3, align 4, !tbaa !5
  %110 = add nsw i32 %109, -1
  store i32 %110, ptr %3, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %115, %90
  %112 = load i32, ptr %3, align 4, !tbaa !5
  %113 = add nsw i32 %112, -1
  store i32 %113, ptr %3, align 4, !tbaa !5
  %114 = icmp ne i32 %112, 0
  br i1 %114, label %115, label %125

115:                                              ; preds = %111
  %116 = load i32, ptr @cur, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %117
  %119 = load i32, ptr @cur, align 4, !tbaa !5
  %120 = sub nsw i32 %119, 1
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2001 x i32], ptr %118, i64 0, i64 %121
  store i32 1, ptr %122, align 4, !tbaa !5
  %123 = load i32, ptr @cur, align 4, !tbaa !5
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr @cur, align 4, !tbaa !5
  br label %111, !llvm.loop !11

125:                                              ; preds = %111
  %126 = load i32, ptr @cur, align 4, !tbaa !5
  %127 = sub nsw i32 %126, 1
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds ([2001 x [2001 x i32]], ptr @g, i64 0, i64 2), i64 0, i64 %128
  store i32 1, ptr %129, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %130

130:                                              ; preds = %125, %24
  br label %131

131:                                              ; preds = %130
  %132 = load i32, ptr %2, align 4, !tbaa !5
  %133 = add nsw i32 %132, -1
  store i32 %133, ptr %2, align 4, !tbaa !5
  br label %20, !llvm.loop !12

134:                                              ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %218, %134
  %136 = load i32, ptr %4, align 4, !tbaa !5
  %137 = load i32, ptr @up, align 4, !tbaa !5
  %138 = icmp slt i32 %136, %137
  br i1 %138, label %140, label %139

139:                                              ; preds = %135
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %221

140:                                              ; preds = %135
  %141 = load i32, ptr @k, align 4, !tbaa !5
  %142 = load i32, ptr %4, align 4, !tbaa !5
  %143 = shl i32 1, %142
  %144 = and i32 %141, %143
  %145 = icmp sgt i32 %144, 0
  br i1 %145, label %146, label %217

146:                                              ; preds = %140
  %147 = load i32, ptr %4, align 4, !tbaa !5
  %148 = icmp eq i32 %147, 0
  br i1 %148, label %149, label %175

149:                                              ; preds = %146
  %150 = load i32, ptr @cur, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %151
  %153 = getelementptr inbounds [2001 x i32], ptr %152, i64 0, i64 1
  store i32 1, ptr %153, align 4, !tbaa !5
  %154 = load i32, ptr @cur, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr @cur, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 29, ptr %5, align 4, !tbaa !5
  br label %156

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

160:                                              ; preds = %156
  %161 = load i32, ptr @cur, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %162
  %164 = load i32, ptr @cur, align 4, !tbaa !5
  %165 = sub nsw i32 %164, 1
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [2001 x i32], ptr %163, i64 0, i64 %166
  store i32 1, ptr %167, align 4, !tbaa !5
  %168 = load i32, ptr @cur, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr @cur, align 4, !tbaa !5
  br label %156, !llvm.loop !13

170:                                              ; preds = %156
  %171 = load i32, ptr @cur, align 4, !tbaa !5
  %172 = sub nsw i32 %171, 1
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds ([2001 x [2001 x i32]], ptr @g, i64 0, i64 2), i64 0, i64 %173
  store i32 1, ptr %174, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %216

175:                                              ; preds = %146
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %176 = load i32, ptr %4, align 4, !tbaa !5
  %177 = add nsw i32 %176, 1
  %178 = mul nsw i32 2, %177
  store i32 %178, ptr %6, align 4, !tbaa !5
  %179 = load i32, ptr @cur, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %180
  %182 = load i32, ptr %6, align 4, !tbaa !5
  %183 = sub nsw i32 %182, 1
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [2001 x i32], ptr %181, i64 0, i64 %184
  store i32 1, ptr %185, align 4, !tbaa !5
  %186 = load i32, ptr @cur, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %187
  %189 = load i32, ptr %6, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [2001 x i32], ptr %188, i64 0, i64 %190
  store i32 1, ptr %191, align 4, !tbaa !5
  %192 = load i32, ptr @cur, align 4, !tbaa !5
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr @cur, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %194 = load i32, ptr %4, align 4, !tbaa !5
  %195 = sub nsw i32 30, %194
  %196 = sub nsw i32 %195, 1
  store i32 %196, ptr %7, align 4, !tbaa !5
  br label %197

197:                                              ; preds = %201, %175
  %198 = load i32, ptr %7, align 4, !tbaa !5
  %199 = add nsw i32 %198, -1
  store i32 %199, ptr %7, align 4, !tbaa !5
  %200 = icmp ne i32 %198, 0
  br i1 %200, label %201, label %211

201:                                              ; preds = %197
  %202 = load i32, ptr @cur, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %203
  %205 = load i32, ptr @cur, align 4, !tbaa !5
  %206 = sub nsw i32 %205, 1
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [2001 x i32], ptr %204, i64 0, i64 %207
  store i32 1, ptr %208, align 4, !tbaa !5
  %209 = load i32, ptr @cur, align 4, !tbaa !5
  %210 = add nsw i32 %209, 1
  store i32 %210, ptr @cur, align 4, !tbaa !5
  br label %197, !llvm.loop !14

211:                                              ; preds = %197
  %212 = load i32, ptr @cur, align 4, !tbaa !5
  %213 = sub nsw i32 %212, 1
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds ([2001 x [2001 x i32]], ptr @g, i64 0, i64 2), i64 0, i64 %214
  store i32 1, ptr %215, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %216

216:                                              ; preds = %211, %170
  br label %217

217:                                              ; preds = %216, %140
  br label %218

218:                                              ; preds = %217
  %219 = load i32, ptr %4, align 4, !tbaa !5
  %220 = add nsw i32 %219, 1
  store i32 %220, ptr %4, align 4, !tbaa !5
  br label %135, !llvm.loop !15

221:                                              ; preds = %139
  %222 = load i32, ptr @cur, align 4, !tbaa !5
  %223 = sub nsw i32 %222, 1
  %224 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %223)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %225

225:                                              ; preds = %257, %221
  %226 = load i32, ptr %8, align 4, !tbaa !5
  %227 = load i32, ptr @cur, align 4, !tbaa !5
  %228 = icmp slt i32 %226, %227
  br i1 %228, label %230, label %229

229:                                              ; preds = %225
  store i32 16, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %260

230:                                              ; preds = %225
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %231

231:                                              ; preds = %253, %230
  %232 = load i32, ptr %10, align 4, !tbaa !5
  %233 = load i32, ptr @cur, align 4, !tbaa !5
  %234 = icmp slt i32 %232, %233
  br i1 %234, label %236, label %235

235:                                              ; preds = %231
  store i32 19, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %256

236:                                              ; preds = %231
  %237 = load i32, ptr %8, align 4, !tbaa !5
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %238
  %240 = load i32, ptr %10, align 4, !tbaa !5
  %241 = sext i32 %240 to i64
  %242 = getelementptr inbounds [2001 x i32], ptr %239, i64 0, i64 %241
  %243 = load i32, ptr %242, align 4, !tbaa !5
  %244 = icmp ne i32 %243, 0
  br i1 %244, label %245, label %252

245:                                              ; preds = %236
  %246 = load i32, ptr %10, align 4, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %247
  %249 = load i32, ptr %8, align 4, !tbaa !5
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [2001 x i32], ptr %248, i64 0, i64 %250
  store i32 1, ptr %251, align 4, !tbaa !5
  br label %252

252:                                              ; preds = %245, %236
  br label %253

253:                                              ; preds = %252
  %254 = load i32, ptr %10, align 4, !tbaa !5
  %255 = add nsw i32 %254, 1
  store i32 %255, ptr %10, align 4, !tbaa !5
  br label %231, !llvm.loop !16

256:                                              ; preds = %235
  br label %257

257:                                              ; preds = %256
  %258 = load i32, ptr %8, align 4, !tbaa !5
  %259 = add nsw i32 %258, 1
  store i32 %259, ptr %8, align 4, !tbaa !5
  br label %225, !llvm.loop !17

260:                                              ; preds = %229
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %261

261:                                              ; preds = %291, %260
  %262 = load i32, ptr %11, align 4, !tbaa !5
  %263 = load i32, ptr @cur, align 4, !tbaa !5
  %264 = icmp slt i32 %262, %263
  br i1 %264, label %266, label %265

265:                                              ; preds = %261
  store i32 22, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %294

266:                                              ; preds = %261
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %267

267:                                              ; preds = %286, %266
  %268 = load i32, ptr %12, align 4, !tbaa !5
  %269 = load i32, ptr @cur, align 4, !tbaa !5
  %270 = icmp slt i32 %268, %269
  br i1 %270, label %272, label %271

271:                                              ; preds = %267
  store i32 25, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %289

272:                                              ; preds = %267
  %273 = load i32, ptr %11, align 4, !tbaa !5
  %274 = sext i32 %273 to i64
  %275 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %274
  %276 = load i32, ptr %12, align 4, !tbaa !5
  %277 = sext i32 %276 to i64
  %278 = getelementptr inbounds [2001 x i32], ptr %275, i64 0, i64 %277
  %279 = load i32, ptr %278, align 4, !tbaa !5
  %280 = icmp ne i32 %279, 0
  br i1 %280, label %281, label %283

281:                                              ; preds = %272
  %282 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %285

283:                                              ; preds = %272
  %284 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %285

285:                                              ; preds = %283, %281
  br label %286

286:                                              ; preds = %285
  %287 = load i32, ptr %12, align 4, !tbaa !5
  %288 = add nsw i32 %287, 1
  store i32 %288, ptr %12, align 4, !tbaa !5
  br label %267, !llvm.loop !18

289:                                              ; preds = %271
  %290 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  br label %291

291:                                              ; preds = %289
  %292 = load i32, ptr %11, align 4, !tbaa !5
  %293 = add nsw i32 %292, 1
  store i32 %293, ptr %11, align 4, !tbaa !5
  br label %261, !llvm.loop !19

294:                                              ; preds = %265
  store i32 0, ptr %1, align 4
  br label %295

295:                                              ; preds = %294, %16
  %296 = load i32, ptr %1, align 4
  ret i32 %296
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

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

attributes #0 = { mustprogress norecurse 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 = { "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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


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

@k = external dso_local global i32, align 4
@g = external dso_local local_unnamed_addr global [2001 x [2001 x i32]], align 16
@cur = external dso_local local_unnamed_addr global i32, align 4
@up = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @k)
  %2 = load i32, ptr @k, align 4, !tbaa !5
  %3 = icmp eq i32 %2, 1
  br i1 %3, label %4, label %.preheader52

.preheader52:                                     ; preds = %0
  %cur.promoted62 = load i32, ptr @cur, align 4, !tbaa !5
  br label %9

4:                                                ; preds = %0
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.loopexit

.preheader51:                                     ; preds = %63
  %7 = load i32, ptr @up, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph85.preheader, label %._crit_edge86

.lr.ph85.preheader:                               ; preds = %.preheader51
  %wide.trip.count = zext nneg i32 %7 to i64
  br label %.lr.ph85

9:                                                ; preds = %.preheader52, %63
  %.04368 = phi i32 [ 29, %.preheader52 ], [ %64, %63 ]
  %.lcssa616567 = phi i32 [ %cur.promoted62, %.preheader52 ], [ %cur.promoted79, %63 ]
  %10 = shl nuw i32 1, %.04368
  %11 = and i32 %10, %2
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %13, label %63

13:                                               ; preds = %9
  store i32 %.04368, ptr @up, align 4, !tbaa !5
  %14 = add nsw i32 %.lcssa616567, 1
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %15, i64 1
  store i32 1, ptr %16, align 4, !tbaa !5
  %17 = sext i32 %.lcssa616567 to i64
  %18 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %17, i64 1
  store i32 1, ptr %18, align 4, !tbaa !5
  %19 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds (i8, ptr @g, i64 8004), i64 0, i64 %15
  store i32 1, ptr %19, align 4, !tbaa !5
  %20 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds (i8, ptr @g, i64 8004), i64 0, i64 %17
  store i32 1, ptr %20, align 4, !tbaa !5
  %21 = add i32 %.lcssa616567, 2
  %.not4753 = icmp eq i32 %.04368, 1
  br i1 %.not4753, label %34, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %13
  %22 = add nsw i32 %.04368, -2
  %23 = sext i32 %21 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %23, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %24 = phi i32 [ %22, %.lr.ph.preheader ], [ %32, %.lr.ph ]
  %25 = add nsw i64 %indvars.iv, -2
  %26 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv, i64 %25
  store i32 1, ptr %26, align 4, !tbaa !5
  %27 = add nsw i64 %indvars.iv, -1
  %28 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv, i64 %27
  store i32 1, ptr %28, align 4, !tbaa !5
  %29 = add nsw i64 %indvars.iv, 1
  %30 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %29, i64 %25
  store i32 1, ptr %30, align 4, !tbaa !5
  %31 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %29, i64 %27
  store i32 1, ptr %31, align 4, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, 2
  %32 = add nsw i32 %24, -1
  %.not47 = icmp eq i32 %24, 0
  br i1 %.not47, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph
  %33 = trunc nsw i64 %indvars.iv.next to i32
  br label %34

34:                                               ; preds = %._crit_edge, %13
  %.lcssa6163 = phi i32 [ %33, %._crit_edge ], [ %21, %13 ]
  %35 = sext i32 %.lcssa6163 to i64
  %36 = add nsw i32 %.lcssa6163, -2
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %35, i64 %37
  store i32 1, ptr %38, align 4, !tbaa !5
  %39 = add nsw i32 %.lcssa6163, -1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %35, i64 %40
  store i32 1, ptr %41, align 4, !tbaa !5
  %42 = add i32 %.lcssa6163, 1
  store i32 %42, ptr @cur, align 4, !tbaa !5
  %.not4856 = icmp eq i32 %.04368, 29
  br i1 %.not4856, label %59, label %.lr.ph59.preheader

.lr.ph59.preheader:                               ; preds = %34
  %43 = sub i32 29, %.04368
  %44 = sext i32 %42 to i64
  %xtraiter = and i32 %43, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph59.prol.loopexit, label %.lr.ph59.prol

.lr.ph59.prol:                                    ; preds = %.lr.ph59.preheader, %.lr.ph59.prol
  %indvars.iv100.prol = phi i64 [ %indvars.iv.next101.prol, %.lr.ph59.prol ], [ %44, %.lr.ph59.preheader ]
  %.04257.prol = phi i32 [ %45, %.lr.ph59.prol ], [ %43, %.lr.ph59.preheader ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph59.prol ], [ 0, %.lr.ph59.preheader ]
  %45 = add nsw i32 %.04257.prol, -1
  %46 = add nsw i64 %indvars.iv100.prol, -1
  %47 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv100.prol, i64 %46
  store i32 1, ptr %47, align 4, !tbaa !5
  %indvars.iv.next101.prol = add nsw i64 %indvars.iv100.prol, 1
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph59.prol.loopexit, label %.lr.ph59.prol, !llvm.loop !11

.lr.ph59.prol.loopexit:                           ; preds = %.lr.ph59.prol, %.lr.ph59.preheader
  %indvars.iv.next101.lcssa.unr = phi i64 [ poison, %.lr.ph59.preheader ], [ %indvars.iv.next101.prol, %.lr.ph59.prol ]
  %indvars.iv100.unr = phi i64 [ %44, %.lr.ph59.preheader ], [ %indvars.iv.next101.prol, %.lr.ph59.prol ]
  %.04257.unr = phi i32 [ %43, %.lr.ph59.preheader ], [ %45, %.lr.ph59.prol ]
  %48 = add i32 %.04368, -26
  %49 = icmp ult i32 %48, 3
  br i1 %49, label %._crit_edge60, label %.lr.ph59

.lr.ph59:                                         ; preds = %.lr.ph59.prol.loopexit, %.lr.ph59
  %indvars.iv100 = phi i64 [ %indvars.iv.next101.3, %.lr.ph59 ], [ %indvars.iv100.unr, %.lr.ph59.prol.loopexit ]
  %.04257 = phi i32 [ %55, %.lr.ph59 ], [ %.04257.unr, %.lr.ph59.prol.loopexit ]
  %50 = add nsw i64 %indvars.iv100, -1
  %51 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv100, i64 %50
  store i32 1, ptr %51, align 4, !tbaa !5
  %indvars.iv.next101 = add nsw i64 %indvars.iv100, 1
  %52 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next101, i64 %indvars.iv100
  store i32 1, ptr %52, align 4, !tbaa !5
  %indvars.iv.next101.1 = add nsw i64 %indvars.iv100, 2
  %53 = add nsw i64 %indvars.iv100, 1
  %54 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next101.1, i64 %53
  store i32 1, ptr %54, align 4, !tbaa !5
  %indvars.iv.next101.2 = add nsw i64 %indvars.iv100, 3
  %55 = add nsw i32 %.04257, -4
  %56 = add nsw i64 %indvars.iv100, 2
  %57 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next101.2, i64 %56
  store i32 1, ptr %57, align 4, !tbaa !5
  %indvars.iv.next101.3 = add nsw i64 %indvars.iv100, 4
  %.not48.3 = icmp eq i32 %55, 0
  br i1 %.not48.3, label %._crit_edge60, label %.lr.ph59, !llvm.loop !13

._crit_edge60:                                    ; preds = %.lr.ph59, %.lr.ph59.prol.loopexit
  %indvars.iv.next101.lcssa = phi i64 [ %indvars.iv.next101.lcssa.unr, %.lr.ph59.prol.loopexit ], [ %indvars.iv.next101.3, %.lr.ph59 ]
  %58 = trunc nsw i64 %indvars.iv.next101.lcssa to i32
  store i32 %58, ptr @cur, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %._crit_edge60, %34
  %.lcssa6166 = phi i32 [ %58, %._crit_edge60 ], [ %42, %34 ]
  %60 = add nsw i32 %.lcssa6166, -1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds (i8, ptr @g, i64 16008), i64 0, i64 %61
  store i32 1, ptr %62, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %9, %59
  %cur.promoted79 = phi i32 [ %.lcssa6166, %59 ], [ %.lcssa616567, %9 ]
  %.2 = phi i32 [ -1, %59 ], [ %.04368, %9 ]
  %64 = add nsw i32 %.2, -1
  %65 = icmp sgt i32 %.2, 0
  br i1 %65, label %9, label %.preheader51, !llvm.loop !14

._crit_edge86:                                    ; preds = %187, %.preheader51
  %66 = phi i32 [ %cur.promoted79, %.preheader51 ], [ %storemerge.lcssa80, %187 ]
  %67 = add nsw i32 %66, -1
  %68 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %67)
  %69 = load i32, ptr @cur, align 4, !tbaa !5
  %70 = icmp sgt i32 %69, 1
  br i1 %70, label %.preheader50.us.preheader, label %.loopexit

.preheader50.us.preheader:                        ; preds = %._crit_edge86
  %wide.trip.count120 = zext nneg i32 %69 to i64
  %71 = add nsw i64 %wide.trip.count120, -1
  %xtraiter160 = and i64 %71, 1
  %72 = icmp eq i32 %69, 2
  %unroll_iter = and i64 %71, -2
  %lcmp.mod161.not = icmp eq i64 %xtraiter160, 0
  br label %.preheader50.us

.preheader50.us:                                  ; preds = %.preheader50.us.preheader, %._crit_edge89.us
  %indvars.iv117 = phi i64 [ 1, %.preheader50.us.preheader ], [ %indvars.iv.next118, %._crit_edge89.us ]
  br i1 %72, label %._crit_edge89.us.unr-lcssa, label %.preheader50.us.new

.preheader50.us.new:                              ; preds = %.preheader50.us, %82
  %indvars.iv112 = phi i64 [ %indvars.iv.next113.1, %82 ], [ 1, %.preheader50.us ]
  %niter = phi i64 [ %niter.next.1, %82 ], [ 0, %.preheader50.us ]
  %73 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv117, i64 %indvars.iv112
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %.not44.us = icmp eq i32 %74, 0
  br i1 %.not44.us, label %77, label %75

75:                                               ; preds = %.preheader50.us.new
  %76 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv112, i64 %indvars.iv117
  store i32 1, ptr %76, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %75, %.preheader50.us.new
  %indvars.iv.next113 = add nuw nsw i64 %indvars.iv112, 1
  %78 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv117, i64 %indvars.iv.next113
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %.not44.us.1 = icmp eq i32 %79, 0
  br i1 %.not44.us.1, label %82, label %80

80:                                               ; preds = %77
  %81 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next113, i64 %indvars.iv117
  store i32 1, ptr %81, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %80, %77
  %indvars.iv.next113.1 = add nuw nsw i64 %indvars.iv112, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge89.us.unr-lcssa, label %.preheader50.us.new, !llvm.loop !15

._crit_edge89.us.unr-lcssa:                       ; preds = %82, %.preheader50.us
  %indvars.iv112.unr = phi i64 [ 1, %.preheader50.us ], [ %indvars.iv.next113.1, %82 ]
  br i1 %lcmp.mod161.not, label %._crit_edge89.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge89.us.unr-lcssa
  %83 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv117, i64 %indvars.iv112.unr
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %.not44.us.epil = icmp eq i32 %84, 0
  br i1 %.not44.us.epil, label %._crit_edge89.us, label %85

85:                                               ; preds = %.epil.preheader
  %86 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv112.unr, i64 %indvars.iv117
  store i32 1, ptr %86, align 4, !tbaa !5
  br label %._crit_edge89.us

._crit_edge89.us:                                 ; preds = %.epil.preheader, %85, %._crit_edge89.us.unr-lcssa
  %indvars.iv.next118 = add nuw nsw i64 %indvars.iv117, 1
  %exitcond121.not = icmp eq i64 %indvars.iv.next118, %wide.trip.count120
  br i1 %exitcond121.not, label %.preheader49, label %.preheader50.us, !llvm.loop !16

.lr.ph85:                                         ; preds = %.lr.ph85.preheader, %187
  %indvars.iv109 = phi i64 [ 0, %.lr.ph85.preheader ], [ %indvars.iv.next110, %187 ]
  %storemerge.lcssa8183 = phi i32 [ %cur.promoted79, %.lr.ph85.preheader ], [ %storemerge.lcssa80, %187 ]
  %87 = trunc i64 %indvars.iv109 to i32
  %88 = sub i32 1, %87
  %89 = trunc i64 %indvars.iv109 to i32
  %90 = trunc nuw nsw i64 %indvars.iv109 to i32
  %91 = shl nuw i32 1, %90
  %92 = and i32 %91, %2
  %93 = icmp sgt i32 %92, 0
  br i1 %93, label %94, label %187

94:                                               ; preds = %.lr.ph85
  %95 = icmp eq i64 %indvars.iv109, 0
  %96 = sext i32 %storemerge.lcssa8183 to i64
  br i1 %95, label %97, label %157

97:                                               ; preds = %94
  %98 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %96, i64 1
  store i32 1, ptr %98, align 4, !tbaa !5
  %storemerge75 = add i32 %storemerge.lcssa8183, 1
  %99 = sext i32 %storemerge75 to i64
  %100 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %99, i64 %96
  store i32 1, ptr %100, align 4, !tbaa !5
  %indvars.iv.next107 = add nsw i64 %99, 1
  %101 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107, i64 %99
  store i32 1, ptr %101, align 4, !tbaa !5
  %indvars.iv.next107.1 = add nsw i64 %99, 2
  %sext128 = shl i64 %indvars.iv.next107, 32
  %102 = ashr exact i64 %sext128, 32
  %103 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.1, i64 %102
  store i32 1, ptr %103, align 4, !tbaa !5
  %indvars.iv.next107.2 = add nsw i64 %99, 3
  %sext129 = shl i64 %indvars.iv.next107.1, 32
  %104 = ashr exact i64 %sext129, 32
  %105 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.2, i64 %104
  store i32 1, ptr %105, align 4, !tbaa !5
  %indvars.iv.next107.3 = add nsw i64 %99, 4
  %sext130 = shl i64 %indvars.iv.next107.2, 32
  %106 = ashr exact i64 %sext130, 32
  %107 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.3, i64 %106
  store i32 1, ptr %107, align 4, !tbaa !5
  %indvars.iv.next107.4 = add nsw i64 %99, 5
  %sext131 = shl i64 %indvars.iv.next107.3, 32
  %108 = ashr exact i64 %sext131, 32
  %109 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.4, i64 %108
  store i32 1, ptr %109, align 4, !tbaa !5
  %indvars.iv.next107.5 = add nsw i64 %99, 6
  %sext132 = shl i64 %indvars.iv.next107.4, 32
  %110 = ashr exact i64 %sext132, 32
  %111 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.5, i64 %110
  store i32 1, ptr %111, align 4, !tbaa !5
  %indvars.iv.next107.6 = add nsw i64 %99, 7
  %sext133 = shl i64 %indvars.iv.next107.5, 32
  %112 = ashr exact i64 %sext133, 32
  %113 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.6, i64 %112
  store i32 1, ptr %113, align 4, !tbaa !5
  %indvars.iv.next107.7 = add nsw i64 %99, 8
  %sext134 = shl i64 %indvars.iv.next107.6, 32
  %114 = ashr exact i64 %sext134, 32
  %115 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.7, i64 %114
  store i32 1, ptr %115, align 4, !tbaa !5
  %indvars.iv.next107.8 = add nsw i64 %99, 9
  %sext135 = shl i64 %indvars.iv.next107.7, 32
  %116 = ashr exact i64 %sext135, 32
  %117 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.8, i64 %116
  store i32 1, ptr %117, align 4, !tbaa !5
  %indvars.iv.next107.9 = add nsw i64 %99, 10
  %sext136 = shl i64 %indvars.iv.next107.8, 32
  %118 = ashr exact i64 %sext136, 32
  %119 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.9, i64 %118
  store i32 1, ptr %119, align 4, !tbaa !5
  %indvars.iv.next107.10 = add nsw i64 %99, 11
  %sext137 = shl i64 %indvars.iv.next107.9, 32
  %120 = ashr exact i64 %sext137, 32
  %121 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.10, i64 %120
  store i32 1, ptr %121, align 4, !tbaa !5
  %indvars.iv.next107.11 = add nsw i64 %99, 12
  %sext138 = shl i64 %indvars.iv.next107.10, 32
  %122 = ashr exact i64 %sext138, 32
  %123 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.11, i64 %122
  store i32 1, ptr %123, align 4, !tbaa !5
  %indvars.iv.next107.12 = add nsw i64 %99, 13
  %sext139 = shl i64 %indvars.iv.next107.11, 32
  %124 = ashr exact i64 %sext139, 32
  %125 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.12, i64 %124
  store i32 1, ptr %125, align 4, !tbaa !5
  %indvars.iv.next107.13 = add nsw i64 %99, 14
  %sext140 = shl i64 %indvars.iv.next107.12, 32
  %126 = ashr exact i64 %sext140, 32
  %127 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.13, i64 %126
  store i32 1, ptr %127, align 4, !tbaa !5
  %indvars.iv.next107.14 = add nsw i64 %99, 15
  %sext141 = shl i64 %indvars.iv.next107.13, 32
  %128 = ashr exact i64 %sext141, 32
  %129 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.14, i64 %128
  store i32 1, ptr %129, align 4, !tbaa !5
  %indvars.iv.next107.15 = add nsw i64 %99, 16
  %sext142 = shl i64 %indvars.iv.next107.14, 32
  %130 = ashr exact i64 %sext142, 32
  %131 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.15, i64 %130
  store i32 1, ptr %131, align 4, !tbaa !5
  %indvars.iv.next107.16 = add nsw i64 %99, 17
  %sext143 = shl i64 %indvars.iv.next107.15, 32
  %132 = ashr exact i64 %sext143, 32
  %133 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.16, i64 %132
  store i32 1, ptr %133, align 4, !tbaa !5
  %indvars.iv.next107.17 = add nsw i64 %99, 18
  %sext144 = shl i64 %indvars.iv.next107.16, 32
  %134 = ashr exact i64 %sext144, 32
  %135 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.17, i64 %134
  store i32 1, ptr %135, align 4, !tbaa !5
  %indvars.iv.next107.18 = add nsw i64 %99, 19
  %sext145 = shl i64 %indvars.iv.next107.17, 32
  %136 = ashr exact i64 %sext145, 32
  %137 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.18, i64 %136
  store i32 1, ptr %137, align 4, !tbaa !5
  %indvars.iv.next107.19 = add nsw i64 %99, 20
  %sext146 = shl i64 %indvars.iv.next107.18, 32
  %138 = ashr exact i64 %sext146, 32
  %139 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.19, i64 %138
  store i32 1, ptr %139, align 4, !tbaa !5
  %indvars.iv.next107.20 = add nsw i64 %99, 21
  %sext147 = shl i64 %indvars.iv.next107.19, 32
  %140 = ashr exact i64 %sext147, 32
  %141 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.20, i64 %140
  store i32 1, ptr %141, align 4, !tbaa !5
  %indvars.iv.next107.21 = add nsw i64 %99, 22
  %sext148 = shl i64 %indvars.iv.next107.20, 32
  %142 = ashr exact i64 %sext148, 32
  %143 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.21, i64 %142
  store i32 1, ptr %143, align 4, !tbaa !5
  %indvars.iv.next107.22 = add nsw i64 %99, 23
  %sext149 = shl i64 %indvars.iv.next107.21, 32
  %144 = ashr exact i64 %sext149, 32
  %145 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.22, i64 %144
  store i32 1, ptr %145, align 4, !tbaa !5
  %indvars.iv.next107.23 = add nsw i64 %99, 24
  %sext150 = shl i64 %indvars.iv.next107.22, 32
  %146 = ashr exact i64 %sext150, 32
  %147 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.23, i64 %146
  store i32 1, ptr %147, align 4, !tbaa !5
  %indvars.iv.next107.24 = add nsw i64 %99, 25
  %sext151 = shl i64 %indvars.iv.next107.23, 32
  %148 = ashr exact i64 %sext151, 32
  %149 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.24, i64 %148
  store i32 1, ptr %149, align 4, !tbaa !5
  %indvars.iv.next107.25 = add nsw i64 %99, 26
  %sext152 = shl i64 %indvars.iv.next107.24, 32
  %150 = ashr exact i64 %sext152, 32
  %151 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.25, i64 %150
  store i32 1, ptr %151, align 4, !tbaa !5
  %indvars.iv.next107.26 = add nsw i64 %99, 27
  %sext153 = shl i64 %indvars.iv.next107.25, 32
  %152 = ashr exact i64 %sext153, 32
  %153 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.26, i64 %152
  store i32 1, ptr %153, align 4, !tbaa !5
  %indvars.iv.next107.27 = add nsw i64 %99, 28
  %sext154 = shl i64 %indvars.iv.next107.26, 32
  %154 = ashr exact i64 %sext154, 32
  %155 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next107.27, i64 %154
  store i32 1, ptr %155, align 4, !tbaa !5
  %indvars.iv.next107.28 = add i32 %storemerge.lcssa8183, 30
  store i32 %indvars.iv.next107.28, ptr @cur, align 4, !tbaa !5
  %sext155 = shl i64 %indvars.iv.next107.27, 32
  %156 = ashr exact i64 %sext155, 32
  br label %.sink.split

157:                                              ; preds = %94
  %158 = shl i64 %indvars.iv109, 33
  %sext = ashr exact i64 %158, 32
  %159 = or disjoint i64 %sext, 1
  %160 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %96, i64 %159
  store i32 1, ptr %160, align 4, !tbaa !5
  %indvars.iv109.tr = trunc i64 %indvars.iv109 to i32
  %161 = shl i32 %indvars.iv109.tr, 1
  %162 = add i32 %161, 2
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %96, i64 %163
  store i32 1, ptr %164, align 4, !tbaa !5
  %165 = add i32 %storemerge.lcssa8183, 1
  store i32 %165, ptr @cur, align 4, !tbaa !5
  %.not4569 = icmp eq i64 %indvars.iv109, 29
  br i1 %.not4569, label %183, label %.lr.ph72.preheader

.lr.ph72.preheader:                               ; preds = %157
  %166 = sext i32 %165 to i64
  %167 = trunc i64 %indvars.iv109 to i32
  %168 = sub i32 29, %167
  %xtraiter157 = and i32 %88, 3
  %lcmp.mod158.not = icmp eq i32 %xtraiter157, 0
  br i1 %lcmp.mod158.not, label %.lr.ph72.prol.loopexit, label %.lr.ph72.prol

.lr.ph72.prol:                                    ; preds = %.lr.ph72.preheader, %.lr.ph72.prol
  %indvars.iv103.prol = phi i64 [ %indvars.iv.next104.prol, %.lr.ph72.prol ], [ %166, %.lr.ph72.preheader ]
  %.03870.prol = phi i32 [ %169, %.lr.ph72.prol ], [ %168, %.lr.ph72.preheader ]
  %prol.iter159 = phi i32 [ %prol.iter159.next, %.lr.ph72.prol ], [ 0, %.lr.ph72.preheader ]
  %169 = add nsw i32 %.03870.prol, -1
  %170 = add nsw i64 %indvars.iv103.prol, -1
  %171 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv103.prol, i64 %170
  store i32 1, ptr %171, align 4, !tbaa !5
  %indvars.iv.next104.prol = add nsw i64 %indvars.iv103.prol, 1
  %prol.iter159.next = add i32 %prol.iter159, 1
  %prol.iter159.cmp.not = icmp eq i32 %prol.iter159.next, %xtraiter157
  br i1 %prol.iter159.cmp.not, label %.lr.ph72.prol.loopexit, label %.lr.ph72.prol, !llvm.loop !17

.lr.ph72.prol.loopexit:                           ; preds = %.lr.ph72.prol, %.lr.ph72.preheader
  %indvars.iv.next104.lcssa.unr = phi i64 [ poison, %.lr.ph72.preheader ], [ %indvars.iv.next104.prol, %.lr.ph72.prol ]
  %indvars.iv103.unr = phi i64 [ %166, %.lr.ph72.preheader ], [ %indvars.iv.next104.prol, %.lr.ph72.prol ]
  %.03870.unr = phi i32 [ %168, %.lr.ph72.preheader ], [ %169, %.lr.ph72.prol ]
  %172 = add i32 %89, -26
  %173 = icmp ult i32 %172, 3
  br i1 %173, label %._crit_edge73, label %.lr.ph72

.lr.ph72:                                         ; preds = %.lr.ph72.prol.loopexit, %.lr.ph72
  %indvars.iv103 = phi i64 [ %indvars.iv.next104.3, %.lr.ph72 ], [ %indvars.iv103.unr, %.lr.ph72.prol.loopexit ]
  %.03870 = phi i32 [ %179, %.lr.ph72 ], [ %.03870.unr, %.lr.ph72.prol.loopexit ]
  %174 = add nsw i64 %indvars.iv103, -1
  %175 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv103, i64 %174
  store i32 1, ptr %175, align 4, !tbaa !5
  %indvars.iv.next104 = add nsw i64 %indvars.iv103, 1
  %176 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next104, i64 %indvars.iv103
  store i32 1, ptr %176, align 4, !tbaa !5
  %indvars.iv.next104.1 = add nsw i64 %indvars.iv103, 2
  %177 = add nsw i64 %indvars.iv103, 1
  %178 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next104.1, i64 %177
  store i32 1, ptr %178, align 4, !tbaa !5
  %indvars.iv.next104.2 = add nsw i64 %indvars.iv103, 3
  %179 = add nsw i32 %.03870, -4
  %180 = add nsw i64 %indvars.iv103, 2
  %181 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv.next104.2, i64 %180
  store i32 1, ptr %181, align 4, !tbaa !5
  %indvars.iv.next104.3 = add nsw i64 %indvars.iv103, 4
  %.not45.3 = icmp eq i32 %179, 0
  br i1 %.not45.3, label %._crit_edge73, label %.lr.ph72, !llvm.loop !18

._crit_edge73:                                    ; preds = %.lr.ph72, %.lr.ph72.prol.loopexit
  %indvars.iv.next104.lcssa = phi i64 [ %indvars.iv.next104.lcssa.unr, %.lr.ph72.prol.loopexit ], [ %indvars.iv.next104.3, %.lr.ph72 ]
  %182 = trunc nsw i64 %indvars.iv.next104.lcssa to i32
  store i32 %182, ptr @cur, align 4, !tbaa !5
  br label %183

183:                                              ; preds = %._crit_edge73, %157
  %storemerge.lcssa82 = phi i32 [ %182, %._crit_edge73 ], [ %165, %157 ]
  %184 = add nsw i32 %storemerge.lcssa82, -1
  %185 = sext i32 %184 to i64
  br label %.sink.split

.sink.split:                                      ; preds = %97, %183
  %.sink156 = phi i64 [ %185, %183 ], [ %156, %97 ]
  %storemerge.lcssa80.ph = phi i32 [ %storemerge.lcssa82, %183 ], [ %indvars.iv.next107.28, %97 ]
  %186 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds (i8, ptr @g, i64 16008), i64 0, i64 %.sink156
  store i32 1, ptr %186, align 4, !tbaa !5
  br label %187

187:                                              ; preds = %.sink.split, %.lr.ph85
  %storemerge.lcssa80 = phi i32 [ %storemerge.lcssa8183, %.lr.ph85 ], [ %storemerge.lcssa80.ph, %.sink.split ]
  %indvars.iv.next110 = add nuw nsw i64 %indvars.iv109, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next110, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge86, label %.lr.ph85, !llvm.loop !19

.preheader49:                                     ; preds = %._crit_edge89.us
  br i1 %70, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %.preheader49, %._crit_edge93
  %188 = phi i32 [ %191, %._crit_edge93 ], [ %69, %.preheader49 ]
  %indvars.iv125 = phi i64 [ %indvars.iv.next126, %._crit_edge93 ], [ 1, %.preheader49 ]
  %189 = icmp sgt i32 %188, 1
  br i1 %189, label %.lr.ph92, label %._crit_edge93

._crit_edge93:                                    ; preds = %.lr.ph92, %.preheader
  %190 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %indvars.iv.next126 = add nuw nsw i64 %indvars.iv125, 1
  %191 = load i32, ptr @cur, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = icmp slt i64 %indvars.iv.next126, %192
  br i1 %193, label %.preheader, label %.loopexit, !llvm.loop !20

.lr.ph92:                                         ; preds = %.preheader, %.lr.ph92
  %indvars.iv122 = phi i64 [ %indvars.iv.next123, %.lr.ph92 ], [ 1, %.preheader ]
  %194 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv125, i64 %indvars.iv122
  %195 = load i32, ptr %194, align 4, !tbaa !5
  %.not = icmp eq i32 %195, 0
  %.str.5..str.4 = select i1 %.not, ptr @.str.5, ptr @.str.4
  %196 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.5..str.4)
  %indvars.iv.next123 = add nuw nsw i64 %indvars.iv122, 1
  %197 = load i32, ptr @cur, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = icmp slt i64 %indvars.iv.next123, %198
  br i1 %199, label %.lr.ph92, label %._crit_edge93, !llvm.loop !21

.loopexit:                                        ; preds = %._crit_edge93, %._crit_edge86, %.preheader49, %4
  ret i32 0
}

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

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

attributes #0 = { mustprogress nofree norecurse 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 = { 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" }

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}


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