; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/236 Division 1/Problem D (D)

; 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
@k = external dso_local global i32, align 4
@dp = external dso_local global [51 x [1001 x i32]], align 16
@r = external dso_local global [51 x [1001 x i32]], align 16
@f = external dso_local global [51 x i64], align 16
@MOD = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = 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 i32, align 4
  %9 = alloca i32, align 4
  %10 = 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) #3
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %11

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

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

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

29:                                               ; preds = %15
  %30 = load i32, ptr %2, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !9
  br label %11, !llvm.loop !11

32:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %41, %32
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 1001
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %44

37:                                               ; preds = %33
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %39
  store i32 1, ptr %40, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %37
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %3, align 4, !tbaa !9
  br label %33, !llvm.loop !13

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

45:                                               ; preds = %155, %44
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = icmp slt i32 %46, 1001
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %106, %49
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 51
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %55 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %55, ptr %7, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %102, %54
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = icmp slt i32 %57, 1001
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %56
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = sub nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [51 x [1001 x i32]], ptr @r, i64 0, i64 %63
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = load i32, ptr %4, align 4, !tbaa !9
  %67 = sub nsw i32 %65, %66
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [1001 x i32], ptr %64, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [51 x [1001 x i32]], ptr @dp, i64 0, i64 %72
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1001 x i32], ptr %73, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = add nsw i32 %77, %70
  store i32 %78, ptr %76, align 4, !tbaa !9
  %79 = load i32, ptr %6, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [51 x [1001 x i32]], ptr @dp, i64 0, i64 %80
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1001 x i32], ptr %81, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = load i64, ptr @MOD, align 8, !tbaa !5
  %88 = icmp sge i64 %86, %87
  br i1 %88, label %89, label %101

89:                                               ; preds = %60
  %90 = load i64, ptr @MOD, align 8, !tbaa !5
  %91 = load i32, ptr %6, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [51 x [1001 x i32]], ptr @dp, i64 0, i64 %92
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [1001 x i32], ptr %93, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = sub nsw i64 %98, %90
  %100 = trunc i64 %99 to i32
  store i32 %100, ptr %96, align 4, !tbaa !9
  br label %101

101:                                              ; preds = %89, %60
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %7, align 4, !tbaa !9
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %7, align 4, !tbaa !9
  br label %56, !llvm.loop !14

105:                                              ; preds = %59
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %6, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %6, align 4, !tbaa !9
  br label %50, !llvm.loop !15

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

110:                                              ; preds = %151, %109
  %111 = load i32, ptr %8, align 4, !tbaa !9
  %112 = icmp slt i32 %111, 51
  br i1 %112, label %114, label %113

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

114:                                              ; preds = %110
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %115

115:                                              ; preds = %147, %114
  %116 = load i32, ptr %10, align 4, !tbaa !9
  %117 = icmp slt i32 %116, 1001
  br i1 %117, label %119, label %118

118:                                              ; preds = %115
  store i32 20, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %150

119:                                              ; preds = %115
  %120 = load i32, ptr %8, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [51 x [1001 x i32]], ptr @dp, i64 0, i64 %121
  %123 = load i32, ptr %10, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1001 x i32], ptr %122, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !9
  %127 = load i32, ptr %9, align 4, !tbaa !9
  %128 = add nsw i32 %127, %126
  store i32 %128, ptr %9, align 4, !tbaa !9
  %129 = load i32, ptr %9, align 4, !tbaa !9
  %130 = sext i32 %129 to i64
  %131 = load i64, ptr @MOD, align 8, !tbaa !5
  %132 = icmp sge i64 %130, %131
  br i1 %132, label %133, label %139

133:                                              ; preds = %119
  %134 = load i64, ptr @MOD, align 8, !tbaa !5
  %135 = load i32, ptr %9, align 4, !tbaa !9
  %136 = sext i32 %135 to i64
  %137 = sub nsw i64 %136, %134
  %138 = trunc i64 %137 to i32
  store i32 %138, ptr %9, align 4, !tbaa !9
  br label %139

139:                                              ; preds = %133, %119
  %140 = load i32, ptr %9, align 4, !tbaa !9
  %141 = load i32, ptr %8, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [51 x [1001 x i32]], ptr @r, i64 0, i64 %142
  %144 = load i32, ptr %10, align 4, !tbaa !9
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [1001 x i32], ptr %143, i64 0, i64 %145
  store i32 %140, ptr %146, align 4, !tbaa !9
  br label %147

147:                                              ; preds = %139
  %148 = load i32, ptr %10, align 4, !tbaa !9
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %10, align 4, !tbaa !9
  br label %115, !llvm.loop !16

150:                                              ; preds = %118
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %151

151:                                              ; preds = %150
  %152 = load i32, ptr %8, align 4, !tbaa !9
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %8, align 4, !tbaa !9
  br label %110, !llvm.loop !17

154:                                              ; preds = %113
  br label %155

155:                                              ; preds = %154
  %156 = load i32, ptr %4, align 4, !tbaa !9
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %4, align 4, !tbaa !9
  br label %45, !llvm.loop !18

158:                                              ; preds = %48
  %159 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %160

160:                                              ; preds = %188, %158
  %161 = load i32, ptr @t, align 4, !tbaa !9
  %162 = add nsw i32 %161, -1
  store i32 %162, ptr @t, align 4, !tbaa !9
  %163 = icmp ne i32 %161, 0
  br i1 %163, label %164, label %189

164:                                              ; preds = %160
  %165 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @k)
  %166 = load i32, ptr @k, align 4, !tbaa !9
  %167 = icmp sgt i32 %166, 50
  br i1 %167, label %168, label %170

168:                                              ; preds = %164
  %169 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %188

170:                                              ; preds = %164
  %171 = load i32, ptr @k, align 4, !tbaa !9
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [51 x i64], ptr @f, i64 0, i64 %172
  %174 = load i64, ptr %173, align 8, !tbaa !5
  %175 = load i32, ptr @k, align 4, !tbaa !9
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [51 x [1001 x i32]], ptr @r, i64 0, i64 %176
  %178 = load i32, ptr @n, align 4, !tbaa !9
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [1001 x i32], ptr %177, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !9
  %182 = sext i32 %181 to i64
  %183 = mul nsw i64 %174, %182
  %184 = load i64, ptr @MOD, align 8, !tbaa !5
  %185 = srem i64 %183, %184
  %186 = trunc i64 %185 to i32
  %187 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %186)
  br label %188

188:                                              ; preds = %170, %168
  br label %160, !llvm.loop !19

189:                                              ; preds = %160
  ret i32 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

declare i32 @__isoc99_scanf(ptr noundef, ...) #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 = { 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}


; 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
@k = external dso_local global i32, align 4
@dp = external dso_local local_unnamed_addr global [51 x [1001 x i32]], align 16
@r = external dso_local local_unnamed_addr global [51 x [1001 x i32]], align 16
@f = external dso_local local_unnamed_addr global [51 x i64], align 16
@MOD = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  store i64 1, ptr @f, align 16, !tbaa !5
  %1 = load i64, ptr @MOD, align 8
  br label %2

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

vector.body:                                      ; preds = %2, %vector.body
  %index = phi i64 [ %index.next.4, %vector.body ], [ 0, %2 ]
  %10 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %index
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %10, align 16, !tbaa !11
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %11, align 16, !tbaa !11
  %index.next = add nuw nsw i64 %index, 8
  %12 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %index.next
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %12, align 16, !tbaa !11
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %13, align 16, !tbaa !11
  %index.next.1 = add nuw nsw i64 %index, 16
  %14 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %index.next.1
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %14, align 16, !tbaa !11
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %15, align 16, !tbaa !11
  %index.next.2 = add nuw nsw i64 %index, 24
  %16 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %index.next.2
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %16, align 16, !tbaa !11
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %17, align 16, !tbaa !11
  %index.next.3 = add nuw nsw i64 %index, 32
  %18 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %index.next.3
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %18, align 16, !tbaa !11
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %19, align 16, !tbaa !11
  %index.next.4 = add nuw nsw i64 %index, 40
  %20 = icmp eq i64 %index.next.4, 1000
  br i1 %20, label %.preheader54, label %vector.body, !llvm.loop !13

.preheader54:                                     ; preds = %vector.body
  store i32 1, ptr getelementptr inbounds (i8, ptr @r, i64 4000), align 16, !tbaa !11
  %21 = trunc i64 %1 to i32
  %broadcast.splatinsert = insertelement <4 x i64> poison, i64 %1, i64 0
  %broadcast.splat = shufflevector <4 x i64> %broadcast.splatinsert, <4 x i64> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert96 = insertelement <4 x i32> poison, i32 %21, i64 0
  %broadcast.splat97 = shufflevector <4 x i32> %broadcast.splatinsert96, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %.preheader52

.preheader52:                                     ; preds = %.preheader54, %44
  %indvar = phi i64 [ 0, %.preheader54 ], [ %indvar.next, %44 ]
  %indvars.iv69 = phi i64 [ 1, %.preheader54 ], [ %indvars.iv.next70, %44 ]
  %22 = sub i64 1000, %indvar
  %min.iters.check = icmp ult i64 %22, 4
  %n.vec = and i64 %22, -4
  %ind.end = add i64 %indvars.iv69, %n.vec
  %cmp.n = icmp eq i64 %22, %n.vec
  br label %.preheader50.us

.preheader50.us:                                  ; preds = %._crit_edge.us, %.preheader52
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %._crit_edge.us ], [ 1, %.preheader52 ]
  %23 = add nsw i64 %indvars.iv75, -1
  br i1 %min.iters.check, label %scalar.ph90.preheader, label %vector.body93

vector.body93:                                    ; preds = %.preheader50.us, %vector.body93
  %index94 = phi i64 [ %index.next98, %vector.body93 ], [ 0, %.preheader50.us ]
  %offset.idx = add i64 %indvars.iv69, %index94
  %24 = getelementptr inbounds [51 x [1001 x i32]], ptr @r, i64 0, i64 %23, i64 %index94
  %wide.load = load <4 x i32>, ptr %24, align 4, !tbaa !11
  %25 = getelementptr inbounds [51 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv75, i64 %offset.idx
  %wide.load95 = load <4 x i32>, ptr %25, align 4, !tbaa !11
  %26 = add nsw <4 x i32> %wide.load95, %wide.load
  %27 = sext <4 x i32> %26 to <4 x i64>
  %28 = icmp sgt <4 x i64> %broadcast.splat, %27
  %29 = select <4 x i1> %28, <4 x i32> zeroinitializer, <4 x i32> %broadcast.splat97
  %30 = sub <4 x i32> %26, %29
  store <4 x i32> %30, ptr %25, align 4, !tbaa !11
  %index.next98 = add nuw i64 %index94, 4
  %31 = icmp eq i64 %index.next98, %n.vec
  br i1 %31, label %middle.block89, label %vector.body93, !llvm.loop !16

middle.block89:                                   ; preds = %vector.body93
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph90.preheader

scalar.ph90.preheader:                            ; preds = %middle.block89, %.preheader50.us
  %indvars.iv71.ph = phi i64 [ %indvars.iv69, %.preheader50.us ], [ %ind.end, %middle.block89 ]
  br label %scalar.ph90

scalar.ph90:                                      ; preds = %scalar.ph90.preheader, %scalar.ph90
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %scalar.ph90 ], [ %indvars.iv71.ph, %scalar.ph90.preheader ]
  %32 = sub nuw nsw i64 %indvars.iv71, %indvars.iv69
  %33 = getelementptr inbounds [51 x [1001 x i32]], ptr @r, i64 0, i64 %23, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = getelementptr inbounds [51 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv75, i64 %indvars.iv71
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = add nsw i32 %36, %34
  %38 = sext i32 %37 to i64
  %.not49.us = icmp sgt i64 %1, %38
  %39 = select i1 %.not49.us, i32 0, i32 %21
  %spec.select = sub i32 %37, %39
  store i32 %spec.select, ptr %35, align 4, !tbaa !11
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %exitcond74.not = icmp eq i64 %indvars.iv.next72, 1001
  br i1 %exitcond74.not, label %._crit_edge.us, label %scalar.ph90, !llvm.loop !17

._crit_edge.us:                                   ; preds = %scalar.ph90, %middle.block89
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %exitcond78.not = icmp eq i64 %indvars.iv.next76, 51
  br i1 %exitcond78.not, label %.preheader, label %.preheader50.us, !llvm.loop !18

40:                                               ; preds = %44
  %41 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %42 = load i32, ptr @t, align 4, !tbaa !11
  %43 = add nsw i32 %42, -1
  store i32 %43, ptr @t, align 4, !tbaa !11
  %.not63 = icmp eq i32 %42, 0
  br i1 %.not63, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %._crit_edge.us, %45
  %indvars.iv83 = phi i64 [ %indvars.iv.next84, %45 ], [ 1, %._crit_edge.us ]
  br label %46

44:                                               ; preds = %45
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %exitcond88.not = icmp eq i64 %indvars.iv.next70, 1001
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond88.not, label %40, label %.preheader52, !llvm.loop !19

45:                                               ; preds = %46
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %exitcond86.not = icmp eq i64 %indvars.iv.next84, 51
  br i1 %exitcond86.not, label %44, label %.preheader, !llvm.loop !20

46:                                               ; preds = %53, %.preheader
  %indvars.iv79 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next80.1, %53 ]
  %.03659 = phi i32 [ 0, %.preheader ], [ %.1.1, %53 ]
  %47 = getelementptr inbounds [51 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv83, i64 %indvars.iv79
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = add nsw i32 %48, %.03659
  %50 = sext i32 %49 to i64
  %.not48 = icmp sgt i64 %1, %50
  %51 = select i1 %.not48, i32 0, i32 %21
  %.1 = sub i32 %49, %51
  %52 = getelementptr inbounds [51 x [1001 x i32]], ptr @r, i64 0, i64 %indvars.iv83, i64 %indvars.iv79
  store i32 %.1, ptr %52, align 4, !tbaa !11
  %exitcond82.not = icmp eq i64 %indvars.iv79, 1000
  br i1 %exitcond82.not, label %45, label %53, !llvm.loop !21

53:                                               ; preds = %46
  %indvars.iv.next80 = or disjoint i64 %indvars.iv79, 1
  %54 = getelementptr inbounds [51 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv83, i64 %indvars.iv.next80
  %55 = load i32, ptr %54, align 4, !tbaa !11
  %56 = add nsw i32 %55, %.1
  %57 = sext i32 %56 to i64
  %.not48.1 = icmp sgt i64 %1, %57
  %58 = select i1 %.not48.1, i32 0, i32 %21
  %.1.1 = sub i32 %56, %58
  %59 = getelementptr inbounds [51 x [1001 x i32]], ptr @r, i64 0, i64 %indvars.iv83, i64 %indvars.iv.next80
  store i32 %.1.1, ptr %59, align 4, !tbaa !11
  %indvars.iv.next80.1 = add nuw nsw i64 %indvars.iv79, 2
  br label %46

.lr.ph:                                           ; preds = %40, %79
  %60 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @k)
  %61 = load i32, ptr @k, align 4, !tbaa !11
  %62 = icmp sgt i32 %61, 50
  br i1 %62, label %63, label %65

63:                                               ; preds = %.lr.ph
  %64 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %79

65:                                               ; preds = %.lr.ph
  %66 = sext i32 %61 to i64
  %67 = getelementptr inbounds [51 x i64], ptr @f, i64 0, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !5
  %69 = load i32, ptr @n, align 4, !tbaa !11
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [51 x [1001 x i32]], ptr @r, i64 0, i64 %66, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !11
  %73 = sext i32 %72 to i64
  %74 = mul nsw i64 %68, %73
  %75 = load i64, ptr @MOD, align 8, !tbaa !5
  %76 = srem i64 %74, %75
  %77 = trunc i64 %76 to i32
  %78 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %77)
  br label %79

79:                                               ; preds = %65, %63
  %80 = load i32, ptr @t, align 4, !tbaa !11
  %81 = add nsw i32 %80, -1
  store i32 %81, ptr @t, align 4, !tbaa !11
  %.not = icmp eq i32 %80, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %79, %40
  ret i32 0
}

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

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

attributes #0 = { mustprogress nofree 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 #1 = { 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" }

!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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !10, !14, !15}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !10, !14, !15}
!17 = distinct !{!17, !10, !15, !14}
!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,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass