; LLVM IR from tangjz/acm-icpc :: Summer_Training/2016-07-17 (E - What is N - tjz)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@tot = external dso_local global i32, align 4
@prime = external dso_local global [100010 x i32], align 16
@phi = external dso_local global [100010 x i32], align 16
@t = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@m = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@preans = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 1, ptr getelementptr inbounds ([100010 x i32], ptr @phi, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %13

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

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

17:                                               ; preds = %13
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %34, label %23

23:                                               ; preds = %17
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sub nsw i32 %24, 1
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %27
  store i32 %25, ptr %28, align 4, !tbaa !5
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = load i32, ptr @tot, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @tot, align 4, !tbaa !5
  %32 = sext i32 %30 to i64
  %33 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %32
  store i32 %29, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %23, %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %98, %34
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = load i32, ptr @tot, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %49

39:                                               ; preds = %35
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = mul nsw i64 %41, %46
  %48 = icmp slt i64 %47, 100010
  br label %49

49:                                               ; preds = %39, %35
  %50 = phi i1 [ false, %35 ], [ %48, %39 ]
  br i1 %50, label %52, label %51

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

52:                                               ; preds = %49
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = srem i32 %53, %57
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %79

60:                                               ; preds = %52
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = mul nsw i32 %64, %69
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = mul nsw i32 %71, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %77
  store i32 %70, ptr %78, align 4, !tbaa !5
  br label %97

79:                                               ; preds = %52
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = mul nsw i32 %83, %87
  %89 = load i32, ptr %2, align 4, !tbaa !5
  %90 = load i32, ptr %4, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = mul nsw i32 %89, %93
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %95
  store i32 %88, ptr %96, align 4, !tbaa !5
  store i32 5, ptr %3, align 4
  br label %101

97:                                               ; preds = %60
  br label %98

98:                                               ; preds = %97
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %4, align 4, !tbaa !5
  br label %35, !llvm.loop !9

101:                                              ; preds = %79, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %102

102:                                              ; preds = %101
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %2, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !11

106:                                              ; preds = %16
  %107 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %253, %106
  %109 = load i32, ptr %5, align 4, !tbaa !5
  %110 = load i32, ptr @t, align 4, !tbaa !5
  %111 = icmp sle i32 %109, %110
  br i1 %111, label %113, label %112

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

113:                                              ; preds = %108
  %114 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @b)
  %115 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %114, ptr noundef nonnull align 4 dereferenceable(4) @p)
  %116 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16) %115, ptr noundef nonnull align 8 dereferenceable(8) @m)
  store i64 0, ptr @ans, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %117 = load i32, ptr @p, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  store i32 %120, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #6
  store i8 0, ptr %8, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #6
  store i8 0, ptr %9, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %121

121:                                              ; preds = %176, %113
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = load i32, ptr %6, align 4, !tbaa !5
  %124 = icmp slt i32 %122, %123
  br i1 %124, label %125, label %130

125:                                              ; preds = %121
  %126 = load i32, ptr %10, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = load i64, ptr @m, align 8, !tbaa !12
  %129 = icmp ule i64 %127, %128
  br label %130

130:                                              ; preds = %125, %121
  %131 = phi i1 [ false, %121 ], [ %129, %125 ]
  br i1 %131, label %133, label %132

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

133:                                              ; preds = %130
  %134 = load i32, ptr %10, align 4, !tbaa !5
  %135 = load i8, ptr %8, align 1, !tbaa !14, !range !16, !noundef !17
  %136 = trunc i8 %135 to i1
  br i1 %136, label %137, label %141

137:                                              ; preds = %133
  %138 = load i32, ptr %7, align 4, !tbaa !5
  %139 = load i32, ptr %6, align 4, !tbaa !5
  %140 = add nsw i32 %138, %139
  br label %143

141:                                              ; preds = %133
  %142 = load i32, ptr %7, align 4, !tbaa !5
  br label %143

143:                                              ; preds = %141, %137
  %144 = phi i32 [ %140, %137 ], [ %142, %141 ]
  %145 = call noundef i32 @_Z7mod_powii(i32 noundef %134, i32 noundef %144)
  %146 = load i32, ptr @b, align 4, !tbaa !5
  %147 = icmp eq i32 %145, %146
  br i1 %147, label %148, label %151

148:                                              ; preds = %143
  %149 = load i64, ptr @ans, align 8, !tbaa !12
  %150 = add i64 %149, 1
  store i64 %150, ptr @ans, align 8, !tbaa !12
  br label %151

151:                                              ; preds = %148, %143
  %152 = load i8, ptr %8, align 1, !tbaa !14, !range !16, !noundef !17
  %153 = trunc i8 %152 to i1
  br i1 %153, label %165, label %154

154:                                              ; preds = %151
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = load i32, ptr %10, align 4, !tbaa !5
  %158 = add nsw i32 %157, 1
  %159 = sext i32 %158 to i64
  %160 = mul nsw i64 %156, %159
  %161 = load i32, ptr %6, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = icmp sge i64 %160, %162
  br i1 %163, label %164, label %165

164:                                              ; preds = %154
  store i8 1, ptr %8, align 1, !tbaa !14
  br label %165

165:                                              ; preds = %164, %154, %151
  %166 = load i32, ptr %7, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = load i32, ptr %10, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  %170 = sext i32 %169 to i64
  %171 = mul nsw i64 %167, %170
  %172 = load i32, ptr %6, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = srem i64 %171, %173
  %175 = trunc i64 %174 to i32
  store i32 %175, ptr %7, align 4, !tbaa !5
  br label %176

176:                                              ; preds = %165
  %177 = load i32, ptr %10, align 4, !tbaa !5
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %10, align 4, !tbaa !5
  br label %121, !llvm.loop !18

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

180:                                              ; preds = %231, %179
  %181 = load i32, ptr %11, align 4, !tbaa !5
  %182 = load i32, ptr @p, align 4, !tbaa !5
  %183 = icmp slt i32 %181, %182
  br i1 %183, label %185, label %184

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

185:                                              ; preds = %180
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %186 = load i32, ptr %11, align 4, !tbaa !5
  %187 = load i32, ptr %6, align 4, !tbaa !5
  %188 = icmp slt i32 %186, %187
  br i1 %188, label %189, label %193

189:                                              ; preds = %185
  %190 = load i32, ptr %11, align 4, !tbaa !5
  %191 = load i32, ptr @p, align 4, !tbaa !5
  %192 = add nsw i32 %190, %191
  br label %195

193:                                              ; preds = %185
  %194 = load i32, ptr %11, align 4, !tbaa !5
  br label %195

195:                                              ; preds = %193, %189
  %196 = phi i32 [ %192, %189 ], [ %194, %193 ]
  store i32 %196, ptr %12, align 4, !tbaa !5
  %197 = load i32, ptr %12, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = load i64, ptr @m, align 8, !tbaa !12
  %200 = icmp ugt i64 %198, %199
  br i1 %200, label %201, label %202

201:                                              ; preds = %195
  store i32 16, ptr %3, align 4
  br label %228

202:                                              ; preds = %195
  %203 = load i32, ptr %11, align 4, !tbaa !5
  %204 = load i32, ptr %7, align 4, !tbaa !5
  %205 = load i32, ptr %6, align 4, !tbaa !5
  %206 = add nsw i32 %204, %205
  %207 = call noundef i32 @_Z7mod_powii(i32 noundef %203, i32 noundef %206)
  %208 = load i32, ptr @b, align 4, !tbaa !5
  %209 = icmp eq i32 %207, %208
  br i1 %209, label %210, label %227

210:                                              ; preds = %202
  %211 = load i64, ptr @ans, align 8, !tbaa !12
  store i64 %211, ptr @preans, align 8, !tbaa !12
  %212 = load i64, ptr @m, align 8, !tbaa !12
  %213 = load i32, ptr %12, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = sub i64 %212, %214
  %216 = load i32, ptr @p, align 4, !tbaa !5
  %217 = sext i32 %216 to i64
  %218 = udiv i64 %215, %217
  %219 = add i64 %218, 1
  %220 = load i64, ptr @ans, align 8, !tbaa !12
  %221 = add i64 %220, %219
  store i64 %221, ptr @ans, align 8, !tbaa !12
  %222 = load i64, ptr @preans, align 8, !tbaa !12
  %223 = load i64, ptr @ans, align 8, !tbaa !12
  %224 = icmp ugt i64 %222, %223
  br i1 %224, label %225, label %226

225:                                              ; preds = %210
  store i8 1, ptr %9, align 1, !tbaa !14
  br label %226

226:                                              ; preds = %225, %210
  br label %227

227:                                              ; preds = %226, %202
  store i32 0, ptr %3, align 4
  br label %228

228:                                              ; preds = %227, %201
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %229 = load i32, ptr %3, align 4
  switch i32 %229, label %257 [
    i32 0, label %230
    i32 16, label %231
  ]

230:                                              ; preds = %228
  br label %231

231:                                              ; preds = %230, %228
  %232 = load i32, ptr %11, align 4, !tbaa !5
  %233 = add nsw i32 %232, 1
  store i32 %233, ptr %11, align 4, !tbaa !5
  br label %180, !llvm.loop !19

234:                                              ; preds = %184
  %235 = load i8, ptr %9, align 1, !tbaa !14, !range !16, !noundef !17
  %236 = trunc i8 %235 to i1
  br i1 %236, label %237, label %244

237:                                              ; preds = %234
  %238 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %239 = load i32, ptr %5, align 4, !tbaa !5
  %240 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %238, i32 noundef %239)
  %241 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %240, ptr noundef @.str.1)
  %242 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %241, ptr noundef @.str.2)
  %243 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %242, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %252

244:                                              ; preds = %234
  %245 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %246 = load i32, ptr %5, align 4, !tbaa !5
  %247 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %245, i32 noundef %246)
  %248 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %247, ptr noundef @.str.1)
  %249 = load i64, ptr @ans, align 8, !tbaa !12
  %250 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEy(ptr noundef nonnull align 8 dereferenceable(8) %248, i64 noundef %249)
  %251 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %250, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %252

252:                                              ; preds = %244, %237
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %253

253:                                              ; preds = %252
  %254 = load i32, ptr %5, align 4, !tbaa !5
  %255 = add nsw i32 %254, 1
  store i32 %255, ptr %5, align 4, !tbaa !5
  br label %108, !llvm.loop !20

256:                                              ; preds = %112
  ret i32 0

257:                                              ; preds = %228
  unreachable
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEy(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #4 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 = { 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 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}


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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@tot = external dso_local local_unnamed_addr global i32, align 4
@prime = external dso_local local_unnamed_addr global [100010 x i32], align 16
@phi = external dso_local local_unnamed_addr global [100010 x i32], align 16
@t = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@m = external dso_local global i64, align 8
@ans = external dso_local local_unnamed_addr global i64, align 8
@preans = external dso_local local_unnamed_addr global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1

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

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

1:                                                ; preds = %.critedge
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @t)
  %3 = load i32, ptr @t, align 4, !tbaa !5
  %.not79 = icmp slt i32 %3, 1
  br i1 %.not79, label %._crit_edge83, label %.lr.ph82

4:                                                ; preds = %0, %.critedge
  %indvars.iv88 = phi i64 [ 2, %0 ], [ %indvars.iv.next89, %.critedge ]
  %5 = phi i32 [ %tot.promoted, %0 ], [ %16, %.critedge ]
  %6 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %indvars.iv88
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %.not64 = icmp eq i32 %7, 0
  br i1 %.not64, label %8, label %15

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

15:                                               ; preds = %8, %4
  %16 = phi i32 [ %11, %8 ], [ %5, %4 ]
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %15
  %wide.trip.count = zext nneg i32 %16 to i64
  %18 = trunc nuw nsw i64 %indvars.iv88 to i32
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %27
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %27 ]
  %19 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = mul nsw i64 %indvars.iv88, %21
  %23 = icmp slt i64 %22, 100010
  br i1 %23, label %24, label %.critedge

24:                                               ; preds = %.lr.ph
  %25 = srem i32 %18, %20
  %.not65 = icmp eq i32 %25, 0
  %26 = load i32, ptr %6, align 4, !tbaa !5
  br i1 %.not65, label %33, label %27

27:                                               ; preds = %24
  %28 = add nsw i32 %20, -1
  %29 = mul nsw i32 %26, %28
  %30 = mul nsw i32 %20, %18
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %31
  store i32 %29, ptr %32, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !9

33:                                               ; preds = %24
  %34 = mul nsw i32 %26, %20
  %35 = mul nsw i32 %20, %18
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %36
  store i32 %34, ptr %37, align 4, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %27, %.lr.ph, %15, %33
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %exitcond91.not = icmp eq i64 %indvars.iv.next89, 100010
  br i1 %exitcond91.not, label %1, label %4, !llvm.loop !11

._crit_edge83:                                    ; preds = %102, %1
  ret i32 0

.lr.ph82:                                         ; preds = %1, %102
  %.05880 = phi i32 [ %104, %102 ], [ 1, %1 ]
  %38 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @b)
  %39 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %38, ptr noundef nonnull align 4 dereferenceable(4) @p)
  %40 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16) %39, ptr noundef nonnull align 8 dereferenceable(8) @m)
  store i64 0, ptr @ans, align 8, !tbaa !12
  %41 = load i32, ptr @p, align 4
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100010 x i32], ptr @phi, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.lr.ph74, label %.preheader

.lr.ph74:                                         ; preds = %.lr.ph82
  %46 = zext nneg i32 %44 to i64
  %47 = zext nneg i32 %44 to i64
  br label %51

.preheader.loopexit:                              ; preds = %._crit_edge97
  %.pre = load i32, ptr @p, align 4
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.lr.ph82
  %48 = phi i32 [ %41, %.lr.ph82 ], [ %.pre, %.preheader.loopexit ]
  %.057.lcssa = phi i32 [ 1, %.lr.ph82 ], [ %62, %.preheader.loopexit ]
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %.lr.ph77, label %.critedge84

.lr.ph77:                                         ; preds = %.preheader
  %50 = add nsw i32 %.057.lcssa, %44
  %.pre95 = load i64, ptr @m, align 8, !tbaa !12
  br label %67

51:                                               ; preds = %.lr.ph74, %._crit_edge97
  %indvars.iv92 = phi i64 [ 0, %.lr.ph74 ], [ %.pre99, %._crit_edge97 ]
  %.05572 = phi i1 [ false, %.lr.ph74 ], [ %.156, %._crit_edge97 ]
  %.05771 = phi i32 [ 1, %.lr.ph74 ], [ %62, %._crit_edge97 ]
  %52 = select i1 %.05572, i32 %44, i32 0
  %53 = add nsw i32 %52, %.05771
  %54 = trunc nuw nsw i64 %indvars.iv92 to i32
  %55 = tail call noundef i32 @_Z7mod_powii(i32 noundef %54, i32 noundef %53)
  %56 = load i32, ptr @b, align 4, !tbaa !5
  %57 = icmp eq i32 %55, %56
  br i1 %57, label %58, label %._crit_edge97

58:                                               ; preds = %51
  %59 = load i64, ptr @ans, align 8, !tbaa !12
  %60 = add i64 %59, 1
  store i64 %60, ptr @ans, align 8, !tbaa !12
  br label %._crit_edge97

._crit_edge97:                                    ; preds = %58, %51
  %.pre98 = sext i32 %.05771 to i64
  %.pre99 = add nuw nsw i64 %indvars.iv92, 1
  %.pre100 = mul nsw i64 %.pre99, %.pre98
  %.not63 = icmp sge i64 %.pre100, %46
  %.156 = select i1 %.05572, i1 true, i1 %.not63
  %61 = srem i64 %.pre100, %46
  %62 = trunc nsw i64 %61 to i32
  %63 = icmp ult i64 %.pre99, %47
  %64 = load i64, ptr @m, align 8
  %65 = icmp ugt i64 %64, %indvars.iv92
  %66 = select i1 %63, i1 %65, i1 false
  br i1 %66, label %51, label %.preheader.loopexit, !llvm.loop !14

._crit_edge:                                      ; preds = %87
  br i1 %.2, label %92, label %.critedge84

67:                                               ; preds = %.lr.ph77, %87
  %68 = phi i32 [ %48, %.lr.ph77 ], [ %88, %87 ]
  %69 = phi i64 [ %.pre95, %.lr.ph77 ], [ %89, %87 ]
  %.05276 = phi i32 [ 0, %.lr.ph77 ], [ %90, %87 ]
  %.05475 = phi i1 [ false, %.lr.ph77 ], [ %.2, %87 ]
  %70 = icmp slt i32 %.05276, %44
  %71 = select i1 %70, i32 %68, i32 0
  %72 = add nsw i32 %71, %.05276
  %73 = sext i32 %72 to i64
  %74 = icmp ult i64 %69, %73
  br i1 %74, label %87, label %75

75:                                               ; preds = %67
  %76 = tail call noundef i32 @_Z7mod_powii(i32 noundef %.05276, i32 noundef %50)
  %77 = load i32, ptr @b, align 4, !tbaa !5
  %78 = icmp eq i32 %76, %77
  %.pre94 = load i64, ptr @m, align 8, !tbaa !12
  %.pre96 = load i32, ptr @p, align 4
  br i1 %78, label %79, label %87

79:                                               ; preds = %75
  %80 = load i64, ptr @ans, align 8, !tbaa !12
  store i64 %80, ptr @preans, align 8, !tbaa !12
  %81 = sub i64 %.pre94, %73
  %82 = sext i32 %.pre96 to i64
  %83 = udiv i64 %81, %82
  %84 = add i64 %80, 1
  %85 = add i64 %84, %83
  store i64 %85, ptr @ans, align 8, !tbaa !12
  %86 = icmp ugt i64 %80, %85
  %spec.select66 = select i1 %86, i1 true, i1 %.05475
  br label %87

87:                                               ; preds = %79, %75, %67
  %88 = phi i32 [ %68, %67 ], [ %.pre96, %75 ], [ %.pre96, %79 ]
  %89 = phi i64 [ %69, %67 ], [ %.pre94, %75 ], [ %.pre94, %79 ]
  %.2 = phi i1 [ %.05475, %67 ], [ %.05475, %75 ], [ %spec.select66, %79 ]
  %90 = add nuw nsw i32 %.05276, 1
  %91 = icmp slt i32 %90, %88
  br i1 %91, label %67, label %._crit_edge, !llvm.loop !15

92:                                               ; preds = %._crit_edge
  %93 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  %94 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %93, i32 noundef %.05880)
  %95 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %94, ptr noundef nonnull @.str.1)
  %96 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %95, ptr noundef nonnull @.str.2)
  br label %102

.critedge84:                                      ; preds = %.preheader, %._crit_edge
  %97 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  %98 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %97, i32 noundef %.05880)
  %99 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %98, ptr noundef nonnull @.str.1)
  %100 = load i64, ptr @ans, align 8, !tbaa !12
  %101 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEy(ptr noundef nonnull align 8 dereferenceable(8) %99, i64 noundef %100)
  br label %102

102:                                              ; preds = %.critedge84, %92
  %.sink = phi ptr [ %101, %.critedge84 ], [ %96, %92 ]
  %103 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %.sink, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %104 = add nuw nsw i32 %.05880, 1
  %105 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.05880, %105
  br i1 %.not.not, label %.lr.ph82, label %._crit_edge83, !llvm.loop !16
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERy(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEy(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #3 align 2

attributes #0 = { 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 #1 = { 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 #2 = { "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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress 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" }

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


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