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

; 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_ostream" = type { ptr, %"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 }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [300100 x i32], align 16
@cnt1 = external dso_local global i32, align 4
@cnt2 = external dso_local global i32, align 4
@l1 = external dso_local global i32, align 4
@l2 = external dso_local global i32, align 4
@dp = external dso_local global [5001 x [5001 x i64]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_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 i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %19, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = icmp sle i32 %10, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %16
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %17)
  br label %19

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !9

22:                                               ; preds = %13
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i32, ptr @a, i64 %24
  %26 = getelementptr inbounds i32, ptr %25, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef getelementptr inbounds (i32, ptr @a, i64 1), ptr noundef %26)
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = load i32, ptr @k, align 4, !tbaa !5
  %29 = srem i32 %27, %28
  store i32 %29, ptr @cnt1, align 4, !tbaa !5
  %30 = load i32, ptr @k, align 4, !tbaa !5
  %31 = load i32, ptr @cnt1, align 4, !tbaa !5
  %32 = sub nsw i32 %30, %31
  store i32 %32, ptr @cnt2, align 4, !tbaa !5
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = load i32, ptr @k, align 4, !tbaa !5
  %35 = sdiv i32 %33, %34
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr @l1, align 4, !tbaa !5
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = load i32, ptr @k, align 4, !tbaa !5
  %39 = sdiv i32 %37, %38
  store i32 %39, ptr @l2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %147, %22
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = load i32, ptr @cnt1, align 4, !tbaa !5
  %43 = icmp sle i32 %41, %42
  br i1 %43, label %45, label %44

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

45:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %143, %45
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = load i32, ptr @cnt2, align 4, !tbaa !5
  %49 = icmp sle i32 %47, %48
  br i1 %49, label %51, label %50

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

51:                                               ; preds = %46
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %58

54:                                               ; preds = %51
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  br label %143

58:                                               ; preds = %54, %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 1000000000000000000, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 1000000000000000000, ptr %7, align 8, !tbaa !11
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = icmp sgt i32 %59, 0
  br i1 %60, label %61, label %96

61:                                               ; preds = %58
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %64
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [5001 x i64], ptr %65, i64 0, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !11
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = load i32, ptr @l1, align 4, !tbaa !5
  %72 = mul nsw i32 %70, %71
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = load i32, ptr @l2, align 4, !tbaa !5
  %75 = mul nsw i32 %73, %74
  %76 = add nsw i32 %72, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = add nsw i64 %69, %80
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = sub nsw i32 %82, 1
  %84 = load i32, ptr @l1, align 4, !tbaa !5
  %85 = mul nsw i32 %83, %84
  %86 = load i32, ptr %5, align 4, !tbaa !5
  %87 = load i32, ptr @l2, align 4, !tbaa !5
  %88 = mul nsw i32 %86, %87
  %89 = add nsw i32 %85, %88
  %90 = add nsw i32 %89, 1
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = sub nsw i64 %81, %94
  store i64 %95, ptr %6, align 8, !tbaa !11
  br label %96

96:                                               ; preds = %61, %58
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = icmp sgt i32 %97, 0
  br i1 %98, label %99, label %134

99:                                               ; preds = %96
  %100 = load i32, ptr %3, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %101
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sub nsw i32 %103, 1
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [5001 x i64], ptr %102, i64 0, i64 %105
  %107 = load i64, ptr %106, align 8, !tbaa !11
  %108 = load i32, ptr %3, align 4, !tbaa !5
  %109 = load i32, ptr @l1, align 4, !tbaa !5
  %110 = mul nsw i32 %108, %109
  %111 = load i32, ptr %5, align 4, !tbaa !5
  %112 = load i32, ptr @l2, align 4, !tbaa !5
  %113 = mul nsw i32 %111, %112
  %114 = add nsw i32 %110, %113
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = add nsw i64 %107, %118
  %120 = load i32, ptr %3, align 4, !tbaa !5
  %121 = load i32, ptr @l1, align 4, !tbaa !5
  %122 = mul nsw i32 %120, %121
  %123 = load i32, ptr %5, align 4, !tbaa !5
  %124 = sub nsw i32 %123, 1
  %125 = load i32, ptr @l2, align 4, !tbaa !5
  %126 = mul nsw i32 %124, %125
  %127 = add nsw i32 %122, %126
  %128 = add nsw i32 %127, 1
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = sub nsw i64 %119, %132
  store i64 %133, ptr %7, align 8, !tbaa !11
  br label %134

134:                                              ; preds = %99, %96
  %135 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %136 = load i64, ptr %135, align 8, !tbaa !11
  %137 = load i32, ptr %3, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %138
  %140 = load i32, ptr %5, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [5001 x i64], ptr %139, i64 0, i64 %141
  store i64 %136, ptr %142, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %143

143:                                              ; preds = %134, %57
  %144 = load i32, ptr %5, align 4, !tbaa !5
  %145 = add nsw i32 %144, 1
  store i32 %145, ptr %5, align 4, !tbaa !5
  br label %46, !llvm.loop !13

146:                                              ; preds = %50
  br label %147

147:                                              ; preds = %146
  %148 = load i32, ptr %3, align 4, !tbaa !5
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %3, align 4, !tbaa !5
  br label %40, !llvm.loop !14

150:                                              ; preds = %44
  %151 = load i32, ptr @cnt1, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %152
  %154 = load i32, ptr @cnt2, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [5001 x i64], ptr %153, i64 0, i64 %155
  %157 = load i64, ptr %156, align 8, !tbaa !11
  %158 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %157)
  %159 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %158, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #5 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) #5 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)) #3

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


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

%"class.std::basic_ostream" = type { ptr, %"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 }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [300100 x i32], align 16
@cnt1 = external dso_local local_unnamed_addr global i32, align 4
@cnt2 = external dso_local local_unnamed_addr global i32, align 4
@l1 = external dso_local local_unnamed_addr global i32, align 4
@l2 = external dso_local local_unnamed_addr global i32, align 4
@dp = external dso_local local_unnamed_addr global [5001 x [5001 x i64]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_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 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @k)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not36 = icmp slt i32 %4, 1
  br i1 %.not36, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre64 = sext i32 %4 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre64, %.._crit_edge_crit_edge ], [ %17, %.lr.ph ]
  %5 = getelementptr inbounds i32, ptr @a, i64 %.pre-phi
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 4), ptr noundef nonnull %6)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = load i32, ptr @k, align 4, !tbaa !5
  %9 = srem i32 %7, %8
  store i32 %9, ptr @cnt1, align 4, !tbaa !5
  %10 = sub nsw i32 %8, %9
  store i32 %10, ptr @cnt2, align 4, !tbaa !5
  %11 = sdiv i32 %7, %8
  %12 = add nsw i32 %11, 1
  store i32 %12, ptr @l1, align 4, !tbaa !5
  store i32 %11, ptr @l2, align 4, !tbaa !5
  %.not3042 = icmp slt i32 %9, 0
  %13 = icmp slt i32 %10, 0
  %or.cond = select i1 %.not3042, i1 true, i1 %13
  br i1 %or.cond, label %._crit_edge45, label %.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %14 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %indvars.iv
  %15 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %.not.not = icmp slt i64 %indvars.iv, %17
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader:                                       ; preds = %._crit_edge, %._crit_edge41
  %18 = phi i32 [ %74, %._crit_edge41 ], [ %10, %._crit_edge ]
  %19 = phi i32 [ %75, %._crit_edge41 ], [ %10, %._crit_edge ]
  %20 = phi i32 [ %76, %._crit_edge41 ], [ %10, %._crit_edge ]
  %.02643 = phi i32 [ %77, %._crit_edge41 ], [ 0, %._crit_edge ]
  %.not3138 = icmp slt i32 %20, 0
  br i1 %.not3138, label %._crit_edge41, label %.lr.ph40

.lr.ph40:                                         ; preds = %.preheader
  %.not32 = icmp eq i32 %.02643, 0
  %21 = add nsw i32 %.02643, -1
  %22 = zext nneg i32 %21 to i64
  %23 = zext nneg i32 %.02643 to i64
  br i1 %.not32, label %.lr.ph40.split.us.preheader, label %24

24:                                               ; preds = %.lr.ph40
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  store i64 1000000000000000000, ptr %2, align 8, !tbaa !11
  %25 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %22, i64 0
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = load i32, ptr @l1, align 4, !tbaa !5
  %28 = mul nsw i32 %27, %.02643
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = add nsw i64 %26, %32
  %34 = mul nsw i32 %27, %21
  %35 = add i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = sub i64 %33, %39
  store i64 %40, ptr %1, align 8, !tbaa !11
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %42 = load i64, ptr %41, align 8, !tbaa !11
  %43 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %23, i64 0
  store i64 %42, ptr %43, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %.pre = load i32, ptr @cnt2, align 4, !tbaa !5
  %.not31.not.peel = icmp sgt i32 %.pre, 0
  br i1 %.not31.not.peel, label %.lr.ph40.split.peel.next, label %._crit_edge41

.lr.ph40.split.us.preheader:                      ; preds = %.lr.ph40
  %.not31.us.not.peel = icmp sgt i32 %19, 0
  br i1 %.not31.us.not.peel, label %.lr.ph40.split.us.peel.next, label %._crit_edge41

.lr.ph40.split.us.peel.next:                      ; preds = %.lr.ph40.split.us.preheader, %.lr.ph40.split.us.peel.next
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %.lr.ph40.split.us.peel.next ], [ 1, %.lr.ph40.split.us.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  store i64 1000000000000000000, ptr %1, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %44 = add nsw i64 %indvars.iv56, -1
  %45 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %23, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = load i32, ptr @l2, align 4, !tbaa !5
  %48 = trunc nuw nsw i64 %indvars.iv56 to i32
  %49 = mul nsw i32 %47, %48
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = add nsw i64 %46, %53
  %55 = trunc nsw i64 %44 to i32
  %56 = mul nsw i32 %47, %55
  %57 = add i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = sub i64 %54, %61
  store i64 %62, ptr %2, align 8, !tbaa !11
  %63 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %64 = load i64, ptr %63, align 8, !tbaa !11
  %65 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %23, i64 %indvars.iv56
  store i64 %64, ptr %65, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %.pre63 = load i32, ptr @cnt2, align 4, !tbaa !5
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %66 = sext i32 %.pre63 to i64
  %.not31.us.not = icmp slt i64 %indvars.iv56, %66
  br i1 %.not31.us.not, label %.lr.ph40.split.us.peel.next, label %._crit_edge41, !llvm.loop !13

._crit_edge45:                                    ; preds = %._crit_edge41, %._crit_edge
  %67 = phi i32 [ %10, %._crit_edge ], [ %74, %._crit_edge41 ]
  %.lcssa = phi i32 [ %9, %._crit_edge ], [ %78, %._crit_edge41 ]
  %68 = sext i32 %.lcssa to i64
  %69 = sext i32 %67 to i64
  %70 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %68, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !11
  %72 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %71)
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %72, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

._crit_edge41:                                    ; preds = %.lr.ph40.split.peel.next, %.lr.ph40.split.us.peel.next, %24, %.lr.ph40.split.us.preheader, %.preheader
  %74 = phi i32 [ %18, %.preheader ], [ %18, %.lr.ph40.split.us.preheader ], [ %.pre, %24 ], [ %.pre63, %.lr.ph40.split.us.peel.next ], [ %.pre61, %.lr.ph40.split.peel.next ]
  %75 = phi i32 [ %19, %.preheader ], [ %19, %.lr.ph40.split.us.preheader ], [ %.pre, %24 ], [ %.pre63, %.lr.ph40.split.us.peel.next ], [ %.pre61, %.lr.ph40.split.peel.next ]
  %76 = phi i32 [ %20, %.preheader ], [ %19, %.lr.ph40.split.us.preheader ], [ %.pre, %24 ], [ %.pre63, %.lr.ph40.split.us.peel.next ], [ %.pre61, %.lr.ph40.split.peel.next ]
  %77 = add i32 %.02643, 1
  %78 = load i32, ptr @cnt1, align 4, !tbaa !5
  %.not30 = icmp sgt i32 %77, %78
  br i1 %.not30, label %._crit_edge45, label %.preheader, !llvm.loop !15

.lr.ph40.split.peel.next:                         ; preds = %24, %.lr.ph40.split.peel.next
  %indvars.iv52 = phi i64 [ %indvars.iv.next53, %.lr.ph40.split.peel.next ], [ 1, %24 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %79 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %22, i64 %indvars.iv52
  %80 = load i64, ptr %79, align 8, !tbaa !11
  %81 = load i32, ptr @l1, align 4, !tbaa !5
  %82 = mul nsw i32 %81, %.02643
  %83 = load i32, ptr @l2, align 4, !tbaa !5
  %84 = trunc nuw nsw i64 %indvars.iv52 to i32
  %85 = mul nsw i32 %83, %84
  %86 = add nsw i32 %85, %82
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = add nsw i64 %80, %90
  %92 = mul nsw i32 %81, %21
  %93 = add i32 %92, 1
  %94 = add i32 %93, %85
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = sub i64 %91, %98
  store i64 %99, ptr %1, align 8, !tbaa !11
  %100 = add nsw i64 %indvars.iv52, -1
  %101 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %23, i64 %100
  %102 = load i64, ptr %101, align 8, !tbaa !11
  %103 = add nsw i64 %102, %90
  %104 = trunc nsw i64 %100 to i32
  %105 = mul nsw i32 %83, %104
  %106 = add i32 %82, 1
  %107 = add i32 %106, %105
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [300100 x i32], ptr @a, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = sub i64 %103, %111
  store i64 %112, ptr %2, align 8, !tbaa !11
  %113 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %114 = load i64, ptr %113, align 8, !tbaa !11
  %115 = getelementptr inbounds [5001 x [5001 x i64]], ptr @dp, i64 0, i64 %23, i64 %indvars.iv52
  store i64 %114, ptr %115, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %.pre61 = load i32, ptr @cnt2, align 4, !tbaa !5
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %116 = sext i32 %.pre61 to i64
  %.not31.not = icmp slt i64 %indvars.iv52, %116
  br i1 %.not31.not, label %.lr.ph40.split.peel.next, label %._crit_edge41, !llvm.loop !17
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = !{!"int", !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 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10, !14}
!14 = !{!"llvm.loop.peeled.count", i32 1}
!15 = distinct !{!15, !10, !16}
!16 = !{!"llvm.loop.unswitch.partial.disable"}
!17 = distinct !{!17, !10, !14}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass