; LLVM IR from tangjz/acm-icpc :: uvalive (7504)

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

%struct.Factor = type { i32, [13 x i32], [13 x i32], i32, [6721 x %"struct.std::pair"] }
%"struct.std::pair" = type { i64, i64 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@r = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@prime = external dso_local global [1000001 x i32], align 16
@d = external dso_local global [1000001 x i32], align 16
@perm = external dso_local global [10001 x i32], align 16
@ctr = external dso_local global [6721 x i32], align 16
@sei = external dso_local global [6721 x i64], align 16
@fr = external dso_local global %struct.Factor, align 8
@fc = external dso_local global %struct.Factor, align 8
@frc = external dso_local global %struct.Factor, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = 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 nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powix(i32 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7mod_invi(i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3lcmii(i32 noundef, i32 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 %struct.Factor, align 8
  %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
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 1, ptr getelementptr inbounds ([1000001 x i32], ptr @d, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %19

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

22:                                               ; preds = %19
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %81

23:                                               ; preds = %19
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1000001 x i32], ptr @d, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %38, label %29

29:                                               ; preds = %23
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1000001 x i32], ptr @d, i64 0, i64 %32
  store i32 %30, ptr %33, align 4, !tbaa !5
  %34 = load i32, ptr @tot, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr @tot, align 4, !tbaa !5
  %36 = sext i32 %34 to i64
  %37 = getelementptr inbounds [1000001 x i32], ptr @prime, i64 0, i64 %36
  store i32 %30, ptr %37, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %29, %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sdiv i32 1000000, %39
  store i32 %40, ptr %5, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %73, %38
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1000001 x i32], ptr @prime, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %41
  store i32 5, ptr %3, align 4
  br label %76

49:                                               ; preds = %41
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1000001 x i32], ptr @prime, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1000001 x i32], ptr @prime, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = mul nsw i32 %54, %58
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1000001 x i32], ptr @d, i64 0, i64 %60
  store i32 %53, ptr %61, align 4, !tbaa !5
  %62 = load i32, ptr %2, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1000001 x i32], ptr @d, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1000001 x i32], ptr @prime, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = icmp eq i32 %65, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %49
  store i32 5, ptr %3, align 4
  br label %76

72:                                               ; preds = %49
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %4, align 4, !tbaa !5
  br label %41, !llvm.loop !9

76:                                               ; preds = %71, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !11

81:                                               ; preds = %22
  %82 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %322, %81
  %84 = load i32, ptr %6, align 4, !tbaa !5
  %85 = load i32, ptr @t, align 4, !tbaa !5
  %86 = icmp sle i32 %84, %85
  br i1 %86, label %88, label %87

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

88:                                               ; preds = %83
  %89 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef @n, ptr noundef @r, ptr noundef @c)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %100, %88
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %90
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %103

95:                                               ; preds = %90
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i32, ptr @perm, i64 %97
  %99 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %98)
  br label %100

100:                                              ; preds = %95
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %7, align 4, !tbaa !5
  br label %90, !llvm.loop !12

103:                                              ; preds = %94
  %104 = load i32, ptr @r, align 4, !tbaa !5
  call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(107648) @fr, i32 noundef %104)
  %105 = load i32, ptr @c, align 4, !tbaa !5
  call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(107648) @fc, i32 noundef %105)
  call void @llvm.lifetime.start.p0(i64 107648, ptr %8) #7
  call void @_ZNK6FactorplERKS_(ptr dead_on_unwind writable sret(%struct.Factor) align 8 %8, ptr noundef nonnull align 8 dereferenceable(107648) @fr, ptr noundef nonnull align 8 dereferenceable(107648) @fc)
  %106 = call noundef nonnull align 8 dereferenceable(107648) ptr @_ZN6FactoraSEOS_(ptr noundef nonnull align 8 dereferenceable(107648) @frc, ptr noundef nonnull align 8 dereferenceable(107648) %8) #7
  call void @llvm.lifetime.end.p0(i64 107648, ptr %8) #7
  %107 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 3), align 4, !tbaa !13
  %108 = sext i32 %107 to i64
  %109 = mul i64 %108, 8
  call void @llvm.memset.p0.i64(ptr align 16 @ctr, i8 0, i64 %109, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %160, %103
  %111 = load i32, ptr %9, align 4, !tbaa !5
  %112 = load i32, ptr @n, align 4, !tbaa !5
  %113 = icmp slt i32 %111, %112
  br i1 %113, label %115, label %114

114:                                              ; preds = %110
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %163

115:                                              ; preds = %110
  %116 = load i32, ptr %9, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [10001 x i32], ptr @perm, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = icmp eq i32 %119, -1
  br i1 %120, label %121, label %122

121:                                              ; preds = %115
  br label %160

122:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 1, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %123 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %123, ptr %11, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %132, %122
  %125 = load i32, ptr %11, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [10001 x i32], ptr @perm, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = icmp ne i32 %128, %129
  br i1 %130, label %131, label %143

131:                                              ; preds = %124
  br label %132

132:                                              ; preds = %131
  %133 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %133, ptr %12, align 4, !tbaa !5
  %134 = load i32, ptr %11, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [10001 x i32], ptr @perm, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  store i32 %137, ptr %11, align 4, !tbaa !5
  %138 = load i32, ptr %12, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [10001 x i32], ptr @perm, i64 0, i64 %139
  store i32 -1, ptr %140, align 4, !tbaa !5
  %141 = load i32, ptr %10, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %10, align 4, !tbaa !5
  br label %124, !llvm.loop !15

143:                                              ; preds = %124
  %144 = load i32, ptr %11, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [10001 x i32], ptr @perm, i64 0, i64 %145
  store i32 -1, ptr %146, align 4, !tbaa !5
  %147 = load i32, ptr %10, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = call noundef i32 @_ZN6Factor5getIDEx(ptr noundef nonnull align 8 dereferenceable(107648) @frc, i64 noundef %148)
  store i32 %149, ptr %11, align 4, !tbaa !5
  %150 = load i32, ptr %11, align 4, !tbaa !5
  %151 = icmp sge i32 %150, 0
  br i1 %151, label %152, label %159

152:                                              ; preds = %143
  %153 = load i32, ptr %10, align 4, !tbaa !5
  %154 = load i32, ptr %11, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [6721 x i32], ptr @ctr, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = add nsw i32 %157, %153
  store i32 %158, ptr %156, align 4, !tbaa !5
  br label %159

159:                                              ; preds = %152, %143
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %160

160:                                              ; preds = %159, %121
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %9, align 4, !tbaa !5
  br label %110, !llvm.loop !16

163:                                              ; preds = %114
  %164 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 3), align 4, !tbaa !13
  %165 = sext i32 %164 to i64
  %166 = mul i64 %165, 8
  call void @llvm.memset.p0.i64(ptr align 16 @sei, i8 0, i64 %166, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %167

167:                                              ; preds = %212, %163
  %168 = load i32, ptr %13, align 4, !tbaa !5
  %169 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @fr, i32 0, i32 3), align 4, !tbaa !13
  %170 = icmp slt i32 %168, %169
  br i1 %170, label %172, label %171

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

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

173:                                              ; preds = %208, %172
  %174 = load i32, ptr %14, align 4, !tbaa !5
  %175 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @fc, i32 0, i32 3), align 4, !tbaa !13
  %176 = icmp slt i32 %174, %175
  br i1 %176, label %178, label %177

177:                                              ; preds = %173
  store i32 23, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %211

178:                                              ; preds = %173
  %179 = load i32, ptr %13, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @fr, i32 0, i32 4), i64 0, i64 %180
  %182 = getelementptr inbounds %"struct.std::pair", ptr %181, i32 0, i32 1
  %183 = load i64, ptr %182, align 8, !tbaa !17
  %184 = load i32, ptr %14, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @fc, i32 0, i32 4), i64 0, i64 %185
  %187 = getelementptr inbounds %"struct.std::pair", ptr %186, i32 0, i32 1
  %188 = load i64, ptr %187, align 8, !tbaa !17
  %189 = mul nsw i64 %183, %188
  %190 = load i32, ptr %13, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @fr, i32 0, i32 4), i64 0, i64 %191
  %193 = getelementptr inbounds %"struct.std::pair", ptr %192, i32 0, i32 0
  %194 = load i64, ptr %193, align 8, !tbaa !20
  %195 = trunc i64 %194 to i32
  %196 = load i32, ptr %14, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @fc, i32 0, i32 4), i64 0, i64 %197
  %199 = getelementptr inbounds %"struct.std::pair", ptr %198, i32 0, i32 0
  %200 = load i64, ptr %199, align 8, !tbaa !20
  %201 = trunc i64 %200 to i32
  %202 = call noundef i64 @_Z3lcmii(i32 noundef %195, i32 noundef %201)
  %203 = call noundef i32 @_ZN6Factor5getIDEx(ptr noundef nonnull align 8 dereferenceable(107648) @frc, i64 noundef %202)
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [6721 x i64], ptr @sei, i64 0, i64 %204
  %206 = load i64, ptr %205, align 8, !tbaa !21
  %207 = add nsw i64 %206, %189
  store i64 %207, ptr %205, align 8, !tbaa !21
  br label %208

208:                                              ; preds = %178
  %209 = load i32, ptr %14, align 4, !tbaa !5
  %210 = add nsw i32 %209, 1
  store i32 %210, ptr %14, align 4, !tbaa !5
  br label %173, !llvm.loop !22

211:                                              ; preds = %177
  br label %212

212:                                              ; preds = %211
  %213 = load i32, ptr %13, align 4, !tbaa !5
  %214 = add nsw i32 %213, 1
  store i32 %214, ptr %13, align 4, !tbaa !5
  br label %167, !llvm.loop !23

215:                                              ; preds = %171
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %216

216:                                              ; preds = %300, %215
  %217 = load i32, ptr %16, align 4, !tbaa !5
  %218 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 3), align 4, !tbaa !13
  %219 = icmp slt i32 %217, %218
  br i1 %219, label %221, label %220

220:                                              ; preds = %216
  store i32 26, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %303

221:                                              ; preds = %216
  %222 = load i32, ptr %16, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [6721 x i64], ptr @sei, i64 0, i64 %223
  %225 = load i64, ptr %224, align 8, !tbaa !21
  %226 = icmp ne i64 %225, 0
  br i1 %226, label %228, label %227

227:                                              ; preds = %221
  br label %300

228:                                              ; preds = %221
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %229

229:                                              ; preds = %266, %228
  %230 = load i32, ptr %18, align 4, !tbaa !5
  %231 = load i32, ptr %16, align 4, !tbaa !5
  %232 = icmp sle i32 %230, %231
  br i1 %232, label %233, label %242

233:                                              ; preds = %229
  %234 = load i32, ptr %18, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 4), i64 0, i64 %235
  %237 = getelementptr inbounds %"struct.std::pair", ptr %236, i32 0, i32 0
  %238 = load i64, ptr %237, align 8, !tbaa !20
  %239 = load i32, ptr @n, align 4, !tbaa !5
  %240 = sext i32 %239 to i64
  %241 = icmp sle i64 %238, %240
  br label %242

242:                                              ; preds = %233, %229
  %243 = phi i1 [ false, %229 ], [ %241, %233 ]
  br i1 %243, label %245, label %244

244:                                              ; preds = %242
  store i32 29, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %269

245:                                              ; preds = %242
  %246 = load i32, ptr %16, align 4, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 4), i64 0, i64 %247
  %249 = getelementptr inbounds %"struct.std::pair", ptr %248, i32 0, i32 0
  %250 = load i64, ptr %249, align 8, !tbaa !20
  %251 = load i32, ptr %18, align 4, !tbaa !5
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 4), i64 0, i64 %252
  %254 = getelementptr inbounds %"struct.std::pair", ptr %253, i32 0, i32 0
  %255 = load i64, ptr %254, align 8, !tbaa !20
  %256 = srem i64 %250, %255
  %257 = icmp eq i64 %256, 0
  br i1 %257, label %258, label %265

258:                                              ; preds = %245
  %259 = load i32, ptr %18, align 4, !tbaa !5
  %260 = sext i32 %259 to i64
  %261 = getelementptr inbounds [6721 x i32], ptr @ctr, i64 0, i64 %260
  %262 = load i32, ptr %261, align 4, !tbaa !5
  %263 = load i32, ptr %17, align 4, !tbaa !5
  %264 = add nsw i32 %263, %262
  store i32 %264, ptr %17, align 4, !tbaa !5
  br label %265

265:                                              ; preds = %258, %245
  br label %266

266:                                              ; preds = %265
  %267 = load i32, ptr %18, align 4, !tbaa !5
  %268 = add nsw i32 %267, 1
  store i32 %268, ptr %18, align 4, !tbaa !5
  br label %229, !llvm.loop !24

269:                                              ; preds = %244
  %270 = load i32, ptr %17, align 4, !tbaa !5
  %271 = icmp sgt i32 %270, 0
  br i1 %271, label %272, label %299

272:                                              ; preds = %269
  %273 = load i32, ptr %15, align 4, !tbaa !5
  %274 = sext i32 %273 to i64
  %275 = load i32, ptr %16, align 4, !tbaa !5
  %276 = sext i32 %275 to i64
  %277 = getelementptr inbounds [6721 x i64], ptr @sei, i64 0, i64 %276
  %278 = load i64, ptr %277, align 8, !tbaa !21
  %279 = srem i64 %278, 1000000007
  %280 = load i32, ptr %17, align 4, !tbaa !5
  %281 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 3), align 4, !tbaa !13
  %282 = sub nsw i32 %281, 1
  %283 = sext i32 %282 to i64
  %284 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 4), i64 0, i64 %283
  %285 = getelementptr inbounds %"struct.std::pair", ptr %284, i32 0, i32 0
  %286 = load i64, ptr %285, align 8, !tbaa !20
  %287 = load i32, ptr %16, align 4, !tbaa !5
  %288 = sext i32 %287 to i64
  %289 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 4), i64 0, i64 %288
  %290 = getelementptr inbounds %"struct.std::pair", ptr %289, i32 0, i32 0
  %291 = load i64, ptr %290, align 8, !tbaa !20
  %292 = sdiv i64 %286, %291
  %293 = call noundef i32 @_Z7mod_powix(i32 noundef %280, i64 noundef %292)
  %294 = sext i32 %293 to i64
  %295 = mul nsw i64 %279, %294
  %296 = add nsw i64 %274, %295
  %297 = srem i64 %296, 1000000007
  %298 = trunc i64 %297 to i32
  store i32 %298, ptr %15, align 4, !tbaa !5
  br label %299

299:                                              ; preds = %272, %269
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %300

300:                                              ; preds = %299, %227
  %301 = load i32, ptr %16, align 4, !tbaa !5
  %302 = add nsw i32 %301, 1
  store i32 %302, ptr %16, align 4, !tbaa !5
  br label %216, !llvm.loop !25

303:                                              ; preds = %220
  %304 = load i32, ptr %15, align 4, !tbaa !5
  %305 = sext i32 %304 to i64
  %306 = load i32, ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 3), align 4, !tbaa !13
  %307 = sub nsw i32 %306, 1
  %308 = sext i32 %307 to i64
  %309 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.Factor, ptr @frc, i32 0, i32 4), i64 0, i64 %308
  %310 = getelementptr inbounds %"struct.std::pair", ptr %309, i32 0, i32 0
  %311 = load i64, ptr %310, align 8, !tbaa !20
  %312 = srem i64 %311, 1000000007
  %313 = trunc i64 %312 to i32
  %314 = call noundef i32 @_Z7mod_invi(i32 noundef %313)
  %315 = sext i32 %314 to i64
  %316 = mul nsw i64 %305, %315
  %317 = srem i64 %316, 1000000007
  %318 = trunc i64 %317 to i32
  store i32 %318, ptr %15, align 4, !tbaa !5
  %319 = load i32, ptr %6, align 4, !tbaa !5
  %320 = load i32, ptr %15, align 4, !tbaa !5
  %321 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %319, i32 noundef %320)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %322

322:                                              ; preds = %303
  %323 = load i32, ptr %6, align 4, !tbaa !5
  %324 = add nsw i32 %323, 1
  store i32 %324, ptr %6, align 4, !tbaa !5
  br label %83, !llvm.loop !26

325:                                              ; preds = %87
  ret i32 0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(107648), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6FactorplERKS_(ptr dead_on_unwind noalias writable sret(%struct.Factor) align 8, ptr noundef nonnull align 8 dereferenceable(107648), ptr noundef nonnull align 8 dereferenceable(107648)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(107648) ptr @_ZN6FactoraSEOS_(ptr noundef nonnull align 8 dereferenceable(107648), ptr noundef nonnull align 8 dereferenceable(107648)) #5 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6Factor5getIDEx(ptr noundef nonnull align 8 dereferenceable(107648), i64 noundef) #2 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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, !6, i64 108}
!14 = !{!"_ZTS6Factor", !6, i64 0, !7, i64 4, !7, i64 56, !6, i64 108, !7, i64 112}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = !{!18, !19, i64 8}
!18 = !{!"_ZTSSt4pairIxxE", !19, i64 0, !19, i64 8}
!19 = !{!"long long", !7, i64 0}
!20 = !{!18, !19, i64 0}
!21 = !{!19, !19, i64 0}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !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"

%struct.Factor = type { i32, [13 x i32], [13 x i32], i32, [6721 x %"struct.std::pair"] }
%"struct.std::pair" = type { i64, i64 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@r = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@prime = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@d = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@perm = external dso_local global [10001 x i32], align 16
@ctr = external dso_local local_unnamed_addr global [6721 x i32], align 16
@sei = external dso_local local_unnamed_addr global [6721 x i64], align 16
@fr = external dso_local global %struct.Factor, align 8
@fc = external dso_local global %struct.Factor, align 8
@frc = external dso_local global %struct.Factor, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = 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 nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powix(i32 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7mod_invi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3lcmii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca %struct.Factor, align 8
  store i32 1, ptr getelementptr inbounds (i8, ptr @d, i64 4), align 4, !tbaa !5
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  br label %5

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

5:                                                ; preds = %0, %._crit_edge
  %indvars.iv129 = phi i64 [ 2, %0 ], [ %indvars.iv.next130, %._crit_edge ]
  %6 = phi i32 [ %tot.promoted, %0 ], [ %14, %._crit_edge ]
  %7 = getelementptr inbounds [1000001 x i32], ptr @d, i64 0, i64 %indvars.iv129
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %.not83 = icmp eq i32 %8, 0
  %9 = trunc nuw nsw i64 %indvars.iv129 to i32
  br i1 %.not83, label %10, label %._crit_edge163

10:                                               ; preds = %5
  store i32 %9, ptr %7, align 4, !tbaa !5
  %11 = add nsw i32 %6, 1
  store i32 %11, ptr @tot, align 4, !tbaa !5
  %12 = sext i32 %6 to i64
  %13 = getelementptr inbounds [1000001 x i32], ptr @prime, i64 0, i64 %12
  store i32 %9, ptr %13, align 4, !tbaa !5
  br label %._crit_edge163

._crit_edge163:                                   ; preds = %5, %10
  %14 = phi i32 [ %11, %10 ], [ %6, %5 ]
  %15 = udiv i32 1000000, %9
  %16 = load i32, ptr @prime, align 16, !tbaa !5
  %.not8489 = icmp sgt i32 %16, %15
  br i1 %.not8489, label %._crit_edge, label %.lr.ph

17:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = getelementptr inbounds [1000001 x i32], ptr @prime, i64 0, i64 %indvars.iv.next
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %.not84 = icmp sgt i32 %19, %15
  br i1 %.not84, label %._crit_edge, label %.lr.ph, !llvm.loop !9

.lr.ph:                                           ; preds = %._crit_edge163, %17
  %indvars.iv = phi i64 [ %indvars.iv.next, %17 ], [ 0, %._crit_edge163 ]
  %20 = phi i32 [ %19, %17 ], [ %16, %._crit_edge163 ]
  %21 = mul nsw i32 %20, %9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1000001 x i32], ptr @d, i64 0, i64 %22
  store i32 %20, ptr %23, align 4, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp eq i32 %24, %20
  br i1 %25, label %._crit_edge, label %17

._crit_edge:                                      ; preds = %17, %.lr.ph, %._crit_edge163
  %indvars.iv.next130 = add nuw nsw i64 %indvars.iv129, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next130, 1000001
  br i1 %exitcond.not, label %2, label %5, !llvm.loop !11

._crit_edge123:                                   ; preds = %._crit_edge116, %2
  ret i32 0

.lr.ph122:                                        ; preds = %2, %._crit_edge116
  %.072120 = phi i32 [ %113, %._crit_edge116 ], [ 1, %2 ]
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull @n, ptr noundef nonnull @r, ptr noundef nonnull @c)
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %.lr.ph95, label %._crit_edge96

._crit_edge96:                                    ; preds = %.lr.ph95, %.lr.ph122
  %29 = load i32, ptr @r, align 4, !tbaa !5
  call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(107648) @fr, i32 noundef %29)
  %30 = load i32, ptr @c, align 4, !tbaa !5
  call void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(107648) @fc, i32 noundef %30)
  call void @llvm.lifetime.start.p0(i64 107648, ptr nonnull %1) #7
  call void @_ZNK6FactorplERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Factor) align 8 %1, ptr noundef nonnull align 8 dereferenceable(107648) @fr, ptr noundef nonnull align 8 dereferenceable(107648) @fc)
  %31 = call noundef nonnull align 8 dereferenceable(107648) ptr @_ZN6FactoraSEOS_(ptr noundef nonnull align 8 dereferenceable(107648) @frc, ptr noundef nonnull align 8 dereferenceable(107648) %1) #7
  call void @llvm.lifetime.end.p0(i64 107648, ptr nonnull %1) #7
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @frc, i64 108), align 4, !tbaa !12
  %33 = sext i32 %32 to i64
  %34 = shl nsw i64 %33, 3
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @ctr, i8 0, i64 %34, i1 false)
  %35 = load i32, ptr @n, align 4, !tbaa !5
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.lr.ph104, label %._crit_edge105

.lr.ph95:                                         ; preds = %.lr.ph122, %.lr.ph95
  %indvars.iv132 = phi i64 [ %indvars.iv.next133, %.lr.ph95 ], [ 0, %.lr.ph122 ]
  %37 = getelementptr inbounds i32, ptr @perm, i64 %indvars.iv132
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %37)
  %indvars.iv.next133 = add nuw nsw i64 %indvars.iv132, 1
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = icmp slt i64 %indvars.iv.next133, %40
  br i1 %41, label %.lr.ph95, label %._crit_edge96, !llvm.loop !14

._crit_edge105.loopexit:                          ; preds = %66
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @frc, i64 108), align 4, !tbaa !12
  %.pre160 = sext i32 %.pre to i64
  %.pre161 = shl nsw i64 %.pre160, 3
  br label %._crit_edge105

._crit_edge105:                                   ; preds = %._crit_edge105.loopexit, %._crit_edge96
  %.pre-phi162 = phi i64 [ %.pre161, %._crit_edge105.loopexit ], [ %34, %._crit_edge96 ]
  %42 = phi i32 [ %.pre, %._crit_edge105.loopexit ], [ %32, %._crit_edge96 ]
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @sei, i8 0, i64 %.pre-phi162, i1 false)
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @fr, i64 108), align 4, !tbaa !12
  %44 = icmp sgt i32 %43, 0
  %45 = load i32, ptr getelementptr inbounds (i8, ptr @fc, i64 108), align 4
  %46 = icmp sgt i32 %45, 0
  %or.cond = select i1 %44, i1 %46, i1 false
  br i1 %or.cond, label %.preheader85, label %.preheader87

.lr.ph104:                                        ; preds = %._crit_edge96, %66
  %indvars.iv135 = phi i64 [ %indvars.iv.next136, %66 ], [ 0, %._crit_edge96 ]
  %47 = getelementptr inbounds [10001 x i32], ptr @perm, i64 0, i64 %indvars.iv135
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = icmp eq i32 %48, -1
  br i1 %49, label %66, label %.preheader86

.preheader86:                                     ; preds = %.lr.ph104
  %50 = zext i32 %48 to i64
  %.not8297 = icmp eq i64 %indvars.iv135, %50
  br i1 %.not8297, label %._crit_edge100, label %.lr.ph99

.lr.ph99:                                         ; preds = %.preheader86, %.lr.ph99
  %51 = phi i32 [ %56, %.lr.ph99 ], [ %48, %.preheader86 ]
  %52 = phi ptr [ %55, %.lr.ph99 ], [ %47, %.preheader86 ]
  %.06998 = phi i32 [ %53, %.lr.ph99 ], [ 1, %.preheader86 ]
  store i32 -1, ptr %52, align 4, !tbaa !5
  %53 = add nuw nsw i32 %.06998, 1
  %54 = sext i32 %51 to i64
  %55 = getelementptr inbounds [10001 x i32], ptr @perm, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = zext i32 %56 to i64
  %.not82 = icmp eq i64 %indvars.iv135, %57
  br i1 %.not82, label %._crit_edge100, label %.lr.ph99, !llvm.loop !15

._crit_edge100:                                   ; preds = %.lr.ph99, %.preheader86
  %.069.lcssa = phi i32 [ 1, %.preheader86 ], [ %53, %.lr.ph99 ]
  %.lcssa = phi ptr [ %47, %.preheader86 ], [ %55, %.lr.ph99 ]
  store i32 -1, ptr %.lcssa, align 4, !tbaa !5
  %58 = zext nneg i32 %.069.lcssa to i64
  %59 = call noundef i32 @_ZN6Factor5getIDEx(ptr noundef nonnull align 8 dereferenceable(107648) @frc, i64 noundef %58)
  %60 = icmp sgt i32 %59, -1
  br i1 %60, label %61, label %66

61:                                               ; preds = %._crit_edge100
  %62 = zext nneg i32 %59 to i64
  %63 = getelementptr inbounds [6721 x i32], ptr @ctr, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = add nsw i32 %64, %.069.lcssa
  store i32 %65, ptr %63, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %._crit_edge100, %61, %.lr.ph104
  %indvars.iv.next136 = add nuw nsw i64 %indvars.iv135, 1
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = icmp slt i64 %indvars.iv.next136, %68
  br i1 %69, label %.lr.ph104, label %._crit_edge105.loopexit, !llvm.loop !16

.preheader87.loopexit:                            ; preds = %._crit_edge108
  %.pre158 = load i32, ptr getelementptr inbounds (i8, ptr @frc, i64 108), align 4, !tbaa !12
  br label %.preheader87

.preheader87:                                     ; preds = %.preheader87.loopexit, %._crit_edge105
  %70 = phi i32 [ %.pre158, %.preheader87.loopexit ], [ %42, %._crit_edge105 ]
  %71 = icmp sgt i32 %70, 0
  br i1 %71, label %.lr.ph115, label %._crit_edge116

.preheader85:                                     ; preds = %._crit_edge105, %._crit_edge108
  %72 = phi i32 [ %77, %._crit_edge108 ], [ %43, %._crit_edge105 ]
  %73 = phi i32 [ %78, %._crit_edge108 ], [ %45, %._crit_edge105 ]
  %indvars.iv141 = phi i64 [ %indvars.iv.next142, %._crit_edge108 ], [ 0, %._crit_edge105 ]
  %74 = icmp sgt i32 %73, 0
  br i1 %74, label %.lr.ph107, label %._crit_edge108

.lr.ph107:                                        ; preds = %.preheader85
  %75 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @fr, i64 112), i64 0, i64 %indvars.iv141
  %76 = getelementptr inbounds i8, ptr %75, i64 8
  br label %81

._crit_edge108.loopexit:                          ; preds = %81
  %.pre157 = load i32, ptr getelementptr inbounds (i8, ptr @fr, i64 108), align 4, !tbaa !12
  br label %._crit_edge108

._crit_edge108:                                   ; preds = %._crit_edge108.loopexit, %.preheader85
  %77 = phi i32 [ %.pre157, %._crit_edge108.loopexit ], [ %72, %.preheader85 ]
  %78 = phi i32 [ %97, %._crit_edge108.loopexit ], [ %73, %.preheader85 ]
  %indvars.iv.next142 = add nuw nsw i64 %indvars.iv141, 1
  %79 = sext i32 %77 to i64
  %80 = icmp slt i64 %indvars.iv.next142, %79
  br i1 %80, label %.preheader85, label %.preheader87.loopexit, !llvm.loop !17

81:                                               ; preds = %.lr.ph107, %81
  %indvars.iv138 = phi i64 [ 0, %.lr.ph107 ], [ %indvars.iv.next139, %81 ]
  %82 = load i64, ptr %76, align 8, !tbaa !19
  %83 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @fc, i64 112), i64 0, i64 %indvars.iv138
  %84 = getelementptr inbounds i8, ptr %83, i64 8
  %85 = load i64, ptr %84, align 8, !tbaa !19
  %86 = mul nsw i64 %85, %82
  %87 = load i64, ptr %75, align 8, !tbaa !22
  %88 = trunc i64 %87 to i32
  %89 = load i64, ptr %83, align 8, !tbaa !22
  %90 = trunc i64 %89 to i32
  %91 = call noundef i64 @_Z3lcmii(i32 noundef %88, i32 noundef %90)
  %92 = call noundef i32 @_ZN6Factor5getIDEx(ptr noundef nonnull align 8 dereferenceable(107648) @frc, i64 noundef %91)
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [6721 x i64], ptr @sei, i64 0, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !23
  %96 = add nsw i64 %95, %86
  store i64 %96, ptr %94, align 8, !tbaa !23
  %indvars.iv.next139 = add nuw nsw i64 %indvars.iv138, 1
  %97 = load i32, ptr getelementptr inbounds (i8, ptr @fc, i64 108), align 4, !tbaa !12
  %98 = sext i32 %97 to i64
  %99 = icmp slt i64 %indvars.iv.next139, %98
  br i1 %99, label %81, label %._crit_edge108.loopexit, !llvm.loop !24

._crit_edge116:                                   ; preds = %149, %.preheader87
  %.063.lcssa = phi i32 [ 0, %.preheader87 ], [ %.2, %149 ]
  %.lcssa88 = phi i32 [ %70, %.preheader87 ], [ %150, %149 ]
  %100 = sext i32 %.063.lcssa to i64
  %101 = add nsw i32 %.lcssa88, -1
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @frc, i64 112), i64 0, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !22
  %105 = srem i64 %104, 1000000007
  %106 = trunc nsw i64 %105 to i32
  %107 = call noundef i32 @_Z7mod_invi(i32 noundef %106)
  %108 = sext i32 %107 to i64
  %109 = mul nsw i64 %108, %100
  %110 = srem i64 %109, 1000000007
  %111 = trunc nsw i64 %110 to i32
  %112 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %.072120, i32 noundef %111)
  %113 = add nuw nsw i32 %.072120, 1
  %114 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.072120, %114
  br i1 %.not.not, label %.lr.ph122, label %._crit_edge123, !llvm.loop !25

.lr.ph115:                                        ; preds = %.preheader87, %149
  %115 = phi i32 [ %150, %149 ], [ %70, %.preheader87 ]
  %indvars.iv152 = phi i64 [ %indvars.iv.next153, %149 ], [ 0, %.preheader87 ]
  %indvars.iv150 = phi i64 [ %indvars.iv.next151, %149 ], [ 1, %.preheader87 ]
  %.063112 = phi i32 [ %.2, %149 ], [ 0, %.preheader87 ]
  %116 = getelementptr inbounds [6721 x i64], ptr @sei, i64 0, i64 %indvars.iv152
  %117 = load i64, ptr %116, align 8, !tbaa !23
  %.not79 = icmp eq i64 %117, 0
  br i1 %.not79, label %149, label %.preheader

.preheader:                                       ; preds = %.lr.ph115
  %118 = load i32, ptr @n, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @frc, i64 112), i64 0, i64 %indvars.iv152
  br label %121

121:                                              ; preds = %.preheader, %133
  %indvars.iv144 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next145, %133 ]
  %.061110 = phi i32 [ 0, %.preheader ], [ %.1, %133 ]
  %122 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @frc, i64 112), i64 0, i64 %indvars.iv144
  %123 = load i64, ptr %122, align 8, !tbaa !22
  %.not81 = icmp sgt i64 %123, %119
  br i1 %.not81, label %.critedge, label %125

.critedge:                                        ; preds = %133, %121
  %.061.lcssa = phi i32 [ %.1, %133 ], [ %.061110, %121 ]
  %124 = icmp sgt i32 %.061.lcssa, 0
  br i1 %124, label %134, label %149

125:                                              ; preds = %121
  %126 = load i64, ptr %120, align 8, !tbaa !22
  %127 = srem i64 %126, %123
  %128 = icmp eq i64 %127, 0
  br i1 %128, label %129, label %133

129:                                              ; preds = %125
  %130 = getelementptr inbounds [6721 x i32], ptr @ctr, i64 0, i64 %indvars.iv144
  %131 = load i32, ptr %130, align 4, !tbaa !5
  %132 = add nsw i32 %131, %.061110
  br label %133

133:                                              ; preds = %125, %129
  %.1 = phi i32 [ %132, %129 ], [ %.061110, %125 ]
  %indvars.iv.next145 = add nuw nsw i64 %indvars.iv144, 1
  %exitcond149.not = icmp eq i64 %indvars.iv.next145, %indvars.iv150
  br i1 %exitcond149.not, label %.critedge, label %121, !llvm.loop !26

134:                                              ; preds = %.critedge
  %135 = sext i32 %.063112 to i64
  %136 = srem i64 %117, 1000000007
  %137 = add nsw i32 %115, -1
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [6721 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @frc, i64 112), i64 0, i64 %138
  %140 = load i64, ptr %139, align 8, !tbaa !22
  %141 = load i64, ptr %120, align 8, !tbaa !22
  %142 = sdiv i64 %140, %141
  %143 = call noundef i32 @_Z7mod_powix(i32 noundef %.061.lcssa, i64 noundef %142)
  %144 = sext i32 %143 to i64
  %145 = mul nsw i64 %136, %144
  %146 = add nsw i64 %145, %135
  %147 = srem i64 %146, 1000000007
  %148 = trunc nsw i64 %147 to i32
  %.pre159 = load i32, ptr getelementptr inbounds (i8, ptr @frc, i64 108), align 4, !tbaa !12
  br label %149

149:                                              ; preds = %.critedge, %134, %.lr.ph115
  %150 = phi i32 [ %115, %.lr.ph115 ], [ %.pre159, %134 ], [ %115, %.critedge ]
  %.2 = phi i32 [ %.063112, %.lr.ph115 ], [ %148, %134 ], [ %.063112, %.critedge ]
  %indvars.iv.next153 = add nuw nsw i64 %indvars.iv152, 1
  %151 = sext i32 %150 to i64
  %152 = icmp slt i64 %indvars.iv.next153, %151
  %indvars.iv.next151 = add nuw nsw i64 %indvars.iv150, 1
  br i1 %152, label %.lr.ph115, label %._crit_edge116, !llvm.loop !27
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Factor4initEi(ptr noundef nonnull align 8 dereferenceable(107648), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6FactorplERKS_(ptr dead_on_unwind noalias writable sret(%struct.Factor) align 8, ptr noundef nonnull align 8 dereferenceable(107648), ptr noundef nonnull align 8 dereferenceable(107648)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(107648) ptr @_ZN6FactoraSEOS_(ptr noundef nonnull align 8 dereferenceable(107648), ptr noundef nonnull align 8 dereferenceable(107648)) local_unnamed_addr #5 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6Factor5getIDEx(ptr noundef nonnull align 8 dereferenceable(107648), i64 noundef) local_unnamed_addr #2 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 = { 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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 = !{!13, !6, i64 108}
!13 = !{!"_ZTS6Factor", !6, i64 0, !7, i64 4, !7, i64 56, !6, i64 108, !7, i64 112}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = !{!20, !21, i64 8}
!20 = !{!"_ZTSSt4pairIxxE", !21, i64 0, !21, i64 8}
!21 = !{!"long long", !7, i64 0}
!22 = !{!20, !21, i64 0}
!23 = !{!21, !21, i64 0}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !10}
!27 = distinct !{!27, !10}


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