; LLVM IR from tangjz/acm-icpc :: lydsy (4018)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@prime = external dso_local global [2000001 x i32], align 16
@sf = external dso_local global [2000001 x [2 x i32]], align 16
@ans = external dso_local global [2 x i32], align 4
@vis = external dso_local global [2000001 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) #0

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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
  store i32 0, ptr %1, align 4
  store i32 1, ptr getelementptr inbounds ([2 x i32], ptr getelementptr inbounds ([2000001 x [2 x i32]], ptr @sf, i64 0, i64 1), i64 0, i64 1), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([2000001 x [2 x i32]], ptr @sf, i64 0, i64 1), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %164, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 2000001
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %167

14:                                               ; preds = %10
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [2000001 x i8], ptr @vis, i64 0, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !9, !range !11, !noundef !12
  %19 = trunc i8 %18 to i1
  br i1 %19, label %40, label %20

20:                                               ; preds = %14
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = load i32, ptr @tot, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @tot, align 4, !tbaa !5
  %24 = sext i32 %22 to i64
  %25 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %24
  store i32 %21, ptr %25, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sub nsw i32 1000000007, %26
  %28 = add nsw i32 %27, 1
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %30
  %32 = getelementptr inbounds [2 x i32], ptr %31, i64 0, i64 0
  store i32 %28, ptr %32, align 8, !tbaa !5
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sub nsw i32 1000000009, %33
  %35 = add nsw i32 %34, 1
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %37
  %39 = getelementptr inbounds [2 x i32], ptr %38, i64 0, i64 1
  store i32 %35, ptr %39, align 4, !tbaa !5
  br label %40

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

41:                                               ; preds = %159, %40
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = load i32, ptr @tot, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %45, label %55

45:                                               ; preds = %41
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = mul nsw i64 %47, %52
  %54 = icmp slt i64 %53, 2000001
  br label %55

55:                                               ; preds = %45, %41
  %56 = phi i1 [ false, %41 ], [ %54, %45 ]
  br i1 %56, label %58, label %57

57:                                               ; preds = %55
  store i32 5, ptr %3, align 4
  br label %162

58:                                               ; preds = %55
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = mul nsw i32 %59, %63
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [2000001 x i8], ptr @vis, i64 0, i64 %65
  store i8 1, ptr %66, align 1, !tbaa !9
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = srem i32 %67, %71
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %103

74:                                               ; preds = %58
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %76
  %78 = getelementptr inbounds [2 x i32], ptr %77, i64 0, i64 0
  %79 = load i32, ptr %78, align 8, !tbaa !5
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = mul nsw i32 %80, %84
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %86
  %88 = getelementptr inbounds [2 x i32], ptr %87, i64 0, i64 0
  store i32 %79, ptr %88, align 8, !tbaa !5
  %89 = load i32, ptr %2, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %90
  %92 = getelementptr inbounds [2 x i32], ptr %91, i64 0, i64 1
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = load i32, ptr %2, align 4, !tbaa !5
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = mul nsw i32 %94, %98
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %100
  %102 = getelementptr inbounds [2 x i32], ptr %101, i64 0, i64 1
  store i32 %93, ptr %102, align 4, !tbaa !5
  store i32 5, ptr %3, align 4
  br label %162

103:                                              ; preds = %58
  %104 = load i32, ptr %2, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %105
  %107 = getelementptr inbounds [2 x i32], ptr %106, i64 0, i64 0
  %108 = load i32, ptr %107, align 8, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = load i32, ptr %4, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %114
  %116 = getelementptr inbounds [2 x i32], ptr %115, i64 0, i64 0
  %117 = load i32, ptr %116, align 8, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = mul nsw i64 %109, %118
  %120 = srem i64 %119, 1000000007
  %121 = trunc i64 %120 to i32
  %122 = load i32, ptr %2, align 4, !tbaa !5
  %123 = load i32, ptr %4, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = mul nsw i32 %122, %126
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %128
  %130 = getelementptr inbounds [2 x i32], ptr %129, i64 0, i64 0
  store i32 %121, ptr %130, align 8, !tbaa !5
  %131 = load i32, ptr %2, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %132
  %134 = getelementptr inbounds [2 x i32], ptr %133, i64 0, i64 1
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = load i32, ptr %4, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %141
  %143 = getelementptr inbounds [2 x i32], ptr %142, i64 0, i64 1
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = mul nsw i64 %136, %145
  %147 = srem i64 %146, 1000000009
  %148 = trunc i64 %147 to i32
  %149 = load i32, ptr %2, align 4, !tbaa !5
  %150 = load i32, ptr %4, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %154 = mul nsw i32 %149, %153
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %155
  %157 = getelementptr inbounds [2 x i32], ptr %156, i64 0, i64 1
  store i32 %148, ptr %157, align 4, !tbaa !5
  br label %158

158:                                              ; preds = %103
  br label %159

159:                                              ; preds = %158
  %160 = load i32, ptr %4, align 4, !tbaa !5
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %4, align 4, !tbaa !5
  br label %41, !llvm.loop !13

162:                                              ; preds = %74, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %163

163:                                              ; preds = %162
  br label %164

164:                                              ; preds = %163
  %165 = load i32, ptr %2, align 4, !tbaa !5
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !15

167:                                              ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 2, ptr %5, align 4, !tbaa !5
  br label %168

168:                                              ; preds = %193, %167
  %169 = load i32, ptr %5, align 4, !tbaa !5
  %170 = icmp slt i32 %169, 2000001
  br i1 %170, label %172, label %171

171:                                              ; preds = %168
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %196

172:                                              ; preds = %168
  %173 = load i32, ptr %5, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %174
  %176 = getelementptr inbounds [2 x i32], ptr %175, i64 0, i64 0
  %177 = load i32, ptr %5, align 4, !tbaa !5
  %178 = sub nsw i32 %177, 1
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %179
  %181 = getelementptr inbounds [2 x i32], ptr %180, i64 0, i64 0
  %182 = load i32, ptr %181, align 8, !tbaa !5
  call void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4) %176, i32 noundef %182, i32 noundef 1000000007)
  %183 = load i32, ptr %5, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %184
  %186 = getelementptr inbounds [2 x i32], ptr %185, i64 0, i64 1
  %187 = load i32, ptr %5, align 4, !tbaa !5
  %188 = sub nsw i32 %187, 1
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %189
  %191 = getelementptr inbounds [2 x i32], ptr %190, i64 0, i64 1
  %192 = load i32, ptr %191, align 4, !tbaa !5
  call void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4) %186, i32 noundef %192, i32 noundef 1000000009)
  br label %193

193:                                              ; preds = %172
  %194 = load i32, ptr %5, align 4, !tbaa !5
  %195 = add nsw i32 %194, 1
  store i32 %195, ptr %5, align 4, !tbaa !5
  br label %168, !llvm.loop !16

196:                                              ; preds = %171
  %197 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %198

198:                                              ; preds = %280, %196
  %199 = load i32, ptr @t, align 4, !tbaa !5
  %200 = add nsw i32 %199, -1
  store i32 %200, ptr @t, align 4, !tbaa !5
  %201 = icmp ne i32 %199, 0
  br i1 %201, label %202, label %284

202:                                              ; preds = %198
  %203 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m)
  %204 = load i32, ptr @n, align 4, !tbaa !5
  %205 = load i32, ptr @m, align 4, !tbaa !5
  %206 = icmp sgt i32 %204, %205
  br i1 %206, label %207, label %208

207:                                              ; preds = %202
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @m) #5
  br label %208

208:                                              ; preds = %207, %202
  store i32 0, ptr getelementptr inbounds ([2 x i32], ptr @ans, i64 0, i64 1), align 4, !tbaa !5
  store i32 0, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  br label %209

209:                                              ; preds = %277, %208
  %210 = load i32, ptr %6, align 4, !tbaa !5
  %211 = load i32, ptr @n, align 4, !tbaa !5
  %212 = icmp sle i32 %210, %211
  br i1 %212, label %214, label %213

213:                                              ; preds = %209
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %280

214:                                              ; preds = %209
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %215 = load i32, ptr @n, align 4, !tbaa !5
  %216 = load i32, ptr @n, align 4, !tbaa !5
  %217 = load i32, ptr %6, align 4, !tbaa !5
  %218 = sdiv i32 %216, %217
  %219 = sdiv i32 %215, %218
  store i32 %219, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %220 = load i32, ptr @m, align 4, !tbaa !5
  %221 = load i32, ptr @m, align 4, !tbaa !5
  %222 = load i32, ptr %6, align 4, !tbaa !5
  %223 = sdiv i32 %221, %222
  %224 = sdiv i32 %220, %223
  store i32 %224, ptr %9, align 4, !tbaa !5
  %225 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %226 = load i32, ptr %225, align 4, !tbaa !5
  store i32 %226, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %227 = load i32, ptr %7, align 4, !tbaa !5
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %228
  %230 = getelementptr inbounds [2 x i32], ptr %229, i64 0, i64 0
  %231 = load i32, ptr %230, align 8, !tbaa !5
  %232 = load i32, ptr %6, align 4, !tbaa !5
  %233 = sub nsw i32 %232, 1
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %234
  %236 = getelementptr inbounds [2 x i32], ptr %235, i64 0, i64 0
  %237 = load i32, ptr %236, align 8, !tbaa !5
  %238 = sub nsw i32 %231, %237
  %239 = add nsw i32 %238, 1000000007
  %240 = sext i32 %239 to i64
  %241 = load i32, ptr @n, align 4, !tbaa !5
  %242 = load i32, ptr %6, align 4, !tbaa !5
  %243 = sdiv i32 %241, %242
  %244 = load i32, ptr @m, align 4, !tbaa !5
  %245 = load i32, ptr %6, align 4, !tbaa !5
  %246 = sdiv i32 %244, %245
  %247 = call noundef i32 @_Z1fiii(i32 noundef %243, i32 noundef %246, i32 noundef 1000000007)
  %248 = sext i32 %247 to i64
  %249 = mul nsw i64 %240, %248
  %250 = srem i64 %249, 1000000007
  %251 = trunc i64 %250 to i32
  call void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4) @ans, i32 noundef %251, i32 noundef 1000000007)
  %252 = load i32, ptr %7, align 4, !tbaa !5
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %253
  %255 = getelementptr inbounds [2 x i32], ptr %254, i64 0, i64 1
  %256 = load i32, ptr %255, align 4, !tbaa !5
  %257 = load i32, ptr %6, align 4, !tbaa !5
  %258 = sub nsw i32 %257, 1
  %259 = sext i32 %258 to i64
  %260 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %259
  %261 = getelementptr inbounds [2 x i32], ptr %260, i64 0, i64 1
  %262 = load i32, ptr %261, align 4, !tbaa !5
  %263 = sub nsw i32 %256, %262
  %264 = add nsw i32 %263, 1000000009
  %265 = sext i32 %264 to i64
  %266 = load i32, ptr @n, align 4, !tbaa !5
  %267 = load i32, ptr %6, align 4, !tbaa !5
  %268 = sdiv i32 %266, %267
  %269 = load i32, ptr @m, align 4, !tbaa !5
  %270 = load i32, ptr %6, align 4, !tbaa !5
  %271 = sdiv i32 %269, %270
  %272 = call noundef i32 @_Z1fiii(i32 noundef %268, i32 noundef %271, i32 noundef 1000000009)
  %273 = sext i32 %272 to i64
  %274 = mul nsw i64 %265, %273
  %275 = srem i64 %274, 1000000009
  %276 = trunc i64 %275 to i32
  call void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds ([2 x i32], ptr @ans, i64 0, i64 1), i32 noundef %276, i32 noundef 1000000009)
  br label %277

277:                                              ; preds = %214
  %278 = load i32, ptr %7, align 4, !tbaa !5
  %279 = add nsw i32 %278, 1
  store i32 %279, ptr %6, align 4, !tbaa !5
  br label %209, !llvm.loop !17

280:                                              ; preds = %213
  %281 = load i32, ptr @ans, align 4, !tbaa !5
  %282 = load i32, ptr getelementptr inbounds ([2 x i32], ptr @ans, i64 0, i64 1), align 4, !tbaa !5
  %283 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %281, i32 noundef %282)
  br label %198, !llvm.loop !18

284:                                              ; preds = %198
  ret i32 0
}

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

; 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)) #1

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

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@prime = external dso_local local_unnamed_addr global [2000001 x i32], align 16
@sf = external dso_local global [2000001 x [2 x i32]], align 16
@ans = external dso_local global [2 x i32], align 4
@vis = external dso_local local_unnamed_addr global [2000001 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) 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: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 1, ptr getelementptr inbounds (i8, ptr @sf, i64 12), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @sf, i64 8), align 8, !tbaa !5
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %0, %.critedge
  %indvars.iv66 = phi i64 [ 2, %0 ], [ %indvars.iv.next67, %.critedge ]
  %4 = phi i32 [ %tot.promoted, %0 ], [ %20, %.critedge ]
  %5 = getelementptr inbounds [2000001 x i8], ptr @vis, i64 0, i64 %indvars.iv66
  %6 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %19, label %8

8:                                                ; preds = %3
  %9 = add nsw i32 %4, 1
  store i32 %9, ptr @tot, align 4, !tbaa !5
  %10 = sext i32 %4 to i64
  %11 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %10
  %12 = trunc nuw nsw i64 %indvars.iv66 to i32
  store i32 %12, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %indvars.iv66
  %14 = trunc i64 %indvars.iv66 to i32
  %15 = sub i32 1000000008, %14
  store i32 %15, ptr %13, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %13, i64 4
  %17 = trunc i64 %indvars.iv66 to i32
  %18 = sub i32 1000000010, %17
  store i32 %18, ptr %16, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %8, %3
  %20 = phi i32 [ %9, %8 ], [ %4, %3 ]
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %19
  %22 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %indvars.iv66
  %23 = getelementptr inbounds i8, ptr %22, i64 4
  %wide.trip.count = zext nneg i32 %20 to i64
  %24 = trunc nuw nsw i64 %indvars.iv66 to i32
  br label %25

25:                                               ; preds = %.lr.ph, %42
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %42 ]
  %26 = getelementptr inbounds [2000001 x i32], ptr @prime, i64 0, i64 %indvars.iv
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = mul nsw i64 %indvars.iv66, %28
  %30 = icmp slt i64 %29, 2000001
  br i1 %30, label %31, label %.critedge

31:                                               ; preds = %25
  %32 = mul nsw i32 %27, %24
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2000001 x i8], ptr @vis, i64 0, i64 %33
  store i8 1, ptr %34, align 1, !tbaa !9
  %35 = srem i32 %24, %27
  %36 = icmp eq i32 %35, 0
  %37 = load i32, ptr %22, align 8, !tbaa !5
  br i1 %36, label %38, label %42

38:                                               ; preds = %31
  %39 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %33
  store i32 %37, ptr %39, align 8, !tbaa !5
  %40 = load i32, ptr %23, align 4, !tbaa !5
  %41 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %33, i64 1
  store i32 %40, ptr %41, align 4, !tbaa !5
  br label %.critedge

42:                                               ; preds = %31
  %43 = sext i32 %37 to i64
  %44 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %28
  %45 = load i32, ptr %44, align 8, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = mul nsw i64 %46, %43
  %48 = srem i64 %47, 1000000007
  %49 = trunc nsw i64 %48 to i32
  %50 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %33
  store i32 %49, ptr %50, align 8, !tbaa !5
  %51 = load i32, ptr %23, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %28, i64 1
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = mul nsw i64 %55, %52
  %57 = srem i64 %56, 1000000009
  %58 = trunc nsw i64 %57 to i32
  %59 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %33, i64 1
  store i32 %58, ptr %59, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %25, !llvm.loop !13

.critedge:                                        ; preds = %42, %25, %19, %38
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %exitcond69.not = icmp eq i64 %indvars.iv.next67, 2000001
  br i1 %exitcond69.not, label %.preheader, label %3, !llvm.loop !15

60:                                               ; preds = %.preheader
  %61 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %62 = load i32, ptr @t, align 4, !tbaa !5
  %63 = add nsw i32 %62, -1
  store i32 %63, ptr @t, align 4, !tbaa !5
  %.not61 = icmp eq i32 %62, 0
  br i1 %.not61, label %._crit_edge64, label %.lr.ph63

.preheader:                                       ; preds = %.critedge, %.preheader
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %.preheader ], [ 2, %.critedge ]
  %64 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %indvars.iv70
  %65 = add nsw i64 %indvars.iv70, -1
  %66 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %65
  %67 = load i32, ptr %66, align 8, !tbaa !5
  tail call void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4) %64, i32 noundef %67, i32 noundef 1000000007)
  %68 = getelementptr inbounds i8, ptr %64, i64 4
  %69 = getelementptr inbounds i8, ptr %66, i64 4
  %70 = load i32, ptr %69, align 4, !tbaa !5
  tail call void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4) %68, i32 noundef %70, i32 noundef 1000000009)
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %exitcond73.not = icmp eq i64 %indvars.iv.next71, 2000001
  br i1 %exitcond73.not, label %60, label %.preheader, !llvm.loop !16

.lr.ph63:                                         ; preds = %60, %._crit_edge
  %71 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %72 = load i32, ptr @n, align 4, !tbaa !5
  %73 = load i32, ptr @m, align 4, !tbaa !5
  %74 = icmp sgt i32 %72, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %.lr.ph63
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @m) #5
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %75, %.lr.ph63
  %77 = phi i32 [ %.pre, %75 ], [ %72, %.lr.ph63 ]
  store i32 0, ptr getelementptr inbounds (i8, ptr @ans, i64 4), align 4, !tbaa !5
  store i32 0, ptr @ans, align 4, !tbaa !5
  %.not5158 = icmp slt i32 %77, 1
  br i1 %.not5158, label %._crit_edge, label %.lr.ph60

._crit_edge.loopexit:                             ; preds = %.lr.ph60
  %.pre74 = load i32, ptr @ans, align 4, !tbaa !5
  %.pre75 = load i32, ptr getelementptr inbounds (i8, ptr @ans, i64 4), align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %76
  %78 = phi i32 [ %.pre75, %._crit_edge.loopexit ], [ 0, %76 ]
  %79 = phi i32 [ %.pre74, %._crit_edge.loopexit ], [ 0, %76 ]
  %80 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %79, i32 noundef %78)
  %81 = load i32, ptr @t, align 4, !tbaa !5
  %82 = add nsw i32 %81, -1
  store i32 %82, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %81, 0
  br i1 %.not, label %._crit_edge64, label %.lr.ph63, !llvm.loop !17

.lr.ph60:                                         ; preds = %76, %.lr.ph60
  %83 = phi i32 [ %127, %.lr.ph60 ], [ %77, %76 ]
  %.04859 = phi i32 [ %126, %.lr.ph60 ], [ 1, %76 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %84 = sdiv i32 %83, %.04859
  %85 = sdiv i32 %83, %84
  store i32 %85, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %86 = load i32, ptr @m, align 4, !tbaa !5
  %87 = sdiv i32 %86, %.04859
  %88 = sdiv i32 %86, %87
  store i32 %88, ptr %2, align 4, !tbaa !5
  %89 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %90 = load i32, ptr %89, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %91
  %93 = load i32, ptr %92, align 8, !tbaa !5
  %94 = add nsw i32 %.04859, -1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2000001 x [2 x i32]], ptr @sf, i64 0, i64 %95
  %97 = load i32, ptr %96, align 8, !tbaa !5
  %98 = add i32 %93, 1000000007
  %99 = sub i32 %98, %97
  %100 = sext i32 %99 to i64
  %101 = load i32, ptr @n, align 4, !tbaa !5
  %102 = sdiv i32 %101, %.04859
  %103 = load i32, ptr @m, align 4, !tbaa !5
  %104 = sdiv i32 %103, %.04859
  %105 = call noundef i32 @_Z1fiii(i32 noundef %102, i32 noundef %104, i32 noundef 1000000007)
  %106 = sext i32 %105 to i64
  %107 = mul nsw i64 %106, %100
  %108 = srem i64 %107, 1000000007
  %109 = trunc nsw i64 %108 to i32
  call void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4) @ans, i32 noundef %109, i32 noundef 1000000007)
  %110 = getelementptr inbounds i8, ptr %92, i64 4
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = getelementptr inbounds i8, ptr %96, i64 4
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = add i32 %111, 1000000009
  %115 = sub i32 %114, %113
  %116 = sext i32 %115 to i64
  %117 = load i32, ptr @n, align 4, !tbaa !5
  %118 = sdiv i32 %117, %.04859
  %119 = load i32, ptr @m, align 4, !tbaa !5
  %120 = sdiv i32 %119, %.04859
  %121 = call noundef i32 @_Z1fiii(i32 noundef %118, i32 noundef %120, i32 noundef 1000000009)
  %122 = sext i32 %121 to i64
  %123 = mul nsw i64 %122, %116
  %124 = srem i64 %123, 1000000009
  %125 = trunc nsw i64 %124 to i32
  call void @_Z3incRiii(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @ans, i64 4), i32 noundef %125, i32 noundef 1000000009)
  %126 = add nsw i32 %90, 1
  %127 = load i32, ptr @n, align 4, !tbaa !5
  %.not51.not = icmp slt i32 %90, %127
  br i1 %.not51.not, label %.lr.ph60, label %._crit_edge.loopexit, !llvm.loop !18

._crit_edge64:                                    ; preds = %._crit_edge, %60
  ret i32 0
}

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

; 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 #1

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

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress norecurse nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #5 = { 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 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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