; LLVM IR from eyangch/competitive-programming :: Codeforces/1475 (e)

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

@MOD = external dso_local global i64, align 8
@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@a = external dso_local global [1000 x i64], align 16
@dp1 = external dso_local global [1001 x [1001 x i64]], align 16
@dp2 = external dso_local global [1001 x [1001 x i64]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %9 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %10 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %11 = getelementptr i8, ptr %10, i64 -24
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %12
  %14 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %13, ptr noundef null)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  br label %16

16:                                               ; preds = %175, %0
  %17 = load i64, ptr @T, align 8, !tbaa !8
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr @T, align 8, !tbaa !8
  %19 = icmp ne i64 %17, 0
  br i1 %19, label %20, label %183

20:                                               ; preds = %16
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(8) @K)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %23

23:                                               ; preds = %32, %20
  %24 = load i64, ptr %2, align 8, !tbaa !8
  %25 = load i64, ptr @N, align 8, !tbaa !8
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %23
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %29
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %30)
  br label %32

32:                                               ; preds = %28
  %33 = load i64, ptr %2, align 8, !tbaa !8
  %34 = add nsw i64 %33, 1
  store i64 %34, ptr %2, align 8, !tbaa !8
  br label %23, !llvm.loop !11

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %36

36:                                               ; preds = %60, %35
  %37 = load i64, ptr %3, align 8, !tbaa !8
  %38 = load i64, ptr @N, align 8, !tbaa !8
  %39 = icmp sle i64 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %63

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !8
  br label %42

42:                                               ; preds = %56, %41
  %43 = load i64, ptr %5, align 8, !tbaa !8
  %44 = load i64, ptr @N, align 8, !tbaa !8
  %45 = icmp sle i64 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %59

47:                                               ; preds = %42
  %48 = load i64, ptr %3, align 8, !tbaa !8
  %49 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %48
  %50 = load i64, ptr %5, align 8, !tbaa !8
  %51 = getelementptr inbounds [1001 x i64], ptr %49, i64 0, i64 %50
  store i64 -1000000000, ptr %51, align 8, !tbaa !8
  %52 = load i64, ptr %3, align 8, !tbaa !8
  %53 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %52
  %54 = load i64, ptr %5, align 8, !tbaa !8
  %55 = getelementptr inbounds [1001 x i64], ptr %53, i64 0, i64 %54
  store i64 -1000000000, ptr %55, align 8, !tbaa !8
  br label %56

56:                                               ; preds = %47
  %57 = load i64, ptr %5, align 8, !tbaa !8
  %58 = add nsw i64 %57, 1
  store i64 %58, ptr %5, align 8, !tbaa !8
  br label %42, !llvm.loop !13

59:                                               ; preds = %46
  br label %60

60:                                               ; preds = %59
  %61 = load i64, ptr %3, align 8, !tbaa !8
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %3, align 8, !tbaa !8
  br label %36, !llvm.loop !14

63:                                               ; preds = %40
  store i64 0, ptr @dp1, align 16, !tbaa !8
  store i64 1, ptr @dp2, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 1, ptr %6, align 8, !tbaa !8
  br label %64

64:                                               ; preds = %172, %63
  %65 = load i64, ptr %6, align 8, !tbaa !8
  %66 = load i64, ptr @N, align 8, !tbaa !8
  %67 = icmp sle i64 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %175

69:                                               ; preds = %64
  %70 = load i64, ptr %6, align 8, !tbaa !8
  %71 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %70
  %72 = getelementptr inbounds [1001 x i64], ptr %71, i64 0, i64 0
  store i64 0, ptr %72, align 8, !tbaa !8
  %73 = load i64, ptr %6, align 8, !tbaa !8
  %74 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %73
  %75 = getelementptr inbounds [1001 x i64], ptr %74, i64 0, i64 0
  store i64 1, ptr %75, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 1, ptr %7, align 8, !tbaa !8
  br label %76

76:                                               ; preds = %168, %69
  %77 = load i64, ptr %7, align 8, !tbaa !8
  %78 = load i64, ptr @K, align 8, !tbaa !8
  %79 = icmp sle i64 %77, %78
  br i1 %79, label %81, label %80

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

81:                                               ; preds = %76
  %82 = load i64, ptr %6, align 8, !tbaa !8
  %83 = sub nsw i64 %82, 1
  %84 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %83
  %85 = load i64, ptr %7, align 8, !tbaa !8
  %86 = getelementptr inbounds [1001 x i64], ptr %84, i64 0, i64 %85
  %87 = load i64, ptr %86, align 8, !tbaa !8
  %88 = load i64, ptr %6, align 8, !tbaa !8
  %89 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %88
  %90 = load i64, ptr %7, align 8, !tbaa !8
  %91 = getelementptr inbounds [1001 x i64], ptr %89, i64 0, i64 %90
  store i64 %87, ptr %91, align 8, !tbaa !8
  %92 = load i64, ptr %6, align 8, !tbaa !8
  %93 = sub nsw i64 %92, 1
  %94 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %93
  %95 = load i64, ptr %7, align 8, !tbaa !8
  %96 = getelementptr inbounds [1001 x i64], ptr %94, i64 0, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !8
  %98 = load i64, ptr %6, align 8, !tbaa !8
  %99 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %98
  %100 = load i64, ptr %7, align 8, !tbaa !8
  %101 = getelementptr inbounds [1001 x i64], ptr %99, i64 0, i64 %100
  store i64 %97, ptr %101, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %102 = load i64, ptr %6, align 8, !tbaa !8
  %103 = sub nsw i64 %102, 1
  %104 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %103
  %105 = load i64, ptr %7, align 8, !tbaa !8
  %106 = sub nsw i64 %105, 1
  %107 = getelementptr inbounds [1001 x i64], ptr %104, i64 0, i64 %106
  %108 = load i64, ptr %107, align 8, !tbaa !8
  %109 = load i64, ptr %6, align 8, !tbaa !8
  %110 = sub nsw i64 %109, 1
  %111 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !8
  %113 = add nsw i64 %108, %112
  store i64 %113, ptr %8, align 8, !tbaa !8
  %114 = load i64, ptr %8, align 8, !tbaa !8
  %115 = load i64, ptr %6, align 8, !tbaa !8
  %116 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %115
  %117 = load i64, ptr %7, align 8, !tbaa !8
  %118 = getelementptr inbounds [1001 x i64], ptr %116, i64 0, i64 %117
  %119 = load i64, ptr %118, align 8, !tbaa !8
  %120 = icmp sgt i64 %114, %119
  br i1 %120, label %121, label %138

121:                                              ; preds = %81
  %122 = load i64, ptr %8, align 8, !tbaa !8
  %123 = load i64, ptr %6, align 8, !tbaa !8
  %124 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %123
  %125 = load i64, ptr %7, align 8, !tbaa !8
  %126 = getelementptr inbounds [1001 x i64], ptr %124, i64 0, i64 %125
  store i64 %122, ptr %126, align 8, !tbaa !8
  %127 = load i64, ptr %6, align 8, !tbaa !8
  %128 = sub nsw i64 %127, 1
  %129 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %128
  %130 = load i64, ptr %7, align 8, !tbaa !8
  %131 = sub nsw i64 %130, 1
  %132 = getelementptr inbounds [1001 x i64], ptr %129, i64 0, i64 %131
  %133 = load i64, ptr %132, align 8, !tbaa !8
  %134 = load i64, ptr %6, align 8, !tbaa !8
  %135 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %134
  %136 = load i64, ptr %7, align 8, !tbaa !8
  %137 = getelementptr inbounds [1001 x i64], ptr %135, i64 0, i64 %136
  store i64 %133, ptr %137, align 8, !tbaa !8
  br label %167

138:                                              ; preds = %81
  %139 = load i64, ptr %8, align 8, !tbaa !8
  %140 = load i64, ptr %6, align 8, !tbaa !8
  %141 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %140
  %142 = load i64, ptr %7, align 8, !tbaa !8
  %143 = getelementptr inbounds [1001 x i64], ptr %141, i64 0, i64 %142
  %144 = load i64, ptr %143, align 8, !tbaa !8
  %145 = icmp eq i64 %139, %144
  br i1 %145, label %146, label %166

146:                                              ; preds = %138
  %147 = load i64, ptr %6, align 8, !tbaa !8
  %148 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %147
  %149 = load i64, ptr %7, align 8, !tbaa !8
  %150 = getelementptr inbounds [1001 x i64], ptr %148, i64 0, i64 %149
  %151 = load i64, ptr %150, align 8, !tbaa !8
  %152 = load i64, ptr %6, align 8, !tbaa !8
  %153 = sub nsw i64 %152, 1
  %154 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %153
  %155 = load i64, ptr %7, align 8, !tbaa !8
  %156 = sub nsw i64 %155, 1
  %157 = getelementptr inbounds [1001 x i64], ptr %154, i64 0, i64 %156
  %158 = load i64, ptr %157, align 8, !tbaa !8
  %159 = add nsw i64 %151, %158
  %160 = load i64, ptr @MOD, align 8, !tbaa !8
  %161 = srem i64 %159, %160
  %162 = load i64, ptr %6, align 8, !tbaa !8
  %163 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %162
  %164 = load i64, ptr %7, align 8, !tbaa !8
  %165 = getelementptr inbounds [1001 x i64], ptr %163, i64 0, i64 %164
  store i64 %161, ptr %165, align 8, !tbaa !8
  br label %166

166:                                              ; preds = %146, %138
  br label %167

167:                                              ; preds = %166, %121
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %168

168:                                              ; preds = %167
  %169 = load i64, ptr %7, align 8, !tbaa !8
  %170 = add nsw i64 %169, 1
  store i64 %170, ptr %7, align 8, !tbaa !8
  br label %76, !llvm.loop !15

171:                                              ; preds = %80
  br label %172

172:                                              ; preds = %171
  %173 = load i64, ptr %6, align 8, !tbaa !8
  %174 = add nsw i64 %173, 1
  store i64 %174, ptr %6, align 8, !tbaa !8
  br label %64, !llvm.loop !16

175:                                              ; preds = %68
  %176 = load i64, ptr @N, align 8, !tbaa !8
  %177 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %176
  %178 = load i64, ptr @K, align 8, !tbaa !8
  %179 = getelementptr inbounds [1001 x i64], ptr %177, i64 0, i64 %178
  %180 = load i64, ptr %179, align 8, !tbaa !8
  %181 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %180)
  %182 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %181, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %16, !llvm.loop !17

183:                                              ; preds = %16
  %184 = load i32, ptr %1, align 4
  ret i32 %184
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 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) #3 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 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 = { "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 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 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !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}


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

@MOD = external dso_local local_unnamed_addr global i64, align 8
@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@a = external dso_local global [1000 x i64], align 16
@dp1 = external dso_local local_unnamed_addr global [1001 x [1001 x i64]], align 16
@dp2 = external dso_local local_unnamed_addr global [1001 x [1001 x i64]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  %8 = load i64, ptr @T, align 8, !tbaa !8
  %9 = add nsw i64 %8, -1
  store i64 %9, ptr @T, align 8, !tbaa !8
  %.not77 = icmp eq i64 %8, 0
  br i1 %.not77, label %._crit_edge80, label %.lr.ph79

.lr.ph79:                                         ; preds = %0, %._crit_edge76
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(8) @K)
  %12 = load i64, ptr @N, align 8, !tbaa !8
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %.lr.ph, label %.preheader59

.preheader59:                                     ; preds = %.lr.ph, %.lr.ph79
  %.lcssa = phi i64 [ %12, %.lr.ph79 ], [ %18, %.lr.ph ]
  %.not5564 = icmp slt i64 %.lcssa, 0
  br i1 %.not5564, label %._crit_edge66.split.thread, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader59
  %14 = add nuw i64 %.lcssa, 1
  %min.iters.check = icmp ult i64 %.lcssa, 3
  %n.vec = and i64 %14, -4
  %cmp.n = icmp eq i64 %14, %n.vec
  br label %.preheader

._crit_edge66.split.thread:                       ; preds = %.preheader59
  store i64 0, ptr @dp1, align 16, !tbaa !8
  store i64 1, ptr @dp2, align 16, !tbaa !8
  %.pre8789 = load i64, ptr @K, align 8, !tbaa !8
  br label %._crit_edge76

.lr.ph:                                           ; preds = %.lr.ph79, %.lr.ph
  %.060 = phi i64 [ %17, %.lr.ph ], [ 0, %.lr.ph79 ]
  %15 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %.060
  %16 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %15)
  %17 = add nuw nsw i64 %.060, 1
  %18 = load i64, ptr @N, align 8, !tbaa !8
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %.lr.ph, label %.preheader59, !llvm.loop !11

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %.05165 = phi i64 [ %33, %._crit_edge ], [ 0, %.preheader.preheader ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader
  %.05062.ph = phi i64 [ 0, %.preheader ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.body:                                      ; preds = %.preheader, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader ]
  %20 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %.05165, i64 %index
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store <2 x i64> <i64 -1000000000, i64 -1000000000>, ptr %20, align 8, !tbaa !8
  store <2 x i64> <i64 -1000000000, i64 -1000000000>, ptr %21, align 8, !tbaa !8
  %22 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %.05165, i64 %index
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  store <2 x i64> <i64 -1000000000, i64 -1000000000>, ptr %22, align 8, !tbaa !8
  store <2 x i64> <i64 -1000000000, i64 -1000000000>, ptr %23, align 8, !tbaa !8
  %index.next = add nuw i64 %index, 4
  %24 = icmp eq i64 %index.next, %n.vec
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge66.split:                              ; preds = %._crit_edge
  store i64 0, ptr @dp1, align 16, !tbaa !8
  store i64 1, ptr @dp2, align 16, !tbaa !8
  %.not5672 = icmp eq i64 %.lcssa, 0
  %.pre87 = load i64, ptr @K, align 8, !tbaa !8
  br i1 %.not5672, label %._crit_edge76, label %.lr.ph75

.lr.ph75:                                         ; preds = %._crit_edge66.split
  %.not5767 = icmp slt i64 %.pre87, 1
  %25 = load i64, ptr @MOD, align 8
  br i1 %.not5767, label %.lr.ph75.split.us.preheader, label %.lr.ph70

.lr.ph75.split.us.preheader:                      ; preds = %.lr.ph75
  %xtraiter = and i64 %.lcssa, 1
  %26 = icmp eq i64 %.lcssa, 1
  br i1 %26, label %._crit_edge76.loopexit.unr-lcssa, label %.lr.ph75.split.us.preheader.new

.lr.ph75.split.us.preheader.new:                  ; preds = %.lr.ph75.split.us.preheader
  %unroll_iter = and i64 %.lcssa, 9223372036854775806
  br label %.lr.ph75.split.us

.lr.ph75.split.us:                                ; preds = %.lr.ph75.split.us, %.lr.ph75.split.us.preheader.new
  %.04973.us = phi i64 [ 1, %.lr.ph75.split.us.preheader.new ], [ %32, %.lr.ph75.split.us ]
  %niter = phi i64 [ 0, %.lr.ph75.split.us.preheader.new ], [ %niter.next.1, %.lr.ph75.split.us ]
  %27 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %.04973.us
  store i64 0, ptr %27, align 8, !tbaa !8
  %28 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %.04973.us
  store i64 1, ptr %28, align 8, !tbaa !8
  %29 = add nuw i64 %.04973.us, 1
  %30 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %29
  store i64 0, ptr %30, align 8, !tbaa !8
  %31 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %29
  store i64 1, ptr %31, align 8, !tbaa !8
  %32 = add nuw i64 %.04973.us, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge76.loopexit.unr-lcssa, label %.lr.ph75.split.us, !llvm.loop !16

._crit_edge:                                      ; preds = %scalar.ph, %middle.block
  %33 = add nuw i64 %.05165, 1
  %exitcond83.not = icmp eq i64 %.05165, %.lcssa
  br i1 %exitcond83.not, label %._crit_edge66.split, label %.preheader, !llvm.loop !17

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.05062 = phi i64 [ %36, %scalar.ph ], [ %.05062.ph, %scalar.ph.preheader ]
  %34 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %.05165, i64 %.05062
  store i64 -1000000000, ptr %34, align 8, !tbaa !8
  %35 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %.05165, i64 %.05062
  store i64 -1000000000, ptr %35, align 8, !tbaa !8
  %36 = add nuw i64 %.05062, 1
  %exitcond.not = icmp eq i64 %.05062, %.lcssa
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !18

._crit_edge76.loopexit.unr-lcssa:                 ; preds = %.lr.ph75.split.us, %.lr.ph75.split.us.preheader
  %.04973.us.unr = phi i64 [ 1, %.lr.ph75.split.us.preheader ], [ %32, %.lr.ph75.split.us ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge76, label %.lr.ph75.split.us.epil

.lr.ph75.split.us.epil:                           ; preds = %._crit_edge76.loopexit.unr-lcssa
  %37 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %.04973.us.unr
  store i64 0, ptr %37, align 8, !tbaa !8
  %38 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %.04973.us.unr
  store i64 1, ptr %38, align 8, !tbaa !8
  br label %._crit_edge76

._crit_edge76:                                    ; preds = %._crit_edge71, %.lr.ph75.split.us.epil, %._crit_edge76.loopexit.unr-lcssa, %._crit_edge66.split.thread, %._crit_edge66.split
  %.pre8790 = phi i64 [ %.pre8789, %._crit_edge66.split.thread ], [ %.pre87, %._crit_edge66.split ], [ %.pre87, %._crit_edge76.loopexit.unr-lcssa ], [ %.pre87, %.lr.ph75.split.us.epil ], [ %.pre87, %._crit_edge71 ]
  %39 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %.lcssa, i64 %.pre8790
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %41 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %40)
  %42 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %43 = load i64, ptr @T, align 8, !tbaa !8
  %44 = add nsw i64 %43, -1
  store i64 %44, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %43, 0
  br i1 %.not, label %._crit_edge80, label %.lr.ph79, !llvm.loop !19

.lr.ph70:                                         ; preds = %.lr.ph75, %._crit_edge71
  %.04973 = phi i64 [ %50, %._crit_edge71 ], [ 1, %.lr.ph75 ]
  %45 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %.04973
  store i64 0, ptr %45, align 8, !tbaa !8
  %46 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %.04973
  store i64 1, ptr %46, align 8, !tbaa !8
  %47 = add nsw i64 %.04973, -1
  %48 = getelementptr inbounds [1000 x i64], ptr @a, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !8
  %.phi.trans.insert = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %47, i64 0
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !8
  br label %51

._crit_edge71:                                    ; preds = %72
  %50 = add nuw i64 %.04973, 1
  %exitcond85.not = icmp eq i64 %.04973, %.lcssa
  br i1 %exitcond85.not, label %._crit_edge76, label %.lr.ph70, !llvm.loop !16

51:                                               ; preds = %.lr.ph70, %72
  %52 = phi i64 [ %.pre, %.lr.ph70 ], [ %54, %72 ]
  %.04868 = phi i64 [ 1, %.lr.ph70 ], [ %73, %72 ]
  %53 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %47, i64 %.04868
  %54 = load i64, ptr %53, align 8, !tbaa !8
  %55 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp1, i64 0, i64 %.04973, i64 %.04868
  store i64 %54, ptr %55, align 8, !tbaa !8
  %56 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %47, i64 %.04868
  %57 = load i64, ptr %56, align 8, !tbaa !8
  %58 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %.04973, i64 %.04868
  store i64 %57, ptr %58, align 8, !tbaa !8
  %59 = add nsw i64 %.04868, -1
  %60 = add nsw i64 %49, %52
  %61 = icmp sgt i64 %60, %54
  br i1 %61, label %62, label %65

62:                                               ; preds = %51
  store i64 %60, ptr %55, align 8, !tbaa !8
  %63 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %47, i64 %59
  %64 = load i64, ptr %63, align 8, !tbaa !8
  br label %.sink.split

65:                                               ; preds = %51
  %66 = icmp eq i64 %60, %54
  br i1 %66, label %67, label %72

67:                                               ; preds = %65
  %68 = getelementptr inbounds [1001 x [1001 x i64]], ptr @dp2, i64 0, i64 %47, i64 %59
  %69 = load i64, ptr %68, align 8, !tbaa !8
  %70 = add nsw i64 %69, %57
  %71 = srem i64 %70, %25
  br label %.sink.split

.sink.split:                                      ; preds = %62, %67
  %.sink = phi i64 [ %71, %67 ], [ %64, %62 ]
  store i64 %.sink, ptr %58, align 8, !tbaa !8
  br label %72

72:                                               ; preds = %.sink.split, %65
  %73 = add nuw i64 %.04868, 1
  %exitcond84.not = icmp eq i64 %.04868, %.pre87
  br i1 %exitcond84.not, label %._crit_edge71, label %51, !llvm.loop !20

._crit_edge80:                                    ; preds = %._crit_edge76, %0
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

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

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

; 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 #3 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 #3 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)) #4

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 = { "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 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 = { 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 #4 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12, !14, !15}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12, !15, !14}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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