; LLVM IR from ncduy0303/Competitive-Programming :: Dynamic Programming/D&C Trick.ll (Z5solvev)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [5001 x i32], align 16
@ps = external dso_local global [5001 x [5001 x i32]], align 16
@dp = external dso_local global [5001 x [5001 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3daciiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 4 dereferenceable(4) @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %10

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

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  br label %23

15:                                               ; preds = %10
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %17
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %18)
  br label %20

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

23:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %56, %23
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = icmp sle i32 %25, %26
  br i1 %27, label %29, label %28

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

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

30:                                               ; preds = %52, %29
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %30
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp sgt i32 %39, %43
  %45 = zext i1 %44 to i32
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %47
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [5001 x i32], ptr %48, i64 0, i64 %50
  store i32 %45, ptr %51, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %35
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %4, align 4, !tbaa !5
  br label %30, !llvm.loop !11

55:                                               ; preds = %34
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %2, align 4, !tbaa !5
  br label %24, !llvm.loop !12

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

60:                                               ; preds = %117, %59
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = icmp sle i32 %61, %62
  br i1 %63, label %65, label %64

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

65:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %113, %65
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = icmp sle i32 %67, %68
  br i1 %69, label %71, label %70

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

71:                                               ; preds = %66
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sub nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %74
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [5001 x i32], ptr %75, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %81
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = sub nsw i32 %83, 1
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [5001 x i32], ptr %82, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = add nsw i32 %79, %87
  %89 = load i32, ptr %5, align 4, !tbaa !5
  %90 = sub nsw i32 %89, 1
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %91
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = sub nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [5001 x i32], ptr %92, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = sub nsw i32 %88, %97
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %100
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [5001 x i32], ptr %101, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = add nsw i32 %98, %105
  %107 = load i32, ptr %5, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %108
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [5001 x i32], ptr %109, i64 0, i64 %111
  store i32 %106, ptr %112, align 4, !tbaa !5
  br label %113

113:                                              ; preds = %71
  %114 = load i32, ptr %6, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %6, align 4, !tbaa !5
  br label %66, !llvm.loop !13

116:                                              ; preds = %70
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %5, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %5, align 4, !tbaa !5
  br label %60, !llvm.loop !14

120:                                              ; preds = %64
  call void @llvm.memset.p0.i64(ptr align 16 @dp, i8 63, i64 100040004, i1 false)
  store i32 0, ptr @dp, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %121

121:                                              ; preds = %132, %120
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = load i32, ptr @m, align 4, !tbaa !5
  %124 = icmp sle i32 %122, %123
  br i1 %124, label %126, label %125

125:                                              ; preds = %121
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %135

126:                                              ; preds = %121
  %127 = load i32, ptr %7, align 4, !tbaa !5
  %128 = load i32, ptr %7, align 4, !tbaa !5
  %129 = load i32, ptr @n, align 4, !tbaa !5
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z3daciiiii(i32 noundef %127, i32 noundef %128, i32 noundef %129, i32 noundef %130, i32 noundef %131)
  br label %132

132:                                              ; preds = %126
  %133 = load i32, ptr %7, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %7, align 4, !tbaa !5
  br label %121, !llvm.loop !15

135:                                              ; preds = %125
  %136 = load i32, ptr @m, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [5001 x [5001 x i32]], ptr @dp, i64 0, i64 %137
  %139 = load i32, ptr @n, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [5001 x i32], ptr %138, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %142)
  %144 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %143, ptr noundef @.str)
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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" }
attributes #5 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !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_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" }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [5001 x i32], align 16
@ps = external dso_local local_unnamed_addr global [5001 x [5001 x i32]], align 16
@dp = external dso_local local_unnamed_addr global [5001 x [5001 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3daciiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = 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) @n)
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not45 = icmp slt i32 %3, 1
  br i1 %.not45, label %._crit_edge57, label %.lr.ph

.preheader43:                                     ; preds = %.lr.ph
  %.not3749 = icmp slt i32 %7, 1
  br i1 %.not3749, label %._crit_edge57, label %.preheader42.preheader

.preheader42.preheader:                           ; preds = %.preheader43
  %4 = add nuw i32 %7, 1
  %wide.trip.count73 = zext i32 %4 to i64
  br label %.preheader42

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %5 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %indvars.iv
  %6 = 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) %5)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %.not.not = icmp slt i64 %indvars.iv, %8
  br i1 %.not.not, label %.lr.ph, label %.preheader43, !llvm.loop !9

.preheader42:                                     ; preds = %.preheader42.preheader, %._crit_edge
  %indvar = phi i64 [ 0, %.preheader42.preheader ], [ %indvar.next, %._crit_edge ]
  %indvars.iv70 = phi i64 [ 1, %.preheader42.preheader ], [ %indvars.iv.next71, %._crit_edge ]
  %9 = icmp ugt i64 %indvars.iv70, 1
  br i1 %9, label %.lr.ph48, label %._crit_edge

.lr.ph48:                                         ; preds = %.preheader42
  %10 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %indvars.iv70
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %min.iters.check = icmp ult i64 %indvar, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph48
  %indvars.iv67.ph = phi i64 [ 1, %.lr.ph48 ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph48
  %n.vec = and i64 %indvar, -8
  %ind.end = or disjoint i64 %n.vec, 1
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %11, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %12 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %offset.idx
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %wide.load = load <4 x i32>, ptr %12, align 4, !tbaa !5
  %wide.load99 = load <4 x i32>, ptr %13, align 4, !tbaa !5
  %14 = icmp sgt <4 x i32> %wide.load, %broadcast.splat
  %15 = icmp sgt <4 x i32> %wide.load99, %broadcast.splat
  %16 = zext <4 x i1> %14 to <4 x i32>
  %17 = zext <4 x i1> %15 to <4 x i32>
  %18 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %indvars.iv70, i64 %offset.idx
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  store <4 x i32> %16, ptr %18, align 4, !tbaa !5
  store <4 x i32> %17, ptr %19, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %20 = icmp eq i64 %index.next, %n.vec
  br i1 %20, label %middle.block, label %vector.body, !llvm.loop !11

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

.preheader41:                                     ; preds = %._crit_edge
  br i1 %.not3749, label %._crit_edge57, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader41
  %21 = add nuw i32 %7, 1
  %wide.trip.count82 = zext i32 %21 to i64
  %.pre85.pre = load i32, ptr @ps, align 16, !tbaa !5
  %22 = zext nneg i32 %7 to i64
  %xtraiter = and i64 %22, 1
  %23 = icmp eq i32 %4, 2
  %unroll_iter = and i64 %22, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %.preheader42
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %exitcond74.not = icmp eq i64 %indvars.iv.next71, %wide.trip.count73
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond74.not, label %.preheader41, label %.preheader42, !llvm.loop !14

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %scalar.ph ], [ %indvars.iv67.ph, %scalar.ph.preheader ]
  %24 = getelementptr inbounds [5001 x i32], ptr @a, i64 0, i64 %indvars.iv67
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, %11
  %27 = zext i1 %26 to i32
  %28 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %indvars.iv70, i64 %indvars.iv67
  store i32 %27, ptr %28, align 4, !tbaa !5
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next68, %indvars.iv70
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !15

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge54
  %.pre85 = phi i32 [ %.pre85.pre, %.preheader.preheader ], [ %.pre, %._crit_edge54 ]
  %indvars.iv79 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next80, %._crit_edge54 ]
  %29 = add nsw i64 %indvars.iv79, -1
  %.phi.trans.insert = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %indvars.iv79, i64 0
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  br i1 %23, label %._crit_edge54.unr-lcssa, label %.preheader.new

._crit_edge57:                                    ; preds = %._crit_edge54, %0, %.preheader43, %.preheader41
  %.lcssa449094 = phi i32 [ %7, %.preheader41 ], [ %7, %.preheader43 ], [ %3, %0 ], [ %7, %._crit_edge54 ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(100040004) @dp, i8 63, i64 100040004, i1 false)
  store i32 0, ptr @dp, align 16, !tbaa !5
  %30 = load i32, ptr @m, align 4, !tbaa !5
  %.not3958 = icmp slt i32 %30, 1
  br i1 %.not3958, label %._crit_edge62, label %.lr.ph61

._crit_edge54.unr-lcssa:                          ; preds = %.preheader.new, %.preheader
  %.unr = phi i32 [ %.pre85, %.preheader ], [ %48, %.preheader.new ]
  %.unr102 = phi i32 [ %.pre, %.preheader ], [ %53, %.preheader.new ]
  %indvars.iv75.unr = phi i64 [ 1, %.preheader ], [ %indvars.iv.next76.1, %.preheader.new ]
  br i1 %lcmp.mod.not, label %._crit_edge54, label %._crit_edge54.epilog-lcssa

._crit_edge54.epilog-lcssa:                       ; preds = %._crit_edge54.unr-lcssa
  %31 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %29, i64 %indvars.iv75.unr
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %.unr102, %32
  %34 = sub i32 %33, %.unr
  %35 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %indvars.iv79, i64 %indvars.iv75.unr
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = add nsw i32 %34, %36
  store i32 %37, ptr %35, align 4, !tbaa !5
  br label %._crit_edge54

._crit_edge54:                                    ; preds = %._crit_edge54.unr-lcssa, %._crit_edge54.epilog-lcssa
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %exitcond83.not = icmp eq i64 %indvars.iv.next80, %wide.trip.count82
  br i1 %exitcond83.not, label %._crit_edge57, label %.preheader, !llvm.loop !16

.preheader.new:                                   ; preds = %.preheader, %.preheader.new
  %38 = phi i32 [ %48, %.preheader.new ], [ %.pre85, %.preheader ]
  %39 = phi i32 [ %53, %.preheader.new ], [ %.pre, %.preheader ]
  %indvars.iv75 = phi i64 [ %indvars.iv.next76.1, %.preheader.new ], [ 1, %.preheader ]
  %niter = phi i64 [ %niter.next.1, %.preheader.new ], [ 0, %.preheader ]
  %40 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %29, i64 %indvars.iv75
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = add nsw i32 %39, %41
  %43 = sub i32 %42, %38
  %44 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %indvars.iv79, i64 %indvars.iv75
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = add nsw i32 %43, %45
  store i32 %46, ptr %44, align 4, !tbaa !5
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %47 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %29, i64 %indvars.iv.next76
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = add nsw i32 %46, %48
  %50 = sub i32 %49, %41
  %51 = getelementptr inbounds [5001 x [5001 x i32]], ptr @ps, i64 0, i64 %indvars.iv79, i64 %indvars.iv.next76
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = add nsw i32 %50, %52
  store i32 %53, ptr %51, align 4, !tbaa !5
  %indvars.iv.next76.1 = add nuw nsw i64 %indvars.iv75, 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_edge54.unr-lcssa, label %.preheader.new, !llvm.loop !17

._crit_edge62.loopexit:                           ; preds = %.lr.ph61
  %.pre86 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge62

._crit_edge62:                                    ; preds = %._crit_edge62.loopexit, %._crit_edge57
  %54 = phi i32 [ %.lcssa449094, %._crit_edge57 ], [ %.pre86, %._crit_edge62.loopexit ]
  %.lcssa = phi i32 [ %30, %._crit_edge57 ], [ %63, %._crit_edge62.loopexit ]
  %55 = sext i32 %.lcssa to i64
  %56 = sext i32 %54 to i64
  %57 = getelementptr inbounds [5001 x [5001 x i32]], ptr @dp, i64 0, i64 %55, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %58)
  %60 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %59, ptr noundef nonnull @.str)
  ret void

.lr.ph61:                                         ; preds = %._crit_edge57, %.lr.ph61
  %.059 = phi i32 [ %62, %.lr.ph61 ], [ 1, %._crit_edge57 ]
  %61 = load i32, ptr @n, align 4, !tbaa !5
  tail call void @_Z3daciiiii(i32 noundef %.059, i32 noundef %.059, i32 noundef %61, i32 noundef %.059, i32 noundef %61)
  %62 = add nuw nsw i32 %.059, 1
  %63 = load i32, ptr @m, align 4, !tbaa !5
  %.not39.not = icmp slt i32 %.059, %63
  br i1 %.not39.not, label %.lr.ph61, label %._crit_edge62.loopexit, !llvm.loop !18
}

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 #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 nocallback nofree nounwind willreturn memory(argmem: write) }
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" }

!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 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !13, !12}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


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