; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/2 Beta/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"

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@n = external dso_local global i32, align 4
@g = external dso_local global [1001 x [1001 x i32]], align 16
@a = external dso_local global [1001 x [1001 x i32]], align 16
@b = external dso_local global [1001 x [1001 x i32]], align 16
@p1 = external dso_local global [1001 x [1001 x i32]], align 16
@p2 = external dso_local global [1001 x [1001 x i32]], align 16
@zx = external dso_local global i32, align 4
@zy = external dso_local global i32, align 4
@zero = external dso_local global i8, align 1
@.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 [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %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
  %13 = alloca i32, align 4
  %14 = alloca %"class.std::__cxx11::basic_string", align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %"class.std::__cxx11::basic_string", align 8
  %20 = alloca %"class.std::__cxx11::basic_string", align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca %"class.std::__cxx11::basic_string", align 8
  %24 = alloca %"class.std::__cxx11::basic_string", align 8
  store i32 0, ptr %1, align 4
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %100, %0
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = icmp sle i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %103

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %96, %31
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = icmp sle i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %99

37:                                               ; preds = %32
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %39
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1001 x i32], ptr %40, i64 0, i64 %42
  %44 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %43)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %46
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1001 x i32], ptr %47, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  store i32 %51, ptr %5, align 4, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %63

54:                                               ; preds = %37
  store i8 1, ptr @zero, align 1, !tbaa !9
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %56
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1001 x i32], ptr %57, i64 0, i64 %59
  store i32 10, ptr %60, align 4, !tbaa !5
  store i32 10, ptr %5, align 4, !tbaa !5
  %61 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %61, ptr @zx, align 4, !tbaa !5
  %62 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %62, ptr @zy, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %54, %37
  br label %64

64:                                               ; preds = %68, %63
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = srem i32 %65, 2
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %79

68:                                               ; preds = %64
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %70
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1001 x i32], ptr %71, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %74, align 4, !tbaa !5
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = sdiv i32 %77, 2
  store i32 %78, ptr %5, align 4, !tbaa !5
  br label %64, !llvm.loop !11

79:                                               ; preds = %64
  br label %80

80:                                               ; preds = %84, %79
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = srem i32 %81, 5
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %84, label %95

84:                                               ; preds = %80
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %86
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [1001 x i32], ptr %87, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %90, align 4, !tbaa !5
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = sdiv i32 %93, 5
  store i32 %94, ptr %5, align 4, !tbaa !5
  br label %80, !llvm.loop !13

95:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %4, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %4, align 4, !tbaa !5
  br label %32, !llvm.loop !14

99:                                               ; preds = %36
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %2, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %2, align 4, !tbaa !5
  br label %26, !llvm.loop !15

103:                                              ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %168, %103
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = load i32, ptr @n, align 4, !tbaa !5
  %107 = icmp sle i32 %105, %106
  br i1 %107, label %109, label %108

108:                                              ; preds = %104
  store i32 12, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %171

109:                                              ; preds = %104
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds ([1001 x [1001 x i32]], ptr @p2, i64 0, i64 1), i64 0, i64 %111
  store i32 1, ptr %112, align 4, !tbaa !5
  %113 = load i32, ptr %6, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds ([1001 x [1001 x i32]], ptr @p1, i64 0, i64 1), i64 0, i64 %114
  store i32 1, ptr %115, align 4, !tbaa !5
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p2, i64 0, i64 %117
  %119 = getelementptr inbounds [1001 x i32], ptr %118, i64 0, i64 1
  store i32 2, ptr %119, align 4, !tbaa !5
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p1, i64 0, i64 %121
  %123 = getelementptr inbounds [1001 x i32], ptr %122, i64 0, i64 1
  store i32 2, ptr %123, align 4, !tbaa !5
  %124 = load i32, ptr %6, align 4, !tbaa !5
  %125 = sub nsw i32 %124, 1
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds ([1001 x [1001 x i32]], ptr @a, i64 0, i64 1), i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = load i32, ptr %6, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds ([1001 x [1001 x i32]], ptr @a, i64 0, i64 1), i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = add nsw i32 %132, %128
  store i32 %133, ptr %131, align 4, !tbaa !5
  %134 = load i32, ptr %6, align 4, !tbaa !5
  %135 = sub nsw i32 %134, 1
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds ([1001 x [1001 x i32]], ptr @b, i64 0, i64 1), i64 0, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !5
  %139 = load i32, ptr %6, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds ([1001 x [1001 x i32]], ptr @b, i64 0, i64 1), i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = add nsw i32 %142, %138
  store i32 %143, ptr %141, align 4, !tbaa !5
  %144 = load i32, ptr %6, align 4, !tbaa !5
  %145 = sub nsw i32 %144, 1
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %146
  %148 = getelementptr inbounds [1001 x i32], ptr %147, i64 0, i64 1
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = load i32, ptr %6, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %151
  %153 = getelementptr inbounds [1001 x i32], ptr %152, i64 0, i64 1
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = add nsw i32 %154, %149
  store i32 %155, ptr %153, align 4, !tbaa !5
  %156 = load i32, ptr %6, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %158
  %160 = getelementptr inbounds [1001 x i32], ptr %159, i64 0, i64 1
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = load i32, ptr %6, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %163
  %165 = getelementptr inbounds [1001 x i32], ptr %164, i64 0, i64 1
  %166 = load i32, ptr %165, align 4, !tbaa !5
  %167 = add nsw i32 %166, %161
  store i32 %167, ptr %165, align 4, !tbaa !5
  br label %168

168:                                              ; preds = %109
  %169 = load i32, ptr %6, align 4, !tbaa !5
  %170 = add nsw i32 %169, 1
  store i32 %170, ptr %6, align 4, !tbaa !5
  br label %104, !llvm.loop !16

171:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 2, ptr %7, align 4, !tbaa !5
  br label %172

172:                                              ; preds = %316, %171
  %173 = load i32, ptr %7, align 4, !tbaa !5
  %174 = load i32, ptr @n, align 4, !tbaa !5
  %175 = icmp sle i32 %173, %174
  br i1 %175, label %177, label %176

176:                                              ; preds = %172
  store i32 15, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %319

177:                                              ; preds = %172
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 2, ptr %8, align 4, !tbaa !5
  br label %178

178:                                              ; preds = %312, %177
  %179 = load i32, ptr %8, align 4, !tbaa !5
  %180 = load i32, ptr @n, align 4, !tbaa !5
  %181 = icmp sle i32 %179, %180
  br i1 %181, label %183, label %182

182:                                              ; preds = %178
  store i32 18, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %315

183:                                              ; preds = %178
  %184 = load i32, ptr %7, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %185
  %187 = load i32, ptr %8, align 4, !tbaa !5
  %188 = sub nsw i32 %187, 1
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [1001 x i32], ptr %186, i64 0, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  %192 = load i32, ptr %7, align 4, !tbaa !5
  %193 = sub nsw i32 %192, 1
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %194
  %196 = load i32, ptr %8, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [1001 x i32], ptr %195, i64 0, i64 %197
  %199 = load i32, ptr %198, align 4, !tbaa !5
  %200 = icmp slt i32 %191, %199
  br i1 %200, label %201, label %224

201:                                              ; preds = %183
  %202 = load i32, ptr %7, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %203
  %205 = load i32, ptr %8, align 4, !tbaa !5
  %206 = sub nsw i32 %205, 1
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [1001 x i32], ptr %204, i64 0, i64 %207
  %209 = load i32, ptr %208, align 4, !tbaa !5
  %210 = load i32, ptr %7, align 4, !tbaa !5
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %211
  %213 = load i32, ptr %8, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [1001 x i32], ptr %212, i64 0, i64 %214
  %216 = load i32, ptr %215, align 4, !tbaa !5
  %217 = add nsw i32 %216, %209
  store i32 %217, ptr %215, align 4, !tbaa !5
  %218 = load i32, ptr %7, align 4, !tbaa !5
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p1, i64 0, i64 %219
  %221 = load i32, ptr %8, align 4, !tbaa !5
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds [1001 x i32], ptr %220, i64 0, i64 %222
  store i32 1, ptr %223, align 4, !tbaa !5
  br label %247

224:                                              ; preds = %183
  %225 = load i32, ptr %7, align 4, !tbaa !5
  %226 = sub nsw i32 %225, 1
  %227 = sext i32 %226 to i64
  %228 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %227
  %229 = load i32, ptr %8, align 4, !tbaa !5
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds [1001 x i32], ptr %228, i64 0, i64 %230
  %232 = load i32, ptr %231, align 4, !tbaa !5
  %233 = load i32, ptr %7, align 4, !tbaa !5
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %234
  %236 = load i32, ptr %8, align 4, !tbaa !5
  %237 = sext i32 %236 to i64
  %238 = getelementptr inbounds [1001 x i32], ptr %235, i64 0, i64 %237
  %239 = load i32, ptr %238, align 4, !tbaa !5
  %240 = add nsw i32 %239, %232
  store i32 %240, ptr %238, align 4, !tbaa !5
  %241 = load i32, ptr %7, align 4, !tbaa !5
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p1, i64 0, i64 %242
  %244 = load i32, ptr %8, align 4, !tbaa !5
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [1001 x i32], ptr %243, i64 0, i64 %245
  store i32 2, ptr %246, align 4, !tbaa !5
  br label %247

247:                                              ; preds = %224, %201
  %248 = load i32, ptr %7, align 4, !tbaa !5
  %249 = sext i32 %248 to i64
  %250 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %249
  %251 = load i32, ptr %8, align 4, !tbaa !5
  %252 = sub nsw i32 %251, 1
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [1001 x i32], ptr %250, i64 0, i64 %253
  %255 = load i32, ptr %254, align 4, !tbaa !5
  %256 = load i32, ptr %7, align 4, !tbaa !5
  %257 = sub nsw i32 %256, 1
  %258 = sext i32 %257 to i64
  %259 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %258
  %260 = load i32, ptr %8, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [1001 x i32], ptr %259, i64 0, i64 %261
  %263 = load i32, ptr %262, align 4, !tbaa !5
  %264 = icmp slt i32 %255, %263
  br i1 %264, label %265, label %288

265:                                              ; preds = %247
  %266 = load i32, ptr %7, align 4, !tbaa !5
  %267 = sext i32 %266 to i64
  %268 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %267
  %269 = load i32, ptr %8, align 4, !tbaa !5
  %270 = sub nsw i32 %269, 1
  %271 = sext i32 %270 to i64
  %272 = getelementptr inbounds [1001 x i32], ptr %268, i64 0, i64 %271
  %273 = load i32, ptr %272, align 4, !tbaa !5
  %274 = load i32, ptr %7, align 4, !tbaa !5
  %275 = sext i32 %274 to i64
  %276 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %275
  %277 = load i32, ptr %8, align 4, !tbaa !5
  %278 = sext i32 %277 to i64
  %279 = getelementptr inbounds [1001 x i32], ptr %276, i64 0, i64 %278
  %280 = load i32, ptr %279, align 4, !tbaa !5
  %281 = add nsw i32 %280, %273
  store i32 %281, ptr %279, align 4, !tbaa !5
  %282 = load i32, ptr %7, align 4, !tbaa !5
  %283 = sext i32 %282 to i64
  %284 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p2, i64 0, i64 %283
  %285 = load i32, ptr %8, align 4, !tbaa !5
  %286 = sext i32 %285 to i64
  %287 = getelementptr inbounds [1001 x i32], ptr %284, i64 0, i64 %286
  store i32 1, ptr %287, align 4, !tbaa !5
  br label %311

288:                                              ; preds = %247
  %289 = load i32, ptr %7, align 4, !tbaa !5
  %290 = sub nsw i32 %289, 1
  %291 = sext i32 %290 to i64
  %292 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %291
  %293 = load i32, ptr %8, align 4, !tbaa !5
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds [1001 x i32], ptr %292, i64 0, i64 %294
  %296 = load i32, ptr %295, align 4, !tbaa !5
  %297 = load i32, ptr %7, align 4, !tbaa !5
  %298 = sext i32 %297 to i64
  %299 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %298
  %300 = load i32, ptr %8, align 4, !tbaa !5
  %301 = sext i32 %300 to i64
  %302 = getelementptr inbounds [1001 x i32], ptr %299, i64 0, i64 %301
  %303 = load i32, ptr %302, align 4, !tbaa !5
  %304 = add nsw i32 %303, %296
  store i32 %304, ptr %302, align 4, !tbaa !5
  %305 = load i32, ptr %7, align 4, !tbaa !5
  %306 = sext i32 %305 to i64
  %307 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p2, i64 0, i64 %306
  %308 = load i32, ptr %8, align 4, !tbaa !5
  %309 = sext i32 %308 to i64
  %310 = getelementptr inbounds [1001 x i32], ptr %307, i64 0, i64 %309
  store i32 2, ptr %310, align 4, !tbaa !5
  br label %311

311:                                              ; preds = %288, %265
  br label %312

312:                                              ; preds = %311
  %313 = load i32, ptr %8, align 4, !tbaa !5
  %314 = add nsw i32 %313, 1
  store i32 %314, ptr %8, align 4, !tbaa !5
  br label %178, !llvm.loop !17

315:                                              ; preds = %182
  br label %316

316:                                              ; preds = %315
  %317 = load i32, ptr %7, align 4, !tbaa !5
  %318 = add nsw i32 %317, 1
  store i32 %318, ptr %7, align 4, !tbaa !5
  br label %172, !llvm.loop !18

319:                                              ; preds = %176
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %320 = load i32, ptr @n, align 4, !tbaa !5
  %321 = sext i32 %320 to i64
  %322 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %321
  %323 = load i32, ptr @n, align 4, !tbaa !5
  %324 = sext i32 %323 to i64
  %325 = getelementptr inbounds [1001 x i32], ptr %322, i64 0, i64 %324
  %326 = load i32, ptr @n, align 4, !tbaa !5
  %327 = sext i32 %326 to i64
  %328 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %327
  %329 = load i32, ptr @n, align 4, !tbaa !5
  %330 = sext i32 %329 to i64
  %331 = getelementptr inbounds [1001 x i32], ptr %328, i64 0, i64 %330
  %332 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %325, ptr noundef nonnull align 4 dereferenceable(4) %331)
  %333 = load i32, ptr %332, align 4, !tbaa !5
  store i32 %333, ptr %9, align 4, !tbaa !5
  %334 = load i8, ptr @zero, align 1, !tbaa !9, !range !19, !noundef !20
  %335 = trunc i8 %334 to i1
  br i1 %335, label %336, label %387

336:                                              ; preds = %319
  %337 = load i32, ptr %9, align 4, !tbaa !5
  %338 = icmp sge i32 %337, 1
  br i1 %338, label %339, label %387

339:                                              ; preds = %336
  %340 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %341

341:                                              ; preds = %348, %339
  %342 = load i32, ptr %10, align 4, !tbaa !5
  %343 = load i32, ptr @zx, align 4, !tbaa !5
  %344 = icmp slt i32 %342, %343
  br i1 %344, label %346, label %345

345:                                              ; preds = %341
  store i32 21, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %351

346:                                              ; preds = %341
  %347 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %348

348:                                              ; preds = %346
  %349 = load i32, ptr %10, align 4, !tbaa !5
  %350 = add nsw i32 %349, 1
  store i32 %350, ptr %10, align 4, !tbaa !5
  br label %341, !llvm.loop !21

351:                                              ; preds = %345
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %352

352:                                              ; preds = %359, %351
  %353 = load i32, ptr %11, align 4, !tbaa !5
  %354 = load i32, ptr @zy, align 4, !tbaa !5
  %355 = icmp slt i32 %353, %354
  br i1 %355, label %357, label %356

356:                                              ; preds = %352
  store i32 24, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %362

357:                                              ; preds = %352
  %358 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %359

359:                                              ; preds = %357
  %360 = load i32, ptr %11, align 4, !tbaa !5
  %361 = add nsw i32 %360, 1
  store i32 %361, ptr %11, align 4, !tbaa !5
  br label %352, !llvm.loop !22

362:                                              ; preds = %356
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %363 = load i32, ptr @zx, align 4, !tbaa !5
  store i32 %363, ptr %12, align 4, !tbaa !5
  br label %364

364:                                              ; preds = %371, %362
  %365 = load i32, ptr %12, align 4, !tbaa !5
  %366 = load i32, ptr @n, align 4, !tbaa !5
  %367 = icmp slt i32 %365, %366
  br i1 %367, label %369, label %368

368:                                              ; preds = %364
  store i32 27, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %374

369:                                              ; preds = %364
  %370 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %371

371:                                              ; preds = %369
  %372 = load i32, ptr %12, align 4, !tbaa !5
  %373 = add nsw i32 %372, 1
  store i32 %373, ptr %12, align 4, !tbaa !5
  br label %364, !llvm.loop !23

374:                                              ; preds = %368
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %375 = load i32, ptr @zy, align 4, !tbaa !5
  store i32 %375, ptr %13, align 4, !tbaa !5
  br label %376

376:                                              ; preds = %383, %374
  %377 = load i32, ptr %13, align 4, !tbaa !5
  %378 = load i32, ptr @n, align 4, !tbaa !5
  %379 = icmp slt i32 %377, %378
  br i1 %379, label %381, label %380

380:                                              ; preds = %376
  store i32 30, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %386

381:                                              ; preds = %376
  %382 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %383

383:                                              ; preds = %381
  %384 = load i32, ptr %13, align 4, !tbaa !5
  %385 = add nsw i32 %384, 1
  store i32 %385, ptr %13, align 4, !tbaa !5
  br label %376, !llvm.loop !24

386:                                              ; preds = %380
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %500

387:                                              ; preds = %336, %319
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14) #6
  %388 = load i32, ptr %9, align 4, !tbaa !5
  %389 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %388)
          to label %390 unwind label %418

390:                                              ; preds = %387
  %391 = load i32, ptr @n, align 4, !tbaa !5
  %392 = sext i32 %391 to i64
  %393 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %392
  %394 = load i32, ptr @n, align 4, !tbaa !5
  %395 = sext i32 %394 to i64
  %396 = getelementptr inbounds [1001 x i32], ptr %393, i64 0, i64 %395
  %397 = load i32, ptr %396, align 4, !tbaa !5
  %398 = load i32, ptr @n, align 4, !tbaa !5
  %399 = sext i32 %398 to i64
  %400 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %399
  %401 = load i32, ptr @n, align 4, !tbaa !5
  %402 = sext i32 %401 to i64
  %403 = getelementptr inbounds [1001 x i32], ptr %400, i64 0, i64 %402
  %404 = load i32, ptr %403, align 4, !tbaa !5
  %405 = icmp slt i32 %397, %404
  br i1 %405, label %406, label %452

406:                                              ; preds = %390
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %407 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %407, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %408 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %408, ptr %18, align 4, !tbaa !5
  br label %409

409:                                              ; preds = %449, %406
  %410 = load i32, ptr %17, align 4, !tbaa !5
  %411 = icmp sgt i32 %410, 1
  br i1 %411, label %415, label %412

412:                                              ; preds = %409
  %413 = load i32, ptr %18, align 4, !tbaa !5
  %414 = icmp sgt i32 %413, 1
  br label %415

415:                                              ; preds = %412, %409
  %416 = phi i1 [ true, %409 ], [ %414, %412 ]
  br i1 %416, label %422, label %417

417:                                              ; preds = %415
  store i32 33, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %451

418:                                              ; preds = %494, %387
  %419 = landingpad { ptr, i32 }
          cleanup
  %420 = extractvalue { ptr, i32 } %419, 0
  store ptr %420, ptr %15, align 8
  %421 = extractvalue { ptr, i32 } %419, 1
  store i32 %421, ptr %16, align 4
  br label %498

422:                                              ; preds = %415
  %423 = load i32, ptr %17, align 4, !tbaa !5
  %424 = sext i32 %423 to i64
  %425 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p1, i64 0, i64 %424
  %426 = load i32, ptr %18, align 4, !tbaa !5
  %427 = sext i32 %426 to i64
  %428 = getelementptr inbounds [1001 x i32], ptr %425, i64 0, i64 %427
  %429 = load i32, ptr %428, align 4, !tbaa !5
  %430 = icmp eq i32 %429, 1
  br i1 %430, label %431, label %440

431:                                              ; preds = %422
  call void @llvm.lifetime.start.p0(i64 32, ptr %19) #6
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %19, i8 noundef signext 82, ptr noundef nonnull align 8 dereferenceable(32) %14)
          to label %432 unwind label %436

432:                                              ; preds = %431
  %433 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull align 8 dereferenceable(32) %19) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %19) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #6
  %434 = load i32, ptr %18, align 4, !tbaa !5
  %435 = add nsw i32 %434, -1
  store i32 %435, ptr %18, align 4, !tbaa !5
  br label %449

436:                                              ; preds = %431
  %437 = landingpad { ptr, i32 }
          cleanup
  %438 = extractvalue { ptr, i32 } %437, 0
  store ptr %438, ptr %15, align 8
  %439 = extractvalue { ptr, i32 } %437, 1
  store i32 %439, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #6
  br label %450

440:                                              ; preds = %422
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #6
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %20, i8 noundef signext 68, ptr noundef nonnull align 8 dereferenceable(32) %14)
          to label %441 unwind label %445

441:                                              ; preds = %440
  %442 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull align 8 dereferenceable(32) %20) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #6
  %443 = load i32, ptr %17, align 4, !tbaa !5
  %444 = add nsw i32 %443, -1
  store i32 %444, ptr %17, align 4, !tbaa !5
  br label %449

445:                                              ; preds = %440
  %446 = landingpad { ptr, i32 }
          cleanup
  %447 = extractvalue { ptr, i32 } %446, 0
  store ptr %447, ptr %15, align 8
  %448 = extractvalue { ptr, i32 } %446, 1
  store i32 %448, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #6
  br label %450

449:                                              ; preds = %441, %432
  br label %409, !llvm.loop !25

450:                                              ; preds = %445, %436
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %498

451:                                              ; preds = %417
  br label %494

452:                                              ; preds = %390
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %453 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %453, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  %454 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %454, ptr %22, align 4, !tbaa !5
  br label %455

455:                                              ; preds = %491, %452
  %456 = load i32, ptr %21, align 4, !tbaa !5
  %457 = icmp sgt i32 %456, 1
  br i1 %457, label %461, label %458

458:                                              ; preds = %455
  %459 = load i32, ptr %22, align 4, !tbaa !5
  %460 = icmp sgt i32 %459, 1
  br label %461

461:                                              ; preds = %458, %455
  %462 = phi i1 [ true, %455 ], [ %460, %458 ]
  br i1 %462, label %464, label %463

463:                                              ; preds = %461
  store i32 35, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  br label %493

464:                                              ; preds = %461
  %465 = load i32, ptr %21, align 4, !tbaa !5
  %466 = sext i32 %465 to i64
  %467 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p2, i64 0, i64 %466
  %468 = load i32, ptr %22, align 4, !tbaa !5
  %469 = sext i32 %468 to i64
  %470 = getelementptr inbounds [1001 x i32], ptr %467, i64 0, i64 %469
  %471 = load i32, ptr %470, align 4, !tbaa !5
  %472 = icmp eq i32 %471, 1
  br i1 %472, label %473, label %482

473:                                              ; preds = %464
  call void @llvm.lifetime.start.p0(i64 32, ptr %23) #6
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %23, i8 noundef signext 82, ptr noundef nonnull align 8 dereferenceable(32) %14)
          to label %474 unwind label %478

474:                                              ; preds = %473
  %475 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull align 8 dereferenceable(32) %23) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %23) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %23) #6
  %476 = load i32, ptr %22, align 4, !tbaa !5
  %477 = add nsw i32 %476, -1
  store i32 %477, ptr %22, align 4, !tbaa !5
  br label %491

478:                                              ; preds = %473
  %479 = landingpad { ptr, i32 }
          cleanup
  %480 = extractvalue { ptr, i32 } %479, 0
  store ptr %480, ptr %15, align 8
  %481 = extractvalue { ptr, i32 } %479, 1
  store i32 %481, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %23) #6
  br label %492

482:                                              ; preds = %464
  call void @llvm.lifetime.start.p0(i64 32, ptr %24) #6
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %24, i8 noundef signext 68, ptr noundef nonnull align 8 dereferenceable(32) %14)
          to label %483 unwind label %487

483:                                              ; preds = %482
  %484 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull align 8 dereferenceable(32) %24) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %24) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %24) #6
  %485 = load i32, ptr %21, align 4, !tbaa !5
  %486 = add nsw i32 %485, -1
  store i32 %486, ptr %21, align 4, !tbaa !5
  br label %491

487:                                              ; preds = %482
  %488 = landingpad { ptr, i32 }
          cleanup
  %489 = extractvalue { ptr, i32 } %488, 0
  store ptr %489, ptr %15, align 8
  %490 = extractvalue { ptr, i32 } %488, 1
  store i32 %490, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %24) #6
  br label %492

491:                                              ; preds = %483, %474
  br label %455, !llvm.loop !26

492:                                              ; preds = %487, %478
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  br label %498

493:                                              ; preds = %463
  br label %494

494:                                              ; preds = %493, %451
  %495 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %14) #6
  %496 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %495)
          to label %497 unwind label %418

497:                                              ; preds = %494
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #6
  br label %499

498:                                              ; preds = %492, %450, %418
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %502

499:                                              ; preds = %497
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %500

500:                                              ; preds = %499, %386
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  %501 = load i32, ptr %1, align 4
  ret i32 %501

502:                                              ; preds = %498
  %503 = load ptr, ptr %15, align 8
  %504 = load i32, ptr %16, align 4
  %505 = insertvalue { ptr, i32 } poison, ptr %503, 0
  %506 = insertvalue { ptr, i32 } %505, i32 %504, 1
  resume { ptr, i32 } %506
}

declare i32 @__isoc99_scanf(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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i8 noundef signext, ptr noundef nonnull align 8 dereferenceable(32)) #5

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #4 align 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 = { inlinehint mustprogress 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 #4 = { mustprogress 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 #5 = { 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 #6 = { 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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !12}
!26 = distinct !{!26, !12}


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

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@n = external dso_local global i32, align 4
@g = external dso_local global [1001 x [1001 x i32]], align 16
@a = external dso_local global [1001 x [1001 x i32]], align 16
@b = external dso_local global [1001 x [1001 x i32]], align 16
@p1 = external dso_local local_unnamed_addr global [1001 x [1001 x i32]], align 16
@p2 = external dso_local local_unnamed_addr global [1001 x [1001 x i32]], align 16
@zx = external dso_local local_unnamed_addr global i32, align 4
@zy = external dso_local local_unnamed_addr global i32, align 4
@zero = external dso_local local_unnamed_addr global i8, align 1
@.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 [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::__cxx11::basic_string", align 8
  %2 = alloca %"class.std::__cxx11::basic_string", align 8
  %3 = alloca %"class.std::__cxx11::basic_string", align 8
  %4 = alloca %"class.std::__cxx11::basic_string", align 8
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not153 = icmp slt i32 %7, 1
  br i1 %.not153, label %._crit_edge165, label %.preheader142

.preheader142:                                    ; preds = %0, %._crit_edge152
  %8 = phi i32 [ %11, %._crit_edge152 ], [ %7, %0 ]
  %indvars.iv192 = phi i64 [ %indvars.iv.next193, %._crit_edge152 ], [ 1, %0 ]
  %.not133149 = icmp slt i32 %8, 1
  br i1 %.not133149, label %.preheader142.._crit_edge152_crit_edge, label %.lr.ph151

.preheader142.._crit_edge152_crit_edge:           ; preds = %.preheader142
  %.pre212 = sext i32 %8 to i64
  br label %._crit_edge152

.lr.ph151:                                        ; preds = %.preheader142
  %9 = trunc nuw nsw i64 %indvars.iv192 to i32
  br label %12

.preheader140:                                    ; preds = %._crit_edge152
  %.not126156 = icmp slt i32 %11, 1
  br i1 %.not126156, label %._crit_edge165, label %.lr.ph158.preheader

.lr.ph158.preheader:                              ; preds = %.preheader140
  %10 = add nuw i32 %11, 1
  %wide.trip.count = zext i32 %10 to i64
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  %.pre209 = load i32, ptr getelementptr inbounds (i8, ptr @b, i64 4), align 4, !tbaa !5
  br label %.lr.ph158

._crit_edge152:                                   ; preds = %37, %.preheader142.._crit_edge152_crit_edge
  %.pre-phi = phi i64 [ %.pre212, %.preheader142.._crit_edge152_crit_edge ], [ %39, %37 ]
  %11 = phi i32 [ %8, %.preheader142.._crit_edge152_crit_edge ], [ %38, %37 ]
  %indvars.iv.next193 = add nuw nsw i64 %indvars.iv192, 1
  %.not.not = icmp slt i64 %indvars.iv192, %.pre-phi
  br i1 %.not.not, label %.preheader142, label %.preheader140, !llvm.loop !9

12:                                               ; preds = %.lr.ph151, %37
  %indvars.iv = phi i64 [ 1, %.lr.ph151 ], [ %indvars.iv.next, %37 ]
  %13 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %indvars.iv192, i64 %indvars.iv
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %13)
  %15 = load i32, ptr %13, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %.thread, label %18

.thread:                                          ; preds = %12
  store i8 1, ptr @zero, align 1, !tbaa !12
  store i32 10, ptr %13, align 4, !tbaa !5
  store i32 %9, ptr @zx, align 4, !tbaa !5
  %17 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %17, ptr @zy, align 4, !tbaa !5
  br label %.lr.ph

18:                                               ; preds = %12
  %19 = and i32 %15, 1
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %.lr.ph, label %.preheader141

.lr.ph:                                           ; preds = %.thread, %18
  %.0115217 = phi i32 [ 10, %.thread ], [ %15, %18 ]
  %21 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %indvars.iv192, i64 %indvars.iv
  %.promoted = load i32, ptr %21, align 4, !tbaa !5
  br label %25

..preheader141_crit_edge:                         ; preds = %25
  store i32 %27, ptr %21, align 4, !tbaa !5
  br label %.preheader141

.preheader141:                                    ; preds = %..preheader141_crit_edge, %18
  %.1116.lcssa = phi i32 [ %28, %..preheader141_crit_edge ], [ %15, %18 ]
  %22 = srem i32 %.1116.lcssa, 5
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %.lr.ph146, label %37

.lr.ph146:                                        ; preds = %.preheader141
  %24 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %indvars.iv192, i64 %indvars.iv
  %.promoted147 = load i32, ptr %24, align 4, !tbaa !5
  br label %31

25:                                               ; preds = %.lr.ph, %25
  %26 = phi i32 [ %.promoted, %.lr.ph ], [ %27, %25 ]
  %.1116143 = phi i32 [ %.0115217, %.lr.ph ], [ %28, %25 ]
  %27 = add nsw i32 %26, 1
  %28 = ashr exact i32 %.1116143, 1
  %29 = and i32 %.1116143, 2
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %25, label %..preheader141_crit_edge, !llvm.loop !14

31:                                               ; preds = %.lr.ph146, %31
  %32 = phi i32 [ %.promoted147, %.lr.ph146 ], [ %33, %31 ]
  %.2117145 = phi i32 [ %.1116.lcssa, %.lr.ph146 ], [ %34, %31 ]
  %33 = add nsw i32 %32, 1
  %34 = sdiv i32 %.2117145, 5
  %35 = srem i32 %34, 5
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %31, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %31
  store i32 %33, ptr %24, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %._crit_edge, %.preheader141
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %.not133.not = icmp slt i64 %indvars.iv, %39
  br i1 %.not133.not, label %12, label %._crit_edge152, !llvm.loop !16

.preheader139:                                    ; preds = %.lr.ph158
  %.not127163 = icmp eq i32 %11, 1
  br i1 %.not127163, label %._crit_edge165, label %.preheader138.preheader

.preheader138.preheader:                          ; preds = %.preheader139
  %40 = add nuw i32 %11, 1
  %wide.trip.count206 = zext i32 %40 to i64
  br label %.preheader138

.lr.ph158:                                        ; preds = %.lr.ph158.preheader, %.lr.ph158
  %41 = phi i32 [ %.pre209, %.lr.ph158.preheader ], [ %63, %.lr.ph158 ]
  %42 = phi i32 [ %.pre, %.lr.ph158.preheader ], [ %60, %.lr.ph158 ]
  %indvars.iv195 = phi i64 [ 1, %.lr.ph158.preheader ], [ %indvars.iv.next196, %.lr.ph158 ]
  %43 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds (i8, ptr @p2, i64 4004), i64 0, i64 %indvars.iv195
  store i32 1, ptr %43, align 4, !tbaa !5
  %44 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds (i8, ptr @p1, i64 4004), i64 0, i64 %indvars.iv195
  store i32 1, ptr %44, align 4, !tbaa !5
  %45 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p2, i64 0, i64 %indvars.iv195, i64 1
  store i32 2, ptr %45, align 4, !tbaa !5
  %46 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p1, i64 0, i64 %indvars.iv195, i64 1
  store i32 2, ptr %46, align 4, !tbaa !5
  %47 = add nsw i64 %indvars.iv195, -1
  %48 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds (i8, ptr @a, i64 4004), i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds (i8, ptr @a, i64 4004), i64 0, i64 %indvars.iv195
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = add nsw i32 %51, %49
  store i32 %52, ptr %50, align 4, !tbaa !5
  %53 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds (i8, ptr @b, i64 4004), i64 0, i64 %47
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = getelementptr inbounds [1001 x i32], ptr getelementptr inbounds (i8, ptr @b, i64 4004), i64 0, i64 %indvars.iv195
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = add nsw i32 %56, %54
  store i32 %57, ptr %55, align 4, !tbaa !5
  %58 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %indvars.iv195, i64 1
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = add nsw i32 %59, %42
  store i32 %60, ptr %58, align 4, !tbaa !5
  %61 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %indvars.iv195, i64 1
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = add nsw i32 %62, %41
  store i32 %63, ptr %61, align 4, !tbaa !5
  %indvars.iv.next196 = add nuw nsw i64 %indvars.iv195, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next196, %wide.trip.count
  br i1 %exitcond.not, label %.preheader139, label %.lr.ph158, !llvm.loop !17

.preheader138:                                    ; preds = %.preheader138.preheader, %._crit_edge162
  %indvar = phi i64 [ 0, %.preheader138.preheader ], [ %indvar.next, %._crit_edge162 ]
  %indvars.iv203 = phi i64 [ 2, %.preheader138.preheader ], [ %indvars.iv.next204, %._crit_edge162 ]
  %64 = mul i64 %indvar, 4004
  %65 = add i64 %64, 8012
  %scevgep = getelementptr i8, ptr @b, i64 %65
  %scevgep247 = getelementptr i8, ptr @a, i64 %65
  %66 = add nsw i64 %indvars.iv203, -1
  %load_initial = load i32, ptr %scevgep, align 4
  %load_initial248 = load i32, ptr %scevgep247, align 4
  br label %75

._crit_edge165:                                   ; preds = %._crit_edge162, %0, %.preheader140, %.preheader139
  %.lcssa215220 = phi i32 [ %11, %.preheader139 ], [ %11, %.preheader140 ], [ %7, %0 ], [ %11, %._crit_edge162 ]
  %67 = sext i32 %.lcssa215220 to i64
  %68 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %67, i64 %67
  %69 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %67, i64 %67
  %70 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %68, ptr noundef nonnull align 4 dereferenceable(4) %69)
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = load i8, ptr @zero, align 1, !tbaa !12, !range !18, !noundef !19
  %73 = trunc nuw i8 %72 to i1
  %74 = icmp sgt i32 %71, 0
  %or.cond = select i1 %73, i1 %74, i1 false
  br i1 %or.cond, label %90, label %120

._crit_edge162:                                   ; preds = %75
  %indvars.iv.next204 = add nuw nsw i64 %indvars.iv203, 1
  %exitcond207.not = icmp eq i64 %indvars.iv.next204, %wide.trip.count206
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond207.not, label %._crit_edge165, label %.preheader138, !llvm.loop !20

75:                                               ; preds = %.preheader138, %75
  %store_forwarded249 = phi i32 [ %load_initial248, %.preheader138 ], [ %81, %75 ]
  %store_forwarded = phi i32 [ %load_initial, %.preheader138 ], [ %88, %75 ]
  %indvars.iv198 = phi i64 [ 2, %.preheader138 ], [ %indvars.iv.next199, %75 ]
  %76 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %66, i64 %indvars.iv198
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = icmp slt i32 %store_forwarded249, %77
  %79 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %indvars.iv203, i64 %indvars.iv198
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %. = tail call i32 @llvm.smin.i32(i32 %store_forwarded249, i32 %77)
  %.237 = select i1 %78, i32 1, i32 2
  %81 = add nsw i32 %80, %.
  store i32 %81, ptr %79, align 4, !tbaa !5
  %82 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p1, i64 0, i64 %indvars.iv203, i64 %indvars.iv198
  store i32 %.237, ptr %82, align 4
  %83 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %66, i64 %indvars.iv198
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = icmp slt i32 %store_forwarded, %84
  %.sink235 = tail call i32 @llvm.smin.i32(i32 %store_forwarded, i32 %84)
  %.sink208 = select i1 %85, i32 1, i32 2
  %86 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %indvars.iv203, i64 %indvars.iv198
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = add nsw i32 %87, %.sink235
  store i32 %88, ptr %86, align 4, !tbaa !5
  %89 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p2, i64 0, i64 %indvars.iv203, i64 %indvars.iv198
  store i32 %.sink208, ptr %89, align 4
  %indvars.iv.next199 = add nuw nsw i64 %indvars.iv198, 1
  %exitcond202.not = icmp eq i64 %indvars.iv.next199, %wide.trip.count206
  br i1 %exitcond202.not, label %._crit_edge162, label %75, !llvm.loop !21

90:                                               ; preds = %._crit_edge165
  %91 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %92 = load i32, ptr @zx, align 4, !tbaa !5
  %93 = icmp sgt i32 %92, 1
  br i1 %93, label %.lr.ph174, label %.preheader

.preheader:                                       ; preds = %.lr.ph174, %90
  %94 = phi i32 [ %92, %90 ], [ %99, %.lr.ph174 ]
  %95 = load i32, ptr @zy, align 4, !tbaa !5
  %96 = icmp sgt i32 %95, 1
  br i1 %96, label %.lr.ph176, label %._crit_edge177

.lr.ph174:                                        ; preds = %90, %.lr.ph174
  %.0110172 = phi i32 [ %98, %.lr.ph174 ], [ 1, %90 ]
  %97 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %98 = add nuw nsw i32 %.0110172, 1
  %99 = load i32, ptr @zx, align 4, !tbaa !5
  %100 = icmp slt i32 %98, %99
  br i1 %100, label %.lr.ph174, label %.preheader, !llvm.loop !22

._crit_edge177.loopexit:                          ; preds = %.lr.ph176
  %.pre210 = load i32, ptr @zx, align 4, !tbaa !5
  br label %._crit_edge177

._crit_edge177:                                   ; preds = %._crit_edge177.loopexit, %.preheader
  %101 = phi i32 [ %107, %._crit_edge177.loopexit ], [ %95, %.preheader ]
  %102 = phi i32 [ %.pre210, %._crit_edge177.loopexit ], [ %94, %.preheader ]
  %103 = load i32, ptr @n, align 4, !tbaa !5
  %104 = icmp slt i32 %102, %103
  br i1 %104, label %.lr.ph180, label %._crit_edge181

.lr.ph176:                                        ; preds = %.preheader, %.lr.ph176
  %.0109175 = phi i32 [ %106, %.lr.ph176 ], [ 1, %.preheader ]
  %105 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %106 = add nuw nsw i32 %.0109175, 1
  %107 = load i32, ptr @zy, align 4, !tbaa !5
  %108 = icmp slt i32 %106, %107
  br i1 %108, label %.lr.ph176, label %._crit_edge177.loopexit, !llvm.loop !23

._crit_edge181.loopexit:                          ; preds = %.lr.ph180
  %.pre211 = load i32, ptr @zy, align 4, !tbaa !5
  br label %._crit_edge181

._crit_edge181:                                   ; preds = %._crit_edge181.loopexit, %._crit_edge177
  %109 = phi i32 [ %114, %._crit_edge181.loopexit ], [ %103, %._crit_edge177 ]
  %110 = phi i32 [ %.pre211, %._crit_edge181.loopexit ], [ %101, %._crit_edge177 ]
  %111 = icmp slt i32 %110, %109
  br i1 %111, label %.lr.ph184, label %.loopexit

.lr.ph180:                                        ; preds = %._crit_edge177, %.lr.ph180
  %.0108178 = phi i32 [ %113, %.lr.ph180 ], [ %102, %._crit_edge177 ]
  %112 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %113 = add nsw i32 %.0108178, 1
  %114 = load i32, ptr @n, align 4, !tbaa !5
  %115 = icmp slt i32 %113, %114
  br i1 %115, label %.lr.ph180, label %._crit_edge181.loopexit, !llvm.loop !24

.lr.ph184:                                        ; preds = %._crit_edge181, %.lr.ph184
  %.0107182 = phi i32 [ %117, %.lr.ph184 ], [ %110, %._crit_edge181 ]
  %116 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %117 = add nsw i32 %.0107182, 1
  %118 = load i32, ptr @n, align 4, !tbaa !5
  %119 = icmp slt i32 %117, %118
  br i1 %119, label %.lr.ph184, label %.loopexit, !llvm.loop !25

120:                                              ; preds = %._crit_edge165
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #7
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #7
  %121 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %71)
  %122 = load i32, ptr @n, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %123, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = getelementptr inbounds [1001 x [1001 x i32]], ptr @b, i64 0, i64 %123, i64 %123
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = icmp slt i32 %125, %127
  %129 = icmp sgt i32 %122, 1
  br i1 %128, label %.preheader134, label %.preheader136

.preheader136:                                    ; preds = %120
  br i1 %129, label %.lr.ph168, label %.loopexit135

.preheader134:                                    ; preds = %120
  br i1 %129, label %.lr.ph171, label %.loopexit135

.lr.ph171:                                        ; preds = %.preheader134, %147
  %.098170 = phi i32 [ %.199, %147 ], [ %122, %.preheader134 ]
  %.0100169 = phi i32 [ %.1101, %147 ], [ %122, %.preheader134 ]
  %130 = sext i32 %.0100169 to i64
  %131 = sext i32 %.098170 to i64
  %132 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p1, i64 0, i64 %130, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = icmp eq i32 %133, 1
  br i1 %134, label %135, label %141

135:                                              ; preds = %.lr.ph171
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #7
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %2, i8 noundef signext 82, ptr noundef nonnull align 8 dereferenceable(32) %1)
          to label %136 unwind label %139

136:                                              ; preds = %135
  %137 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) #7
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %2) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #7
  %138 = add nsw i32 %.098170, -1
  br label %147

139:                                              ; preds = %135
  %140 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #7
  br label %174

141:                                              ; preds = %.lr.ph171
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #7
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %3, i8 noundef signext 68, ptr noundef nonnull align 8 dereferenceable(32) %1)
          to label %142 unwind label %145

142:                                              ; preds = %141
  %143 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %3) #7
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #7
  %144 = add nsw i32 %.0100169, -1
  br label %147

145:                                              ; preds = %141
  %146 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #7
  br label %174

147:                                              ; preds = %142, %136
  %.1101 = phi i32 [ %.0100169, %136 ], [ %144, %142 ]
  %.199 = phi i32 [ %138, %136 ], [ %.098170, %142 ]
  %148 = icmp sgt i32 %.1101, 1
  %149 = icmp sgt i32 %.199, 1
  %150 = select i1 %148, i1 true, i1 %149
  br i1 %150, label %.lr.ph171, label %.loopexit135, !llvm.loop !26

.lr.ph168:                                        ; preds = %.preheader136, %168
  %.0167 = phi i32 [ %.1, %168 ], [ %122, %.preheader136 ]
  %.096166 = phi i32 [ %.197, %168 ], [ %122, %.preheader136 ]
  %151 = sext i32 %.096166 to i64
  %152 = sext i32 %.0167 to i64
  %153 = getelementptr inbounds [1001 x [1001 x i32]], ptr @p2, i64 0, i64 %151, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = icmp eq i32 %154, 1
  br i1 %155, label %156, label %162

156:                                              ; preds = %.lr.ph168
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #7
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %4, i8 noundef signext 82, ptr noundef nonnull align 8 dereferenceable(32) %1)
          to label %157 unwind label %160

157:                                              ; preds = %156
  %158 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %4) #7
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #7
  %159 = add nsw i32 %.0167, -1
  br label %168

160:                                              ; preds = %156
  %161 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #7
  br label %174

162:                                              ; preds = %.lr.ph168
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #7
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %5, i8 noundef signext 68, ptr noundef nonnull align 8 dereferenceable(32) %1)
          to label %163 unwind label %166

163:                                              ; preds = %162
  %164 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %5) #7
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #7
  %165 = add nsw i32 %.096166, -1
  br label %168

166:                                              ; preds = %162
  %167 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #7
  br label %174

168:                                              ; preds = %163, %157
  %.197 = phi i32 [ %.096166, %157 ], [ %165, %163 ]
  %.1 = phi i32 [ %159, %157 ], [ %.0167, %163 ]
  %169 = icmp sgt i32 %.197, 1
  %170 = icmp sgt i32 %.1, 1
  %171 = select i1 %169, i1 true, i1 %170
  br i1 %171, label %.lr.ph168, label %.loopexit135, !llvm.loop !27

.loopexit135:                                     ; preds = %168, %147, %.preheader136, %.preheader134
  %172 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #7
  %173 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef %172)
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #7
  br label %.loopexit

174:                                              ; preds = %160, %166, %139, %145
  %.pn129.pn = phi { ptr, i32 } [ %140, %139 ], [ %146, %145 ], [ %161, %160 ], [ %167, %166 ]
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #7
  resume { ptr, i32 } %.pn129.pn

.loopexit:                                        ; preds = %.lr.ph184, %._crit_edge181, %.loopexit135
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EES5_RKS8_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i8 noundef signext, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #6

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress 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 #4 = { mustprogress 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 #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unswitch.partial.disable"}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !10}
!27 = distinct !{!27, !10}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass