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

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

@w = external dso_local global [262145 x i32], align 16
@inv2 = external dso_local global [19 x i32], align 16
@n = external dso_local global i32, align 4
@fact = external dso_local global [130001 x i32], align 16
@iact = external dso_local global [130001 x i32], align 16
@pw = external dso_local global [130001 x i32], align 16
@f = external dso_local global [262145 x i32], align 16
@g = external dso_local global [262145 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z3NTTiPii(i32 noundef, ptr noundef, i32 noundef) #2

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

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

13:                                               ; preds = %32, %0
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = icmp slt i32 %14, 262144
  br i1 %15, label %17, label %16

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

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

32:                                               ; preds = %17
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !9

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

36:                                               ; preds = %55, %35
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = icmp sle i32 %37, 18
  br i1 %38, label %40, label %39

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

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

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

58:                                               ; preds = %39
  %59 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  store i32 1, ptr getelementptr inbounds ([130001 x i32], ptr @iact, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 2, ptr %4, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %82, %58
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = icmp sle i32 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %85

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

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

85:                                               ; preds = %64
  store i32 1, ptr @pw, align 16, !tbaa !5
  store i32 1, ptr @iact, align 16, !tbaa !5
  store i32 1, ptr @fact, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %140, %85
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = load i32, ptr @n, align 4, !tbaa !5
  %89 = icmp sle i32 %87, %88
  br i1 %89, label %91, label %90

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

91:                                               ; preds = %86
  %92 = load i32, ptr %5, align 4, !tbaa !5
  %93 = sub nsw i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [130001 x i32], ptr @fact, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = load i32, ptr %5, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = mul nsw i64 %97, %99
  %101 = srem i64 %100, 1004535809
  %102 = trunc i64 %101 to i32
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [130001 x i32], ptr @fact, i64 0, i64 %104
  store i32 %102, ptr %105, align 4, !tbaa !5
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = sub nsw i32 %106, 1
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = load i32, ptr %5, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = mul nsw i64 %111, %116
  %118 = srem i64 %117, 1004535809
  %119 = trunc i64 %118 to i32
  %120 = load i32, ptr %5, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %121
  store i32 %119, ptr %122, align 4, !tbaa !5
  %123 = load i32, ptr %5, align 4, !tbaa !5
  %124 = sub nsw i32 %123, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [130001 x i32], ptr @pw, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = shl i32 %127, 1
  %129 = load i32, ptr %5, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [130001 x i32], ptr @pw, i64 0, i64 %130
  store i32 %128, ptr %131, align 4, !tbaa !5
  %132 = icmp sge i32 %128, 1004535809
  br i1 %132, label %133, label %139

133:                                              ; preds = %91
  %134 = load i32, ptr %5, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [130001 x i32], ptr @pw, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = sub nsw i32 %137, 1004535809
  store i32 %138, ptr %136, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %133, %91
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %5, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %5, align 4, !tbaa !5
  br label %86, !llvm.loop !13

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

144:                                              ; preds = %150, %143
  %145 = load i32, ptr %6, align 4, !tbaa !5
  %146 = load i32, ptr @n, align 4, !tbaa !5
  %147 = shl i32 %146, 1
  %148 = icmp sle i32 %145, %147
  br i1 %148, label %149, label %153

149:                                              ; preds = %144
  br label %150

150:                                              ; preds = %149
  %151 = load i32, ptr %6, align 4, !tbaa !5
  %152 = shl i32 %151, 1
  store i32 %152, ptr %6, align 4, !tbaa !5
  br label %144, !llvm.loop !14

153:                                              ; preds = %144
  store i32 1, ptr @f, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %154

154:                                              ; preds = %183, %153
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = load i32, ptr @n, align 4, !tbaa !5
  %157 = icmp sle i32 %155, %156
  br i1 %157, label %159, label %158

158:                                              ; preds = %154
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %186

159:                                              ; preds = %154
  %160 = load i32, ptr %8, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = load i32, ptr %7, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %163
  %165 = load i32, ptr %164, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = mul nsw i64 %161, %166
  %168 = srem i64 %167, 1004535809
  %169 = trunc i64 %168 to i32
  %170 = load i32, ptr %7, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %171
  store i32 %169, ptr %172, align 4, !tbaa !5
  %173 = load i32, ptr %8, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = load i32, ptr %7, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [130001 x i32], ptr @pw, i64 0, i64 %176
  %178 = load i32, ptr %177, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = mul nsw i64 %174, %179
  %181 = srem i64 %180, 1004535809
  %182 = trunc i64 %181 to i32
  store i32 %182, ptr %8, align 4, !tbaa !5
  br label %183

183:                                              ; preds = %159
  %184 = load i32, ptr %7, align 4, !tbaa !5
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %7, align 4, !tbaa !5
  br label %154, !llvm.loop !15

186:                                              ; preds = %158
  %187 = load i32, ptr @n, align 4, !tbaa !5
  %188 = add nsw i32 %187, 1
  call void @_Z7PolyInviPiS_(i32 noundef %188, ptr noundef @f, ptr noundef @g)
  store i32 0, ptr @f, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 1, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %189

189:                                              ; preds = %219, %186
  %190 = load i32, ptr %9, align 4, !tbaa !5
  %191 = load i32, ptr @n, align 4, !tbaa !5
  %192 = icmp sle i32 %190, %191
  br i1 %192, label %194, label %193

193:                                              ; preds = %189
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %222

194:                                              ; preds = %189
  %195 = load i32, ptr %10, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = load i32, ptr %9, align 4, !tbaa !5
  %198 = sub nsw i32 %197, 1
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %199
  %201 = load i32, ptr %200, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = mul nsw i64 %196, %202
  %204 = srem i64 %203, 1004535809
  %205 = trunc i64 %204 to i32
  %206 = load i32, ptr %9, align 4, !tbaa !5
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %207
  store i32 %205, ptr %208, align 4, !tbaa !5
  %209 = load i32, ptr %10, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = load i32, ptr %9, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [130001 x i32], ptr @pw, i64 0, i64 %212
  %214 = load i32, ptr %213, align 4, !tbaa !5
  %215 = sext i32 %214 to i64
  %216 = mul nsw i64 %210, %215
  %217 = srem i64 %216, 1004535809
  %218 = trunc i64 %217 to i32
  store i32 %218, ptr %10, align 4, !tbaa !5
  br label %219

219:                                              ; preds = %194
  %220 = load i32, ptr %9, align 4, !tbaa !5
  %221 = add nsw i32 %220, 1
  store i32 %221, ptr %9, align 4, !tbaa !5
  br label %189, !llvm.loop !16

222:                                              ; preds = %193
  %223 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z3NTTiPii(i32 noundef %223, ptr noundef @f, i32 noundef 1)
  %224 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z3NTTiPii(i32 noundef %224, ptr noundef @g, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %225

225:                                              ; preds = %247, %222
  %226 = load i32, ptr %11, align 4, !tbaa !5
  %227 = load i32, ptr %6, align 4, !tbaa !5
  %228 = icmp slt i32 %226, %227
  br i1 %228, label %230, label %229

229:                                              ; preds = %225
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %250

230:                                              ; preds = %225
  %231 = load i32, ptr %11, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %232
  %234 = load i32, ptr %233, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = load i32, ptr %11, align 4, !tbaa !5
  %237 = sext i32 %236 to i64
  %238 = getelementptr inbounds [262145 x i32], ptr @g, i64 0, i64 %237
  %239 = load i32, ptr %238, align 4, !tbaa !5
  %240 = sext i32 %239 to i64
  %241 = mul nsw i64 %235, %240
  %242 = srem i64 %241, 1004535809
  %243 = trunc i64 %242 to i32
  %244 = load i32, ptr %11, align 4, !tbaa !5
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %245
  store i32 %243, ptr %246, align 4, !tbaa !5
  br label %247

247:                                              ; preds = %230
  %248 = load i32, ptr %11, align 4, !tbaa !5
  %249 = add nsw i32 %248, 1
  store i32 %249, ptr %11, align 4, !tbaa !5
  br label %225, !llvm.loop !17

250:                                              ; preds = %229
  %251 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z3NTTiPii(i32 noundef %251, ptr noundef @f, i32 noundef -1)
  %252 = load i32, ptr @n, align 4, !tbaa !5
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %253
  %255 = load i32, ptr %254, align 4, !tbaa !5
  %256 = sext i32 %255 to i64
  %257 = load i32, ptr @n, align 4, !tbaa !5
  %258 = sub nsw i32 %257, 1
  %259 = sext i32 %258 to i64
  %260 = getelementptr inbounds [130001 x i32], ptr @fact, i64 0, i64 %259
  %261 = load i32, ptr %260, align 4, !tbaa !5
  %262 = sext i32 %261 to i64
  %263 = mul nsw i64 %256, %262
  %264 = srem i64 %263, 1004535809
  %265 = trunc i64 %264 to i32
  %266 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %265)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  ret i32 0
}

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

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

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

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

@w = external dso_local local_unnamed_addr global [262145 x i32], align 16
@inv2 = external dso_local local_unnamed_addr global [19 x i32], align 16
@n = external dso_local global i32, align 4
@fact = external dso_local local_unnamed_addr global [130001 x i32], align 16
@iact = external dso_local local_unnamed_addr global [130001 x i32], align 16
@pw = external dso_local local_unnamed_addr global [130001 x i32], align 16
@f = external dso_local global [262145 x i32], align 16
@g = external dso_local global [262145 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

2:                                                ; preds = %5
  store <4 x i32> <i32 1, i32 502267905, i32 753401857, i32 878968833>, ptr @inv2, align 16, !tbaa !5
  store <4 x i32> <i32 941752321, i32 973144065, i32 988839937, i32 996687873>, ptr getelementptr inbounds (i8, ptr @inv2, i64 16), align 16, !tbaa !5
  store <4 x i32> <i32 1000611841, i32 1002573825, i32 1003554817, i32 1004045313>, ptr getelementptr inbounds (i8, ptr @inv2, i64 32), align 16, !tbaa !5
  store <4 x i32> <i32 1004290561, i32 1004413185, i32 1004474497, i32 1004505153>, ptr getelementptr inbounds (i8, ptr @inv2, i64 48), align 16, !tbaa !5
  store i32 1004520481, ptr getelementptr inbounds (i8, ptr @inv2, i64 64), align 16, !tbaa !5
  store i32 1004528145, ptr getelementptr inbounds (i8, ptr @inv2, i64 68), align 4, !tbaa !5
  store i32 1004531977, ptr getelementptr inbounds (i8, ptr @inv2, i64 72), align 8, !tbaa !5
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  store i32 1, ptr getelementptr inbounds (i8, ptr @iact, i64 4), align 4, !tbaa !5
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not66 = icmp slt i32 %4, 2
  br i1 %.not66, label %._crit_edge, label %.lr.ph.preheader

5:                                                ; preds = %5, %0
  %6 = phi i32 [ %1, %0 ], [ %18, %5 ]
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next.1, %5 ]
  %7 = sext i32 %6 to i64
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @w, i64 4), align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = mul nsw i64 %9, %7
  %11 = srem i64 %10, 1004535809
  %12 = trunc nsw i64 %11 to i32
  %13 = getelementptr inbounds [262145 x i32], ptr @w, i64 0, i64 %indvars.iv
  store i32 %12, ptr %13, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @w, i64 4), align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = mul nsw i64 %11, %15
  %17 = srem i64 %16, 1004535809
  %18 = trunc nsw i64 %17 to i32
  %19 = getelementptr inbounds [262145 x i32], ptr @w, i64 0, i64 %indvars.iv.next
  store i32 %18, ptr %19, 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, 262144
  br i1 %exitcond.not.1, label %2, label %5, !llvm.loop !9

.lr.ph.preheader:                                 ; preds = %2
  %20 = add nuw i32 %4, 1
  %wide.trip.count = zext i32 %20 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  store i32 1, ptr @pw, align 16, !tbaa !5
  store i32 1, ptr @iact, align 16, !tbaa !5
  store i32 1, ptr @fact, align 16, !tbaa !5
  %.not6068 = icmp slt i32 %4, 1
  br i1 %.not6068, label %.preheader, label %.lr.ph71.preheader

.lr.ph71.preheader:                               ; preds = %._crit_edge
  %21 = add nuw i32 %4, 1
  %wide.trip.count100 = zext i32 %21 to i64
  br label %.lr.ph71

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv93 = phi i64 [ 2, %.lr.ph.preheader ], [ %indvars.iv.next94, %.lr.ph ]
  %22 = trunc nuw nsw i64 %indvars.iv93 to i32
  %23 = udiv i32 1004535809, %22
  %24 = zext nneg i32 %23 to i64
  %25 = urem i32 1004535809, %22
  %26 = zext nneg i32 %25 to i64
  %27 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = mul nsw i64 %29, %24
  %31 = srem i64 %30, 1004535809
  %32 = trunc nsw i64 %31 to i32
  %33 = sub nsw i32 1004535809, %32
  %34 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %indvars.iv93
  store i32 %33, ptr %34, align 4, !tbaa !5
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %exitcond96.not = icmp eq i64 %indvars.iv.next94, %wide.trip.count
  br i1 %exitcond96.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph71, %._crit_edge
  %35 = shl i32 %4, 1
  br label %53

.lr.ph71:                                         ; preds = %.lr.ph71.preheader, %.lr.ph71
  %36 = phi i32 [ 1, %.lr.ph71.preheader ], [ %spec.select, %.lr.ph71 ]
  %37 = phi i64 [ 1, %.lr.ph71.preheader ], [ %47, %.lr.ph71 ]
  %38 = phi i64 [ 1, %.lr.ph71.preheader ], [ %40, %.lr.ph71 ]
  %indvars.iv97 = phi i64 [ 1, %.lr.ph71.preheader ], [ %indvars.iv.next98, %.lr.ph71 ]
  %39 = mul nsw i64 %38, %indvars.iv97
  %40 = srem i64 %39, 1004535809
  %41 = trunc nsw i64 %40 to i32
  %42 = getelementptr inbounds [130001 x i32], ptr @fact, i64 0, i64 %indvars.iv97
  store i32 %41, ptr %42, align 4, !tbaa !5
  %43 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %indvars.iv97
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = mul nsw i64 %37, %45
  %47 = srem i64 %46, 1004535809
  %48 = trunc nsw i64 %47 to i32
  store i32 %48, ptr %43, align 4, !tbaa !5
  %49 = shl i32 %36, 1
  %50 = getelementptr inbounds [130001 x i32], ptr @pw, i64 0, i64 %indvars.iv97
  %51 = icmp sgt i32 %49, 1004535808
  %52 = add nsw i32 %49, -1004535809
  %spec.select = select i1 %51, i32 %52, i32 %49
  store i32 %spec.select, ptr %50, align 4, !tbaa !5
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %exitcond101.not = icmp eq i64 %indvars.iv.next98, %wide.trip.count100
  br i1 %exitcond101.not, label %.preheader, label %.lr.ph71, !llvm.loop !12

53:                                               ; preds = %53, %.preheader
  %.053 = phi i32 [ %54, %53 ], [ 1, %.preheader ]
  %.not61 = icmp sgt i32 %.053, %35
  %54 = shl i32 %.053, 1
  br i1 %.not61, label %55, label %53, !llvm.loop !13

55:                                               ; preds = %53
  store i32 1, ptr @f, align 16, !tbaa !5
  %.pre = add i32 %4, 1
  br i1 %.not6068, label %._crit_edge77, label %.lr.ph76.preheader

.lr.ph76.preheader:                               ; preds = %55
  %wide.trip.count105 = zext i32 %.pre to i64
  br label %.lr.ph76

._crit_edge77:                                    ; preds = %.lr.ph76, %55
  tail call void @_Z7PolyInviPiS_(i32 noundef %.pre, ptr noundef nonnull @f, ptr noundef nonnull @g)
  store i32 0, ptr @f, align 16, !tbaa !5
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %.not6378 = icmp slt i32 %56, 1
  br i1 %.not6378, label %._crit_edge83, label %.lr.ph82.preheader

.lr.ph82.preheader:                               ; preds = %._crit_edge77
  %57 = add nuw i32 %56, 1
  %wide.trip.count110 = zext i32 %57 to i64
  br label %.lr.ph82

.lr.ph76:                                         ; preds = %.lr.ph76.preheader, %.lr.ph76
  %indvars.iv102 = phi i64 [ 1, %.lr.ph76.preheader ], [ %indvars.iv.next103, %.lr.ph76 ]
  %.05174 = phi i64 [ 1, %.lr.ph76.preheader ], [ %69, %.lr.ph76 ]
  %58 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %indvars.iv102
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = mul nsw i64 %.05174, %60
  %62 = srem i64 %61, 1004535809
  %63 = trunc nsw i64 %62 to i32
  %64 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %indvars.iv102
  store i32 %63, ptr %64, align 4, !tbaa !5
  %65 = getelementptr inbounds [130001 x i32], ptr @pw, i64 0, i64 %indvars.iv102
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = mul nsw i64 %.05174, %67
  %69 = srem i64 %68, 1004535809
  %indvars.iv.next103 = add nuw nsw i64 %indvars.iv102, 1
  %exitcond106.not = icmp eq i64 %indvars.iv.next103, %wide.trip.count105
  br i1 %exitcond106.not, label %._crit_edge77, label %.lr.ph76, !llvm.loop !14

._crit_edge83:                                    ; preds = %.lr.ph82, %._crit_edge77
  tail call void @_Z3NTTiPii(i32 noundef %.053, ptr noundef nonnull @f, i32 noundef 1)
  tail call void @_Z3NTTiPii(i32 noundef %.053, ptr noundef nonnull @g, i32 noundef 1)
  %70 = icmp sgt i32 %.053, 0
  br i1 %70, label %.lr.ph86.preheader, label %._crit_edge87

.lr.ph86.preheader:                               ; preds = %._crit_edge83
  %wide.trip.count115 = zext nneg i32 %.053 to i64
  %xtraiter = and i64 %wide.trip.count115, 1
  %71 = icmp eq i32 %.053, 1
  br i1 %71, label %._crit_edge87.loopexit.unr-lcssa, label %.lr.ph86.preheader.new

.lr.ph86.preheader.new:                           ; preds = %.lr.ph86.preheader
  %unroll_iter = and i64 %wide.trip.count115, 2147483646
  br label %.lr.ph86

.lr.ph82:                                         ; preds = %.lr.ph82.preheader, %.lr.ph82
  %indvars.iv107 = phi i64 [ 1, %.lr.ph82.preheader ], [ %indvars.iv.next108, %.lr.ph82 ]
  %.04980 = phi i64 [ 1, %.lr.ph82.preheader ], [ %84, %.lr.ph82 ]
  %72 = add nsw i64 %indvars.iv107, -1
  %73 = getelementptr inbounds [130001 x i32], ptr @iact, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = mul nsw i64 %.04980, %75
  %77 = srem i64 %76, 1004535809
  %78 = trunc nsw i64 %77 to i32
  %79 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %indvars.iv107
  store i32 %78, ptr %79, align 4, !tbaa !5
  %80 = getelementptr inbounds [130001 x i32], ptr @pw, i64 0, i64 %indvars.iv107
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = mul nsw i64 %.04980, %82
  %84 = srem i64 %83, 1004535809
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %exitcond111.not = icmp eq i64 %indvars.iv.next108, %wide.trip.count110
  br i1 %exitcond111.not, label %._crit_edge83, label %.lr.ph82, !llvm.loop !15

._crit_edge87.loopexit.unr-lcssa:                 ; preds = %.lr.ph86, %.lr.ph86.preheader
  %indvars.iv112.unr = phi i64 [ 0, %.lr.ph86.preheader ], [ %indvars.iv.next113.1, %.lr.ph86 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge87, label %.lr.ph86.epil

.lr.ph86.epil:                                    ; preds = %._crit_edge87.loopexit.unr-lcssa
  %85 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %indvars.iv112.unr
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [262145 x i32], ptr @g, i64 0, i64 %indvars.iv112.unr
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = mul nsw i64 %90, %87
  %92 = srem i64 %91, 1004535809
  %93 = trunc nsw i64 %92 to i32
  store i32 %93, ptr %85, align 4, !tbaa !5
  br label %._crit_edge87

._crit_edge87:                                    ; preds = %.lr.ph86.epil, %._crit_edge87.loopexit.unr-lcssa, %._crit_edge83
  tail call void @_Z3NTTiPii(i32 noundef %.053, ptr noundef nonnull @f, i32 noundef -1)
  %94 = load i32, ptr @n, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = add nsw i32 %94, -1
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [130001 x i32], ptr @fact, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = mul nsw i64 %103, %98
  %105 = srem i64 %104, 1004535809
  %106 = trunc nsw i64 %105 to i32
  %107 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %106)
  ret i32 0

.lr.ph86:                                         ; preds = %.lr.ph86, %.lr.ph86.preheader.new
  %indvars.iv112 = phi i64 [ 0, %.lr.ph86.preheader.new ], [ %indvars.iv.next113.1, %.lr.ph86 ]
  %niter = phi i64 [ 0, %.lr.ph86.preheader.new ], [ %niter.next.1, %.lr.ph86 ]
  %108 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %indvars.iv112
  %109 = load i32, ptr %108, align 8, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [262145 x i32], ptr @g, i64 0, i64 %indvars.iv112
  %112 = load i32, ptr %111, align 8, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = mul nsw i64 %113, %110
  %115 = srem i64 %114, 1004535809
  %116 = trunc nsw i64 %115 to i32
  store i32 %116, ptr %108, align 8, !tbaa !5
  %indvars.iv.next113 = or disjoint i64 %indvars.iv112, 1
  %117 = getelementptr inbounds [262145 x i32], ptr @f, i64 0, i64 %indvars.iv.next113
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [262145 x i32], ptr @g, i64 0, i64 %indvars.iv.next113
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = mul nsw i64 %122, %119
  %124 = srem i64 %123, 1004535809
  %125 = trunc nsw i64 %124 to i32
  store i32 %125, ptr %117, align 4, !tbaa !5
  %indvars.iv.next113.1 = add nuw nsw i64 %indvars.iv112, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge87.loopexit.unr-lcssa, label %.lr.ph86, !llvm.loop !16
}

; 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

attributes #0 = { 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 #1 = { 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 #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" }

!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 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


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