; LLVM IR from tangjz/acm-icpc :: 51nod/Contest/Algorithm_Marathon_16 (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"

@inv = external dso_local global [2000001 x i32], align 16
@fact = external dso_local global [2000001 x i32], align 16
@w = external dso_local global [4194304 x i32], align 16
@inv2 = external dso_local global [23 x i32], align 16
@pool = external dso_local global [7194309 x i32], align 16
@f = external dso_local global [4 x ptr], align 16
@sz = external dso_local global [4 x i32], 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 [14 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7PolyExpiPiS_(i32 noundef, ptr noundef, ptr noundef) #1

; 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 i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 1, ptr @w, align 16, !tbaa !5
  %15 = call noundef i32 @_Z7mod_powii(i32 noundef 3, i32 noundef 235)
  store i32 %15, ptr getelementptr inbounds ([4194304 x i32], ptr @w, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %35, %0
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = icmp slt i32 %17, 4194304
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %38

20:                                               ; preds = %16
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sub nsw i32 %21, 1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [4194304 x i32], ptr @w, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = load i32, ptr getelementptr inbounds ([4194304 x i32], ptr @w, i64 0, i64 1), align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = mul nsw i64 %26, %28
  %30 = srem i64 %29, 985661441
  %31 = trunc i64 %30 to i32
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [4194304 x i32], ptr @w, i64 0, i64 %33
  store i32 %31, ptr %34, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %20
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %2, align 4, !tbaa !5
  br label %16, !llvm.loop !9

38:                                               ; preds = %19
  store i32 1, ptr @inv2, align 16, !tbaa !5
  store i32 492830721, ptr getelementptr inbounds ([23 x i32], ptr @inv2, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %58, %38
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = icmp sle i32 %40, 22
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %61

43:                                               ; preds = %39
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [23 x i32], ptr @inv2, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = load i32, ptr getelementptr inbounds ([23 x i32], ptr @inv2, i64 0, i64 1), align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = mul nsw i64 %49, %51
  %53 = srem i64 %52, 985661441
  %54 = trunc i64 %53 to i32
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [23 x i32], ptr @inv2, i64 0, i64 %56
  store i32 %54, ptr %57, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %43
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %3, align 4, !tbaa !5
  br label %39, !llvm.loop !11

61:                                               ; preds = %42
  store i32 1, ptr getelementptr inbounds ([2000001 x i32], ptr @inv, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 2, ptr %4, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %83, %61
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = icmp slt i32 %63, 2000001
  br i1 %64, label %66, label %65

65:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %86

66:                                               ; preds = %62
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = sdiv i32 985661441, %67
  %69 = sext i32 %68 to i64
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = srem i32 985661441, %70
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [2000001 x i32], ptr @inv, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = mul nsw i64 %69, %75
  %77 = srem i64 %76, 985661441
  %78 = sub nsw i64 985661441, %77
  %79 = trunc i64 %78 to i32
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [2000001 x i32], ptr @inv, i64 0, i64 %81
  store i32 %79, ptr %82, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %66
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %4, align 4, !tbaa !5
  br label %62, !llvm.loop !12

86:                                               ; preds = %65
  store ptr getelementptr inbounds (i32, ptr @pool, i64 1), ptr getelementptr inbounds ([4 x ptr], ptr @f, i64 0, i64 1), align 8, !tbaa !13
  store i32 2000001, ptr getelementptr inbounds ([4 x i32], ptr @sz, i64 0, i64 1), align 4, !tbaa !5
  %87 = load ptr, ptr getelementptr inbounds ([4 x ptr], ptr @f, i64 0, i64 1), align 8, !tbaa !13
  %88 = getelementptr inbounds i32, ptr %87, i64 0
  store i32 1, ptr %88, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %113, %86
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = icmp slt i32 %90, 2000001
  br i1 %91, label %93, label %92

92:                                               ; preds = %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %116

93:                                               ; preds = %89
  %94 = load ptr, ptr getelementptr inbounds ([4 x ptr], ptr @f, i64 0, i64 1), align 8, !tbaa !13
  %95 = load i32, ptr %5, align 4, !tbaa !5
  %96 = sub nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i32, ptr %94, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = load i32, ptr %5, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2000001 x i32], ptr @inv, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = mul nsw i64 %100, %105
  %107 = srem i64 %106, 985661441
  %108 = trunc i64 %107 to i32
  %109 = load ptr, ptr getelementptr inbounds ([4 x ptr], ptr @f, i64 0, i64 1), align 8, !tbaa !13
  %110 = load i32, ptr %5, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds i32, ptr %109, i64 %111
  store i32 %108, ptr %112, align 4, !tbaa !5
  br label %113

113:                                              ; preds = %93
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %5, align 4, !tbaa !5
  br label %89, !llvm.loop !15

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

117:                                              ; preds = %158, %116
  %118 = load i32, ptr %6, align 4, !tbaa !5
  %119 = icmp slt i32 %118, 4
  br i1 %119, label %121, label %120

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

121:                                              ; preds = %117
  %122 = load i32, ptr %6, align 4, !tbaa !5
  %123 = sub nsw i32 %122, 1
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %124
  %126 = load ptr, ptr %125, align 8, !tbaa !13
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = sub nsw i32 %127, 1
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [4 x i32], ptr @sz, i64 0, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i32, ptr %126, i64 %132
  %134 = getelementptr inbounds i32, ptr %133, i64 1
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %136
  store ptr %134, ptr %137, align 8, !tbaa !13
  %138 = load i32, ptr %6, align 4, !tbaa !5
  %139 = sdiv i32 2000000, %138
  %140 = add nsw i32 %139, 1
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [4 x i32], ptr @sz, i64 0, i64 %142
  store i32 %140, ptr %143, align 4, !tbaa !5
  %144 = load i32, ptr %6, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [4 x i32], ptr @sz, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = load i32, ptr %6, align 4, !tbaa !5
  %149 = sub nsw i32 %148, 1
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %150
  %152 = load ptr, ptr %151, align 8, !tbaa !13
  %153 = getelementptr inbounds i32, ptr %152, i64 -1
  %154 = load i32, ptr %6, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %155
  %157 = load ptr, ptr %156, align 8, !tbaa !13
  call void @_Z7PolyExpiPiS_(i32 noundef %147, ptr noundef %153, ptr noundef %157)
  br label %158

158:                                              ; preds = %121
  %159 = load i32, ptr %6, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %6, align 4, !tbaa !5
  br label %117, !llvm.loop !16

161:                                              ; preds = %120
  store i32 1, ptr @fact, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %162

162:                                              ; preds = %181, %161
  %163 = load i32, ptr %7, align 4, !tbaa !5
  %164 = icmp slt i32 %163, 2000001
  br i1 %164, label %166, label %165

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

166:                                              ; preds = %162
  %167 = load i32, ptr %7, align 4, !tbaa !5
  %168 = sub nsw i32 %167, 1
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [2000001 x i32], ptr @fact, i64 0, i64 %169
  %171 = load i32, ptr %170, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = load i32, ptr %7, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = mul nsw i64 %172, %174
  %176 = srem i64 %175, 985661441
  %177 = trunc i64 %176 to i32
  %178 = load i32, ptr %7, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [2000001 x i32], ptr @fact, i64 0, i64 %179
  store i32 %177, ptr %180, align 4, !tbaa !5
  br label %181

181:                                              ; preds = %166
  %182 = load i32, ptr %7, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %7, align 4, !tbaa !5
  br label %162, !llvm.loop !17

184:                                              ; preds = %165
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %185

185:                                              ; preds = %228, %184
  %186 = load i32, ptr %8, align 4, !tbaa !5
  %187 = icmp slt i32 %186, 4
  br i1 %187, label %189, label %188

188:                                              ; preds = %185
  store i32 20, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %231

189:                                              ; preds = %185
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %190 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %190, ptr %10, align 4, !tbaa !5
  br label %191

191:                                              ; preds = %224, %189
  %192 = load i32, ptr %10, align 4, !tbaa !5
  %193 = load i32, ptr %8, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [4 x i32], ptr @sz, i64 0, i64 %194
  %196 = load i32, ptr %195, align 4, !tbaa !5
  %197 = icmp slt i32 %192, %196
  br i1 %197, label %199, label %198

198:                                              ; preds = %191
  store i32 23, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %227

199:                                              ; preds = %191
  %200 = load i32, ptr %8, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %201
  %203 = load ptr, ptr %202, align 8, !tbaa !13
  %204 = load i32, ptr %10, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds i32, ptr %203, i64 %205
  %207 = load i32, ptr %206, align 4, !tbaa !5
  %208 = sext i32 %207 to i64
  %209 = load i32, ptr %10, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [2000001 x i32], ptr @fact, i64 0, i64 %210
  %212 = load i32, ptr %211, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = mul nsw i64 %208, %213
  %215 = srem i64 %214, 985661441
  %216 = trunc i64 %215 to i32
  %217 = load i32, ptr %8, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %218
  %220 = load ptr, ptr %219, align 8, !tbaa !13
  %221 = load i32, ptr %10, align 4, !tbaa !5
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds i32, ptr %220, i64 %222
  store i32 %216, ptr %223, align 4, !tbaa !5
  br label %224

224:                                              ; preds = %199
  %225 = load i32, ptr %10, align 4, !tbaa !5
  %226 = add nsw i32 %225, 1
  store i32 %226, ptr %10, align 4, !tbaa !5
  br label %191, !llvm.loop !18

227:                                              ; preds = %198
  br label %228

228:                                              ; preds = %227
  %229 = load i32, ptr %8, align 4, !tbaa !5
  %230 = add nsw i32 %229, 1
  store i32 %230, ptr %8, align 4, !tbaa !5
  br label %185, !llvm.loop !19

231:                                              ; preds = %188
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %232 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 1, ptr %14, align 4, !tbaa !5
  br label %233

233:                                              ; preds = %259, %231
  %234 = load i32, ptr %14, align 4, !tbaa !5
  %235 = load i32, ptr %11, align 4, !tbaa !5
  %236 = icmp sle i32 %234, %235
  br i1 %236, label %238, label %237

237:                                              ; preds = %233
  store i32 26, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %262

238:                                              ; preds = %233
  %239 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %12, ptr noundef %13)
  %240 = load i32, ptr %13, align 4, !tbaa !5
  %241 = load i32, ptr %12, align 4, !tbaa !5
  %242 = icmp slt i32 %240, %241
  br i1 %242, label %243, label %245

243:                                              ; preds = %238
  %244 = load i32, ptr %13, align 4, !tbaa !5
  br label %247

245:                                              ; preds = %238
  %246 = load i32, ptr %12, align 4, !tbaa !5
  br label %247

247:                                              ; preds = %245, %243
  %248 = phi i32 [ %244, %243 ], [ %246, %245 ]
  store i32 %248, ptr %13, align 4, !tbaa !5
  %249 = load i32, ptr %14, align 4, !tbaa !5
  %250 = load i32, ptr %13, align 4, !tbaa !5
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %251
  %253 = load ptr, ptr %252, align 8, !tbaa !13
  %254 = load i32, ptr %12, align 4, !tbaa !5
  %255 = sext i32 %254 to i64
  %256 = getelementptr inbounds i32, ptr %253, i64 %255
  %257 = load i32, ptr %256, align 4, !tbaa !5
  %258 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %249, i32 noundef %257)
  br label %259

259:                                              ; preds = %247
  %260 = load i32, ptr %14, align 4, !tbaa !5
  %261 = add nsw i32 %260, 1
  store i32 %261, ptr %14, align 4, !tbaa !5
  br label %233, !llvm.loop !20

262:                                              ; preds = %237
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %263 = load i32, ptr %1, align 4
  ret i32 %263
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powii(i32 noundef, i32 noundef) #3

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

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

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


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

@inv = external dso_local local_unnamed_addr global [2000001 x i32], align 16
@fact = external dso_local local_unnamed_addr global [2000001 x i32], align 16
@w = external dso_local local_unnamed_addr global [4194304 x i32], align 16
@inv2 = external dso_local local_unnamed_addr global [23 x i32], align 16
@pool = external dso_local global [7194309 x i32], align 16
@f = external dso_local local_unnamed_addr global [4 x ptr], align 16
@sz = external dso_local local_unnamed_addr global [4 x i32], 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 [14 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7PolyExpiPiS_(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 1, ptr @w, align 16, !tbaa !5
  %4 = tail call noundef i32 @_Z7mod_powii(i32 noundef 3, i32 noundef 235)
  store i32 %4, ptr getelementptr inbounds (i8, ptr @w, i64 4), align 4, !tbaa !5
  br label %6

5:                                                ; preds = %6
  store <4 x i32> <i32 1, i32 492830721, i32 739246081, i32 862453761>, ptr @inv2, align 16, !tbaa !5
  store <4 x i32> <i32 924057601, i32 954859521, i32 970260481, i32 977960961>, ptr getelementptr inbounds (i8, ptr @inv2, i64 16), align 16, !tbaa !5
  store <4 x i32> <i32 981811201, i32 983736321, i32 984698881, i32 985180161>, ptr getelementptr inbounds (i8, ptr @inv2, i64 32), align 16, !tbaa !5
  store <4 x i32> <i32 985420801, i32 985541121, i32 985601281, i32 985631361>, ptr getelementptr inbounds (i8, ptr @inv2, i64 48), align 16, !tbaa !5
  store <4 x i32> <i32 985646401, i32 985653921, i32 985657681, i32 985659561>, ptr getelementptr inbounds (i8, ptr @inv2, i64 64), align 16, !tbaa !5
  store i32 985660501, ptr getelementptr inbounds (i8, ptr @inv2, i64 80), align 16, !tbaa !5
  store i32 985660971, ptr getelementptr inbounds (i8, ptr @inv2, i64 84), align 4, !tbaa !5
  store i32 985661206, ptr getelementptr inbounds (i8, ptr @inv2, i64 88), align 8, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @inv, i64 4), align 4, !tbaa !5
  br label %22

6:                                                ; preds = %6, %0
  %7 = phi i32 [ %4, %0 ], [ %19, %6 ]
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next.1, %6 ]
  %8 = sext i32 %7 to i64
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @w, i64 4), align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = mul nsw i64 %10, %8
  %12 = srem i64 %11, 985661441
  %13 = trunc nsw i64 %12 to i32
  %14 = getelementptr inbounds [4194304 x i32], ptr @w, i64 0, i64 %indvars.iv
  store i32 %13, ptr %14, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @w, i64 4), align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = mul nsw i64 %12, %16
  %18 = srem i64 %17, 985661441
  %19 = trunc nsw i64 %18 to i32
  %20 = getelementptr inbounds [4194304 x i32], ptr @w, i64 0, i64 %indvars.iv.next
  store i32 %19, ptr %20, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 4194304
  br i1 %exitcond.not.1, label %5, label %6, !llvm.loop !9

21:                                               ; preds = %22
  store ptr getelementptr inbounds (i8, ptr @pool, i64 4), ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !11
  store i32 2000001, ptr getelementptr inbounds (i8, ptr @sz, i64 4), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @pool, i64 4), align 4, !tbaa !5
  br label %36

22:                                               ; preds = %5, %22
  %indvars.iv76 = phi i64 [ 2, %5 ], [ %indvars.iv.next77, %22 ]
  %23 = trunc nuw nsw i64 %indvars.iv76 to i32
  %24 = udiv i32 985661441, %23
  %25 = zext nneg i32 %24 to i64
  %26 = urem i32 985661441, %23
  %27 = zext nneg i32 %26 to i64
  %28 = getelementptr inbounds [2000001 x i32], ptr @inv, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = mul nsw i64 %30, %25
  %32 = srem i64 %31, 985661441
  %33 = trunc nsw i64 %32 to i32
  %34 = sub nsw i32 985661441, %33
  %35 = getelementptr inbounds [2000001 x i32], ptr @inv, i64 0, i64 %indvars.iv76
  store i32 %34, ptr %35, align 4, !tbaa !5
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %exitcond79.not = icmp eq i64 %indvars.iv.next77, 2000001
  br i1 %exitcond79.not, label %21, label %22, !llvm.loop !13

36:                                               ; preds = %36, %21
  %store_forwarded = phi i64 [ 1, %21 ], [ %49, %36 ]
  %indvars.iv80 = phi i64 [ 1, %21 ], [ %indvars.iv.next81.1, %36 ]
  %37 = getelementptr i32, ptr getelementptr inbounds (i8, ptr @pool, i64 4), i64 %indvars.iv80
  %38 = getelementptr inbounds [2000001 x i32], ptr @inv, i64 0, i64 %indvars.iv80
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = mul nsw i64 %store_forwarded, %40
  %42 = srem i64 %41, 985661441
  %43 = trunc nsw i64 %42 to i32
  store i32 %43, ptr %37, align 4, !tbaa !5
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %44 = getelementptr i32, ptr getelementptr inbounds (i8, ptr @pool, i64 4), i64 %indvars.iv.next81
  %45 = getelementptr inbounds [2000001 x i32], ptr @inv, i64 0, i64 %indvars.iv.next81
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = mul nsw i64 %42, %47
  %49 = srem i64 %48, 985661441
  %50 = trunc nsw i64 %49 to i32
  store i32 %50, ptr %44, align 4, !tbaa !5
  %indvars.iv.next81.1 = add nuw nsw i64 %indvars.iv80, 2
  %exitcond83.not.1 = icmp eq i64 %indvars.iv.next81.1, 2000001
  br i1 %exitcond83.not.1, label %.preheader57.preheader, label %36, !llvm.loop !14

.preheader57.preheader:                           ; preds = %36
  store ptr getelementptr inbounds (i8, ptr @pool, i64 8000012), ptr getelementptr inbounds (i8, ptr @f, i64 16), align 16, !tbaa !11
  store i32 1000001, ptr getelementptr inbounds (i8, ptr @sz, i64 8), align 8, !tbaa !5
  tail call void @_Z7PolyExpiPiS_(i32 noundef 1000001, ptr noundef nonnull @pool, ptr noundef nonnull getelementptr inbounds (i8, ptr @pool, i64 8000012))
  %51 = load ptr, ptr getelementptr inbounds (i8, ptr @f, i64 16), align 16, !tbaa !11
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @sz, i64 8), align 8, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  %55 = getelementptr inbounds i8, ptr %54, i64 4
  store ptr %55, ptr getelementptr inbounds (i8, ptr @f, i64 24), align 8, !tbaa !11
  store i32 666667, ptr getelementptr inbounds (i8, ptr @sz, i64 12), align 4, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %51, i64 -4
  tail call void @_Z7PolyExpiPiS_(i32 noundef 666667, ptr noundef nonnull %56, ptr noundef nonnull %55)
  store i32 1, ptr @fact, align 16, !tbaa !5
  br label %57

57:                                               ; preds = %57, %.preheader57.preheader
  %58 = phi i64 [ 1, %.preheader57.preheader ], [ %64, %57 ]
  %indvars.iv88 = phi i64 [ 1, %.preheader57.preheader ], [ %indvars.iv.next89.1, %57 ]
  %59 = mul nsw i64 %58, %indvars.iv88
  %60 = srem i64 %59, 985661441
  %61 = trunc nsw i64 %60 to i32
  %62 = getelementptr inbounds [2000001 x i32], ptr @fact, i64 0, i64 %indvars.iv88
  store i32 %61, ptr %62, align 4, !tbaa !5
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %63 = mul nsw i64 %60, %indvars.iv.next89
  %64 = srem i64 %63, 985661441
  %65 = trunc nsw i64 %64 to i32
  %66 = getelementptr inbounds [2000001 x i32], ptr @fact, i64 0, i64 %indvars.iv.next89
  store i32 %65, ptr %66, align 4, !tbaa !5
  %indvars.iv.next89.1 = add nuw nsw i64 %indvars.iv88, 2
  %exitcond91.not.1 = icmp eq i64 %indvars.iv.next89.1, 2000001
  br i1 %exitcond91.not.1, label %.preheader.preheader, label %57, !llvm.loop !15

.preheader.preheader:                             ; preds = %57
  %67 = load i32, ptr getelementptr inbounds (i8, ptr @sz, i64 4), align 4, !tbaa !5
  %68 = icmp sgt i32 %67, 1
  br i1 %68, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader.preheader
  %69 = load ptr, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !11
  br label %104

._crit_edge:                                      ; preds = %104, %.preheader.preheader
  %70 = load i32, ptr getelementptr inbounds (i8, ptr @sz, i64 8), align 8, !tbaa !5
  %71 = icmp sgt i32 %70, 2
  br i1 %71, label %.lr.ph.1, label %._crit_edge.1

.lr.ph.1:                                         ; preds = %._crit_edge
  %72 = load ptr, ptr getelementptr inbounds (i8, ptr @f, i64 16), align 16, !tbaa !11
  br label %73

73:                                               ; preds = %73, %.lr.ph.1
  %indvars.iv94.1 = phi i64 [ 2, %.lr.ph.1 ], [ %indvars.iv.next95.1, %73 ]
  %74 = getelementptr inbounds i32, ptr %72, i64 %indvars.iv94.1
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [2000001 x i32], ptr @fact, i64 0, i64 %indvars.iv94.1
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = mul nsw i64 %79, %76
  %81 = srem i64 %80, 985661441
  %82 = trunc nsw i64 %81 to i32
  store i32 %82, ptr %74, align 4, !tbaa !5
  %indvars.iv.next95.1 = add nuw nsw i64 %indvars.iv94.1, 1
  %83 = load i32, ptr getelementptr inbounds (i8, ptr @sz, i64 8), align 8, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = icmp slt i64 %indvars.iv.next95.1, %84
  br i1 %85, label %73, label %._crit_edge.1, !llvm.loop !16

._crit_edge.1:                                    ; preds = %73, %._crit_edge
  %86 = load i32, ptr getelementptr inbounds (i8, ptr @sz, i64 12), align 4, !tbaa !5
  %87 = icmp sgt i32 %86, 3
  br i1 %87, label %.lr.ph.2, label %._crit_edge.2

.lr.ph.2:                                         ; preds = %._crit_edge.1
  %88 = load ptr, ptr getelementptr inbounds (i8, ptr @f, i64 24), align 8, !tbaa !11
  br label %89

89:                                               ; preds = %89, %.lr.ph.2
  %indvars.iv94.2 = phi i64 [ 3, %.lr.ph.2 ], [ %indvars.iv.next95.2, %89 ]
  %90 = getelementptr inbounds i32, ptr %88, i64 %indvars.iv94.2
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [2000001 x i32], ptr @fact, i64 0, i64 %indvars.iv94.2
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = mul nsw i64 %95, %92
  %97 = srem i64 %96, 985661441
  %98 = trunc nsw i64 %97 to i32
  store i32 %98, ptr %90, align 4, !tbaa !5
  %indvars.iv.next95.2 = add nuw nsw i64 %indvars.iv94.2, 1
  %99 = load i32, ptr getelementptr inbounds (i8, ptr @sz, i64 12), align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = icmp slt i64 %indvars.iv.next95.2, %100
  br i1 %101, label %89, label %._crit_edge.2, !llvm.loop !16

._crit_edge.2:                                    ; preds = %89, %._crit_edge.1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %102 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %103 = load i32, ptr %1, align 4, !tbaa !5
  %.not66 = icmp slt i32 %103, 1
  br i1 %.not66, label %._crit_edge70, label %.lr.ph69

104:                                              ; preds = %.lr.ph, %104
  %indvars.iv94 = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next95, %104 ]
  %105 = getelementptr inbounds i32, ptr %69, i64 %indvars.iv94
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [2000001 x i32], ptr @fact, i64 0, i64 %indvars.iv94
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = mul nsw i64 %110, %107
  %112 = srem i64 %111, 985661441
  %113 = trunc nsw i64 %112 to i32
  store i32 %113, ptr %105, align 4, !tbaa !5
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %114 = load i32, ptr getelementptr inbounds (i8, ptr @sz, i64 4), align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = icmp slt i64 %indvars.iv.next95, %115
  br i1 %116, label %104, label %._crit_edge, !llvm.loop !16

._crit_edge70:                                    ; preds = %.lr.ph69, %._crit_edge.2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0

.lr.ph69:                                         ; preds = %._crit_edge.2, %.lr.ph69
  %.067 = phi i32 [ %128, %.lr.ph69 ], [ 1, %._crit_edge.2 ]
  %117 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %118 = load i32, ptr %3, align 4
  %119 = load i32, ptr %2, align 4
  %120 = call i32 @llvm.smin.i32(i32 %118, i32 %119)
  store i32 %120, ptr %3, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %121
  %123 = load ptr, ptr %122, align 8, !tbaa !11
  %124 = sext i32 %119 to i64
  %125 = getelementptr inbounds i32, ptr %123, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.067, i32 noundef %126)
  %128 = add nuw nsw i32 %.067, 1
  %129 = load i32, ptr %1, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.067, %129
  br i1 %.not.not, label %.lr.ph69, label %._crit_edge70, !llvm.loop !17
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powii(i32 noundef, i32 noundef) local_unnamed_addr #3

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

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

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

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


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass