; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/CROC 2016 - Elimination Round (Rated Unofficial Edition)/Problem F (F)

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

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@f = external dso_local global [200100 x i64], align 16
@invf = external dso_local global [200100 x i64], align 16
@p = external dso_local global [1001000 x i32], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %34

18:                                               ; preds = %14
  %19 = load i32, ptr %2, align 4, !tbaa !9
  %20 = sub nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [200100 x i64], ptr @f, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = mul nsw i64 %23, %25
  %27 = srem i64 %26, 1000000007
  %28 = load i32, ptr %2, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [200100 x i64], ptr @f, i64 0, i64 %29
  store i64 %27, ptr %30, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %18
  %32 = load i32, ptr %2, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !9
  br label %14, !llvm.loop !11

34:                                               ; preds = %17
  %35 = load i64, ptr getelementptr inbounds ([200100 x i64], ptr @f, i64 0, i64 200099), align 8, !tbaa !5
  %36 = call noundef i64 @_Z4fastxx(i64 noundef %35, i64 noundef 1000000005)
  store i64 %36, ptr getelementptr inbounds ([200100 x i64], ptr @invf, i64 0, i64 200099), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 200098, ptr %3, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %55, %34
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = icmp sge i32 %38, 0
  br i1 %39, label %41, label %40

40:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %58

41:                                               ; preds = %37
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [200100 x i64], ptr @invf, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = mul nsw i64 %46, %49
  %51 = srem i64 %50, 1000000007
  %52 = load i32, ptr %3, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [200100 x i64], ptr @invf, i64 0, i64 %53
  store i64 %51, ptr %54, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %41
  %56 = load i32, ptr %3, align 4, !tbaa !9
  %57 = add nsw i32 %56, -1
  store i32 %57, ptr %3, align 4, !tbaa !9
  br label %37, !llvm.loop !13

58:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %68, %58
  %60 = load i32, ptr %4, align 4, !tbaa !9
  %61 = icmp slt i32 %60, 1001000
  br i1 %61, label %63, label %62

62:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %71

63:                                               ; preds = %59
  %64 = load i32, ptr %4, align 4, !tbaa !9
  %65 = load i32, ptr %4, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %66
  store i32 %64, ptr %67, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %63
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %4, align 4, !tbaa !9
  br label %59, !llvm.loop !14

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

72:                                               ; preds = %99, %71
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = icmp slt i32 %73, 1001000
  br i1 %74, label %76, label %75

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

76:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %77 = load i32, ptr %5, align 4, !tbaa !9
  %78 = load i32, ptr %5, align 4, !tbaa !9
  %79 = add nsw i32 %77, %78
  store i32 %79, ptr %7, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %94, %76
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = icmp slt i32 %81, 1001000
  br i1 %82, label %84, label %83

83:                                               ; preds = %80
  store i32 14, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %98

84:                                               ; preds = %80
  %85 = load i32, ptr %5, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !9
  %93 = sub nsw i32 %92, %88
  store i32 %93, ptr %91, align 4, !tbaa !9
  br label %94

94:                                               ; preds = %84
  %95 = load i32, ptr %5, align 4, !tbaa !9
  %96 = load i32, ptr %7, align 4, !tbaa !9
  %97 = add nsw i32 %96, %95
  store i32 %97, ptr %7, align 4, !tbaa !9
  br label %80, !llvm.loop !15

98:                                               ; preds = %83
  br label %99

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

102:                                              ; preds = %75
  %103 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @k, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %104

104:                                              ; preds = %139, %102
  %105 = load i32, ptr %10, align 4, !tbaa !9
  %106 = load i32, ptr @n, align 4, !tbaa !9
  %107 = icmp sle i32 %105, %106
  br i1 %107, label %109, label %108

108:                                              ; preds = %104
  store i32 17, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %142

109:                                              ; preds = %104
  %110 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %135, %109
  %112 = load i32, ptr %11, align 4, !tbaa !9
  %113 = load i32, ptr %11, align 4, !tbaa !9
  %114 = mul nsw i32 %112, %113
  %115 = load i32, ptr %8, align 4, !tbaa !9
  %116 = icmp sle i32 %114, %115
  br i1 %116, label %118, label %117

117:                                              ; preds = %111
  store i32 20, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %138

118:                                              ; preds = %111
  %119 = load i32, ptr %8, align 4, !tbaa !9
  %120 = load i32, ptr %11, align 4, !tbaa !9
  %121 = srem i32 %119, %120
  %122 = icmp eq i32 %121, 0
  br i1 %122, label %123, label %134

123:                                              ; preds = %118
  %124 = load i32, ptr %11, align 4, !tbaa !9
  call void @_Z6updatei(i32 noundef %124)
  %125 = load i32, ptr %8, align 4, !tbaa !9
  %126 = load i32, ptr %11, align 4, !tbaa !9
  %127 = sdiv i32 %125, %126
  store i32 %127, ptr %9, align 4, !tbaa !9
  %128 = load i32, ptr %9, align 4, !tbaa !9
  %129 = load i32, ptr %11, align 4, !tbaa !9
  %130 = icmp ne i32 %128, %129
  br i1 %130, label %131, label %133

131:                                              ; preds = %123
  %132 = load i32, ptr %9, align 4, !tbaa !9
  call void @_Z6updatei(i32 noundef %132)
  br label %133

133:                                              ; preds = %131, %123
  br label %134

134:                                              ; preds = %133, %118
  br label %135

135:                                              ; preds = %134
  %136 = load i32, ptr %11, align 4, !tbaa !9
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %11, align 4, !tbaa !9
  br label %111, !llvm.loop !17

138:                                              ; preds = %117
  br label %139

139:                                              ; preds = %138
  %140 = load i32, ptr %10, align 4, !tbaa !9
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %10, align 4, !tbaa !9
  br label %104, !llvm.loop !18

142:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %143

143:                                              ; preds = %180, %142
  %144 = load i32, ptr %12, align 4, !tbaa !9
  %145 = load i32, ptr @q, align 4, !tbaa !9
  %146 = icmp sle i32 %144, %145
  br i1 %146, label %148, label %147

147:                                              ; preds = %143
  store i32 23, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %183

148:                                              ; preds = %143
  %149 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %150

150:                                              ; preds = %174, %148
  %151 = load i32, ptr %13, align 4, !tbaa !9
  %152 = load i32, ptr %13, align 4, !tbaa !9
  %153 = mul nsw i32 %151, %152
  %154 = load i32, ptr %8, align 4, !tbaa !9
  %155 = icmp sle i32 %153, %154
  br i1 %155, label %157, label %156

156:                                              ; preds = %150
  store i32 26, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %177

157:                                              ; preds = %150
  %158 = load i32, ptr %8, align 4, !tbaa !9
  %159 = load i32, ptr %13, align 4, !tbaa !9
  %160 = srem i32 %158, %159
  %161 = icmp eq i32 %160, 0
  br i1 %161, label %162, label %173

162:                                              ; preds = %157
  %163 = load i32, ptr %13, align 4, !tbaa !9
  call void @_Z6updatei(i32 noundef %163)
  %164 = load i32, ptr %8, align 4, !tbaa !9
  %165 = load i32, ptr %13, align 4, !tbaa !9
  %166 = sdiv i32 %164, %165
  store i32 %166, ptr %9, align 4, !tbaa !9
  %167 = load i32, ptr %9, align 4, !tbaa !9
  %168 = load i32, ptr %13, align 4, !tbaa !9
  %169 = icmp ne i32 %167, %168
  br i1 %169, label %170, label %172

170:                                              ; preds = %162
  %171 = load i32, ptr %9, align 4, !tbaa !9
  call void @_Z6updatei(i32 noundef %171)
  br label %172

172:                                              ; preds = %170, %162
  br label %173

173:                                              ; preds = %172, %157
  br label %174

174:                                              ; preds = %173
  %175 = load i32, ptr %13, align 4, !tbaa !9
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %13, align 4, !tbaa !9
  br label %150, !llvm.loop !19

177:                                              ; preds = %156
  %178 = load i64, ptr @ans, align 8, !tbaa !5
  %179 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %178)
  br label %180

180:                                              ; preds = %177
  %181 = load i32, ptr %12, align 4, !tbaa !9
  %182 = add nsw i32 %181, 1
  store i32 %182, ptr %12, align 4, !tbaa !9
  br label %143, !llvm.loop !20

183:                                              ; preds = %147
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %184 = load i32, ptr %1, align 4
  ret i32 %184
}

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

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 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@f = external dso_local local_unnamed_addr global [200100 x i64], align 16
@invf = external dso_local local_unnamed_addr global [200100 x i64], align 16
@p = external dso_local local_unnamed_addr global [1001000 x i32], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z4fastxx(i64 noundef, i64 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 void @_Z6updatei(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
  store i64 1, ptr @f, align 16, !tbaa !5
  br label %5

2:                                                ; preds = %5
  %3 = load i64, ptr getelementptr inbounds (i8, ptr @f, i64 1600792), align 8, !tbaa !5
  %4 = tail call noundef i64 @_Z4fastxx(i64 noundef %3, i64 noundef 1000000005)
  store i64 %4, ptr getelementptr inbounds (i8, ptr @invf, i64 1600792), align 8, !tbaa !5
  br label %14

5:                                                ; preds = %10, %0
  %6 = phi i64 [ 1, %0 ], [ %12, %10 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.1, %10 ]
  %7 = mul nsw i64 %6, %indvars.iv
  %8 = srem i64 %7, 1000000007
  %9 = getelementptr inbounds [200100 x i64], ptr @f, i64 0, i64 %indvars.iv
  store i64 %8, ptr %9, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 200100
  br i1 %exitcond.not, label %2, label %10, !llvm.loop !9

10:                                               ; preds = %5
  %11 = mul nsw i64 %8, %indvars.iv.next
  %12 = srem i64 %11, 1000000007
  %13 = getelementptr inbounds [200100 x i64], ptr @f, i64 0, i64 %indvars.iv.next
  store i64 %12, ptr %13, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %5

14:                                               ; preds = %20, %2
  %15 = phi i64 [ %4, %2 ], [ %22, %20 ]
  %indvars.iv89 = phi i64 [ 200098, %2 ], [ %indvars.iv.next90.1, %20 ]
  %16 = or disjoint i64 %indvars.iv89, 1
  %17 = mul nsw i64 %15, %16
  %18 = srem i64 %17, 1000000007
  %19 = getelementptr inbounds [200100 x i64], ptr @invf, i64 0, i64 %indvars.iv89
  store i64 %18, ptr %19, align 16, !tbaa !5
  %.not = icmp eq i64 %indvars.iv89, 0
  br i1 %.not, label %vector.body, label %20, !llvm.loop !11

20:                                               ; preds = %14
  %indvars.iv.next90 = add nsw i64 %indvars.iv89, -1
  %21 = mul nsw i64 %18, %indvars.iv89
  %22 = srem i64 %21, 1000000007
  %23 = getelementptr inbounds [200100 x i64], ptr @invf, i64 0, i64 %indvars.iv.next90
  store i64 %22, ptr %23, align 8, !tbaa !5
  %indvars.iv.next90.1 = add nsw i64 %indvars.iv89, -2
  br label %14

vector.body:                                      ; preds = %14, %vector.body
  %index = phi i64 [ %index.next.2, %vector.body ], [ 0, %14 ]
  %vec.ind = phi <4 x i32> [ %vec.ind.next.2, %vector.body ], [ <i32 1, i32 2, i32 3, i32 4>, %14 ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %offset.idx = or disjoint i64 %index, 1
  %24 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %offset.idx
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  store <4 x i32> %vec.ind, ptr %24, align 4, !tbaa !12
  store <4 x i32> %step.add, ptr %25, align 4, !tbaa !12
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %step.add.1 = add <4 x i32> %vec.ind, <i32 12, i32 12, i32 12, i32 12>
  %offset.idx.1 = add nuw nsw i64 %index, 9
  %26 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %offset.idx.1
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  store <4 x i32> %vec.ind.next, ptr %26, align 4, !tbaa !12
  store <4 x i32> %step.add.1, ptr %27, align 4, !tbaa !12
  %vec.ind.next.1 = add <4 x i32> %vec.ind, <i32 16, i32 16, i32 16, i32 16>
  %step.add.2 = add <4 x i32> %vec.ind, <i32 20, i32 20, i32 20, i32 20>
  %offset.idx.2 = add nuw nsw i64 %index, 17
  %28 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %offset.idx.2
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  store <4 x i32> %vec.ind.next.1, ptr %28, align 4, !tbaa !12
  store <4 x i32> %step.add.2, ptr %29, align 4, !tbaa !12
  %index.next.2 = add nuw nsw i64 %index, 24
  %vec.ind.next.2 = add <4 x i32> %vec.ind, <i32 24, i32 24, i32 24, i32 24>
  %30 = icmp eq i64 %index.next.2, 1000992
  br i1 %30, label %.preheader64, label %vector.body, !llvm.loop !14

.preheader64:                                     ; preds = %vector.body
  store i32 1000993, ptr getelementptr inbounds (i8, ptr @p, i64 4003972), align 4, !tbaa !12
  store i32 1000994, ptr getelementptr inbounds (i8, ptr @p, i64 4003976), align 8, !tbaa !12
  store i32 1000995, ptr getelementptr inbounds (i8, ptr @p, i64 4003980), align 4, !tbaa !12
  store i32 1000996, ptr getelementptr inbounds (i8, ptr @p, i64 4003984), align 16, !tbaa !12
  store i32 1000997, ptr getelementptr inbounds (i8, ptr @p, i64 4003988), align 4, !tbaa !12
  store i32 1000998, ptr getelementptr inbounds (i8, ptr @p, i64 4003992), align 8, !tbaa !12
  store i32 1000999, ptr getelementptr inbounds (i8, ptr @p, i64 4003996), align 4, !tbaa !12
  br label %.preheader63

31:                                               ; preds = %._crit_edge
  %32 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @k, ptr noundef nonnull @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %33 = load i32, ptr @n, align 4, !tbaa !12
  %.not75 = icmp slt i32 %33, 1
  br i1 %.not75, label %.preheader, label %.lr.ph78

.preheader63:                                     ; preds = %.preheader64, %._crit_edge
  %indvars.iv98 = phi i64 [ %indvars.iv.next99, %._crit_edge ], [ 1, %.preheader64 ]
  %indvars.iv96 = phi i64 [ %indvars.iv.next97, %._crit_edge ], [ 2, %.preheader64 ]
  %34 = icmp ult i64 %indvars.iv98, 500500
  br i1 %34, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader63
  %35 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %indvars.iv98
  br label %36

._crit_edge:                                      ; preds = %36, %.preheader63
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 2
  %exitcond104.not = icmp eq i64 %indvars.iv.next99, 1001000
  br i1 %exitcond104.not, label %31, label %.preheader63, !llvm.loop !17

36:                                               ; preds = %.lr.ph, %36
  %indvars.iv100 = phi i64 [ %indvars.iv96, %.lr.ph ], [ %indvars.iv.next101, %36 ]
  %37 = load i32, ptr %35, align 4, !tbaa !12
  %38 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %indvars.iv100
  %39 = load i32, ptr %38, align 4, !tbaa !12
  %40 = sub nsw i32 %39, %37
  store i32 %40, ptr %38, align 4, !tbaa !12
  %indvars.iv.next101 = add nuw nsw i64 %indvars.iv100, %indvars.iv98
  %41 = icmp ult i64 %indvars.iv.next101, 1001000
  br i1 %41, label %36, label %._crit_edge, !llvm.loop !18

.preheader:                                       ; preds = %._crit_edge74, %31
  %42 = load i32, ptr @q, align 4, !tbaa !12
  %.not5884 = icmp slt i32 %42, 1
  br i1 %.not5884, label %._crit_edge87, label %.lr.ph86

.lr.ph78:                                         ; preds = %31, %._crit_edge74
  %.04876 = phi i32 [ %45, %._crit_edge74 ], [ 1, %31 ]
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %44 = load i32, ptr %1, align 4, !tbaa !12
  %.not6170 = icmp slt i32 %44, 1
  br i1 %.not6170, label %._crit_edge74, label %.lr.ph73

._crit_edge74:                                    ; preds = %54, %.lr.ph78
  %45 = add nuw nsw i32 %.04876, 1
  %46 = load i32, ptr @n, align 4, !tbaa !12
  %.not.not = icmp slt i32 %.04876, %46
  br i1 %.not.not, label %.lr.ph78, label %.preheader, !llvm.loop !19

.lr.ph73:                                         ; preds = %.lr.ph78, %54
  %47 = phi i32 [ %55, %54 ], [ %44, %.lr.ph78 ]
  %.04771 = phi i32 [ %56, %54 ], [ 1, %.lr.ph78 ]
  %48 = srem i32 %47, %.04771
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %54

50:                                               ; preds = %.lr.ph73
  call void @_Z6updatei(i32 noundef %.04771)
  %51 = load i32, ptr %1, align 4, !tbaa !12
  %52 = sdiv i32 %51, %.04771
  %.not62 = icmp eq i32 %52, %.04771
  br i1 %.not62, label %54, label %53

53:                                               ; preds = %50
  call void @_Z6updatei(i32 noundef %52)
  %.pre = load i32, ptr %1, align 4, !tbaa !12
  br label %54

54:                                               ; preds = %.lr.ph73, %53, %50
  %55 = phi i32 [ %47, %.lr.ph73 ], [ %.pre, %53 ], [ %51, %50 ]
  %56 = add nuw nsw i32 %.04771, 1
  %57 = mul nuw nsw i32 %56, %56
  %.not61 = icmp sgt i32 %57, %55
  br i1 %.not61, label %._crit_edge74, label %.lr.ph73, !llvm.loop !20

._crit_edge87:                                    ; preds = %._crit_edge83, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0

.lr.ph86:                                         ; preds = %.preheader, %._crit_edge83
  %.04685 = phi i32 [ %62, %._crit_edge83 ], [ 1, %.preheader ]
  %58 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %59 = load i32, ptr %1, align 4, !tbaa !12
  %.not5979 = icmp slt i32 %59, 1
  br i1 %.not5979, label %._crit_edge83, label %.lr.ph82

._crit_edge83:                                    ; preds = %71, %.lr.ph86
  %60 = load i64, ptr @ans, align 8, !tbaa !5
  %61 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %60)
  %62 = add nuw nsw i32 %.04685, 1
  %63 = load i32, ptr @q, align 4, !tbaa !12
  %.not58.not = icmp slt i32 %.04685, %63
  br i1 %.not58.not, label %.lr.ph86, label %._crit_edge87, !llvm.loop !21

.lr.ph82:                                         ; preds = %.lr.ph86, %71
  %64 = phi i32 [ %72, %71 ], [ %59, %.lr.ph86 ]
  %.080 = phi i32 [ %73, %71 ], [ 1, %.lr.ph86 ]
  %65 = srem i32 %64, %.080
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %71

67:                                               ; preds = %.lr.ph82
  call void @_Z6updatei(i32 noundef %.080)
  %68 = load i32, ptr %1, align 4, !tbaa !12
  %69 = sdiv i32 %68, %.080
  %.not60 = icmp eq i32 %69, %.080
  br i1 %.not60, label %71, label %70

70:                                               ; preds = %67
  call void @_Z6updatei(i32 noundef %69)
  %.pre105 = load i32, ptr %1, align 4, !tbaa !12
  br label %71

71:                                               ; preds = %.lr.ph82, %70, %67
  %72 = phi i32 [ %64, %.lr.ph82 ], [ %.pre105, %70 ], [ %68, %67 ]
  %73 = add nuw nsw i32 %.080, 1
  %74 = mul nuw nsw i32 %73, %73
  %.not59 = icmp sgt i32 %74, %72
  br i1 %.not59, label %._crit_edge83, label %.lr.ph82, !llvm.loop !22
}

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

; 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 = { 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 = !{!"long long", !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 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !10, !15, !16}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}


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