; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/309 Division 2/Problem C (C)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@dp = external dso_local global [1001 x [1001 x i64]], align 16
@sum = external dso_local global [1001 x [1001 x i64]], align 16
@MOD = external dso_local global i64, align 8
@f = external dso_local global [1001 x i64], align 16
@k = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@c = external dso_local global [1001 x i32], align 16
@l = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3nCrii(i32 noundef, i32 noundef) #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
  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) #6
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %26, %0
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = icmp sle i32 %9, 1000
  br i1 %10, label %12, label %11

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

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

26:                                               ; preds = %12
  %27 = load i32, ptr %2, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !9
  br label %8, !llvm.loop !11

29:                                               ; preds = %11
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %47, %29
  %32 = load i32, ptr %3, align 4, !tbaa !9
  %33 = load i32, ptr @k, align 4, !tbaa !9
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %50

36:                                               ; preds = %31
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %38
  %40 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %39)
  %41 = load i32, ptr %3, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = load i32, ptr @n, align 4, !tbaa !9
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr @n, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %36
  %48 = load i32, ptr %3, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %3, align 4, !tbaa !9
  br label %31, !llvm.loop !13

50:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %51 = load i32, ptr getelementptr inbounds ([1001 x i32], ptr @c, i64 0, i64 1), align 4, !tbaa !9
  store i32 %51, ptr %4, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %84, %50
  %53 = load i32, ptr %4, align 4, !tbaa !9
  %54 = load i32, ptr @n, align 4, !tbaa !9
  %55 = load i32, ptr @k, align 4, !tbaa !9
  %56 = sub nsw i32 %54, %55
  %57 = add nsw i32 %56, 1
  %58 = icmp sle i32 %53, %57
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %52
  %61 = load i32, ptr %4, align 4, !tbaa !9
  %62 = sub nsw i32 %61, 1
  %63 = load i32, ptr getelementptr inbounds ([1001 x i32], ptr @c, i64 0, i64 1), align 4, !tbaa !9
  %64 = sub nsw i32 %63, 1
  %65 = call noundef i64 @_Z3nCrii(i32 noundef %62, i32 noundef %64)
  %66 = load i32, ptr %4, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1001 x i64], ptr getelementptr inbounds ([1001 x [1001 x i64]], ptr @dp, i64 0, i64 1), i64 0, i64 %67
  store i64 %65, ptr %68, align 8, !tbaa !5
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = sub nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1001 x i64], ptr getelementptr inbounds ([1001 x [1001 x i64]], ptr @sum, i64 0, i64 1), i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !5
  %74 = load i32, ptr %4, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1001 x i64], ptr getelementptr inbounds ([1001 x [1001 x i64]], ptr @dp, i64 0, i64 1), i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !5
  %78 = add nsw i64 %73, %77
  %79 = load i64, ptr @MOD, align 8, !tbaa !5
  %80 = srem i64 %78, %79
  %81 = load i32, ptr %4, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1001 x i64], ptr getelementptr inbounds ([1001 x [1001 x i64]], ptr @sum, i64 0, i64 1), i64 0, i64 %82
  store i64 %80, ptr %83, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %60
  %85 = load i32, ptr %4, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %4, align 4, !tbaa !9
  br label %52, !llvm.loop !14

87:                                               ; preds = %59
  %88 = load i32, ptr getelementptr inbounds ([1001 x i32], ptr @c, i64 0, i64 1), align 4, !tbaa !9
  store i32 %88, ptr @l, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 2, ptr %5, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %173, %87
  %90 = load i32, ptr %5, align 4, !tbaa !9
  %91 = load i32, ptr @k, align 4, !tbaa !9
  %92 = icmp sle i32 %90, %91
  br i1 %92, label %94, label %93

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

94:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %95 = load i32, ptr @l, align 4, !tbaa !9
  %96 = load i32, ptr %5, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !9
  %100 = add nsw i32 %95, %99
  store i32 %100, ptr %7, align 4, !tbaa !9
  br label %101

101:                                              ; preds = %163, %94
  %102 = load i32, ptr %7, align 4, !tbaa !9
  %103 = load i32, ptr @n, align 4, !tbaa !9
  %104 = load i32, ptr @k, align 4, !tbaa !9
  %105 = sub nsw i32 %103, %104
  %106 = load i32, ptr %5, align 4, !tbaa !9
  %107 = add nsw i32 %105, %106
  %108 = icmp sle i32 %102, %107
  br i1 %108, label %110, label %109

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

110:                                              ; preds = %101
  %111 = load i32, ptr %5, align 4, !tbaa !9
  %112 = sub nsw i32 %111, 1
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [1001 x [1001 x i64]], ptr @sum, i64 0, i64 %113
  %115 = load i32, ptr %7, align 4, !tbaa !9
  %116 = sub nsw i32 %115, 1
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [1001 x i64], ptr %114, i64 0, i64 %117
  %119 = load i64, ptr %118, align 8, !tbaa !5
  %120 = load i32, ptr %7, align 4, !tbaa !9
  %121 = load i32, ptr @l, align 4, !tbaa !9
  %122 = sub nsw i32 %120, %121
  %123 = sub nsw i32 %122, 1
  %124 = load i32, ptr %5, align 4, !tbaa !9
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !9
  %128 = sub nsw i32 %127, 1
  %129 = call noundef i64 @_Z3nCrii(i32 noundef %123, i32 noundef %128)
  %130 = mul nsw i64 %119, %129
  %131 = load i64, ptr @MOD, align 8, !tbaa !5
  %132 = srem i64 %130, %131
  %133 = load i32, ptr %5, align 4, !tbaa !9
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp, i64 0, i64 %134
  %136 = load i32, ptr %7, align 4, !tbaa !9
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [1001 x i64], ptr %135, i64 0, i64 %137
  store i64 %132, ptr %138, align 8, !tbaa !5
  %139 = load i32, ptr %5, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [1001 x [1001 x i64]], ptr @sum, i64 0, i64 %140
  %142 = load i32, ptr %7, align 4, !tbaa !9
  %143 = sub nsw i32 %142, 1
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [1001 x i64], ptr %141, i64 0, i64 %144
  %146 = load i64, ptr %145, align 8, !tbaa !5
  %147 = load i32, ptr %5, align 4, !tbaa !9
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp, i64 0, i64 %148
  %150 = load i32, ptr %7, align 4, !tbaa !9
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [1001 x i64], ptr %149, i64 0, i64 %151
  %153 = load i64, ptr %152, align 8, !tbaa !5
  %154 = add nsw i64 %146, %153
  %155 = load i64, ptr @MOD, align 8, !tbaa !5
  %156 = srem i64 %154, %155
  %157 = load i32, ptr %5, align 4, !tbaa !9
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1001 x [1001 x i64]], ptr @sum, i64 0, i64 %158
  %160 = load i32, ptr %7, align 4, !tbaa !9
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [1001 x i64], ptr %159, i64 0, i64 %161
  store i64 %156, ptr %162, align 8, !tbaa !5
  br label %163

163:                                              ; preds = %110
  %164 = load i32, ptr %7, align 4, !tbaa !9
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %7, align 4, !tbaa !9
  br label %101, !llvm.loop !15

166:                                              ; preds = %109
  %167 = load i32, ptr %5, align 4, !tbaa !9
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !9
  %171 = load i32, ptr @l, align 4, !tbaa !9
  %172 = add nsw i32 %171, %170
  store i32 %172, ptr @l, align 4, !tbaa !9
  br label %173

173:                                              ; preds = %166
  %174 = load i32, ptr %5, align 4, !tbaa !9
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %5, align 4, !tbaa !9
  br label %89, !llvm.loop !16

176:                                              ; preds = %93
  %177 = load i32, ptr @k, align 4, !tbaa !9
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp, i64 0, i64 %178
  %180 = load i32, ptr @n, align 4, !tbaa !9
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [1001 x i64], ptr %179, i64 0, i64 %181
  %183 = load i64, ptr %182, align 8, !tbaa !5
  %184 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %183)
  %185 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %184, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #4 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@dp = external dso_local local_unnamed_addr global [1001 x [1001 x i64]], align 16
@sum = external dso_local local_unnamed_addr global [1001 x [1001 x i64]], align 16
@MOD = external dso_local local_unnamed_addr global i64, align 8
@f = external dso_local local_unnamed_addr global [1001 x i64], align 16
@k = external dso_local global i32, align 4
@n = external dso_local local_unnamed_addr global i32, align 4
@c = external dso_local global [1001 x i32], align 16
@l = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

2:                                                ; preds = %5
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @k)
  %4 = load i32, ptr @k, align 4, !tbaa !9
  %.not45 = icmp slt i32 %4, 1
  br i1 %.not45, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %2
  %.pre = load i32, ptr @n, align 4, !tbaa !9
  br label %._crit_edge

5:                                                ; preds = %5, %0
  %6 = phi i64 [ 1, %0 ], [ %11, %5 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.1, %5 ]
  %7 = mul nsw i64 %6, %indvars.iv
  %8 = srem i64 %7, %1
  %9 = getelementptr inbounds [1001 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
  %10 = mul nsw i64 %8, %indvars.iv.next
  %11 = srem i64 %10, %1
  %12 = getelementptr inbounds [1001 x i64], ptr @f, i64 0, i64 %indvars.iv.next
  store i64 %11, ptr %12, 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, 1001
  br i1 %exitcond.not.1, label %2, label %5, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %13 = phi i32 [ %4, %.._crit_edge_crit_edge ], [ %24, %.lr.ph ]
  %14 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %23, %.lr.ph ]
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @c, i64 4), align 4, !tbaa !9
  %16 = add i32 %14, 1
  %17 = sub i32 %16, %13
  %.not4048 = icmp sgt i32 %15, %17
  br i1 %.not4048, label %._crit_edge52, label %.lr.ph51.preheader

.lr.ph51.preheader:                               ; preds = %._crit_edge
  %18 = sext i32 %15 to i64
  br label %.lr.ph51

.lr.ph:                                           ; preds = %2, %.lr.ph
  %indvars.iv66 = phi i64 [ %indvars.iv.next67, %.lr.ph ], [ 1, %2 ]
  %19 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %indvars.iv66
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %19)
  %21 = load i32, ptr %19, align 4, !tbaa !9
  %22 = load i32, ptr @n, align 4, !tbaa !9
  %23 = add nsw i32 %22, %21
  store i32 %23, ptr @n, align 4, !tbaa !9
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %24 = load i32, ptr @k, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %.not.not = icmp slt i64 %indvars.iv66, %25
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge52.loopexit:                           ; preds = %.lr.ph51
  %.pre78 = load i32, ptr getelementptr inbounds (i8, ptr @c, i64 4), align 4, !tbaa !9
  br label %._crit_edge52

._crit_edge52:                                    ; preds = %._crit_edge52.loopexit, %._crit_edge
  %26 = phi i32 [ %41, %._crit_edge52.loopexit ], [ %14, %._crit_edge ]
  %27 = phi i32 [ %42, %._crit_edge52.loopexit ], [ %13, %._crit_edge ]
  %28 = phi i32 [ %.pre78, %._crit_edge52.loopexit ], [ %15, %._crit_edge ]
  store i32 %28, ptr @l, align 4, !tbaa !9
  %.not4159 = icmp slt i32 %27, 2
  br i1 %.not4159, label %._crit_edge52.._crit_edge63_crit_edge, label %.lr.ph62

._crit_edge52.._crit_edge63_crit_edge:            ; preds = %._crit_edge52
  %.pre82 = sext i32 %27 to i64
  br label %._crit_edge63

.lr.ph51:                                         ; preds = %.lr.ph51.preheader, %.lr.ph51
  %indvars.iv69 = phi i64 [ %18, %.lr.ph51.preheader ], [ %indvars.iv.next70, %.lr.ph51 ]
  %29 = add nsw i64 %indvars.iv69, -1
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @c, i64 4), align 4, !tbaa !9
  %31 = add nsw i32 %30, -1
  %32 = trunc nsw i64 %29 to i32
  %33 = tail call noundef i64 @_Z3nCrii(i32 noundef %32, i32 noundef %31)
  %34 = getelementptr inbounds [1001 x i64], ptr getelementptr inbounds (i8, ptr @dp, i64 8008), i64 0, i64 %indvars.iv69
  store i64 %33, ptr %34, align 8, !tbaa !5
  %35 = getelementptr inbounds [1001 x i64], ptr getelementptr inbounds (i8, ptr @sum, i64 8008), i64 0, i64 %29
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = add nsw i64 %36, %33
  %38 = load i64, ptr @MOD, align 8, !tbaa !5
  %39 = srem i64 %37, %38
  %40 = getelementptr inbounds [1001 x i64], ptr getelementptr inbounds (i8, ptr @sum, i64 8008), i64 0, i64 %indvars.iv69
  store i64 %39, ptr %40, align 8, !tbaa !5
  %indvars.iv.next70 = add nsw i64 %indvars.iv69, 1
  %41 = load i32, ptr @n, align 4, !tbaa !9
  %42 = load i32, ptr @k, align 4, !tbaa !9
  %43 = add i32 %41, 1
  %44 = sub i32 %43, %42
  %45 = sext i32 %44 to i64
  %.not40.not = icmp slt i64 %indvars.iv69, %45
  br i1 %.not40.not, label %.lr.ph51, label %._crit_edge52.loopexit, !llvm.loop !14

._crit_edge63:                                    ; preds = %._crit_edge58, %._crit_edge52.._crit_edge63_crit_edge
  %.pre-phi83 = phi i64 [ %.pre82, %._crit_edge52.._crit_edge63_crit_edge ], [ %67, %._crit_edge58 ]
  %46 = phi i32 [ %26, %._crit_edge52.._crit_edge63_crit_edge ], [ %66, %._crit_edge58 ]
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp, i64 0, i64 %.pre-phi83, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !5
  %50 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %49)
  %51 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %50, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.lr.ph62:                                         ; preds = %._crit_edge52, %._crit_edge58
  %52 = phi i32 [ %65, %._crit_edge58 ], [ %27, %._crit_edge52 ]
  %53 = phi i32 [ %66, %._crit_edge58 ], [ %26, %._crit_edge52 ]
  %54 = phi i32 [ %.pre-phi, %._crit_edge58 ], [ %28, %._crit_edge52 ]
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %._crit_edge58 ], [ 2, %._crit_edge52 ]
  %55 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %indvars.iv75
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = add nsw i32 %56, %54
  %58 = trunc nuw nsw i64 %indvars.iv75 to i32
  %59 = add i32 %53, %58
  %60 = sub i32 %59, %52
  %.not4254 = icmp sgt i32 %57, %60
  br i1 %.not4254, label %._crit_edge58, label %.lr.ph57

.lr.ph57:                                         ; preds = %.lr.ph62
  %61 = add nsw i64 %indvars.iv75, -1
  %62 = sext i32 %56 to i64
  %63 = sext i32 %54 to i64
  %64 = add nsw i64 %62, %63
  br label %68

._crit_edge58.loopexit:                           ; preds = %68
  %.pre79 = load i32, ptr %55, align 4, !tbaa !9
  %.pre80 = load i32, ptr @l, align 4, !tbaa !9
  %.pre81 = add nsw i32 %.pre80, %.pre79
  br label %._crit_edge58

._crit_edge58:                                    ; preds = %._crit_edge58.loopexit, %.lr.ph62
  %.pre-phi = phi i32 [ %.pre81, %._crit_edge58.loopexit ], [ %57, %.lr.ph62 ]
  %65 = phi i32 [ %89, %._crit_edge58.loopexit ], [ %52, %.lr.ph62 ]
  %66 = phi i32 [ %88, %._crit_edge58.loopexit ], [ %53, %.lr.ph62 ]
  store i32 %.pre-phi, ptr @l, align 4, !tbaa !9
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %67 = sext i32 %65 to i64
  %.not41.not = icmp slt i64 %indvars.iv75, %67
  br i1 %.not41.not, label %.lr.ph62, label %._crit_edge63, !llvm.loop !15

68:                                               ; preds = %.lr.ph57, %68
  %indvars.iv72 = phi i64 [ %64, %.lr.ph57 ], [ %indvars.iv.next73, %68 ]
  %69 = add nsw i64 %indvars.iv72, -1
  %70 = getelementptr inbounds [1001 x [1001 x i64]], ptr @sum, i64 0, i64 %61, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !5
  %72 = load i32, ptr @l, align 4, !tbaa !9
  %73 = xor i32 %72, -1
  %74 = trunc nsw i64 %indvars.iv72 to i32
  %75 = add i32 %74, %73
  %76 = load i32, ptr %55, align 4, !tbaa !9
  %77 = add nsw i32 %76, -1
  %78 = tail call noundef i64 @_Z3nCrii(i32 noundef %75, i32 noundef %77)
  %79 = mul nsw i64 %78, %71
  %80 = load i64, ptr @MOD, align 8, !tbaa !5
  %81 = srem i64 %79, %80
  %82 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp, i64 0, i64 %indvars.iv75, i64 %indvars.iv72
  store i64 %81, ptr %82, align 8, !tbaa !5
  %83 = getelementptr inbounds [1001 x [1001 x i64]], ptr @sum, i64 0, i64 %indvars.iv75, i64 %69
  %84 = load i64, ptr %83, align 8, !tbaa !5
  %85 = add nsw i64 %84, %81
  %86 = srem i64 %85, %80
  %87 = getelementptr inbounds [1001 x [1001 x i64]], ptr @sum, i64 0, i64 %indvars.iv75, i64 %indvars.iv72
  store i64 %86, ptr %87, align 8, !tbaa !5
  %indvars.iv.next73 = add nsw i64 %indvars.iv72, 1
  %88 = load i32, ptr @n, align 4, !tbaa !9
  %89 = load i32, ptr @k, align 4, !tbaa !9
  %90 = add i32 %88, %58
  %91 = sub i32 %90, %89
  %92 = sext i32 %91 to i64
  %.not42.not = icmp slt i64 %indvars.iv72, %92
  br i1 %.not42.not, label %68, label %._crit_edge58.loopexit, !llvm.loop !16
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #4 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!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}


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