; LLVM IR from tangjz/acm-icpc :: 51nod (1035)

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

@cnt = external dso_local global i32, align 4
@p = external dso_local global [16 x i64], align 16
@tot = external dso_local global i32, align 4
@prime = external dso_local global [83333 x i32], align 16
@vis = external dso_local global [1000001 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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 i64 @_Z7mod_powxxx(i64 noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z12miller_rabinx(i64 noundef) #1

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

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

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

21:                                               ; preds = %17
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !9, !range !11, !noundef !12
  %26 = trunc i8 %25 to i1
  br i1 %26, label %33, label %27

27:                                               ; preds = %21
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = load i32, ptr @tot, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr @tot, align 4, !tbaa !5
  %31 = sext i32 %29 to i64
  %32 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %31
  store i32 %28, ptr %32, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %27, %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sdiv i32 1000000, %34
  store i32 %35, ptr %5, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %68, %33
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = load i32, ptr @tot, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %47

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

47:                                               ; preds = %40, %36
  %48 = phi i1 [ false, %36 ], [ %46, %40 ]
  br i1 %48, label %50, label %49

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

50:                                               ; preds = %47
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = mul nsw i32 %51, %55
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %57
  store i8 1, ptr %58, align 1, !tbaa !9
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = srem i32 %59, %63
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %66, label %67

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

67:                                               ; preds = %50
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %4, align 4, !tbaa !5
  br label %36, !llvm.loop !13

71:                                               ; preds = %66, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %72

72:                                               ; preds = %71
  br label %73

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

76:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 -1, ptr %7, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %77 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6)
  br label %78

78:                                               ; preds = %271, %76
  %79 = load i64, ptr %6, align 8, !tbaa !16
  %80 = call noundef zeroext i1 @_Z12miller_rabinx(i64 noundef %79)
  br i1 %80, label %81, label %134

81:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #6
  store i8 1, ptr %9, align 1, !tbaa !9
  store i32 0, ptr @cnt, align 4, !tbaa !5
  %82 = load i64, ptr %6, align 8, !tbaa !16
  %83 = sub nsw i64 %82, 1
  call void @_Z13decompositionx(i64 noundef %83)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %112, %81
  %85 = load i32, ptr %10, align 4, !tbaa !5
  %86 = load i32, ptr @cnt, align 4, !tbaa !5
  %87 = icmp slt i32 %85, %86
  br i1 %87, label %88, label %91

88:                                               ; preds = %84
  %89 = load i8, ptr %9, align 1, !tbaa !9, !range !11, !noundef !12
  %90 = trunc i8 %89 to i1
  br label %91

91:                                               ; preds = %88, %84
  %92 = phi i1 [ false, %84 ], [ %90, %88 ]
  br i1 %92, label %94, label %93

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

94:                                               ; preds = %91
  %95 = load i64, ptr %6, align 8, !tbaa !16
  %96 = sub nsw i64 %95, 1
  %97 = load i32, ptr %10, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [16 x i64], ptr @p, i64 0, i64 %98
  %100 = load i64, ptr %99, align 8, !tbaa !16
  %101 = sdiv i64 %96, %100
  %102 = load i64, ptr %6, align 8, !tbaa !16
  %103 = call noundef i64 @_Z7mod_powxxx(i64 noundef 10, i64 noundef %101, i64 noundef %102)
  %104 = icmp ne i64 %103, 1
  %105 = zext i1 %104 to i32
  %106 = load i8, ptr %9, align 1, !tbaa !9, !range !11, !noundef !12
  %107 = trunc i8 %106 to i1
  %108 = zext i1 %107 to i32
  %109 = and i32 %108, %105
  %110 = icmp ne i32 %109, 0
  %111 = zext i1 %110 to i8
  store i8 %111, ptr %9, align 1, !tbaa !9
  br label %112

112:                                              ; preds = %94
  %113 = load i32, ptr %10, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %10, align 4, !tbaa !5
  br label %84, !llvm.loop !18

115:                                              ; preds = %93
  %116 = load i8, ptr %9, align 1, !tbaa !9, !range !11, !noundef !12
  %117 = trunc i8 %116 to i1
  br i1 %117, label %118, label %130

118:                                              ; preds = %115
  %119 = load i64, ptr %7, align 8, !tbaa !16
  %120 = load i64, ptr %6, align 8, !tbaa !16
  %121 = sub nsw i64 %120, 1
  %122 = icmp slt i64 %119, %121
  br i1 %122, label %123, label %125

123:                                              ; preds = %118
  %124 = load i64, ptr %6, align 8, !tbaa !16
  br label %127

125:                                              ; preds = %118
  %126 = load i64, ptr %8, align 8, !tbaa !16
  br label %127

127:                                              ; preds = %125, %123
  %128 = phi i64 [ %124, %123 ], [ %126, %125 ]
  %129 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %128)
  store i32 8, ptr %3, align 4
  br label %131

130:                                              ; preds = %115
  store i32 0, ptr %3, align 4
  br label %131

131:                                              ; preds = %130, %127
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  %132 = load i32, ptr %3, align 4
  switch i32 %132, label %276 [
    i32 0, label %133
    i32 8, label %274
  ]

133:                                              ; preds = %131
  br label %270

134:                                              ; preds = %78
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #6
  store i8 1, ptr %11, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %135 = load i64, ptr %6, align 8, !tbaa !16
  %136 = call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %135)
  %137 = fptosi double %136 to i64
  store i64 %137, ptr %12, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %138 = load i64, ptr %12, align 8, !tbaa !16
  %139 = load i64, ptr %12, align 8, !tbaa !16
  %140 = mul nsw i64 %138, %139
  %141 = load i64, ptr %6, align 8, !tbaa !16
  %142 = icmp eq i64 %140, %141
  br i1 %142, label %143, label %148

143:                                              ; preds = %134
  %144 = load i64, ptr %12, align 8, !tbaa !16
  %145 = call noundef zeroext i1 @_Z12miller_rabinx(i64 noundef %144)
  br i1 %145, label %146, label %148

146:                                              ; preds = %143
  %147 = load i64, ptr %12, align 8, !tbaa !16
  store i64 %147, ptr %13, align 8, !tbaa !16
  store i64 2, ptr %14, align 8, !tbaa !16
  br label %206

148:                                              ; preds = %143, %134
  %149 = load i64, ptr %6, align 8, !tbaa !16
  store i64 %149, ptr %12, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %150

150:                                              ; preds = %201, %148
  %151 = load i32, ptr %15, align 4, !tbaa !5
  %152 = load i32, ptr @tot, align 4, !tbaa !5
  %153 = icmp slt i32 %151, %152
  br i1 %153, label %155, label %154

154:                                              ; preds = %150
  store i32 14, ptr %3, align 4
  br label %204

155:                                              ; preds = %150
  %156 = load i64, ptr %12, align 8, !tbaa !16
  %157 = load i32, ptr %15, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = srem i64 %156, %161
  %163 = icmp eq i64 %162, 0
  br i1 %163, label %164, label %200

164:                                              ; preds = %155
  %165 = load i32, ptr %15, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  store i64 %169, ptr %13, align 8, !tbaa !16
  store i64 0, ptr %14, align 8, !tbaa !16
  br label %170

170:                                              ; preds = %180, %164
  %171 = load i64, ptr %12, align 8, !tbaa !16
  %172 = load i32, ptr %15, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %173
  %175 = load i32, ptr %174, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = srem i64 %171, %176
  %178 = icmp eq i64 %177, 0
  br i1 %178, label %179, label %190

179:                                              ; preds = %170
  br label %180

180:                                              ; preds = %179
  %181 = load i64, ptr %14, align 8, !tbaa !16
  %182 = add nsw i64 %181, 1
  store i64 %182, ptr %14, align 8, !tbaa !16
  %183 = load i32, ptr %15, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = load i64, ptr %12, align 8, !tbaa !16
  %189 = sdiv i64 %188, %187
  store i64 %189, ptr %12, align 8, !tbaa !16
  br label %170, !llvm.loop !19

190:                                              ; preds = %170
  %191 = load i64, ptr %12, align 8, !tbaa !16
  %192 = icmp eq i64 %191, 1
  %193 = zext i1 %192 to i32
  %194 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %195 = trunc i8 %194 to i1
  %196 = zext i1 %195 to i32
  %197 = and i32 %196, %193
  %198 = icmp ne i32 %197, 0
  %199 = zext i1 %198 to i8
  store i8 %199, ptr %11, align 1, !tbaa !9
  store i32 14, ptr %3, align 4
  br label %204

200:                                              ; preds = %155
  br label %201

201:                                              ; preds = %200
  %202 = load i32, ptr %15, align 4, !tbaa !5
  %203 = add nsw i32 %202, 1
  store i32 %203, ptr %15, align 4, !tbaa !5
  br label %150, !llvm.loop !20

204:                                              ; preds = %190, %154
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %205

205:                                              ; preds = %204
  br label %206

206:                                              ; preds = %205, %146
  %207 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %208 = trunc i8 %207 to i1
  br i1 %208, label %210, label %209

209:                                              ; preds = %206
  store i32 10, ptr %3, align 4
  br label %267

210:                                              ; preds = %206
  store i32 0, ptr @cnt, align 4, !tbaa !5
  %211 = load i64, ptr %13, align 8, !tbaa !16
  %212 = icmp sgt i64 %211, 2
  br i1 %212, label %213, label %216

213:                                              ; preds = %210
  %214 = load i64, ptr %13, align 8, !tbaa !16
  %215 = sub nsw i64 %214, 1
  call void @_Z13decompositionx(i64 noundef %215)
  br label %216

216:                                              ; preds = %213, %210
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %217

217:                                              ; preds = %245, %216
  %218 = load i32, ptr %16, align 4, !tbaa !5
  %219 = load i32, ptr @cnt, align 4, !tbaa !5
  %220 = icmp slt i32 %218, %219
  br i1 %220, label %221, label %224

221:                                              ; preds = %217
  %222 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %223 = trunc i8 %222 to i1
  br label %224

224:                                              ; preds = %221, %217
  %225 = phi i1 [ false, %217 ], [ %223, %221 ]
  br i1 %225, label %227, label %226

226:                                              ; preds = %224
  store i32 20, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %248

227:                                              ; preds = %224
  %228 = load i64, ptr %13, align 8, !tbaa !16
  %229 = sub nsw i64 %228, 1
  %230 = load i32, ptr %16, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [16 x i64], ptr @p, i64 0, i64 %231
  %233 = load i64, ptr %232, align 8, !tbaa !16
  %234 = sdiv i64 %229, %233
  %235 = load i64, ptr %13, align 8, !tbaa !16
  %236 = call noundef i64 @_Z7mod_powxxx(i64 noundef 10, i64 noundef %234, i64 noundef %235)
  %237 = icmp ne i64 %236, 1
  %238 = zext i1 %237 to i32
  %239 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %240 = trunc i8 %239 to i1
  %241 = zext i1 %240 to i32
  %242 = and i32 %241, %238
  %243 = icmp ne i32 %242, 0
  %244 = zext i1 %243 to i8
  store i8 %244, ptr %11, align 1, !tbaa !9
  br label %245

245:                                              ; preds = %227
  %246 = load i32, ptr %16, align 4, !tbaa !5
  %247 = add nsw i32 %246, 1
  store i32 %247, ptr %16, align 4, !tbaa !5
  br label %217, !llvm.loop !21

248:                                              ; preds = %226
  %249 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %250 = trunc i8 %249 to i1
  br i1 %250, label %251, label %266

251:                                              ; preds = %248
  %252 = load i64, ptr %7, align 8, !tbaa !16
  %253 = load i64, ptr %6, align 8, !tbaa !16
  %254 = load i64, ptr %6, align 8, !tbaa !16
  %255 = load i64, ptr %13, align 8, !tbaa !16
  %256 = sdiv i64 %254, %255
  %257 = sub nsw i64 %253, %256
  %258 = icmp slt i64 %252, %257
  br i1 %258, label %259, label %266

259:                                              ; preds = %251
  %260 = load i64, ptr %6, align 8, !tbaa !16
  %261 = load i64, ptr %6, align 8, !tbaa !16
  %262 = load i64, ptr %13, align 8, !tbaa !16
  %263 = sdiv i64 %261, %262
  %264 = sub nsw i64 %260, %263
  store i64 %264, ptr %7, align 8, !tbaa !16
  %265 = load i64, ptr %6, align 8, !tbaa !16
  store i64 %265, ptr %8, align 8, !tbaa !16
  br label %266

266:                                              ; preds = %259, %251, %248
  store i32 0, ptr %3, align 4
  br label %267

267:                                              ; preds = %266, %209
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #6
  %268 = load i32, ptr %3, align 4
  switch i32 %268, label %276 [
    i32 0, label %269
    i32 10, label %271
  ]

269:                                              ; preds = %267
  br label %270

270:                                              ; preds = %269, %133
  br label %271

271:                                              ; preds = %270, %267
  %272 = load i64, ptr %6, align 8, !tbaa !16
  %273 = add nsw i64 %272, -1
  store i64 %273, ptr %6, align 8, !tbaa !16
  br label %78, !llvm.loop !22

274:                                              ; preds = %131
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %275 = load i32, ptr %1, align 4
  ret i32 %275

276:                                              ; preds = %267, %131
  unreachable
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) #5

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 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}


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

@cnt = external dso_local local_unnamed_addr global i32, align 4
@p = external dso_local local_unnamed_addr global [16 x i64], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@prime = external dso_local local_unnamed_addr global [83333 x i32], align 16
@vis = external dso_local local_unnamed_addr global [1000001 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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 i64 @_Z7mod_powxxx(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z12miller_rabinx(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13decompositionx(i64 noundef) local_unnamed_addr #2

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

2:                                                ; preds = %.critedge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.pre = load i64, ptr %1, align 8, !tbaa !9
  br label %28

4:                                                ; preds = %0, %.critedge
  %indvars.iv107 = phi i64 [ 2, %0 ], [ %indvars.iv.next108, %.critedge ]
  %5 = phi i32 [ %tot.promoted, %0 ], [ %15, %.critedge ]
  %6 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %indvars.iv107
  %7 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %._crit_edge125, label %9

._crit_edge125:                                   ; preds = %4
  %.pre126 = trunc nuw nsw i64 %indvars.iv107 to i32
  br label %14

9:                                                ; preds = %4
  %10 = add nsw i32 %5, 1
  store i32 %10, ptr @tot, align 4, !tbaa !5
  %11 = sext i32 %5 to i64
  %12 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %11
  %13 = trunc nuw nsw i64 %indvars.iv107 to i32
  store i32 %13, ptr %12, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %._crit_edge125, %9
  %.pre-phi = phi i32 [ %.pre126, %._crit_edge125 ], [ %13, %9 ]
  %15 = phi i32 [ %5, %._crit_edge125 ], [ %10, %9 ]
  %16 = udiv i32 1000000, %.pre-phi
  %17 = icmp sgt i32 %15, 0
  br i1 %17, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %14
  %18 = zext nneg i32 %15 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %21
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %21 ]
  %19 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not = icmp sgt i32 %20, %16
  br i1 %.not, label %.critedge, label %21

21:                                               ; preds = %.lr.ph
  %22 = mul nsw i32 %20, %.pre-phi
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %23
  store i8 1, ptr %24, align 1, !tbaa !11
  %25 = srem i32 %.pre-phi, %20
  %26 = icmp ne i32 %25, 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = icmp ult i64 %indvars.iv.next, %18
  %or.cond = select i1 %26, i1 %27, i1 false
  br i1 %or.cond, label %.lr.ph, label %.critedge, !llvm.loop !15

.critedge:                                        ; preds = %.lr.ph, %21, %14
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next108, 1000001
  br i1 %exitcond.not, label %2, label %4, !llvm.loop !17

28:                                               ; preds = %.thread, %2
  %29 = phi i64 [ %.pre, %2 ], [ %90, %.thread ]
  %.066 = phi i64 [ -1, %2 ], [ %.369, %.thread ]
  %.062 = phi i64 [ undef, %2 ], [ %.365, %.thread ]
  %.055 = phi i64 [ undef, %2 ], [ %.3, %.thread ]
  %30 = call noundef zeroext i1 @_Z12miller_rabinx(i64 noundef %29)
  br i1 %30, label %31, label %47

31:                                               ; preds = %28
  store i32 0, ptr @cnt, align 4, !tbaa !5
  %32 = load i64, ptr %1, align 8, !tbaa !9
  %33 = add nsw i64 %32, -1
  call void @_Z13decompositionx(i64 noundef %33)
  %34 = load i32, ptr @cnt, align 4, !tbaa !5
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %.lr.ph98, label %.critedge101

._crit_edge99:                                    ; preds = %.lr.ph98
  br i1 %42, label %.critedge101, label %._crit_edge99..thread_crit_edge

._crit_edge99..thread_crit_edge:                  ; preds = %._crit_edge99
  %.pre123 = load i64, ptr %1, align 8, !tbaa !9
  br label %.thread

.lr.ph98:                                         ; preds = %31, %.lr.ph98
  %indvars.iv117 = phi i64 [ %indvars.iv.next118, %.lr.ph98 ], [ 0, %31 ]
  %36 = load i64, ptr %1, align 8, !tbaa !9
  %37 = add nsw i64 %36, -1
  %38 = getelementptr inbounds [16 x i64], ptr @p, i64 0, i64 %indvars.iv117
  %39 = load i64, ptr %38, align 8, !tbaa !9
  %40 = sdiv i64 %37, %39
  %41 = call noundef i64 @_Z7mod_powxxx(i64 noundef 10, i64 noundef %40, i64 noundef %36)
  %42 = icmp ne i64 %41, 1
  %indvars.iv.next118 = add nuw nsw i64 %indvars.iv117, 1
  %43 = load i32, ptr @cnt, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = icmp slt i64 %indvars.iv.next118, %44
  %46 = and i1 %42, %45
  br i1 %46, label %.lr.ph98, label %._crit_edge99, !llvm.loop !18

47:                                               ; preds = %28
  %48 = load i64, ptr %1, align 8, !tbaa !9
  %49 = call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %48)
  %50 = fptosi double %49 to i64
  %51 = mul nsw i64 %50, %50
  %52 = load i64, ptr %1, align 8, !tbaa !9
  %53 = icmp eq i64 %51, %52
  br i1 %53, label %54, label %56

54:                                               ; preds = %47
  %55 = call noundef zeroext i1 @_Z12miller_rabinx(i64 noundef %50)
  br i1 %55, label %.thread78, label %._crit_edge120

._crit_edge120:                                   ; preds = %54
  %.pre121 = load i64, ptr %1, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %._crit_edge120, %47
  %57 = phi i64 [ %.pre121, %._crit_edge120 ], [ %52, %47 ]
  %58 = load i32, ptr @tot, align 4, !tbaa !5
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %.lr.ph88.preheader, label %.thread78

.lr.ph88.preheader:                               ; preds = %56
  %wide.trip.count = zext nneg i32 %58 to i64
  br label %.lr.ph88

60:                                               ; preds = %.lr.ph88
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %exitcond113.not = icmp eq i64 %indvars.iv.next111, %wide.trip.count
  br i1 %exitcond113.not, label %.thread78, label %.lr.ph88, !llvm.loop !19

.lr.ph88:                                         ; preds = %.lr.ph88.preheader, %60
  %indvars.iv110 = phi i64 [ 0, %.lr.ph88.preheader ], [ %indvars.iv.next111, %60 ]
  %61 = getelementptr inbounds [83333 x i32], ptr @prime, i64 0, i64 %indvars.iv110
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = srem i64 %57, %63
  %65 = icmp eq i64 %64, 0
  br i1 %65, label %.lr.ph90, label %60

.lr.ph90:                                         ; preds = %.lr.ph88, %.lr.ph90
  %.05689 = phi i64 [ %66, %.lr.ph90 ], [ %57, %.lr.ph88 ]
  %66 = sdiv i64 %.05689, %63
  %67 = srem i64 %66, %63
  %68 = icmp eq i64 %67, 0
  br i1 %68, label %.lr.ph90, label %._crit_edge, !llvm.loop !20

._crit_edge:                                      ; preds = %.lr.ph90
  %69 = icmp eq i64 %66, 1
  br i1 %69, label %.thread78, label %.thread

.thread78:                                        ; preds = %60, %56, %54, %._crit_edge
  %.282 = phi i64 [ %63, %._crit_edge ], [ %50, %54 ], [ %.055, %56 ], [ %.055, %60 ]
  store i32 0, ptr @cnt, align 4, !tbaa !5
  %70 = icmp sgt i64 %.282, 2
  br i1 %70, label %71, label %._crit_edge94.thread

71:                                               ; preds = %.thread78
  %72 = add nsw i64 %.282, -1
  call void @_Z13decompositionx(i64 noundef %72)
  %.pre122 = load i32, ptr @cnt, align 4, !tbaa !5
  %73 = icmp sgt i32 %.pre122, 0
  br i1 %73, label %.lr.ph93, label %._crit_edge94.thread

.lr.ph93:                                         ; preds = %71
  %74 = add nsw i64 %.282, -1
  br label %75

._crit_edge94.thread:                             ; preds = %71, %.thread78
  %.pre124129 = load i64, ptr %1, align 8, !tbaa !9
  br label %85

._crit_edge94:                                    ; preds = %75
  %.pre124 = load i64, ptr %1, align 8, !tbaa !9
  br i1 %80, label %85, label %.thread

75:                                               ; preds = %.lr.ph93, %75
  %indvars.iv114 = phi i64 [ 0, %.lr.ph93 ], [ %indvars.iv.next115, %75 ]
  %76 = getelementptr inbounds [16 x i64], ptr @p, i64 0, i64 %indvars.iv114
  %77 = load i64, ptr %76, align 8, !tbaa !9
  %78 = sdiv i64 %74, %77
  %79 = call noundef i64 @_Z7mod_powxxx(i64 noundef 10, i64 noundef %78, i64 noundef %.282)
  %80 = icmp ne i64 %79, 1
  %indvars.iv.next115 = add nuw nsw i64 %indvars.iv114, 1
  %81 = load i32, ptr @cnt, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = icmp slt i64 %indvars.iv.next115, %82
  %84 = and i1 %80, %83
  br i1 %84, label %75, label %._crit_edge94, !llvm.loop !21

85:                                               ; preds = %._crit_edge94.thread, %._crit_edge94
  %.pre124130 = phi i64 [ %.pre124129, %._crit_edge94.thread ], [ %.pre124, %._crit_edge94 ]
  %86 = sdiv i64 %.pre124130, %.282
  %87 = sub nsw i64 %.pre124130, %86
  %88 = icmp slt i64 %.066, %87
  %spec.select = call i64 @llvm.smax.i64(i64 %.066, i64 %87)
  %spec.select75 = select i1 %88, i64 %.pre124130, i64 %.062
  br label %.thread

.thread:                                          ; preds = %._crit_edge99..thread_crit_edge, %85, %._crit_edge, %._crit_edge94
  %89 = phi i64 [ %57, %._crit_edge ], [ %.pre124, %._crit_edge94 ], [ %.pre124130, %85 ], [ %.pre123, %._crit_edge99..thread_crit_edge ]
  %.369 = phi i64 [ %.066, %._crit_edge ], [ %.066, %._crit_edge94 ], [ %spec.select, %85 ], [ %.066, %._crit_edge99..thread_crit_edge ]
  %.365 = phi i64 [ %.062, %._crit_edge ], [ %.062, %._crit_edge94 ], [ %spec.select75, %85 ], [ %.062, %._crit_edge99..thread_crit_edge ]
  %.3 = phi i64 [ %63, %._crit_edge ], [ %.282, %._crit_edge94 ], [ %.282, %85 ], [ %.055, %._crit_edge99..thread_crit_edge ]
  %90 = add nsw i64 %89, -1
  store i64 %90, ptr %1, align 8, !tbaa !9
  br label %28, !llvm.loop !22

.critedge101:                                     ; preds = %31, %._crit_edge99
  %91 = load i64, ptr %1, align 8
  %92 = add nsw i64 %91, -1
  %93 = icmp slt i64 %.066, %92
  %94 = select i1 %93, i64 %91, i64 %.062
  %95 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %94)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) local_unnamed_addr #5

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !16}
!20 = distinct !{!20, !16}
!21 = distinct !{!21, !16}
!22 = distinct !{!22, !16}


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