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

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@prime = external dso_local global [100010 x i32], align 16
@fact = external dso_local global [100010 x i32], align 16
@cnt = external dso_local global [100010 x i32], align 16
@ans = external dso_local global i32, align 4
@vis = external dso_local global [100010 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

15:                                               ; preds = %11
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [100010 x i8], ptr @vis, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !9, !range !11, !noundef !12
  %20 = trunc i8 %19 to i1
  br i1 %20, label %45, label %21

21:                                               ; preds = %15
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr @tot, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr @tot, align 4, !tbaa !5
  %25 = sext i32 %23 to i64
  %26 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %25
  store i32 %22, ptr %26, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %27, ptr %4, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %40, %21
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 100010
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %28
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100010 x i8], ptr @vis, i64 0, i64 %34
  store i8 1, ptr %35, align 1, !tbaa !9
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100010 x i32], ptr @fact, i64 0, i64 %38
  store i32 %36, ptr %39, align 4, !tbaa !5
  br label %40

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

44:                                               ; preds = %31
  br label %45

45:                                               ; preds = %44, %15
  br label %46

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

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

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

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

56:                                               ; preds = %51
  store i32 1, ptr @ans, align 4, !tbaa !5
  %57 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.memset.p0.i64(ptr align 16 @cnt, i8 0, i64 400040, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 2, ptr %6, align 4, !tbaa !5
  br label %58

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

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

63:                                               ; preds = %58
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %65
  store i32 1, ptr %66, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %63
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %6, align 4, !tbaa !5
  br label %58, !llvm.loop !16

70:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %71 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %71, ptr %7, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %111, %70
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = icmp sge i32 %73, 2
  br i1 %74, label %76, label %75

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

76:                                               ; preds = %72
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100010 x i32], ptr @fact, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = load i32, ptr %7, align 4, !tbaa !5
  %82 = icmp ne i32 %80, %81
  br i1 %82, label %83, label %110

83:                                               ; preds = %76
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [100010 x i32], ptr @fact, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = add nsw i32 %94, %87
  store i32 %95, ptr %93, align 4, !tbaa !5
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [100010 x i32], ptr @fact, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = sdiv i32 %100, %104
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = add nsw i32 %108, %99
  store i32 %109, ptr %107, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %83, %76
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %7, align 4, !tbaa !5
  %113 = add nsw i32 %112, -1
  store i32 %113, ptr %7, align 4, !tbaa !5
  br label %72, !llvm.loop !17

114:                                              ; preds = %75
  %115 = load i32, ptr getelementptr inbounds ([100010 x i32], ptr @cnt, i64 0, i64 2), align 8, !tbaa !5
  %116 = add nsw i32 %115, -1
  store i32 %116, ptr getelementptr inbounds ([100010 x i32], ptr @cnt, i64 0, i64 2), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %117

117:                                              ; preds = %167, %114
  %118 = load i32, ptr %8, align 4, !tbaa !5
  %119 = load i32, ptr @tot, align 4, !tbaa !5
  %120 = icmp slt i32 %118, %119
  br i1 %120, label %122, label %121

121:                                              ; preds = %117
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %170

122:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %124
  store ptr %125, ptr %9, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %126 = load i32, ptr %8, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %130
  store ptr %131, ptr %10, align 8, !tbaa !18
  %132 = load ptr, ptr %10, align 8, !tbaa !18
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %136, label %135

135:                                              ; preds = %122
  store i32 19, ptr %3, align 4
  br label %164

136:                                              ; preds = %122
  %137 = load i32, ptr @ans, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = load ptr, ptr %9, align 8, !tbaa !18
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load ptr, ptr %10, align 8, !tbaa !18
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = sub nsw i32 %142, 1
  %144 = call noundef i32 @_Z7mod_powij(i32 noundef %140, i32 noundef %143)
  %145 = sext i32 %144 to i64
  %146 = mul nsw i64 %138, %145
  %147 = srem i64 %146, 1000000007
  %148 = load ptr, ptr %9, align 8, !tbaa !18
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = sub nsw i32 %149, 1
  %151 = sext i32 %150 to i64
  %152 = load ptr, ptr %10, align 8, !tbaa !18
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = mul nsw i64 %151, %154
  %156 = srem i64 %155, 1000000007
  %157 = load ptr, ptr %9, align 8, !tbaa !18
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = add nsw i64 %156, %159
  %161 = mul nsw i64 %147, %160
  %162 = srem i64 %161, 1000000007
  %163 = trunc i64 %162 to i32
  store i32 %163, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr %3, align 4
  br label %164

164:                                              ; preds = %136, %135
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %165 = load i32, ptr %3, align 4
  switch i32 %165, label %178 [
    i32 0, label %166
    i32 19, label %167
  ]

166:                                              ; preds = %164
  br label %167

167:                                              ; preds = %166, %164
  %168 = load i32, ptr %8, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %8, align 4, !tbaa !5
  br label %117, !llvm.loop !20

170:                                              ; preds = %121
  %171 = load i32, ptr %5, align 4, !tbaa !5
  %172 = load i32, ptr @ans, align 4, !tbaa !5
  %173 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %171, i32 noundef %172)
  br label %174

174:                                              ; preds = %170
  %175 = load i32, ptr %5, align 4, !tbaa !5
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %5, align 4, !tbaa !5
  br label %51, !llvm.loop !21

177:                                              ; preds = %55
  ret i32 0

178:                                              ; preds = %164
  unreachable
}

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

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

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!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 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = !{!19, !19, i64 0}
!19 = !{!"any pointer", !7, i64 0}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@prime = external dso_local local_unnamed_addr global [100010 x i32], align 16
@fact = external dso_local local_unnamed_addr global [100010 x i32], align 16
@cnt = external dso_local local_unnamed_addr global [100010 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@vis = external dso_local local_unnamed_addr global [100010 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

4:                                                ; preds = %0, %.loopexit
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next, %.loopexit ]
  %5 = phi i32 [ %tot.promoted, %0 ], [ %16, %.loopexit ]
  %6 = getelementptr inbounds [100010 x i8], ptr @vis, i64 0, i64 %indvars.iv
  %7 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %.loopexit, label %.lr.ph.preheader

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv63 = phi i64 [ %indvars.iv, %.lr.ph.preheader ], [ %indvars.iv.next64, %.lr.ph ]
  %13 = getelementptr inbounds [100010 x i8], ptr @vis, i64 0, i64 %indvars.iv63
  store i8 1, ptr %13, align 1, !tbaa !9
  %14 = getelementptr inbounds [100010 x i32], ptr @fact, i64 0, i64 %indvars.iv63
  store i32 %12, ptr %14, align 4, !tbaa !5
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, %indvars.iv
  %15 = icmp ult i64 %indvars.iv.next64, 100010
  br i1 %15, label %.lr.ph, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph, %4
  %16 = phi i32 [ %5, %4 ], [ %9, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100010
  br i1 %exitcond.not, label %1, label %4, !llvm.loop !15

._crit_edge62:                                    ; preds = %._crit_edge57, %1
  ret i32 0

.lr.ph61:                                         ; preds = %1, %._crit_edge57
  %.03859 = phi i32 [ %51, %._crit_edge57 ], [ 1, %1 ]
  store i32 1, ptr @ans, align 4, !tbaa !5
  %17 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400040) @cnt, i8 0, i64 400040, i1 false)
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %.not4349 = icmp slt i32 %18, 2
  br i1 %.not4349, label %._crit_edge, label %.lr.ph51.preheader

.lr.ph51.preheader:                               ; preds = %.lr.ph61
  %19 = add nuw i32 %18, 1
  %wide.trip.count = zext i32 %19 to i64
  %20 = add nsw i64 %wide.trip.count, -2
  %min.iters.check = icmp ult i64 %20, 8
  br i1 %min.iters.check, label %.lr.ph51.preheader77, label %vector.ph

.lr.ph51.preheader77:                             ; preds = %middle.block, %.lr.ph51.preheader
  %indvars.iv67.ph = phi i64 [ 2, %.lr.ph51.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph51

vector.ph:                                        ; preds = %.lr.ph51.preheader
  %n.vec = and i64 %20, -8
  %ind.end = or disjoint i64 %n.vec, 2
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 2
  %21 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %offset.idx
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %21, align 8, !tbaa !5
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %22, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %20, %n.vec
  br i1 %cmp.n, label %.lr.ph53.preheader, label %.lr.ph51.preheader77

.lr.ph53.preheader:                               ; preds = %.lr.ph51, %middle.block
  %24 = zext nneg i32 %18 to i64
  br label %.lr.ph53

.lr.ph51:                                         ; preds = %.lr.ph51.preheader77, %.lr.ph51
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %.lr.ph51 ], [ %indvars.iv67.ph, %.lr.ph51.preheader77 ]
  %25 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %indvars.iv67
  store i32 1, ptr %25, align 4, !tbaa !5
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond70.not = icmp eq i64 %indvars.iv.next68, %wide.trip.count
  br i1 %exitcond70.not, label %.lr.ph53.preheader, label %.lr.ph51, !llvm.loop !19

._crit_edge:                                      ; preds = %47, %.lr.ph61
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @cnt, i64 8), align 8, !tbaa !5
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr getelementptr inbounds (i8, ptr @cnt, i64 8), align 8, !tbaa !5
  %28 = load i32, ptr @tot, align 4, !tbaa !5
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %.lr.ph56, label %._crit_edge57

.lr.ph53:                                         ; preds = %.lr.ph53.preheader, %47
  %indvars.iv71 = phi i64 [ %24, %.lr.ph53.preheader ], [ %indvars.iv.next72, %47 ]
  %30 = getelementptr inbounds [100010 x i32], ptr @fact, i64 0, i64 %indvars.iv71
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = zext i32 %31 to i64
  %.not45 = icmp eq i64 %indvars.iv71, %32
  br i1 %.not45, label %47, label %33

33:                                               ; preds = %.lr.ph53
  %34 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %indvars.iv71
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sext i32 %31 to i64
  %37 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = add nsw i32 %38, %35
  store i32 %39, ptr %37, align 4, !tbaa !5
  %40 = load i32, ptr %34, align 4, !tbaa !5
  %41 = trunc nuw nsw i64 %indvars.iv71 to i32
  %42 = sdiv i32 %41, %31
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = add nsw i32 %45, %40
  store i32 %46, ptr %44, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %.lr.ph53, %33
  %indvars.iv.next72 = add nsw i64 %indvars.iv71, -1
  %48 = icmp sgt i64 %indvars.iv71, 2
  br i1 %48, label %.lr.ph53, label %._crit_edge, !llvm.loop !20

._crit_edge57:                                    ; preds = %79, %._crit_edge
  %49 = load i32, ptr @ans, align 4, !tbaa !5
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.03859, i32 noundef %49)
  %51 = add nuw nsw i32 %.03859, 1
  %52 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.03859, %52
  br i1 %.not.not, label %.lr.ph61, label %._crit_edge62, !llvm.loop !21

.lr.ph56:                                         ; preds = %._crit_edge, %79
  %53 = phi i32 [ %80, %79 ], [ %28, %._crit_edge ]
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %79 ], [ 0, %._crit_edge ]
  %54 = getelementptr inbounds [100010 x i32], ptr @prime, i64 0, i64 %indvars.iv74
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100010 x i32], ptr @cnt, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %.not44 = icmp eq i32 %58, 0
  br i1 %.not44, label %79, label %59

59:                                               ; preds = %.lr.ph56
  %60 = load i32, ptr @ans, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = add nsw i32 %58, -1
  %63 = tail call noundef i32 @_Z7mod_powij(i32 noundef %55, i32 noundef %62)
  %64 = sext i32 %63 to i64
  %65 = mul nsw i64 %64, %61
  %66 = srem i64 %65, 1000000007
  %67 = load i32, ptr %54, align 4, !tbaa !5
  %68 = add nsw i32 %67, -1
  %69 = sext i32 %68 to i64
  %70 = load i32, ptr %57, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = mul nsw i64 %69, %71
  %73 = srem i64 %72, 1000000007
  %74 = sext i32 %67 to i64
  %75 = add nsw i64 %73, %74
  %76 = mul nsw i64 %75, %66
  %77 = srem i64 %76, 1000000007
  %78 = trunc nsw i64 %77 to i32
  store i32 %78, ptr @ans, align 4, !tbaa !5
  %.pre = load i32, ptr @tot, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %.lr.ph56, %59
  %80 = phi i32 [ %53, %.lr.ph56 ], [ %.pre, %59 ]
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %81 = sext i32 %80 to i64
  %82 = icmp slt i64 %indvars.iv.next75, %81
  br i1 %82, label %.lr.ph56, label %._crit_edge57, !llvm.loop !22
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 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 = { 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 nocallback nofree nounwind willreturn memory(argmem: write) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!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 = distinct !{!16, !14, !17, !18}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = distinct !{!19, !14, !18, !17}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass