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

; 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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Node, std::allocator<Node>>::_Vector_impl" }
%"struct.std::_Vector_base<Node, std::allocator<Node>>::_Vector_impl" = type { %"struct.std::_Vector_base<Node, std::allocator<Node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Node, std::allocator<Node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.Node = type { i32 }

@fact = external dso_local global [500001 x i32], align 16
@pw = external dso_local global [500001 x i32], align 16
@n = external dso_local global i32, align 4
@a = external dso_local global [500001 x i32], align 16
@b = external dso_local global [500001 x i32], align 16
@cnt = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@m = external dso_local global i64, align 8
@Q = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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.Node, align 4
  store i32 0, ptr %1, align 4
  store i32 1, ptr @pw, align 16, !tbaa !5
  store i32 1, ptr @fact, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %40, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 500001
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %43

13:                                               ; preds = %9
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sub nsw i32 %14, 1
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [500001 x i32], ptr @fact, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = mul nsw i64 %19, %21
  %23 = srem i64 %22, 1000000007
  %24 = trunc i64 %23 to i32
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [500001 x i32], ptr @fact, i64 0, i64 %26
  store i32 %24, ptr %27, align 4, !tbaa !5
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sub nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = mul nsw i64 2, %33
  %35 = srem i64 %34, 1000000007
  %36 = trunc i64 %35 to i32
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %38
  store i32 %36, ptr %39, align 4, !tbaa !5
  br label %40

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

43:                                               ; preds = %12
  br label %44

44:                                               ; preds = %251, %43
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %46 = icmp eq i32 %45, 2
  br i1 %46, label %47, label %254

47:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %69, %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %72

53:                                               ; preds = %48
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr @a, i64 %55
  %57 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %56)
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = icmp sgt i32 %59, 0
  %61 = zext i1 %60 to i32
  %62 = sub nsw i32 %58, %61
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [500001 x i32], ptr @b, i64 0, i64 %67
  store i32 %65, ptr %68, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %53
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %3, align 4, !tbaa !5
  br label %48, !llvm.loop !11

72:                                               ; preds = %52
  store i32 0, ptr @cnt, align 4, !tbaa !5
  store i32 0, ptr @ans, align 4, !tbaa !5
  %73 = load i32, ptr @a, align 16, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = load i64, ptr @m, align 8, !tbaa !12
  %76 = sub nsw i64 %75, %74
  store i64 %76, ptr @m, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %230, %72
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = icmp slt i32 %78, %79
  br i1 %80, label %82, label %81

81:                                               ; preds = %77
  store i32 10, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %233

82:                                               ; preds = %77
  %83 = load i64, ptr @m, align 8, !tbaa !12
  %84 = icmp slt i64 %83, 0
  br i1 %84, label %85, label %142

85:                                               ; preds = %82
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [500001 x i32], ptr @a, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = load i64, ptr @m, align 8, !tbaa !12
  %92 = sub nsw i64 %91, %90
  store i64 %92, ptr @m, align 8, !tbaa !12
  br label %93

93:                                               ; preds = %125, %85
  %94 = call noundef zeroext i1 @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %95 = xor i1 %94, true
  br i1 %95, label %96, label %126

96:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %97 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %98 = getelementptr inbounds %struct.Node, ptr %97, i32 0, i32 0
  %99 = load i32, ptr %98, align 4, !tbaa !14
  store i32 %99, ptr %6, align 4, !tbaa !5
  %100 = load i64, ptr @m, align 8, !tbaa !12
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [500001 x i32], ptr @a, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = add nsw i64 %100, %105
  %107 = icmp sge i64 %106, 0
  br i1 %107, label %108, label %109

108:                                              ; preds = %96
  store i32 14, ptr %5, align 4
  br label %123

109:                                              ; preds = %96
  call void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [500001 x i32], ptr @b, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = load i32, ptr @cnt, align 4, !tbaa !5
  %115 = sub nsw i32 %114, %113
  store i32 %115, ptr @cnt, align 4, !tbaa !5
  %116 = icmp slt i32 %115, 0
  br i1 %116, label %117, label %121

117:                                              ; preds = %109
  %118 = load i32, ptr @cnt, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1000000007
  store i32 %119, ptr @cnt, align 4, !tbaa !5
  %120 = icmp ne i32 %119, 0
  br label %121

121:                                              ; preds = %117, %109
  %122 = phi i1 [ false, %109 ], [ %120, %117 ]
  store i32 0, ptr %5, align 4
  br label %123

123:                                              ; preds = %121, %108
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %124 = load i32, ptr %5, align 4
  switch i32 %124, label %255 [
    i32 0, label %125
    i32 14, label %126
  ]

125:                                              ; preds = %123
  br label %93, !llvm.loop !16

126:                                              ; preds = %123, %93
  %127 = load i32, ptr @ans, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = load i32, ptr @cnt, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = load i32, ptr @n, align 4, !tbaa !5
  %132 = load i32, ptr %4, align 4, !tbaa !5
  %133 = sub nsw i32 %131, %132
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [500001 x i32], ptr @fact, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = mul nsw i64 %130, %137
  %139 = add nsw i64 %128, %138
  %140 = srem i64 %139, 1000000007
  %141 = trunc i64 %140 to i32
  store i32 %141, ptr @ans, align 4, !tbaa !5
  br label %229

142:                                              ; preds = %82
  %143 = load i32, ptr %4, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [500001 x i32], ptr @a, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = load i64, ptr @m, align 8, !tbaa !12
  %149 = sub nsw i64 %148, %147
  store i64 %149, ptr @m, align 8, !tbaa !12
  %150 = load i64, ptr @m, align 8, !tbaa !12
  %151 = icmp slt i64 %150, 0
  br i1 %151, label %152, label %209

152:                                              ; preds = %142
  br label %153

153:                                              ; preds = %157, %152
  %154 = call noundef zeroext i1 @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %155 = xor i1 %154, true
  br i1 %155, label %156, label %158

156:                                              ; preds = %153
  br label %157

157:                                              ; preds = %156
  call void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br label %153, !llvm.loop !17

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

159:                                              ; preds = %190, %158
  %160 = load i32, ptr %7, align 4, !tbaa !5
  %161 = load i32, ptr %4, align 4, !tbaa !5
  %162 = icmp sle i32 %160, %161
  br i1 %162, label %164, label %163

163:                                              ; preds = %159
  store i32 18, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %193

164:                                              ; preds = %159
  %165 = load i64, ptr @m, align 8, !tbaa !12
  %166 = load i32, ptr %7, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [500001 x i32], ptr @a, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = add nsw i64 %165, %170
  %172 = icmp sge i64 %171, 0
  br i1 %172, label %173, label %189

173:                                              ; preds = %164
  %174 = load i32, ptr %7, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [500001 x i32], ptr @b, i64 0, i64 %175
  %177 = load i32, ptr %176, align 4, !tbaa !5
  %178 = load i32, ptr @cnt, align 4, !tbaa !5
  %179 = add nsw i32 %178, %177
  store i32 %179, ptr @cnt, align 4, !tbaa !5
  %180 = icmp sge i32 %179, 1000000007
  br i1 %180, label %181, label %185

181:                                              ; preds = %173
  %182 = load i32, ptr @cnt, align 4, !tbaa !5
  %183 = sub nsw i32 %182, 1000000007
  store i32 %183, ptr @cnt, align 4, !tbaa !5
  %184 = icmp ne i32 %183, 0
  br label %185

185:                                              ; preds = %181, %173
  %186 = phi i1 [ false, %173 ], [ %184, %181 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %187 = getelementptr inbounds %struct.Node, ptr %8, i32 0, i32 0
  %188 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %188, ptr %187, align 4, !tbaa !14
  call void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %189

189:                                              ; preds = %185, %164
  br label %190

190:                                              ; preds = %189
  %191 = load i32, ptr %7, align 4, !tbaa !5
  %192 = add nsw i32 %191, 1
  store i32 %192, ptr %7, align 4, !tbaa !5
  br label %159, !llvm.loop !18

193:                                              ; preds = %163
  %194 = load i32, ptr @ans, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = load i32, ptr @cnt, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = load i32, ptr @n, align 4, !tbaa !5
  %199 = load i32, ptr %4, align 4, !tbaa !5
  %200 = sub nsw i32 %198, %199
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [500001 x i32], ptr @fact, i64 0, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !5
  %204 = sext i32 %203 to i64
  %205 = mul nsw i64 %197, %204
  %206 = add nsw i64 %195, %205
  %207 = srem i64 %206, 1000000007
  %208 = trunc i64 %207 to i32
  store i32 %208, ptr @ans, align 4, !tbaa !5
  br label %228

209:                                              ; preds = %142
  %210 = load i32, ptr @ans, align 4, !tbaa !5
  %211 = sext i32 %210 to i64
  %212 = load i32, ptr %4, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %213
  %215 = load i32, ptr %214, align 4, !tbaa !5
  %216 = sext i32 %215 to i64
  %217 = load i32, ptr @n, align 4, !tbaa !5
  %218 = load i32, ptr %4, align 4, !tbaa !5
  %219 = sub nsw i32 %217, %218
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [500001 x i32], ptr @fact, i64 0, i64 %220
  %222 = load i32, ptr %221, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = mul nsw i64 %216, %223
  %225 = add nsw i64 %211, %224
  %226 = srem i64 %225, 1000000007
  %227 = trunc i64 %226 to i32
  store i32 %227, ptr @ans, align 4, !tbaa !5
  br label %228

228:                                              ; preds = %209, %193
  br label %229

229:                                              ; preds = %228, %126
  br label %230

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

233:                                              ; preds = %81
  %234 = load i64, ptr @m, align 8, !tbaa !12
  %235 = icmp sge i64 %234, 0
  br i1 %235, label %236, label %251

236:                                              ; preds = %233
  %237 = load i32, ptr @n, align 4, !tbaa !5
  %238 = sub nsw i32 %237, 1
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  %242 = load i32, ptr @ans, align 4, !tbaa !5
  %243 = add nsw i32 %242, %241
  store i32 %243, ptr @ans, align 4, !tbaa !5
  %244 = icmp sge i32 %243, 1000000007
  br i1 %244, label %245, label %249

245:                                              ; preds = %236
  %246 = load i32, ptr @ans, align 4, !tbaa !5
  %247 = sub nsw i32 %246, 1000000007
  store i32 %247, ptr @ans, align 4, !tbaa !5
  %248 = icmp ne i32 %247, 0
  br label %249

249:                                              ; preds = %245, %236
  %250 = phi i1 [ false, %236 ], [ %248, %245 ]
  br label %251

251:                                              ; preds = %249, %233
  %252 = load i32, ptr @ans, align 4, !tbaa !5
  %253 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %252)
  br label %44, !llvm.loop !20

254:                                              ; preds = %44
  ret i32 0

255:                                              ; preds = %123
  unreachable
}

; 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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #4 align 2

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = { 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, !6, i64 0}
!15 = !{!"_ZTS4Node", !6, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Node, std::allocator<Node>>::_Vector_impl" }
%"struct.std::_Vector_base<Node, std::allocator<Node>>::_Vector_impl" = type { %"struct.std::_Vector_base<Node, std::allocator<Node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Node, std::allocator<Node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.Node = type { i32 }

@fact = external dso_local local_unnamed_addr global [500001 x i32], align 16
@pw = external dso_local local_unnamed_addr global [500001 x i32], align 16
@n = external dso_local global i32, align 4
@a = external dso_local global [500001 x i32], align 16
@b = external dso_local local_unnamed_addr global [500001 x i32], align 16
@cnt = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local global i64, align 8
@Q = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.Node, align 4
  store i32 1, ptr @pw, align 16, !tbaa !5
  store i32 1, ptr @fact, align 16, !tbaa !5
  br label %4

.preheader45:                                     ; preds = %4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %3 = icmp eq i32 %2, 2
  br i1 %3, label %.preheader44, label %._crit_edge57

4:                                                ; preds = %0, %4
  %5 = phi i64 [ 1, %0 ], [ %12, %4 ]
  %6 = phi i64 [ 1, %0 ], [ %8, %4 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %4 ]
  %7 = mul nsw i64 %6, %indvars.iv
  %8 = srem i64 %7, 1000000007
  %9 = trunc nsw i64 %8 to i32
  %10 = getelementptr inbounds [500001 x i32], ptr @fact, i64 0, i64 %indvars.iv
  store i32 %9, ptr %10, align 4, !tbaa !5
  %11 = shl nsw i64 %5, 1
  %12 = srem i64 %11, 1000000007
  %13 = trunc nsw i64 %12 to i32
  %14 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %indvars.iv
  store i32 %13, ptr %14, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 500001
  br i1 %exitcond.not, label %.preheader45, label %4, !llvm.loop !9

.preheader44:                                     ; preds = %.preheader45, %116
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader44
  %17 = phi i32 [ %15, %.preheader44 ], [ %31, %.lr.ph ]
  store i32 0, ptr @cnt, align 4, !tbaa !5
  store i32 0, ptr @ans, align 4, !tbaa !5
  %18 = load i32, ptr @a, align 16, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = load i64, ptr @m, align 8, !tbaa !11
  %21 = sub nsw i64 %20, %19
  store i64 %21, ptr @m, align 8, !tbaa !11
  %22 = icmp sgt i32 %17, 1
  br i1 %22, label %.lr.ph55, label %._crit_edge56

.lr.ph:                                           ; preds = %.preheader44, %.lr.ph
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %.lr.ph ], [ 0, %.preheader44 ]
  %23 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv60
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %23)
  %25 = icmp ne i64 %indvars.iv60, 0
  %.neg = sext i1 %25 to i64
  %26 = add i64 %indvars.iv60, %.neg
  %sext = shl i64 %26, 32
  %27 = ashr exact i64 %sext, 32
  %28 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = getelementptr inbounds [500001 x i32], ptr @b, i64 0, i64 %indvars.iv60
  store i32 %29, ptr %30, align 4, !tbaa !5
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = icmp slt i64 %indvars.iv.next61, %32
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge56.loopexit:                           ; preds = %94
  %.pre77 = load i64, ptr @m, align 8, !tbaa !11
  br label %._crit_edge56

._crit_edge56:                                    ; preds = %._crit_edge56.loopexit, %._crit_edge
  %34 = phi i32 [ 0, %._crit_edge ], [ %104, %._crit_edge56.loopexit ]
  %35 = phi i64 [ %21, %._crit_edge ], [ %.pre77, %._crit_edge56.loopexit ]
  %.lcssa = phi i32 [ %17, %._crit_edge ], [ %.sink87, %._crit_edge56.loopexit ]
  %36 = icmp sgt i64 %35, -1
  br i1 %36, label %107, label %116

.lr.ph55thread-pre-split:                         ; preds = %94
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %.pr = load i64, ptr @m, align 8, !tbaa !11
  br label %.lr.ph55

.lr.ph55:                                         ; preds = %._crit_edge, %.lr.ph55thread-pre-split
  %37 = phi i64 [ %.pr, %.lr.ph55thread-pre-split ], [ %21, %._crit_edge ]
  %38 = phi i32 [ %.sink87, %.lr.ph55thread-pre-split ], [ %17, %._crit_edge ]
  %39 = phi i64 [ %103, %.lr.ph55thread-pre-split ], [ 0, %._crit_edge ]
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %.lr.ph55thread-pre-split ], [ 1, %._crit_edge ]
  %indvars.iv69 = phi i64 [ %indvars.iv.next70, %.lr.ph55thread-pre-split ], [ 2, %._crit_edge ]
  %40 = icmp slt i64 %37, 0
  %41 = getelementptr inbounds [500001 x i32], ptr @a, i64 0, i64 %indvars.iv71
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = sub nsw i64 %37, %43
  store i64 %44, ptr @m, align 8, !tbaa !11
  br i1 %40, label %45, label %67

45:                                               ; preds = %.lr.ph55
  %46 = call noundef zeroext i1 @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %46, label %.thread, label %.lr.ph51

.lr.ph51:                                         ; preds = %45, %56
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %48 = load i32, ptr %47, align 4, !tbaa !14
  %49 = load i64, ptr @m, align 8, !tbaa !11
  %50 = sext i32 %48 to i64
  %51 = getelementptr inbounds [500001 x i32], ptr @a, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = add nsw i64 %49, %53
  %55 = icmp sgt i64 %54, -1
  br i1 %55, label %.thread, label %56

56:                                               ; preds = %.lr.ph51
  call void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %57 = getelementptr inbounds [500001 x i32], ptr @b, i64 0, i64 %50
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = load i32, ptr @cnt, align 4, !tbaa !5
  %60 = sub nsw i32 %59, %58
  %61 = icmp slt i32 %60, 0
  %62 = add nsw i32 %60, 1000000007
  %spec.select = select i1 %61, i32 %62, i32 %60
  store i32 %spec.select, ptr @cnt, align 4, !tbaa !5
  %63 = call noundef zeroext i1 @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %63, label %.thread, label %.lr.ph51

.thread:                                          ; preds = %56, %.lr.ph51, %45
  %64 = load i32, ptr @ans, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = load i32, ptr @n, align 4, !tbaa !5
  br label %94

67:                                               ; preds = %.lr.ph55
  %68 = icmp slt i64 %44, 0
  br i1 %68, label %.preheader43, label %92

.preheader43:                                     ; preds = %67
  %69 = call noundef zeroext i1 @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %69, label %.preheader, label %.lr.ph48

.preheader:                                       ; preds = %.lr.ph48, %.preheader43
  %.pre76 = load i64, ptr @m, align 8, !tbaa !11
  br label %75

.lr.ph48:                                         ; preds = %.preheader43, %.lr.ph48
  call void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %70 = call noundef zeroext i1 @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br i1 %70, label %.preheader, label %.lr.ph48, !llvm.loop !16

71:                                               ; preds = %90
  %72 = load i32, ptr @ans, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = load i32, ptr @n, align 4, !tbaa !5
  br label %94

75:                                               ; preds = %.preheader, %90
  %76 = phi i64 [ %.pre76, %.preheader ], [ %91, %90 ]
  %indvars.iv63 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next64, %90 ]
  %77 = getelementptr inbounds [500001 x i32], ptr @a, i64 0, i64 %indvars.iv63
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = add nsw i64 %76, %79
  %81 = icmp sgt i64 %80, -1
  br i1 %81, label %82, label %90

82:                                               ; preds = %75
  %83 = getelementptr inbounds [500001 x i32], ptr @b, i64 0, i64 %indvars.iv63
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = load i32, ptr @cnt, align 4, !tbaa !5
  %86 = add nsw i32 %85, %84
  %87 = icmp sgt i32 %86, 1000000006
  %88 = add nsw i32 %86, -1000000007
  %spec.select40 = select i1 %87, i32 %88, i32 %86
  store i32 %spec.select40, ptr @cnt, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %89 = trunc nuw nsw i64 %indvars.iv63 to i32
  store i32 %89, ptr %1, align 4, !tbaa !14
  call void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %.pre = load i64, ptr @m, align 8, !tbaa !11
  br label %90

90:                                               ; preds = %75, %82
  %91 = phi i64 [ %76, %75 ], [ %.pre, %82 ]
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %exitcond68.not = icmp eq i64 %indvars.iv.next64, %indvars.iv69
  br i1 %exitcond68.not, label %71, label %75, !llvm.loop !17

92:                                               ; preds = %67
  %93 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %indvars.iv71
  br label %94

94:                                               ; preds = %.thread, %92, %71
  %.sink87 = phi i32 [ %66, %.thread ], [ %38, %92 ], [ %74, %71 ]
  %.sink84.in.in = phi ptr [ @cnt, %.thread ], [ %93, %92 ], [ @cnt, %71 ]
  %.sink83 = phi i64 [ %65, %.thread ], [ %39, %92 ], [ %73, %71 ]
  %.sink84.in = load i32, ptr %.sink84.in.in, align 4, !tbaa !5
  %.sink84 = sext i32 %.sink84.in to i64
  %95 = trunc nuw nsw i64 %indvars.iv71 to i32
  %96 = sub nsw i32 %.sink87, %95
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [500001 x i32], ptr @fact, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = mul nsw i64 %100, %.sink84
  %102 = add nsw i64 %101, %.sink83
  %103 = srem i64 %102, 1000000007
  %104 = trunc nsw i64 %103 to i32
  store i32 %104, ptr @ans, align 4, !tbaa !5
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %105 = sext i32 %.sink87 to i64
  %106 = icmp slt i64 %indvars.iv.next72, %105
  br i1 %106, label %.lr.ph55thread-pre-split, label %._crit_edge56.loopexit, !llvm.loop !18

107:                                              ; preds = %._crit_edge56
  %108 = add nsw i32 %.lcssa, -1
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [500001 x i32], ptr @pw, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = add nsw i32 %34, %111
  store i32 %112, ptr @ans, align 4, !tbaa !5
  %113 = icmp sgt i32 %112, 1000000006
  br i1 %113, label %114, label %116

114:                                              ; preds = %107
  %115 = add nsw i32 %112, -1000000007
  store i32 %115, ptr @ans, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %107, %114, %._crit_edge56
  %117 = phi i32 [ %112, %107 ], [ %115, %114 ], [ %34, %._crit_edge56 ]
  %118 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %117)
  %119 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %120 = icmp eq i32 %119, 2
  br i1 %120, label %.preheader44, label %._crit_edge57, !llvm.loop !19

._crit_edge57:                                    ; preds = %116, %.preheader45
  ret i32 0
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueI4NodeSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 align 2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS4Node", !6, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


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