; LLVM IR from tangjz/acm-icpc :: hdu (6159)

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

@phi = external dso_local global [30001 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@mod = external dso_local global i32, align 4
@inv = external dso_local global [30001 x i32], align 16
@fact = external dso_local global [30001 x i32], align 16
@iact = external dso_local global [30001 x i32], align 16
@F = external dso_local global [30001 x i32], align 16
@G = external dso_local global [30001 x i32], align 16
@A = external dso_local global [30001 x i32], align 16
@B = external dso_local global [30001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powix(i32 noundef, i64 noundef) #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
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

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

15:                                               ; preds = %12
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %48

16:                                               ; preds = %12
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [30001 x i32], ptr @phi, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = add nsw i32 %21, %17
  store i32 %22, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %23, %24
  store i32 %25, ptr %4, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %40, %16
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 30001
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %44

30:                                               ; preds = %26
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [30001 x i32], ptr @phi, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [30001 x i32], ptr @phi, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sub nsw i32 %38, %34
  store i32 %39, ptr %37, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %30
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = add nsw i32 %42, %41
  store i32 %43, ptr %4, align 4, !tbaa !5
  br label %26, !llvm.loop !9

44:                                               ; preds = %29
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !11

48:                                               ; preds = %15
  %49 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %268, %48
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = load i32, ptr @t, align 4, !tbaa !5
  %53 = icmp sle i32 %51, %52
  br i1 %53, label %55, label %54

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

55:                                               ; preds = %50
  %56 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @n, ptr noundef @mod)
  store i32 1, ptr getelementptr inbounds ([30001 x i32], ptr @inv, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 2, ptr %6, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %84, %55
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = load i32, ptr @n, align 4, !tbaa !5
  %60 = icmp sle i32 %58, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %57
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %87

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

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

87:                                               ; preds = %61
  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 %7) #6
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %129, %87
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = icmp sle i32 %89, %90
  br i1 %91, label %93, label %92

92:                                               ; preds = %88
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %132

93:                                               ; preds = %88
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = sub nsw i32 %94, 1
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [30001 x i32], ptr @fact, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = mul nsw i64 %99, %101
  %103 = load i32, ptr @mod, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = srem i64 %102, %104
  %106 = trunc i64 %105 to i32
  %107 = load i32, ptr %7, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [30001 x i32], ptr @fact, i64 0, i64 %108
  store i32 %106, ptr %109, align 4, !tbaa !5
  %110 = load i32, ptr %7, align 4, !tbaa !5
  %111 = sub nsw i32 %110, 1
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [30001 x i32], ptr @iact, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = load i32, ptr %7, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [30001 x i32], ptr @inv, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = mul nsw i64 %115, %120
  %122 = load i32, ptr @mod, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = srem i64 %121, %123
  %125 = trunc i64 %124 to i32
  %126 = load i32, ptr %7, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [30001 x i32], ptr @iact, i64 0, i64 %127
  store i32 %125, ptr %128, align 4, !tbaa !5
  br label %129

129:                                              ; preds = %93
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %7, align 4, !tbaa !5
  br label %88, !llvm.loop !13

132:                                              ; preds = %92
  call void @_Z8FFT_initv()
  store i32 1, ptr @G, align 16, !tbaa !5
  store i32 0, ptr @A, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %176, %132
  %134 = load i32, ptr %8, align 4, !tbaa !5
  %135 = load i32, ptr @n, align 4, !tbaa !5
  %136 = icmp sle i32 %134, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %133
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %179

138:                                              ; preds = %133
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = load i32, ptr %8, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = sub nsw i64 %142, 1
  %144 = mul nsw i64 %140, %143
  %145 = ashr i64 %144, 1
  %146 = call noundef i32 @_Z7mod_powix(i32 noundef 2, i64 noundef %145)
  %147 = sext i32 %146 to i64
  %148 = load i32, ptr %8, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [30001 x i32], ptr @iact, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = mul nsw i64 %147, %152
  %154 = load i32, ptr @mod, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = srem i64 %153, %155
  %157 = trunc i64 %156 to i32
  %158 = load i32, ptr %8, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [30001 x i32], ptr @G, i64 0, i64 %159
  store i32 %157, ptr %160, align 4, !tbaa !5
  %161 = load i32, ptr %8, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [30001 x i32], ptr @G, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = load i32, ptr %8, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = mul nsw i64 %165, %167
  %169 = load i32, ptr @mod, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = srem i64 %168, %170
  %172 = trunc i64 %171 to i32
  %173 = load i32, ptr %8, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [30001 x i32], ptr @A, i64 0, i64 %174
  store i32 %172, ptr %175, align 4, !tbaa !5
  br label %176

176:                                              ; preds = %138
  %177 = load i32, ptr %8, align 4, !tbaa !5
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %8, align 4, !tbaa !5
  br label %133, !llvm.loop !14

179:                                              ; preds = %137
  %180 = load i32, ptr @n, align 4, !tbaa !5
  %181 = add nsw i32 %180, 1
  call void @_Z8poly_inviPiS_(i32 noundef %181, ptr noundef @G, ptr noundef @B)
  %182 = load i32, ptr @n, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  %184 = load i32, ptr @n, align 4, !tbaa !5
  %185 = add nsw i32 %184, 1
  %186 = load i32, ptr @n, align 4, !tbaa !5
  %187 = add nsw i32 %186, 1
  call void @_Z9poly_conviPiiS_iS_b(i32 noundef %183, ptr noundef @A, i32 noundef %185, ptr noundef @B, i32 noundef %187, ptr noundef @F, i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %188 = load i32, ptr @n, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [30001 x i32], ptr @G, i64 0, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  store i32 %191, ptr %9, align 4, !tbaa !5
  store i32 2, ptr @d, align 4, !tbaa !5
  br label %192

192:                                              ; preds = %249, %179
  %193 = load i32, ptr @d, align 4, !tbaa !5
  %194 = load i32, ptr @n, align 4, !tbaa !5
  %195 = icmp sle i32 %193, %194
  br i1 %195, label %196, label %252

196:                                              ; preds = %192
  %197 = load i32, ptr @n, align 4, !tbaa !5
  %198 = load i32, ptr @d, align 4, !tbaa !5
  %199 = srem i32 %197, %198
  %200 = icmp sgt i32 %199, 0
  br i1 %200, label %201, label %202

201:                                              ; preds = %196
  br label %249

202:                                              ; preds = %196
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %203

203:                                              ; preds = %219, %202
  %204 = load i32, ptr %10, align 4, !tbaa !5
  %205 = load i32, ptr @n, align 4, !tbaa !5
  %206 = icmp sle i32 %204, %205
  br i1 %206, label %208, label %207

207:                                              ; preds = %203
  store i32 23, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %225

208:                                              ; preds = %203
  %209 = load i32, ptr %10, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [30001 x i32], ptr @F, i64 0, i64 %210
  %212 = load i32, ptr %211, align 4, !tbaa !5
  %213 = load i32, ptr %11, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [30001 x i32], ptr @A, i64 0, i64 %214
  store i32 %212, ptr %215, align 4, !tbaa !5
  %216 = load i32, ptr %11, align 4, !tbaa !5
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [30001 x i32], ptr @B, i64 0, i64 %217
  store i32 0, ptr %218, align 4, !tbaa !5
  br label %219

219:                                              ; preds = %208
  %220 = load i32, ptr @d, align 4, !tbaa !5
  %221 = load i32, ptr %10, align 4, !tbaa !5
  %222 = add nsw i32 %221, %220
  store i32 %222, ptr %10, align 4, !tbaa !5
  %223 = load i32, ptr %11, align 4, !tbaa !5
  %224 = add nsw i32 %223, 1
  store i32 %224, ptr %11, align 4, !tbaa !5
  br label %203, !llvm.loop !15

225:                                              ; preds = %207
  %226 = load i32, ptr @n, align 4, !tbaa !5
  %227 = load i32, ptr @d, align 4, !tbaa !5
  %228 = sdiv i32 %226, %227
  call void @_Z3cdqii(i32 noundef 0, i32 noundef %228)
  %229 = load i32, ptr %9, align 4, !tbaa !5
  %230 = sext i32 %229 to i64
  %231 = load i32, ptr @d, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [30001 x i32], ptr @phi, i64 0, i64 %232
  %234 = load i32, ptr %233, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = load i32, ptr @n, align 4, !tbaa !5
  %237 = load i32, ptr @d, align 4, !tbaa !5
  %238 = sdiv i32 %236, %237
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [30001 x i32], ptr @B, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  %242 = sext i32 %241 to i64
  %243 = mul nsw i64 %235, %242
  %244 = add nsw i64 %230, %243
  %245 = load i32, ptr @mod, align 4, !tbaa !5
  %246 = sext i32 %245 to i64
  %247 = srem i64 %244, %246
  %248 = trunc i64 %247 to i32
  store i32 %248, ptr %9, align 4, !tbaa !5
  br label %249

249:                                              ; preds = %225, %201
  %250 = load i32, ptr @d, align 4, !tbaa !5
  %251 = add nsw i32 %250, 1
  store i32 %251, ptr @d, align 4, !tbaa !5
  br label %192, !llvm.loop !16

252:                                              ; preds = %192
  %253 = load i32, ptr %9, align 4, !tbaa !5
  %254 = sext i32 %253 to i64
  %255 = load i32, ptr @n, align 4, !tbaa !5
  %256 = sext i32 %255 to i64
  %257 = getelementptr inbounds [30001 x i32], ptr @fact, i64 0, i64 %256
  %258 = load i32, ptr %257, align 4, !tbaa !5
  %259 = sext i32 %258 to i64
  %260 = mul nsw i64 %254, %259
  %261 = load i32, ptr @mod, align 4, !tbaa !5
  %262 = sext i32 %261 to i64
  %263 = srem i64 %260, %262
  %264 = trunc i64 %263 to i32
  store i32 %264, ptr %9, align 4, !tbaa !5
  %265 = load i32, ptr %5, align 4, !tbaa !5
  %266 = load i32, ptr %9, align 4, !tbaa !5
  %267 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %265, i32 noundef %266)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %268

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

271:                                              ; preds = %54
  ret i32 0
}

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

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

declare i32 @printf(ptr noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = 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"

@phi = external dso_local local_unnamed_addr global [30001 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@d = external dso_local local_unnamed_addr global i32, align 4
@mod = external dso_local global i32, align 4
@inv = external dso_local local_unnamed_addr global [30001 x i32], align 16
@fact = external dso_local local_unnamed_addr global [30001 x i32], align 16
@iact = external dso_local local_unnamed_addr global [30001 x i32], align 16
@F = external dso_local global [30001 x i32], align 16
@G = external dso_local global [30001 x i32], align 16
@A = external dso_local global [30001 x i32], align 16
@B = external dso_local global [30001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  br label %4

1:                                                ; preds = %._crit_edge
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %3 = load i32, ptr @t, align 4, !tbaa !5
  %.not96 = icmp slt i32 %3, 1
  br i1 %.not96, label %._crit_edge100, label %.lr.ph99

4:                                                ; preds = %0, %._crit_edge
  %indvars.iv102 = phi i64 [ 1, %0 ], [ %indvars.iv.next103, %._crit_edge ]
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next, %._crit_edge ]
  %5 = getelementptr inbounds [30001 x i32], ptr @phi, i64 0, i64 %indvars.iv102
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = trunc nuw nsw i64 %indvars.iv102 to i32
  %8 = add nsw i32 %6, %7
  store i32 %8, ptr %5, align 4, !tbaa !5
  %9 = icmp ult i64 %indvars.iv102, 15001
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %4
  %indvars.iv.next103 = add nuw nsw i64 %indvars.iv102, 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not = icmp eq i64 %indvars.iv.next103, 30001
  br i1 %exitcond.not, label %1, label %4, !llvm.loop !9

.lr.ph:                                           ; preds = %4, %.lr.ph
  %indvars.iv104 = phi i64 [ %indvars.iv.next105, %.lr.ph ], [ %indvars.iv, %4 ]
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = getelementptr inbounds [30001 x i32], ptr @phi, i64 0, i64 %indvars.iv104
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = sub nsw i32 %12, %10
  store i32 %13, ptr %11, align 4, !tbaa !5
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, %indvars.iv102
  %14 = icmp ult i64 %indvars.iv.next105, 30001
  br i1 %14, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge100:                                   ; preds = %._crit_edge93, %1
  ret i32 0

.lr.ph99:                                         ; preds = %1, %._crit_edge93
  %.05097 = phi i32 [ %131, %._crit_edge93 ], [ 1, %1 ]
  %15 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @n, ptr noundef nonnull @mod)
  store i32 1, ptr getelementptr inbounds (i8, ptr @inv, i64 4), align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %.not5867 = icmp slt i32 %16, 2
  br i1 %.not5867, label %._crit_edge71, label %.lr.ph70

.lr.ph70:                                         ; preds = %.lr.ph99
  %17 = load i32, ptr @mod, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = add nuw i32 %16, 1
  %wide.trip.count = zext i32 %19 to i64
  br label %23

._crit_edge71:                                    ; preds = %23, %.lr.ph99
  store i32 1, ptr @iact, align 16, !tbaa !5
  store i32 1, ptr @fact, align 16, !tbaa !5
  %.not5972 = icmp slt i32 %16, 1
  br i1 %.not5972, label %._crit_edge76, label %.lr.ph75

.lr.ph75:                                         ; preds = %._crit_edge71
  %20 = load i32, ptr @mod, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = add nuw i32 %16, 1
  %wide.trip.count115 = zext i32 %22 to i64
  br label %38

23:                                               ; preds = %.lr.ph70, %23
  %indvars.iv108 = phi i64 [ 2, %.lr.ph70 ], [ %indvars.iv.next109, %23 ]
  %24 = trunc nuw nsw i64 %indvars.iv108 to i32
  %25 = sdiv i32 %17, %24
  %26 = sext i32 %25 to i64
  %27 = srem i32 %17, %24
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [30001 x i32], ptr @inv, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = mul nsw i64 %31, %26
  %33 = srem i64 %32, %18
  %34 = trunc nsw i64 %33 to i32
  %35 = sub nsw i32 %17, %34
  %36 = getelementptr inbounds [30001 x i32], ptr @inv, i64 0, i64 %indvars.iv108
  store i32 %35, ptr %36, align 4, !tbaa !5
  %indvars.iv.next109 = add nuw nsw i64 %indvars.iv108, 1
  %exitcond111.not = icmp eq i64 %indvars.iv.next109, %wide.trip.count
  br i1 %exitcond111.not, label %._crit_edge71, label %23, !llvm.loop !12

._crit_edge76:                                    ; preds = %38, %._crit_edge71
  tail call void @_Z8FFT_initv()
  store i32 1, ptr @G, align 16, !tbaa !5
  store i32 0, ptr @A, align 16, !tbaa !5
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %.not6077 = icmp slt i32 %37, 1
  br i1 %.not6077, label %._crit_edge81, label %.lr.ph80

38:                                               ; preds = %.lr.ph75, %38
  %39 = phi i64 [ 1, %.lr.ph75 ], [ %51, %38 ]
  %40 = phi i64 [ 1, %.lr.ph75 ], [ %43, %38 ]
  %indvars.iv112 = phi i64 [ 1, %.lr.ph75 ], [ %indvars.iv.next113, %38 ]
  %sext = shl i64 %40, 32
  %41 = ashr exact i64 %sext, 32
  %42 = mul nsw i64 %41, %indvars.iv112
  %43 = srem i64 %42, %21
  %44 = trunc nsw i64 %43 to i32
  %45 = getelementptr inbounds [30001 x i32], ptr @fact, i64 0, i64 %indvars.iv112
  store i32 %44, ptr %45, align 4, !tbaa !5
  %sext127 = shl i64 %39, 32
  %46 = ashr exact i64 %sext127, 32
  %47 = getelementptr inbounds [30001 x i32], ptr @inv, i64 0, i64 %indvars.iv112
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = mul nsw i64 %46, %49
  %51 = srem i64 %50, %21
  %52 = trunc nsw i64 %51 to i32
  %53 = getelementptr inbounds [30001 x i32], ptr @iact, i64 0, i64 %indvars.iv112
  store i32 %52, ptr %53, align 4, !tbaa !5
  %indvars.iv.next113 = add nuw nsw i64 %indvars.iv112, 1
  %exitcond116.not = icmp eq i64 %indvars.iv.next113, %wide.trip.count115
  br i1 %exitcond116.not, label %._crit_edge76, label %38, !llvm.loop !13

._crit_edge81:                                    ; preds = %.lr.ph80, %._crit_edge76
  %.lcssa63 = phi i32 [ %37, %._crit_edge76 ], [ %79, %.lr.ph80 ]
  %54 = add nsw i32 %.lcssa63, 1
  tail call void @_Z8poly_inviPiS_(i32 noundef %54, ptr noundef nonnull @G, ptr noundef nonnull @B)
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  tail call void @_Z9poly_conviPiiS_iS_b(i32 noundef %56, ptr noundef nonnull @A, i32 noundef %56, ptr noundef nonnull @B, i32 noundef %56, ptr noundef nonnull @F, i1 noundef zeroext false)
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [30001 x i32], ptr @G, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  store i32 2, ptr @d, align 4, !tbaa !5
  %.not6188 = icmp slt i32 %57, 2
  br i1 %.not6188, label %._crit_edge93, label %.lr.ph92

.lr.ph80:                                         ; preds = %._crit_edge76, %.lr.ph80
  %indvars.iv117 = phi i64 [ %indvars.iv.next118, %.lr.ph80 ], [ 1, %._crit_edge76 ]
  %61 = add nsw i64 %indvars.iv117, -1
  %62 = mul nsw i64 %61, %indvars.iv117
  %63 = ashr i64 %62, 1
  %64 = tail call noundef i32 @_Z7mod_powix(i32 noundef 2, i64 noundef %63)
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [30001 x i32], ptr @iact, i64 0, i64 %indvars.iv117
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = mul nsw i64 %68, %65
  %70 = load i32, ptr @mod, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = srem i64 %69, %71
  %73 = trunc nsw i64 %72 to i32
  %74 = getelementptr inbounds [30001 x i32], ptr @G, i64 0, i64 %indvars.iv117
  store i32 %73, ptr %74, align 4, !tbaa !5
  %75 = mul nsw i64 %72, %indvars.iv117
  %76 = srem i64 %75, %71
  %77 = trunc nsw i64 %76 to i32
  %78 = getelementptr inbounds [30001 x i32], ptr @A, i64 0, i64 %indvars.iv117
  store i32 %77, ptr %78, align 4, !tbaa !5
  %indvars.iv.next118 = add nuw nsw i64 %indvars.iv117, 1
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %.not60.not = icmp slt i64 %indvars.iv117, %80
  br i1 %.not60.not, label %.lr.ph80, label %._crit_edge81, !llvm.loop !14

.lr.ph92:                                         ; preds = %._crit_edge81, %117
  %81 = phi i32 [ %118, %117 ], [ %57, %._crit_edge81 ]
  %.04690 = phi i32 [ %.1, %117 ], [ %60, %._crit_edge81 ]
  %storemerge89 = phi i32 [ %120, %117 ], [ 2, %._crit_edge81 ]
  %82 = srem i32 %81, %storemerge89
  %83 = sdiv i32 %81, %storemerge89
  %84 = icmp sgt i32 %82, 0
  br i1 %84, label %117, label %.preheader

.preheader:                                       ; preds = %.lr.ph92
  %.not6283 = icmp slt i32 %81, 0
  br i1 %.not6283, label %._crit_edge87, label %.lr.ph86.preheader

.lr.ph86.preheader:                               ; preds = %.preheader
  %85 = add nuw i32 %81, 1
  %smax = tail call i32 @llvm.smax.i32(i32 %storemerge89, i32 %85)
  %86 = icmp slt i32 %storemerge89, %85
  %umin = zext i1 %86 to i32
  %87 = add i32 %storemerge89, %umin
  %88 = sub i32 %smax, %87
  %umax = tail call i32 @llvm.umax.i32(i32 %storemerge89, i32 1)
  %89 = udiv i32 %88, %umax
  %90 = add i32 %89, %umin
  %91 = zext i32 %90 to i64
  %92 = shl nuw nsw i64 %91, 2
  %93 = add nuw nsw i64 %92, 4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) @B, i8 0, i64 %93, i1 false), !tbaa !5
  %94 = sext i32 %storemerge89 to i64
  %95 = zext nneg i32 %81 to i64
  br label %.lr.ph86

._crit_edge87:                                    ; preds = %.lr.ph86, %.preheader
  tail call void @_Z3cdqii(i32 noundef 0, i32 noundef %83)
  %96 = sext i32 %.04690 to i64
  %97 = load i32, ptr @d, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [30001 x i32], ptr @phi, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = load i32, ptr @n, align 4, !tbaa !5
  %103 = sdiv i32 %102, %97
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [30001 x i32], ptr @B, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = mul nsw i64 %107, %101
  %109 = add nsw i64 %108, %96
  %110 = load i32, ptr @mod, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = srem i64 %109, %111
  %113 = trunc nsw i64 %112 to i32
  br label %117

.lr.ph86:                                         ; preds = %.lr.ph86.preheader, %.lr.ph86
  %indvars.iv122 = phi i64 [ 0, %.lr.ph86.preheader ], [ %indvars.iv.next123, %.lr.ph86 ]
  %indvars.iv120 = phi i64 [ 0, %.lr.ph86.preheader ], [ %indvars.iv.next121, %.lr.ph86 ]
  %114 = getelementptr inbounds [30001 x i32], ptr @F, i64 0, i64 %indvars.iv122
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = getelementptr inbounds [30001 x i32], ptr @A, i64 0, i64 %indvars.iv120
  store i32 %115, ptr %116, align 4, !tbaa !5
  %indvars.iv.next123 = add nsw i64 %indvars.iv122, %94
  %indvars.iv.next121 = add nuw nsw i64 %indvars.iv120, 1
  %.not62 = icmp sgt i64 %indvars.iv.next123, %95
  br i1 %.not62, label %._crit_edge87, label %.lr.ph86, !llvm.loop !15

117:                                              ; preds = %.lr.ph92, %._crit_edge87
  %118 = phi i32 [ %81, %.lr.ph92 ], [ %102, %._crit_edge87 ]
  %119 = phi i32 [ %storemerge89, %.lr.ph92 ], [ %97, %._crit_edge87 ]
  %.1 = phi i32 [ %.04690, %.lr.ph92 ], [ %113, %._crit_edge87 ]
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr @d, align 4, !tbaa !5
  %.not61.not = icmp slt i32 %119, %118
  br i1 %.not61.not, label %.lr.ph92, label %._crit_edge93.loopexit, !llvm.loop !17

._crit_edge93.loopexit:                           ; preds = %117
  %.pre = sext i32 %118 to i64
  br label %._crit_edge93

._crit_edge93:                                    ; preds = %._crit_edge93.loopexit, %._crit_edge81
  %.pre-phi = phi i64 [ %.pre, %._crit_edge93.loopexit ], [ %58, %._crit_edge81 ]
  %.046.lcssa = phi i32 [ %.1, %._crit_edge93.loopexit ], [ %60, %._crit_edge81 ]
  %121 = sext i32 %.046.lcssa to i64
  %122 = getelementptr inbounds [30001 x i32], ptr @fact, i64 0, i64 %.pre-phi
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = mul nsw i64 %124, %121
  %126 = load i32, ptr @mod, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = srem i64 %125, %127
  %129 = trunc nsw i64 %128 to i32
  %130 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.05097, i32 noundef %129)
  %131 = add nuw nsw i32 %.05097, 1
  %132 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.05097, %132
  br i1 %.not.not, label %.lr.ph99, label %._crit_edge100, !llvm.loop !18
}

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

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

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

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

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

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

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 = { 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 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 = { 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 #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DivRemPairsPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass