; LLVM IR from tangjz/acm-icpc :: codeforces/complete (906D)

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

@tot = external dso_local global i32, align 4
@pr = external dso_local global [31623 x i32], align 16
@d = external dso_local global [31623 x i32], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@mod = external dso_local global [61 x i32], align 16
@a = external dso_local global [100001 x i32], align 16
@q = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 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 nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powiii(i32 noundef, 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 nounwind uwtable
declare dso_local noundef i32 @_Z7int_powii(i32 noundef, i32 noundef) #0

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

; 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 i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  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 %14

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

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

18:                                               ; preds = %14
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [31623 x i32], ptr @d, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %33, label %24

24:                                               ; preds = %18
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [31623 x i32], ptr @d, i64 0, i64 %27
  store i32 %25, ptr %28, align 4, !tbaa !5
  %29 = load i32, ptr @tot, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr @tot, align 4, !tbaa !5
  %31 = sext i32 %29 to i64
  %32 = getelementptr inbounds [31623 x i32], ptr @pr, i64 0, i64 %31
  store i32 %25, ptr %32, align 4, !tbaa !5
  br label %33

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

34:                                               ; preds = %62, %33
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [31623 x i32], ptr @pr, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = mul nsw i32 %35, %39
  store i32 %40, ptr %5, align 4, !tbaa !5
  %41 = icmp slt i32 %40, 31623
  br i1 %41, label %43, label %42

42:                                               ; preds = %34
  store i32 5, ptr %3, align 4
  br label %65

43:                                               ; preds = %34
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [31623 x i32], ptr @pr, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [31623 x i32], ptr @d, i64 0, i64 %49
  store i32 %47, ptr %50, align 4, !tbaa !5
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [31623 x i32], ptr @d, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [31623 x i32], ptr @pr, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = icmp eq i32 %54, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %43
  store i32 5, ptr %3, align 4
  br label %65

61:                                               ; preds = %43
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %4, align 4, !tbaa !5
  br label %34, !llvm.loop !9

65:                                               ; preds = %60, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !11

70:                                               ; preds = %17
  %71 = load i32, ptr @tot, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [31623 x i32], ptr @pr, i64 0, i64 %72
  store i32 31623, ptr %73, align 4, !tbaa !5
  %74 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @mod)
  store i32 1, ptr @m, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %83, %70
  %76 = load i32, ptr @m, align 4, !tbaa !5
  %77 = sub nsw i32 %76, 1
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = icmp sgt i32 %80, 1
  br i1 %81, label %82, label %95

82:                                               ; preds = %75
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr @m, align 4, !tbaa !5
  %85 = sub nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = call noundef i32 @_Z3phii(i32 noundef %88)
  %90 = load i32, ptr @m, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %91
  store i32 %89, ptr %92, align 4, !tbaa !5
  %93 = load i32, ptr @m, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr @m, align 4, !tbaa !5
  br label %75, !llvm.loop !12

95:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %106, %95
  %97 = load i32, ptr %6, align 4, !tbaa !5
  %98 = load i32, ptr @n, align 4, !tbaa !5
  %99 = icmp sle i32 %97, %98
  br i1 %99, label %101, label %100

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

101:                                              ; preds = %96
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds i32, ptr @a, i64 %103
  %105 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %104)
  br label %106

106:                                              ; preds = %101
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %6, align 4, !tbaa !5
  br label %96, !llvm.loop !13

109:                                              ; preds = %100
  %110 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @q)
  br label %111

111:                                              ; preds = %192, %109
  %112 = load i32, ptr @q, align 4, !tbaa !5
  %113 = add nsw i32 %112, -1
  store i32 %113, ptr @q, align 4, !tbaa !5
  %114 = icmp ne i32 %112, 0
  br i1 %114, label %115, label %195

115:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %116 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %7, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %117 = load i32, ptr %7, align 4, !tbaa !5
  %118 = load i32, ptr @m, align 4, !tbaa !5
  %119 = add nsw i32 %117, %118
  %120 = sub nsw i32 %119, 1
  store i32 %120, ptr %9, align 4, !tbaa !5
  %121 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %122 = load i32, ptr %121, align 4, !tbaa !5
  store i32 %122, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  store i8 0, ptr %10, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 1, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = load i32, ptr %7, align 4, !tbaa !5
  %125 = sub nsw i32 %123, %124
  store i32 %125, ptr %12, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %189, %115
  %127 = load i32, ptr %12, align 4, !tbaa !5
  %128 = icmp sge i32 %127, 0
  br i1 %128, label %130, label %129

129:                                              ; preds = %126
  store i32 16, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %192

130:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %131 = load i32, ptr %11, align 4, !tbaa !5
  %132 = load i8, ptr %10, align 1, !tbaa !14, !range !16, !noundef !17
  %133 = trunc i8 %132 to i1
  %134 = zext i1 %133 to i32
  %135 = load i32, ptr %12, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = mul nsw i32 %134, %139
  %141 = add nsw i32 %131, %140
  store i32 %141, ptr %13, align 4, !tbaa !5
  %142 = load i32, ptr %7, align 4, !tbaa !5
  %143 = load i32, ptr %12, align 4, !tbaa !5
  %144 = add nsw i32 %142, %143
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = load i32, ptr %13, align 4, !tbaa !5
  %149 = call noundef double @_ZSt3powIiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef %147, i32 noundef %148)
  %150 = fcmp olt double %149, 0x41CF9F9F9F800000
  br i1 %150, label %151, label %175

151:                                              ; preds = %130
  %152 = load i32, ptr %7, align 4, !tbaa !5
  %153 = load i32, ptr %12, align 4, !tbaa !5
  %154 = add nsw i32 %152, %153
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = load i32, ptr %13, align 4, !tbaa !5
  %159 = call noundef i32 @_Z7int_powii(i32 noundef %157, i32 noundef %158)
  store i32 %159, ptr %11, align 4, !tbaa !5
  %160 = load i32, ptr %11, align 4, !tbaa !5
  %161 = load i32, ptr %12, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = icmp sge i32 %160, %164
  br i1 %165, label %166, label %173

166:                                              ; preds = %151
  %167 = load i32, ptr %12, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = load i32, ptr %11, align 4, !tbaa !5
  %172 = srem i32 %171, %170
  store i32 %172, ptr %11, align 4, !tbaa !5
  store i8 1, ptr %10, align 1, !tbaa !14
  br label %174

173:                                              ; preds = %151
  store i8 0, ptr %10, align 1, !tbaa !14
  br label %174

174:                                              ; preds = %173, %166
  br label %188

175:                                              ; preds = %130
  %176 = load i32, ptr %7, align 4, !tbaa !5
  %177 = load i32, ptr %12, align 4, !tbaa !5
  %178 = add nsw i32 %176, %177
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = load i32, ptr %13, align 4, !tbaa !5
  %183 = load i32, ptr %12, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !5
  %187 = call noundef i32 @_Z7mod_powiii(i32 noundef %181, i32 noundef %182, i32 noundef %186)
  store i32 %187, ptr %11, align 4, !tbaa !5
  store i8 1, ptr %10, align 1, !tbaa !14
  br label %188

188:                                              ; preds = %175, %174
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %189

189:                                              ; preds = %188
  %190 = load i32, ptr %12, align 4, !tbaa !5
  %191 = add nsw i32 %190, -1
  store i32 %191, ptr %12, align 4, !tbaa !5
  br label %126, !llvm.loop !18

192:                                              ; preds = %129
  %193 = load i32, ptr %11, align 4, !tbaa !5
  %194 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %193)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %111, !llvm.loop !19

195:                                              ; preds = %111
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i32 noundef) #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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !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"

@tot = external dso_local local_unnamed_addr global i32, align 4
@pr = external dso_local local_unnamed_addr global [31623 x i32], align 16
@d = external dso_local local_unnamed_addr global [31623 x i32], align 16
@n = external dso_local global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@mod = external dso_local global [61 x i32], align 16
@a = external dso_local global [100001 x i32], align 16
@q = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 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 nounwind uwtable
declare dso_local noundef i32 @_Z7mod_powiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7int_powii(i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

4:                                                ; preds = %._crit_edge
  %5 = sext i32 %19 to i64
  %6 = getelementptr inbounds [31623 x i32], ptr @pr, i64 0, i64 %5
  store i32 31623, ptr %6, align 4, !tbaa !5
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @mod)
  store i32 1, ptr @m, align 4, !tbaa !5
  %8 = load i32, ptr @mod, align 16, !tbaa !5
  %9 = icmp sgt i32 %8, 1
  br i1 %9, label %.lr.ph50, label %.preheader

10:                                               ; preds = %0, %._crit_edge
  %indvars.iv66 = phi i64 [ 2, %0 ], [ %indvars.iv.next67, %._crit_edge ]
  %11 = phi i32 [ %tot.promoted, %0 ], [ %19, %._crit_edge ]
  %12 = getelementptr inbounds [31623 x i32], ptr @d, i64 0, i64 %indvars.iv66
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %.not45 = icmp eq i32 %13, 0
  %14 = trunc nuw nsw i64 %indvars.iv66 to i32
  br i1 %.not45, label %15, label %._crit_edge74

15:                                               ; preds = %10
  store i32 %14, ptr %12, align 4, !tbaa !5
  %16 = add nsw i32 %11, 1
  store i32 %16, ptr @tot, align 4, !tbaa !5
  %17 = sext i32 %11 to i64
  %18 = getelementptr inbounds [31623 x i32], ptr @pr, i64 0, i64 %17
  store i32 %14, ptr %18, align 4, !tbaa !5
  br label %._crit_edge74

._crit_edge74:                                    ; preds = %10, %15
  %19 = phi i32 [ %16, %15 ], [ %11, %10 ]
  %20 = load i32, ptr @pr, align 16, !tbaa !5
  %21 = mul nsw i32 %20, %14
  %22 = icmp slt i32 %21, 31623
  br i1 %22, label %.lr.ph, label %._crit_edge

23:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = getelementptr inbounds [31623 x i32], ptr @pr, i64 0, i64 %indvars.iv.next
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = mul nsw i32 %25, %14
  %27 = icmp slt i32 %26, 31623
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph:                                           ; preds = %._crit_edge74, %23
  %indvars.iv = phi i64 [ %indvars.iv.next, %23 ], [ 0, %._crit_edge74 ]
  %28 = phi i32 [ %26, %23 ], [ %21, %._crit_edge74 ]
  %29 = phi i32 [ %25, %23 ], [ %20, %._crit_edge74 ]
  %30 = sext i32 %28 to i64
  %31 = getelementptr inbounds [31623 x i32], ptr @d, i64 0, i64 %30
  store i32 %29, ptr %31, align 4, !tbaa !5
  %32 = load i32, ptr %12, align 4, !tbaa !5
  %33 = icmp eq i32 %32, %29
  br i1 %33, label %._crit_edge, label %23

._crit_edge:                                      ; preds = %23, %.lr.ph, %._crit_edge74
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next67, 31623
  br i1 %exitcond.not, label %4, label %10, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph50, %4
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %.not51 = icmp slt i32 %34, 1
  br i1 %.not51, label %._crit_edge54, label %.lr.ph53

.lr.ph50:                                         ; preds = %4, %.lr.ph50
  %35 = phi i32 [ %36, %.lr.ph50 ], [ %8, %4 ]
  %36 = tail call noundef i32 @_Z3phii(i32 noundef %35)
  %37 = load i32, ptr @m, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %38
  store i32 %36, ptr %39, align 4, !tbaa !5
  %40 = add nsw i32 %37, 1
  store i32 %40, ptr @m, align 4, !tbaa !5
  %41 = icmp sgt i32 %36, 1
  br i1 %41, label %.lr.ph50, label %.preheader, !llvm.loop !12

._crit_edge54:                                    ; preds = %.lr.ph53, %.preheader
  %42 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @q)
  %43 = load i32, ptr @q, align 4, !tbaa !5
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr @q, align 4, !tbaa !5
  %.not4361 = icmp eq i32 %43, 0
  br i1 %.not4361, label %._crit_edge64, label %.lr.ph63

.lr.ph53:                                         ; preds = %.preheader, %.lr.ph53
  %indvars.iv69 = phi i64 [ %indvars.iv.next70, %.lr.ph53 ], [ 1, %.preheader ]
  %45 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv69
  %46 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %45)
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %47 = load i32, ptr @n, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %.not.not = icmp slt i64 %indvars.iv69, %48
  br i1 %.not.not, label %.lr.ph53, label %._crit_edge54, !llvm.loop !13

.lr.ph63:                                         ; preds = %._crit_edge54, %._crit_edge60
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %49 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %50 = load i32, ptr %1, align 4, !tbaa !5
  %51 = load i32, ptr @m, align 4, !tbaa !5
  %52 = add i32 %50, -1
  %53 = add i32 %52, %51
  store i32 %53, ptr %3, align 4, !tbaa !5
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %55 = load i32, ptr %54, align 4, !tbaa !5
  store i32 %55, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %56 = load i32, ptr %1, align 4, !tbaa !5
  %57 = sub nsw i32 %55, %56
  %58 = icmp sgt i32 %57, -1
  br i1 %58, label %.lr.ph59.preheader, label %._crit_edge60

.lr.ph59.preheader:                               ; preds = %.lr.ph63
  %59 = zext nneg i32 %57 to i64
  br label %.lr.ph59

._crit_edge60:                                    ; preds = %91, %.lr.ph63
  %.033.lcssa = phi i32 [ 1, %.lr.ph63 ], [ %.1, %91 ]
  %60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.033.lcssa)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %61 = load i32, ptr @q, align 4, !tbaa !5
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr @q, align 4, !tbaa !5
  %.not43 = icmp eq i32 %61, 0
  br i1 %.not43, label %._crit_edge64, label %.lr.ph63, !llvm.loop !14

.lr.ph59:                                         ; preds = %.lr.ph59.preheader, %91
  %indvars.iv72 = phi i64 [ %59, %.lr.ph59.preheader ], [ %indvars.iv.next73, %91 ]
  %.03356 = phi i32 [ 1, %.lr.ph59.preheader ], [ %.1, %91 ]
  %.03455 = phi i1 [ false, %.lr.ph59.preheader ], [ %.135, %91 ]
  %63 = add nuw nsw i64 %indvars.iv72, 1
  %64 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = select i1 %.03455, i32 %65, i32 0
  %67 = add nsw i32 %66, %.03356
  %68 = load i32, ptr %1, align 4, !tbaa !5
  %69 = trunc nuw i64 %indvars.iv72 to i32
  %70 = add nsw i32 %68, %69
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = call noundef double @_ZSt3powIiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef %73, i32 noundef %67)
  %75 = fcmp olt double %74, 0x41CF9F9F9F800000
  %76 = load i32, ptr %1, align 4, !tbaa !5
  %77 = add nsw i32 %76, %69
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  br i1 %75, label %81, label %87

81:                                               ; preds = %.lr.ph59
  %82 = call noundef i32 @_Z7int_powii(i32 noundef %80, i32 noundef %67)
  %83 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %indvars.iv72
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %.not44 = icmp slt i32 %82, %84
  br i1 %.not44, label %91, label %85

85:                                               ; preds = %81
  %86 = srem i32 %82, %84
  br label %91

87:                                               ; preds = %.lr.ph59
  %88 = getelementptr inbounds [61 x i32], ptr @mod, i64 0, i64 %indvars.iv72
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = call noundef i32 @_Z7mod_powiii(i32 noundef %80, i32 noundef %67, i32 noundef %89)
  br label %91

91:                                               ; preds = %81, %85, %87
  %.135 = phi i1 [ true, %85 ], [ true, %87 ], [ false, %81 ]
  %.1 = phi i32 [ %86, %85 ], [ %90, %87 ], [ %82, %81 ]
  %92 = icmp sgt i32 %69, 0
  %indvars.iv.next73 = add nsw i64 %indvars.iv72, -1
  br i1 %92, label %.lr.ph59, label %._crit_edge60, !llvm.loop !15

._crit_edge64:                                    ; preds = %._crit_edge60, %._crit_edge54
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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