; LLVM IR from eyangch/competitive-programming :: USACOcontests/platinum/2020.03 (sprinklers2)

; 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@MOD = external dso_local global i32, align 4
@N = external dso_local global i32, align 4
@mp = external dso_local global [2001 x [2001 x [2 x i32]]], align 16
@p2 = external dso_local global [2001 x i32], align 16
@dp = external dso_local global [2001 x [2001 x [2 x i64]]], align 16
@S = external dso_local global [2000 x [2000 x i8]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; 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 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %15
  %17 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  %18 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %19 = load ptr, ptr @stdin, align 8, !tbaa !8
  %20 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %19)
  %21 = load ptr, ptr @stdout, align 8, !tbaa !8
  %22 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %21)
  store i32 1, ptr @p2, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !11
  br label %23

23:                                               ; preds = %39, %0
  %24 = load i32, ptr %2, align 4, !tbaa !11
  %25 = icmp sle i32 %24, 2000
  br i1 %25, label %27, label %26

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

27:                                               ; preds = %23
  %28 = load i32, ptr %2, align 4, !tbaa !11
  %29 = sub nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = mul nsw i32 %32, 2
  %34 = load i32, ptr @MOD, align 4, !tbaa !11
  %35 = srem i32 %33, %34
  %36 = load i32, ptr %2, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %37
  store i32 %35, ptr %38, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %27
  %40 = load i32, ptr %2, align 4, !tbaa !11
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %2, align 4, !tbaa !11
  br label %23, !llvm.loop !13

42:                                               ; preds = %26
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %44

44:                                               ; preds = %55, %42
  %45 = load i32, ptr %3, align 4, !tbaa !11
  %46 = load i32, ptr @N, align 4, !tbaa !11
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %58

49:                                               ; preds = %44
  %50 = load i32, ptr %3, align 4, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %51
  %53 = getelementptr inbounds [2000 x i8], ptr %52, i64 0, i64 0
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef %53)
  br label %55

55:                                               ; preds = %49
  %56 = load i32, ptr %3, align 4, !tbaa !11
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %3, align 4, !tbaa !11
  br label %44, !llvm.loop !15

58:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %59

59:                                               ; preds = %152, %58
  %60 = load i32, ptr %4, align 4, !tbaa !11
  %61 = load i32, ptr @N, align 4, !tbaa !11
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %155

64:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %65 = load i32, ptr @N, align 4, !tbaa !11
  %66 = sub nsw i32 %65, 1
  store i32 %66, ptr %6, align 4, !tbaa !11
  br label %67

67:                                               ; preds = %148, %64
  %68 = load i32, ptr %6, align 4, !tbaa !11
  %69 = icmp sge i32 %68, 0
  br i1 %69, label %71, label %70

70:                                               ; preds = %67
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %151

71:                                               ; preds = %67
  %72 = load i32, ptr %4, align 4, !tbaa !11
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %73
  %75 = load i32, ptr %6, align 4, !tbaa !11
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [2000 x i8], ptr %74, i64 0, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !16
  %79 = sext i8 %78 to i32
  %80 = icmp eq i32 %79, 46
  %81 = zext i1 %80 to i32
  %82 = load i32, ptr %4, align 4, !tbaa !11
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %83
  %85 = load i32, ptr %6, align 4, !tbaa !11
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2001 x [2 x i32]], ptr %84, i64 0, i64 %86
  %88 = getelementptr inbounds [2 x i32], ptr %87, i64 0, i64 0
  store i32 %81, ptr %88, align 8, !tbaa !11
  %89 = load i32, ptr %6, align 4, !tbaa !11
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %90
  %92 = load i32, ptr %4, align 4, !tbaa !11
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [2000 x i8], ptr %91, i64 0, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !16
  %96 = sext i8 %95 to i32
  %97 = icmp eq i32 %96, 46
  %98 = zext i1 %97 to i32
  %99 = load i32, ptr %6, align 4, !tbaa !11
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %100
  %102 = load i32, ptr %4, align 4, !tbaa !11
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [2001 x [2 x i32]], ptr %101, i64 0, i64 %103
  %105 = getelementptr inbounds [2 x i32], ptr %104, i64 0, i64 1
  store i32 %98, ptr %105, align 4, !tbaa !11
  %106 = load i32, ptr %6, align 4, !tbaa !11
  %107 = load i32, ptr @N, align 4, !tbaa !11
  %108 = sub nsw i32 %107, 1
  %109 = icmp ne i32 %106, %108
  br i1 %109, label %110, label %147

110:                                              ; preds = %71
  %111 = load i32, ptr %4, align 4, !tbaa !11
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %112
  %114 = load i32, ptr %6, align 4, !tbaa !11
  %115 = add nsw i32 %114, 1
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [2001 x [2 x i32]], ptr %113, i64 0, i64 %116
  %118 = getelementptr inbounds [2 x i32], ptr %117, i64 0, i64 0
  %119 = load i32, ptr %118, align 8, !tbaa !11
  %120 = load i32, ptr %4, align 4, !tbaa !11
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %121
  %123 = load i32, ptr %6, align 4, !tbaa !11
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [2001 x [2 x i32]], ptr %122, i64 0, i64 %124
  %126 = getelementptr inbounds [2 x i32], ptr %125, i64 0, i64 0
  %127 = load i32, ptr %126, align 8, !tbaa !11
  %128 = add nsw i32 %127, %119
  store i32 %128, ptr %126, align 8, !tbaa !11
  %129 = load i32, ptr %6, align 4, !tbaa !11
  %130 = add nsw i32 %129, 1
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %131
  %133 = load i32, ptr %4, align 4, !tbaa !11
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [2001 x [2 x i32]], ptr %132, i64 0, i64 %134
  %136 = getelementptr inbounds [2 x i32], ptr %135, i64 0, i64 1
  %137 = load i32, ptr %136, align 4, !tbaa !11
  %138 = load i32, ptr %6, align 4, !tbaa !11
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %139
  %141 = load i32, ptr %4, align 4, !tbaa !11
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [2001 x [2 x i32]], ptr %140, i64 0, i64 %142
  %144 = getelementptr inbounds [2 x i32], ptr %143, i64 0, i64 1
  %145 = load i32, ptr %144, align 4, !tbaa !11
  %146 = add nsw i32 %145, %137
  store i32 %146, ptr %144, align 4, !tbaa !11
  br label %147

147:                                              ; preds = %110, %71
  br label %148

148:                                              ; preds = %147
  %149 = load i32, ptr %6, align 4, !tbaa !11
  %150 = add nsw i32 %149, -1
  store i32 %150, ptr %6, align 4, !tbaa !11
  br label %67, !llvm.loop !17

151:                                              ; preds = %70
  br label %152

152:                                              ; preds = %151
  %153 = load i32, ptr %4, align 4, !tbaa !11
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %4, align 4, !tbaa !11
  br label %59, !llvm.loop !18

155:                                              ; preds = %63
  store i64 1, ptr getelementptr inbounds ([2 x i64], ptr @dp, i64 0, i64 1), align 8, !tbaa !19
  store i64 1, ptr @dp, align 16, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %156

156:                                              ; preds = %380, %155
  %157 = load i32, ptr %7, align 4, !tbaa !11
  %158 = load i32, ptr @N, align 4, !tbaa !11
  %159 = icmp sle i32 %157, %158
  br i1 %159, label %161, label %160

160:                                              ; preds = %156
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %383

161:                                              ; preds = %156
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %162

162:                                              ; preds = %376, %161
  %163 = load i32, ptr %8, align 4, !tbaa !11
  %164 = load i32, ptr @N, align 4, !tbaa !11
  %165 = icmp sle i32 %163, %164
  br i1 %165, label %167, label %166

166:                                              ; preds = %162
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %379

167:                                              ; preds = %162
  %168 = load i32, ptr %7, align 4, !tbaa !11
  %169 = icmp sgt i32 %168, 0
  br i1 %169, label %170, label %205

170:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %171 = load i32, ptr %7, align 4, !tbaa !11
  %172 = sub nsw i32 %171, 1
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %173
  %175 = load i32, ptr %8, align 4, !tbaa !11
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [2001 x [2 x i32]], ptr %174, i64 0, i64 %176
  %178 = getelementptr inbounds [2 x i32], ptr %177, i64 0, i64 0
  %179 = load i32, ptr %178, align 8, !tbaa !11
  store i32 %179, ptr %9, align 4, !tbaa !11
  %180 = load i32, ptr %7, align 4, !tbaa !11
  %181 = sub nsw i32 %180, 1
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %182
  %184 = load i32, ptr %8, align 4, !tbaa !11
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [2001 x [2 x i64]], ptr %183, i64 0, i64 %185
  %187 = getelementptr inbounds [2 x i64], ptr %186, i64 0, i64 0
  %188 = load i64, ptr %187, align 16, !tbaa !19
  %189 = load i32, ptr %9, align 4, !tbaa !11
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %190
  %192 = load i32, ptr %191, align 4, !tbaa !11
  %193 = sext i32 %192 to i64
  %194 = mul nsw i64 %188, %193
  %195 = load i32, ptr @MOD, align 4, !tbaa !11
  %196 = sext i32 %195 to i64
  %197 = srem i64 %194, %196
  %198 = load i32, ptr %7, align 4, !tbaa !11
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %199
  %201 = load i32, ptr %8, align 4, !tbaa !11
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [2001 x [2 x i64]], ptr %200, i64 0, i64 %202
  %204 = getelementptr inbounds [2 x i64], ptr %203, i64 0, i64 0
  store i64 %197, ptr %204, align 16, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %205

205:                                              ; preds = %170, %167
  %206 = load i32, ptr %8, align 4, !tbaa !11
  %207 = icmp sgt i32 %206, 0
  br i1 %207, label %208, label %271

208:                                              ; preds = %205
  %209 = load i32, ptr %7, align 4, !tbaa !11
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %210
  %212 = load i32, ptr %8, align 4, !tbaa !11
  %213 = sub nsw i32 %212, 1
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [2000 x i8], ptr %211, i64 0, i64 %214
  %216 = load i8, ptr %215, align 1, !tbaa !16
  %217 = sext i8 %216 to i32
  %218 = icmp eq i32 %217, 46
  br i1 %218, label %219, label %271

219:                                              ; preds = %208
  %220 = load i32, ptr %7, align 4, !tbaa !11
  %221 = load i32, ptr @N, align 4, !tbaa !11
  %222 = icmp slt i32 %220, %221
  br i1 %222, label %223, label %271

223:                                              ; preds = %219
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %224 = load i32, ptr %7, align 4, !tbaa !11
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %225
  %227 = load i32, ptr %8, align 4, !tbaa !11
  %228 = sub nsw i32 %227, 1
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [2001 x [2 x i32]], ptr %226, i64 0, i64 %229
  %231 = getelementptr inbounds [2 x i32], ptr %230, i64 0, i64 1
  %232 = load i32, ptr %231, align 4, !tbaa !11
  store i32 %232, ptr %10, align 4, !tbaa !11
  %233 = load i32, ptr %7, align 4, !tbaa !11
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %234
  %236 = load i32, ptr %8, align 4, !tbaa !11
  %237 = sext i32 %236 to i64
  %238 = getelementptr inbounds [2001 x [2 x i64]], ptr %235, i64 0, i64 %237
  %239 = getelementptr inbounds [2 x i64], ptr %238, i64 0, i64 0
  %240 = load i64, ptr %239, align 16, !tbaa !19
  %241 = load i32, ptr %7, align 4, !tbaa !11
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %242
  %244 = load i32, ptr %8, align 4, !tbaa !11
  %245 = sub nsw i32 %244, 1
  %246 = sext i32 %245 to i64
  %247 = getelementptr inbounds [2001 x [2 x i64]], ptr %243, i64 0, i64 %246
  %248 = getelementptr inbounds [2 x i64], ptr %247, i64 0, i64 1
  %249 = load i64, ptr %248, align 8, !tbaa !19
  %250 = load i32, ptr %10, align 4, !tbaa !11
  %251 = sub nsw i32 %250, 1
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %252
  %254 = load i32, ptr %253, align 4, !tbaa !11
  %255 = sext i32 %254 to i64
  %256 = mul nsw i64 %249, %255
  %257 = load i32, ptr @MOD, align 4, !tbaa !11
  %258 = sext i32 %257 to i64
  %259 = srem i64 %256, %258
  %260 = add nsw i64 %240, %259
  %261 = load i32, ptr @MOD, align 4, !tbaa !11
  %262 = sext i32 %261 to i64
  %263 = srem i64 %260, %262
  %264 = load i32, ptr %7, align 4, !tbaa !11
  %265 = sext i32 %264 to i64
  %266 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %265
  %267 = load i32, ptr %8, align 4, !tbaa !11
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds [2001 x [2 x i64]], ptr %266, i64 0, i64 %268
  %270 = getelementptr inbounds [2 x i64], ptr %269, i64 0, i64 0
  store i64 %263, ptr %270, align 16, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %271

271:                                              ; preds = %223, %219, %208, %205
  %272 = load i32, ptr %8, align 4, !tbaa !11
  %273 = icmp sgt i32 %272, 0
  br i1 %273, label %274, label %309

274:                                              ; preds = %271
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %275 = load i32, ptr %7, align 4, !tbaa !11
  %276 = sext i32 %275 to i64
  %277 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %276
  %278 = load i32, ptr %8, align 4, !tbaa !11
  %279 = sub nsw i32 %278, 1
  %280 = sext i32 %279 to i64
  %281 = getelementptr inbounds [2001 x [2 x i32]], ptr %277, i64 0, i64 %280
  %282 = getelementptr inbounds [2 x i32], ptr %281, i64 0, i64 1
  %283 = load i32, ptr %282, align 4, !tbaa !11
  store i32 %283, ptr %11, align 4, !tbaa !11
  %284 = load i32, ptr %7, align 4, !tbaa !11
  %285 = sext i32 %284 to i64
  %286 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %285
  %287 = load i32, ptr %8, align 4, !tbaa !11
  %288 = sub nsw i32 %287, 1
  %289 = sext i32 %288 to i64
  %290 = getelementptr inbounds [2001 x [2 x i64]], ptr %286, i64 0, i64 %289
  %291 = getelementptr inbounds [2 x i64], ptr %290, i64 0, i64 1
  %292 = load i64, ptr %291, align 8, !tbaa !19
  %293 = load i32, ptr %11, align 4, !tbaa !11
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %294
  %296 = load i32, ptr %295, align 4, !tbaa !11
  %297 = sext i32 %296 to i64
  %298 = mul nsw i64 %292, %297
  %299 = load i32, ptr @MOD, align 4, !tbaa !11
  %300 = sext i32 %299 to i64
  %301 = srem i64 %298, %300
  %302 = load i32, ptr %7, align 4, !tbaa !11
  %303 = sext i32 %302 to i64
  %304 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %303
  %305 = load i32, ptr %8, align 4, !tbaa !11
  %306 = sext i32 %305 to i64
  %307 = getelementptr inbounds [2001 x [2 x i64]], ptr %304, i64 0, i64 %306
  %308 = getelementptr inbounds [2 x i64], ptr %307, i64 0, i64 1
  store i64 %301, ptr %308, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %309

309:                                              ; preds = %274, %271
  %310 = load i32, ptr %7, align 4, !tbaa !11
  %311 = icmp sgt i32 %310, 0
  br i1 %311, label %312, label %375

312:                                              ; preds = %309
  %313 = load i32, ptr %7, align 4, !tbaa !11
  %314 = sub nsw i32 %313, 1
  %315 = sext i32 %314 to i64
  %316 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %315
  %317 = load i32, ptr %8, align 4, !tbaa !11
  %318 = sext i32 %317 to i64
  %319 = getelementptr inbounds [2000 x i8], ptr %316, i64 0, i64 %318
  %320 = load i8, ptr %319, align 1, !tbaa !16
  %321 = sext i8 %320 to i32
  %322 = icmp eq i32 %321, 46
  br i1 %322, label %323, label %375

323:                                              ; preds = %312
  %324 = load i32, ptr %8, align 4, !tbaa !11
  %325 = load i32, ptr @N, align 4, !tbaa !11
  %326 = icmp slt i32 %324, %325
  br i1 %326, label %327, label %375

327:                                              ; preds = %323
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %328 = load i32, ptr %7, align 4, !tbaa !11
  %329 = sub nsw i32 %328, 1
  %330 = sext i32 %329 to i64
  %331 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %330
  %332 = load i32, ptr %8, align 4, !tbaa !11
  %333 = sext i32 %332 to i64
  %334 = getelementptr inbounds [2001 x [2 x i32]], ptr %331, i64 0, i64 %333
  %335 = getelementptr inbounds [2 x i32], ptr %334, i64 0, i64 0
  %336 = load i32, ptr %335, align 8, !tbaa !11
  store i32 %336, ptr %12, align 4, !tbaa !11
  %337 = load i32, ptr %7, align 4, !tbaa !11
  %338 = sext i32 %337 to i64
  %339 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %338
  %340 = load i32, ptr %8, align 4, !tbaa !11
  %341 = sext i32 %340 to i64
  %342 = getelementptr inbounds [2001 x [2 x i64]], ptr %339, i64 0, i64 %341
  %343 = getelementptr inbounds [2 x i64], ptr %342, i64 0, i64 1
  %344 = load i64, ptr %343, align 8, !tbaa !19
  %345 = load i32, ptr %7, align 4, !tbaa !11
  %346 = sub nsw i32 %345, 1
  %347 = sext i32 %346 to i64
  %348 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %347
  %349 = load i32, ptr %8, align 4, !tbaa !11
  %350 = sext i32 %349 to i64
  %351 = getelementptr inbounds [2001 x [2 x i64]], ptr %348, i64 0, i64 %350
  %352 = getelementptr inbounds [2 x i64], ptr %351, i64 0, i64 0
  %353 = load i64, ptr %352, align 16, !tbaa !19
  %354 = load i32, ptr %12, align 4, !tbaa !11
  %355 = sub nsw i32 %354, 1
  %356 = sext i32 %355 to i64
  %357 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %356
  %358 = load i32, ptr %357, align 4, !tbaa !11
  %359 = sext i32 %358 to i64
  %360 = mul nsw i64 %353, %359
  %361 = load i32, ptr @MOD, align 4, !tbaa !11
  %362 = sext i32 %361 to i64
  %363 = srem i64 %360, %362
  %364 = add nsw i64 %344, %363
  %365 = load i32, ptr @MOD, align 4, !tbaa !11
  %366 = sext i32 %365 to i64
  %367 = srem i64 %364, %366
  %368 = load i32, ptr %7, align 4, !tbaa !11
  %369 = sext i32 %368 to i64
  %370 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %369
  %371 = load i32, ptr %8, align 4, !tbaa !11
  %372 = sext i32 %371 to i64
  %373 = getelementptr inbounds [2001 x [2 x i64]], ptr %370, i64 0, i64 %372
  %374 = getelementptr inbounds [2 x i64], ptr %373, i64 0, i64 1
  store i64 %367, ptr %374, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %375

375:                                              ; preds = %327, %323, %312, %309
  br label %376

376:                                              ; preds = %375
  %377 = load i32, ptr %8, align 4, !tbaa !11
  %378 = add nsw i32 %377, 1
  store i32 %378, ptr %8, align 4, !tbaa !11
  br label %162, !llvm.loop !21

379:                                              ; preds = %166
  br label %380

380:                                              ; preds = %379
  %381 = load i32, ptr %7, align 4, !tbaa !11
  %382 = add nsw i32 %381, 1
  store i32 %382, ptr %7, align 4, !tbaa !11
  br label %156, !llvm.loop !22

383:                                              ; preds = %160
  %384 = load i32, ptr @N, align 4, !tbaa !11
  %385 = sext i32 %384 to i64
  %386 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %385
  %387 = load i32, ptr @N, align 4, !tbaa !11
  %388 = sext i32 %387 to i64
  %389 = getelementptr inbounds [2001 x [2 x i64]], ptr %386, i64 0, i64 %388
  %390 = getelementptr inbounds [2 x i64], ptr %389, i64 0, i64 0
  %391 = load i64, ptr %390, align 16, !tbaa !19
  %392 = load i32, ptr @N, align 4, !tbaa !11
  %393 = sext i32 %392 to i64
  %394 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %393
  %395 = load i32, ptr @N, align 4, !tbaa !11
  %396 = sext i32 %395 to i64
  %397 = getelementptr inbounds [2001 x [2 x i64]], ptr %394, i64 0, i64 %396
  %398 = getelementptr inbounds [2 x i64], ptr %397, i64 0, i64 1
  %399 = load i64, ptr %398, align 8, !tbaa !19
  %400 = add nsw i64 %391, %399
  %401 = load i32, ptr @MOD, align 4, !tbaa !11
  %402 = sext i32 %401 to i64
  %403 = srem i64 %400, %402
  %404 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %403)
  %405 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %404, i8 noundef signext 10)
  %406 = load i32, ptr %1, align 4
  ret i32 %406
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #1 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #2

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #2

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) #4

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #5 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 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = !{!20, !20, i64 0}
!20 = !{!"long long", !10, i64 0}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}


; 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@MOD = external dso_local local_unnamed_addr global i32, align 4
@N = external dso_local global i32, align 4
@mp = external dso_local local_unnamed_addr global [2001 x [2001 x [2 x i32]]], align 16
@p2 = external dso_local local_unnamed_addr global [2001 x i32], align 16
@dp = external dso_local local_unnamed_addr global [2001 x [2001 x [2 x i64]]], align 16
@S = external dso_local global [2000 x [2000 x i8]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %2 = getelementptr i8, ptr %1, i64 -24
  %3 = load i64, ptr %2, align 8
  %4 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %3
  %5 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %4, ptr noundef null)
  %6 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = load ptr, ptr @stdin, align 8, !tbaa !8
  %8 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %7)
  %9 = load ptr, ptr @stdout, align 8, !tbaa !8
  %10 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %9)
  store i32 1, ptr @p2, align 16, !tbaa !11
  %11 = load i32, ptr @MOD, align 4, !tbaa !11
  br label %16

12:                                               ; preds = %16
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %14 = load i32, ptr @N, align 4
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge98

16:                                               ; preds = %16, %0
  %17 = phi i32 [ 1, %0 ], [ %22, %16 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.1, %16 ]
  %18 = shl nsw i32 %17, 1
  %19 = srem i32 %18, %11
  %20 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %indvars.iv
  store i32 %19, ptr %20, align 4, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = shl nsw i32 %19, 1
  %22 = srem i32 %21, %11
  %23 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %indvars.iv.next
  store i32 %22, ptr %23, align 4, !tbaa !11
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 2001
  br i1 %exitcond.not.1, label %12, label %16, !llvm.loop !13

.preheader90:                                     ; preds = %.lr.ph
  %24 = icmp sgt i32 %54, 0
  br i1 %24, label %.preheader89.lr.ph, label %._crit_edge98

.preheader89.lr.ph:                               ; preds = %.preheader90
  %25 = zext nneg i32 %54 to i64
  %indvars.iv.next111.peel = add nsw i64 %25, -1
  %.not = icmp eq i32 %54, 1
  br label %26

26:                                               ; preds = %.preheader89.lr.ph, %._crit_edge.us
  %indvars.iv114 = phi i64 [ %indvars.iv.next115, %._crit_edge.us ], [ 0, %.preheader89.lr.ph ]
  %27 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %indvars.iv114, i64 %indvars.iv.next111.peel
  %28 = load i8, ptr %27, align 1, !tbaa !15
  %29 = icmp eq i8 %28, 46
  %30 = zext i1 %29 to i32
  %31 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %indvars.iv114, i64 %indvars.iv.next111.peel
  store i32 %30, ptr %31, align 8, !tbaa !11
  %32 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %indvars.iv.next111.peel, i64 %indvars.iv114
  %33 = load i8, ptr %32, align 1, !tbaa !15
  %34 = icmp eq i8 %33, 46
  %35 = zext i1 %34 to i32
  %36 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %indvars.iv.next111.peel, i64 %indvars.iv114, i64 1
  store i32 %35, ptr %36, align 4, !tbaa !11
  br i1 %.not, label %._crit_edge.us, label %.peel.next

.peel.next:                                       ; preds = %26, %.peel.next
  %37 = phi i32 [ %50, %.peel.next ], [ %35, %26 ]
  %38 = phi i32 [ %49, %.peel.next ], [ %30, %26 ]
  %indvars.iv110 = phi i64 [ %indvars.iv.next111, %.peel.next ], [ %indvars.iv.next111.peel, %26 ]
  %indvars.iv.next111 = add nsw i64 %indvars.iv110, -1
  %39 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %indvars.iv114, i64 %indvars.iv.next111
  %40 = load i8, ptr %39, align 1, !tbaa !15
  %41 = icmp eq i8 %40, 46
  %42 = zext i1 %41 to i32
  %43 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %indvars.iv114, i64 %indvars.iv.next111
  %44 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %indvars.iv.next111, i64 %indvars.iv114
  %45 = load i8, ptr %44, align 1, !tbaa !15
  %46 = icmp eq i8 %45, 46
  %47 = zext i1 %46 to i32
  %48 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %indvars.iv.next111, i64 %indvars.iv114, i64 1
  %49 = add nuw nsw i32 %38, %42
  store i32 %49, ptr %43, align 8, !tbaa !11
  %50 = add nuw nsw i32 %37, %47
  store i32 %50, ptr %48, align 4, !tbaa !11
  %51 = icmp sgt i64 %indvars.iv110, 1
  br i1 %51, label %.peel.next, label %._crit_edge.us, !llvm.loop !16

._crit_edge.us:                                   ; preds = %.peel.next, %26
  %indvars.iv.next115 = add nuw nsw i64 %indvars.iv114, 1
  %exitcond117.not = icmp eq i64 %indvars.iv.next115, %25
  br i1 %exitcond117.not, label %._crit_edge98, label %26, !llvm.loop !18

.lr.ph:                                           ; preds = %12, %.lr.ph
  %indvars.iv107 = phi i64 [ %indvars.iv.next108, %.lr.ph ], [ 0, %12 ]
  %52 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %indvars.iv107
  %53 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef %52)
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %54 = load i32, ptr @N, align 4
  %55 = sext i32 %54 to i64
  %56 = icmp slt i64 %indvars.iv.next108, %55
  br i1 %56, label %.lr.ph, label %.preheader90, !llvm.loop !19

._crit_edge98:                                    ; preds = %._crit_edge.us, %12, %.preheader90
  %.lcssa140 = phi i32 [ %54, %.preheader90 ], [ %14, %12 ], [ %54, %._crit_edge.us ]
  store i64 1, ptr getelementptr inbounds (i8, ptr @dp, i64 8), align 8, !tbaa !20
  store i64 1, ptr @dp, align 16, !tbaa !20
  %.not102 = icmp slt i32 %.lcssa140, 0
  %.pre135 = load i32, ptr @MOD, align 4
  br i1 %.not102, label %._crit_edge98.._crit_edge104_crit_edge, label %.preheader.lr.ph

._crit_edge98.._crit_edge104_crit_edge:           ; preds = %._crit_edge98
  %.pre136 = sext i32 %.lcssa140 to i64
  %.pre137 = sext i32 %.pre135 to i64
  br label %._crit_edge104

.preheader.lr.ph:                                 ; preds = %._crit_edge98
  %57 = sext i32 %.pre135 to i64
  %58 = zext nneg i32 %.lcssa140 to i64
  %59 = add nuw i32 %.lcssa140, 1
  %wide.trip.count129 = zext i32 %59 to i64
  %60 = icmp ne i32 %.lcssa140, 0
  %exitcond122.peel.not = icmp eq i32 %.lcssa140, 0
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %indvars.iv126 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next127, %._crit_edge ]
  %.not83 = icmp eq i64 %indvars.iv126, 0
  %61 = add nsw i64 %indvars.iv126, -1
  %62 = icmp ult i64 %indvars.iv126, %58
  br i1 %.not83, label %.critedge.peel.thread, label %63

63:                                               ; preds = %.preheader
  %64 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %61, i64 0
  %65 = load i32, ptr %64, align 8, !tbaa !11
  %66 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %61, i64 0
  %67 = load i64, ptr %66, align 16, !tbaa !20
  %68 = sext i32 %65 to i64
  %69 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !11
  %71 = sext i32 %70 to i64
  %72 = mul nsw i64 %67, %71
  %73 = srem i64 %72, %57
  %74 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv126, i64 0
  store i64 %73, ptr %74, align 16, !tbaa !20
  %75 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %61, i64 0
  %76 = load i8, ptr %75, align 16, !tbaa !15
  %77 = icmp eq i8 %76, 46
  %or.cond88.peel = and i1 %60, %77
  br i1 %or.cond88.peel, label %.thread, label %.critedge.peel.thread

.thread:                                          ; preds = %63
  %78 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %61, i64 0
  %79 = load i32, ptr %78, align 8, !tbaa !11
  %80 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv126, i64 0, i64 1
  %81 = load i64, ptr %80, align 8, !tbaa !20
  %82 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %61, i64 0
  %83 = load i64, ptr %82, align 16, !tbaa !20
  %84 = add nsw i32 %79, -1
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !11
  %88 = sext i32 %87 to i64
  %89 = mul nsw i64 %83, %88
  %90 = srem i64 %89, %57
  %91 = add nsw i64 %90, %81
  %92 = srem i64 %91, %57
  store i64 %92, ptr %80, align 8, !tbaa !20
  br label %.peel.next124.preheader

.critedge.peel.thread:                            ; preds = %.preheader, %63
  br i1 %exitcond122.peel.not, label %._crit_edge, label %.peel.next124.preheader

.peel.next124.preheader:                          ; preds = %.thread, %.critedge.peel.thread
  br label %.peel.next124

._crit_edge104:                                   ; preds = %._crit_edge, %._crit_edge98.._crit_edge104_crit_edge
  %.pre-phi138 = phi i64 [ %.pre137, %._crit_edge98.._crit_edge104_crit_edge ], [ %57, %._crit_edge ]
  %.pre-phi = phi i64 [ %.pre136, %._crit_edge98.._crit_edge104_crit_edge ], [ %58, %._crit_edge ]
  %93 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %.pre-phi, i64 %.pre-phi
  %94 = load i64, ptr %93, align 16, !tbaa !20
  %95 = getelementptr inbounds i8, ptr %93, i64 8
  %96 = load i64, ptr %95, align 8, !tbaa !20
  %97 = add nsw i64 %96, %94
  %98 = srem i64 %97, %.pre-phi138
  %99 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %98)
  %100 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %99, i8 noundef signext 10)
  ret i32 0

._crit_edge:                                      ; preds = %163, %.critedge.peel.thread
  %indvars.iv.next127 = add nuw nsw i64 %indvars.iv126, 1
  %exitcond130.not = icmp eq i64 %indvars.iv.next127, %wide.trip.count129
  br i1 %exitcond130.not, label %._crit_edge104, label %.preheader, !llvm.loop !22

.peel.next124:                                    ; preds = %.peel.next124.preheader, %163
  %indvars.iv118 = phi i64 [ %indvars.iv.next119, %163 ], [ 1, %.peel.next124.preheader ]
  br i1 %.not83, label %113, label %101

101:                                              ; preds = %.peel.next124
  %102 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %61, i64 %indvars.iv118
  %103 = load i32, ptr %102, align 8, !tbaa !11
  %104 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %61, i64 %indvars.iv118
  %105 = load i64, ptr %104, align 16, !tbaa !20
  %106 = sext i32 %103 to i64
  %107 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !11
  %109 = sext i32 %108 to i64
  %110 = mul nsw i64 %105, %109
  %111 = srem i64 %110, %57
  %112 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv126, i64 %indvars.iv118
  store i64 %111, ptr %112, align 16, !tbaa !20
  br label %113

113:                                              ; preds = %.peel.next124, %101
  %114 = add nsw i64 %indvars.iv118, -1
  %115 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %indvars.iv126, i64 %114
  %116 = load i8, ptr %115, align 1, !tbaa !15
  %117 = icmp eq i8 %116, 46
  %or.cond = and i1 %62, %117
  %118 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %indvars.iv126, i64 %114, i64 1
  %119 = load i32, ptr %118, align 4, !tbaa !11
  br i1 %or.cond, label %120, label %._crit_edge132

._crit_edge132:                                   ; preds = %113
  %.phi.trans.insert133 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv126, i64 %114, i64 1
  %.pre134 = load i64, ptr %.phi.trans.insert133, align 8, !tbaa !20
  br label %.critedge

120:                                              ; preds = %113
  %121 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv126, i64 %indvars.iv118
  %122 = load i64, ptr %121, align 16, !tbaa !20
  %123 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv126, i64 %114, i64 1
  %124 = load i64, ptr %123, align 8, !tbaa !20
  %125 = add nsw i32 %119, -1
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !11
  %129 = sext i32 %128 to i64
  %130 = mul nsw i64 %124, %129
  %131 = srem i64 %130, %57
  %132 = add nsw i64 %131, %122
  %133 = srem i64 %132, %57
  store i64 %133, ptr %121, align 16, !tbaa !20
  br label %.critedge

.critedge:                                        ; preds = %120, %._crit_edge132
  %134 = phi i64 [ %.pre134, %._crit_edge132 ], [ %124, %120 ]
  %135 = sext i32 %119 to i64
  %136 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !11
  %138 = sext i32 %137 to i64
  %139 = mul nsw i64 %134, %138
  %140 = srem i64 %139, %57
  %141 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv126, i64 %indvars.iv118, i64 1
  store i64 %140, ptr %141, align 8, !tbaa !20
  br i1 %.not83, label %163, label %142

142:                                              ; preds = %.critedge
  %143 = getelementptr inbounds [2000 x [2000 x i8]], ptr @S, i64 0, i64 %61, i64 %indvars.iv118
  %144 = load i8, ptr %143, align 1, !tbaa !15
  %145 = icmp eq i8 %144, 46
  %146 = icmp ult i64 %indvars.iv118, %58
  %or.cond88 = and i1 %146, %145
  br i1 %or.cond88, label %147, label %163

147:                                              ; preds = %142
  %148 = getelementptr inbounds [2001 x [2001 x [2 x i32]]], ptr @mp, i64 0, i64 %61, i64 %indvars.iv118
  %149 = load i32, ptr %148, align 8, !tbaa !11
  %150 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv126, i64 %indvars.iv118, i64 1
  %151 = load i64, ptr %150, align 8, !tbaa !20
  %152 = getelementptr inbounds [2001 x [2001 x [2 x i64]]], ptr @dp, i64 0, i64 %61, i64 %indvars.iv118
  %153 = load i64, ptr %152, align 16, !tbaa !20
  %154 = add nsw i32 %149, -1
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [2001 x i32], ptr @p2, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !11
  %158 = sext i32 %157 to i64
  %159 = mul nsw i64 %153, %158
  %160 = srem i64 %159, %57
  %161 = add nsw i64 %160, %151
  %162 = srem i64 %161, %57
  store i64 %162, ptr %150, align 8, !tbaa !20
  br label %163

163:                                              ; preds = %.critedge, %142, %147
  %indvars.iv.next119 = add nuw nsw i64 %indvars.iv118, 1
  %exitcond122.not = icmp eq i64 %indvars.iv.next119, %wide.trip.count129
  br i1 %exitcond122.not, label %._crit_edge, label %.peel.next124, !llvm.loop !23
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #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 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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" }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!10, !10, i64 0}
!16 = distinct !{!16, !14, !17}
!17 = !{!"llvm.loop.peeled.count", i32 1}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = !{!21, !21, i64 0}
!21 = !{!"long long", !10, i64 0}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14, !17}


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