; LLVM IR from kazunetakahashi/atcoder :: 2019/0209_yahoo-procon2019-qual (F)

; 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] }
%"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" }

@_Z1SB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@N = external dso_local global i32, align 4
@DP = external dso_local global [2010 x [4010 x i64]], align 16
@R = external dso_local global [2010 x i32], align 16
@B = external dso_local global [2010 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4initv() #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z1Cii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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 i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @_Z4initv()
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11)
  %16 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11) #6
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr @N, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %26, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 4010
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %18
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [4010 x i64], ptr @DP, i64 0, i64 %24
  store i64 0, ptr %25, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %22
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !11

29:                                               ; preds = %21
  store i64 1, ptr @DP, align 16, !tbaa !9
  store i32 0, ptr @B, align 16, !tbaa !5
  store i32 0, ptr @R, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %108, %29
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = load i32, ptr @N, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %30
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11, i64 noundef %38)
  %40 = load i8, ptr %39, align 1, !tbaa !13
  %41 = sext i8 %40 to i32
  %42 = icmp eq i32 %41, 48
  br i1 %42, label %43, label %61

43:                                               ; preds = %35
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = add nsw i32 %48, 2
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %51
  store i32 %49, ptr %52, align 4, !tbaa !5
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sub nsw i32 %53, 1
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %59
  store i32 %57, ptr %60, align 4, !tbaa !5
  br label %107

61:                                               ; preds = %35
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11, i64 noundef %64)
  %66 = load i8, ptr %65, align 1, !tbaa !13
  %67 = sext i8 %66 to i32
  %68 = icmp eq i32 %67, 49
  br i1 %68, label %69, label %88

69:                                               ; preds = %61
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = sub nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %77
  store i32 %75, ptr %78, align 4, !tbaa !5
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = sub nsw i32 %79, 1
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  %85 = load i32, ptr %3, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %86
  store i32 %84, ptr %87, align 4, !tbaa !5
  br label %106

88:                                               ; preds = %61
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = sub nsw i32 %89, 1
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = load i32, ptr %3, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %95
  store i32 %93, ptr %96, align 4, !tbaa !5
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = sub nsw i32 %97, 1
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = add nsw i32 %101, 2
  %103 = load i32, ptr %3, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %104
  store i32 %102, ptr %105, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %88, %69
  br label %107

107:                                              ; preds = %106, %43
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %3, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %3, align 4, !tbaa !5
  br label %30, !llvm.loop !14

111:                                              ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %214, %111
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = load i32, ptr @N, align 4, !tbaa !5
  %115 = icmp slt i32 %113, %114
  br i1 %115, label %117, label %116

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

117:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %210, %117
  %119 = load i32, ptr %6, align 4, !tbaa !5
  %120 = load i32, ptr %4, align 4, !tbaa !5
  %121 = icmp sle i32 %119, %120
  br i1 %121, label %123, label %122

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

123:                                              ; preds = %118
  %124 = load i32, ptr %4, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %125
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [4010 x i64], ptr %126, i64 0, i64 %128
  %130 = load i64, ptr %129, align 8, !tbaa !9
  %131 = icmp eq i64 %130, 0
  br i1 %131, label %132, label %133

132:                                              ; preds = %123
  br label %210

133:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %134 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %134, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %135 = load i32, ptr %4, align 4, !tbaa !5
  %136 = load i32, ptr %7, align 4, !tbaa !5
  %137 = sub nsw i32 %135, %136
  store i32 %137, ptr %8, align 4, !tbaa !5
  %138 = load i32, ptr %4, align 4, !tbaa !5
  %139 = add nsw i32 %138, 1
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = load i32, ptr %7, align 4, !tbaa !5
  %144 = sub nsw i32 %142, %143
  %145 = icmp sgt i32 %144, 0
  br i1 %145, label %146, label %174

146:                                              ; preds = %133
  %147 = load i32, ptr %4, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %148
  %150 = load i32, ptr %6, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [4010 x i64], ptr %149, i64 0, i64 %151
  %153 = load i64, ptr %152, align 8, !tbaa !9
  %154 = load i32, ptr %4, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %156
  %158 = load i32, ptr %6, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [4010 x i64], ptr %157, i64 0, i64 %160
  %162 = load i64, ptr %161, align 8, !tbaa !9
  %163 = add nsw i64 %162, %153
  store i64 %163, ptr %161, align 8, !tbaa !9
  %164 = load i32, ptr %4, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %166
  %168 = load i32, ptr %6, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [4010 x i64], ptr %167, i64 0, i64 %170
  %172 = load i64, ptr %171, align 8, !tbaa !9
  %173 = srem i64 %172, 998244353
  store i64 %173, ptr %171, align 8, !tbaa !9
  br label %174

174:                                              ; preds = %146, %133
  %175 = load i32, ptr %4, align 4, !tbaa !5
  %176 = add nsw i32 %175, 1
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = load i32, ptr %8, align 4, !tbaa !5
  %181 = sub nsw i32 %179, %180
  %182 = icmp sgt i32 %181, 0
  br i1 %182, label %183, label %209

183:                                              ; preds = %174
  %184 = load i32, ptr %4, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %185
  %187 = load i32, ptr %6, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [4010 x i64], ptr %186, i64 0, i64 %188
  %190 = load i64, ptr %189, align 8, !tbaa !9
  %191 = load i32, ptr %4, align 4, !tbaa !5
  %192 = add nsw i32 %191, 1
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %193
  %195 = load i32, ptr %6, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [4010 x i64], ptr %194, i64 0, i64 %196
  %198 = load i64, ptr %197, align 8, !tbaa !9
  %199 = add nsw i64 %198, %190
  store i64 %199, ptr %197, align 8, !tbaa !9
  %200 = load i32, ptr %4, align 4, !tbaa !5
  %201 = add nsw i32 %200, 1
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %202
  %204 = load i32, ptr %6, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [4010 x i64], ptr %203, i64 0, i64 %205
  %207 = load i64, ptr %206, align 8, !tbaa !9
  %208 = srem i64 %207, 998244353
  store i64 %208, ptr %206, align 8, !tbaa !9
  br label %209

209:                                              ; preds = %183, %174
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %210

210:                                              ; preds = %209, %132
  %211 = load i32, ptr %6, align 4, !tbaa !5
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %6, align 4, !tbaa !5
  br label %118, !llvm.loop !15

213:                                              ; preds = %122
  br label %214

214:                                              ; preds = %213
  %215 = load i32, ptr %4, align 4, !tbaa !5
  %216 = add nsw i32 %215, 1
  store i32 %216, ptr %4, align 4, !tbaa !5
  br label %112, !llvm.loop !16

217:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %218

218:                                              ; preds = %268, %217
  %219 = load i32, ptr %10, align 4, !tbaa !5
  %220 = load i32, ptr @N, align 4, !tbaa !5
  %221 = icmp sle i32 %219, %220
  br i1 %221, label %223, label %222

222:                                              ; preds = %218
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %271

223:                                              ; preds = %218
  %224 = load i32, ptr @N, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %225
  %227 = load i32, ptr %10, align 4, !tbaa !5
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds [4010 x i64], ptr %226, i64 0, i64 %228
  %230 = load i64, ptr %229, align 8, !tbaa !9
  %231 = icmp eq i64 %230, 0
  br i1 %231, label %232, label %233

232:                                              ; preds = %223
  br label %268

233:                                              ; preds = %223
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %234 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %234, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %235 = load i32, ptr @N, align 4, !tbaa !5
  %236 = load i32, ptr %10, align 4, !tbaa !5
  %237 = sub nsw i32 %235, %236
  store i32 %237, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %238 = load i32, ptr @N, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  %242 = load i32, ptr %11, align 4, !tbaa !5
  %243 = sub nsw i32 %241, %242
  store i32 %243, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %244 = load i32, ptr @N, align 4, !tbaa !5
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %245
  %247 = load i32, ptr %246, align 4, !tbaa !5
  %248 = load i32, ptr %12, align 4, !tbaa !5
  %249 = sub nsw i32 %247, %248
  store i32 %249, ptr %14, align 4, !tbaa !5
  %250 = load i32, ptr @N, align 4, !tbaa !5
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %251
  %253 = load i32, ptr %10, align 4, !tbaa !5
  %254 = sext i32 %253 to i64
  %255 = getelementptr inbounds [4010 x i64], ptr %252, i64 0, i64 %254
  %256 = load i64, ptr %255, align 8, !tbaa !9
  %257 = load i32, ptr %13, align 4, !tbaa !5
  %258 = load i32, ptr %14, align 4, !tbaa !5
  %259 = add nsw i32 %257, %258
  %260 = load i32, ptr %13, align 4, !tbaa !5
  %261 = call noundef i64 @_Z1Cii(i32 noundef %259, i32 noundef %260)
  %262 = mul nsw i64 %256, %261
  %263 = srem i64 %262, 998244353
  %264 = load i64, ptr %9, align 8, !tbaa !9
  %265 = add nsw i64 %264, %263
  store i64 %265, ptr %9, align 8, !tbaa !9
  %266 = load i64, ptr %9, align 8, !tbaa !9
  %267 = srem i64 %266, 998244353
  store i64 %267, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %268

268:                                              ; preds = %233, %232
  %269 = load i32, ptr %10, align 4, !tbaa !5
  %270 = add nsw i32 %269, 1
  store i32 %270, ptr %10, align 4, !tbaa !5
  br label %218, !llvm.loop !17

271:                                              ; preds = %222
  %272 = load i64, ptr %9, align 8, !tbaa !9
  %273 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %272)
  %274 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %273, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %275 = load i32, ptr %1, align 4
  ret i32 %275
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #0 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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" }
attributes #5 = { 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 #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 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !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] }
%"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" }

@_Z1SB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@N = external dso_local local_unnamed_addr global i32, align 4
@DP = external dso_local local_unnamed_addr global [2010 x [4010 x i64]], align 16
@R = external dso_local local_unnamed_addr global [2010 x i32], align 16
@B = external dso_local local_unnamed_addr global [2010 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4initv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z1Cii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  tail call void @_Z4initv()
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11)
  %2 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11) #6
  %3 = trunc i64 %2 to i32
  store i32 %3, ptr @N, align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32080) @DP, i8 0, i64 32080, i1 false), !tbaa !9
  store i64 1, ptr @DP, align 16, !tbaa !9
  store i32 0, ptr @B, align 16, !tbaa !5
  store i32 0, ptr @R, align 16, !tbaa !5
  %.not75 = icmp slt i32 %3, 1
  br i1 %.not75, label %.preheader, label %.lr.ph

.preheader73:                                     ; preds = %33
  %4 = icmp sgt i32 %35, 0
  br i1 %4, label %.preheader72.preheader, label %.preheader

.preheader72.preheader:                           ; preds = %.preheader73
  %wide.trip.count100 = zext nneg i32 %35 to i64
  br label %.preheader72

.lr.ph:                                           ; preds = %0, %33
  %indvars.iv = phi i64 [ %indvars.iv.next, %33 ], [ 1, %0 ]
  %5 = add nsw i64 %indvars.iv, -1
  %6 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11, i64 noundef %5)
  %7 = load i8, ptr %6, align 1, !tbaa !11
  %8 = icmp eq i8 %7, 48
  br i1 %8, label %9, label %16

9:                                                ; preds = %.lr.ph
  %10 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %5
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = add nsw i32 %11, 2
  %13 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %indvars.iv
  store i32 %12, ptr %13, align 4, !tbaa !5
  %14 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %5
  %15 = load i32, ptr %14, align 4, !tbaa !5
  br label %33

16:                                               ; preds = %.lr.ph
  %17 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11, i64 noundef %5)
  %18 = load i8, ptr %17, align 1, !tbaa !11
  %19 = icmp eq i8 %18, 49
  %20 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %5
  %21 = load i32, ptr %20, align 4, !tbaa !5
  br i1 %19, label %22, label %28

22:                                               ; preds = %16
  %23 = add nsw i32 %21, 1
  %24 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %indvars.iv
  store i32 %23, ptr %24, align 4, !tbaa !5
  %25 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %5
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  br label %33

28:                                               ; preds = %16
  %29 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %indvars.iv
  store i32 %21, ptr %29, align 4, !tbaa !5
  %30 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %5
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = add nsw i32 %31, 2
  br label %33

33:                                               ; preds = %9, %28, %22
  %.sink = phi i32 [ %15, %9 ], [ %32, %28 ], [ %27, %22 ]
  %34 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %indvars.iv
  store i32 %.sink, ptr %34, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = load i32, ptr @N, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %.not.not = icmp slt i64 %indvars.iv, %36
  br i1 %.not.not, label %.lr.ph, label %.preheader73, !llvm.loop !12

.preheader72:                                     ; preds = %.preheader72.preheader, %41
  %indvars.iv95 = phi i64 [ 0, %.preheader72.preheader ], [ %indvars.iv.next96, %41 ]
  %indvars.iv93 = phi i64 [ 1, %.preheader72.preheader ], [ %indvars.iv.next94, %41 ]
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %37 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %indvars.iv.next96
  %38 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %indvars.iv.next96
  %39 = trunc nuw nsw i64 %indvars.iv95 to i32
  br label %42

.preheader:                                       ; preds = %41, %0, %.preheader73
  %40 = phi i32 [ %35, %.preheader73 ], [ %3, %0 ], [ %35, %41 ]
  %.not6879 = icmp slt i32 %40, 0
  br i1 %.not6879, label %._crit_edge, label %.lr.ph82

41:                                               ; preds = %65
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %exitcond101.not = icmp eq i64 %indvars.iv.next96, %wide.trip.count100
  br i1 %exitcond101.not, label %.preheader, label %.preheader72, !llvm.loop !14

42:                                               ; preds = %.preheader72, %65
  %indvars.iv87 = phi i64 [ 0, %.preheader72 ], [ %indvars.iv.next88, %65 ]
  %43 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %indvars.iv95, i64 %indvars.iv87
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = icmp eq i64 %44, 0
  br i1 %45, label %65, label %46

46:                                               ; preds = %42
  %indvars90 = trunc i64 %indvars.iv87 to i32
  %.neg70 = sub nsw i32 %indvars90, %39
  %47 = load i32, ptr %37, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = icmp slt i64 %indvars.iv87, %48
  br i1 %49, label %50, label %56

50:                                               ; preds = %46
  %51 = add nuw nsw i64 %indvars.iv87, 1
  %52 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %indvars.iv.next96, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !9
  %54 = add nsw i64 %53, %44
  %55 = srem i64 %54, 998244353
  store i64 %55, ptr %52, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %50, %46
  %57 = load i32, ptr %38, align 4, !tbaa !5
  %58 = add i32 %.neg70, %57
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %60, label %65

60:                                               ; preds = %56
  %61 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %indvars.iv.next96, i64 %indvars.iv87
  %62 = load i64, ptr %61, align 8, !tbaa !9
  %63 = add nsw i64 %62, %44
  %64 = srem i64 %63, 998244353
  store i64 %64, ptr %61, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %56, %60, %42
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next88, %indvars.iv93
  br i1 %exitcond.not, label %41, label %42, !llvm.loop !15

._crit_edge:                                      ; preds = %87, %.preheader
  %.063.lcssa = phi i64 [ 0, %.preheader ], [ %.1, %87 ]
  %66 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.063.lcssa)
  %67 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %66, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.lr.ph82:                                         ; preds = %.preheader, %87
  %68 = phi i32 [ %88, %87 ], [ %40, %.preheader ]
  %indvars.iv102 = phi i64 [ %indvars.iv.next103, %87 ], [ 0, %.preheader ]
  %.06380 = phi i64 [ %.1, %87 ], [ 0, %.preheader ]
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2010 x [4010 x i64]], ptr @DP, i64 0, i64 %69, i64 %indvars.iv102
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %72 = icmp eq i64 %71, 0
  br i1 %72, label %87, label %73

73:                                               ; preds = %.lr.ph82
  %74 = trunc nuw nsw i64 %indvars.iv102 to i32
  %.neg = sub i32 %74, %68
  %75 = getelementptr inbounds [2010 x i32], ptr @R, i64 0, i64 %69
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sub nsw i32 %76, %74
  %78 = getelementptr inbounds [2010 x i32], ptr @B, i64 0, i64 %69
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = add i32 %.neg, %79
  %81 = add nsw i32 %80, %77
  %82 = tail call noundef i64 @_Z1Cii(i32 noundef %81, i32 noundef %77)
  %83 = mul nsw i64 %82, %71
  %84 = srem i64 %83, 998244353
  %85 = add nsw i64 %84, %.06380
  %86 = srem i64 %85, 998244353
  %.pre = load i32, ptr @N, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %.lr.ph82, %73
  %88 = phi i32 [ %68, %.lr.ph82 ], [ %.pre, %73 ]
  %.1 = phi i64 [ %.06380, %.lr.ph82 ], [ %86, %73 ]
  %indvars.iv.next103 = add nuw nsw i64 %indvars.iv102, 1
  %89 = sext i32 %88 to i64
  %.not68.not = icmp slt i64 %indvars.iv102, %89
  br i1 %.not68.not, label %.lr.ph82, label %._crit_edge, !llvm.loop !16
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; 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 #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

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

attributes #0 = { 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 #1 = { 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 #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 = { 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


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