; LLVM IR from eyangch/competitive-programming :: JOI/2018 (tents)

; 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
@H = external dso_local global i32, align 4
@W = external dso_local global i32, align 4
@dp = external dso_local global [3001 x [3001 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 i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %7 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @H)
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 4 dereferenceable(4) @W)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %18, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr @W, 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) #5
  br label %21

14:                                               ; preds = %9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [3001 x i64], ptr @dp, i64 0, i64 %16
  store i64 1, ptr %17, align 8, !tbaa !9
  br label %18

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

21:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %32, %21
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = load i32, ptr @H, align 4, !tbaa !5
  %25 = icmp sle i32 %23, %24
  br i1 %25, label %27, label %26

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

27:                                               ; preds = %22
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %29
  %31 = getelementptr inbounds [3001 x i64], ptr %30, i64 0, i64 0
  store i64 1, ptr %31, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %3, align 4, !tbaa !5
  br label %22, !llvm.loop !13

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

36:                                               ; preds = %170, %35
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = load i32, ptr @H, align 4, !tbaa !5
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %41, label %40

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

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

42:                                               ; preds = %166, %41
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = load i32, ptr @W, align 4, !tbaa !5
  %45 = icmp sle i32 %43, %44
  br i1 %45, label %47, label %46

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

47:                                               ; preds = %42
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %50, label %67

50:                                               ; preds = %47
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sub nsw i32 %51, 1
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %53
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [3001 x i64], ptr %54, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %60
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [3001 x i64], ptr %61, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !9
  %66 = add nsw i64 %65, %58
  store i64 %66, ptr %64, align 8, !tbaa !9
  br label %67

67:                                               ; preds = %50, %47
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = icmp sgt i32 %68, 0
  br i1 %69, label %70, label %95

70:                                               ; preds = %67
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %73, label %95

73:                                               ; preds = %70
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = mul nsw i32 4, %74
  %76 = sext i32 %75 to i64
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = sub nsw i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %79
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = sub nsw i32 %81, 1
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [3001 x i64], ptr %80, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !9
  %86 = mul nsw i64 %76, %85
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %88
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [3001 x i64], ptr %89, i64 0, i64 %91
  %93 = load i64, ptr %92, align 8, !tbaa !9
  %94 = add nsw i64 %93, %86
  store i64 %94, ptr %92, align 8, !tbaa !9
  br label %95

95:                                               ; preds = %73, %70, %67
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = icmp sgt i32 %96, 0
  br i1 %97, label %98, label %126

98:                                               ; preds = %95
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = icmp sgt i32 %99, 1
  br i1 %100, label %101, label %126

101:                                              ; preds = %98
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = load i32, ptr %6, align 4, !tbaa !5
  %104 = sub nsw i32 %103, 1
  %105 = mul nsw i32 %102, %104
  %106 = sdiv i32 %105, 2
  %107 = sext i32 %106 to i64
  %108 = load i32, ptr %4, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 1
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %110
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sub nsw i32 %112, 2
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [3001 x i64], ptr %111, i64 0, i64 %114
  %116 = load i64, ptr %115, align 8, !tbaa !9
  %117 = mul nsw i64 %107, %116
  %118 = load i32, ptr %4, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %119
  %121 = load i32, ptr %6, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [3001 x i64], ptr %120, i64 0, i64 %122
  %124 = load i64, ptr %123, align 8, !tbaa !9
  %125 = add nsw i64 %124, %117
  store i64 %125, ptr %123, align 8, !tbaa !9
  br label %126

126:                                              ; preds = %101, %98, %95
  %127 = load i32, ptr %4, align 4, !tbaa !5
  %128 = icmp sgt i32 %127, 1
  br i1 %128, label %129, label %156

129:                                              ; preds = %126
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = icmp sgt i32 %130, 0
  br i1 %131, label %132, label %156

132:                                              ; preds = %129
  %133 = load i32, ptr %6, align 4, !tbaa !5
  %134 = load i32, ptr %4, align 4, !tbaa !5
  %135 = sub nsw i32 %134, 1
  %136 = mul nsw i32 %133, %135
  %137 = sext i32 %136 to i64
  %138 = load i32, ptr %4, align 4, !tbaa !5
  %139 = sub nsw i32 %138, 2
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %140
  %142 = load i32, ptr %6, align 4, !tbaa !5
  %143 = sub nsw i32 %142, 1
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [3001 x i64], ptr %141, i64 0, i64 %144
  %146 = load i64, ptr %145, align 8, !tbaa !9
  %147 = mul nsw i64 %137, %146
  %148 = load i32, ptr %4, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %149
  %151 = load i32, ptr %6, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [3001 x i64], ptr %150, i64 0, i64 %152
  %154 = load i64, ptr %153, align 8, !tbaa !9
  %155 = add nsw i64 %154, %147
  store i64 %155, ptr %153, align 8, !tbaa !9
  br label %156

156:                                              ; preds = %132, %129, %126
  %157 = load i64, ptr @MOD, align 8, !tbaa !9
  %158 = load i32, ptr %4, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %159
  %161 = load i32, ptr %6, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [3001 x i64], ptr %160, i64 0, i64 %162
  %164 = load i64, ptr %163, align 8, !tbaa !9
  %165 = srem i64 %164, %157
  store i64 %165, ptr %163, align 8, !tbaa !9
  br label %166

166:                                              ; preds = %156
  %167 = load i32, ptr %6, align 4, !tbaa !5
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %6, align 4, !tbaa !5
  br label %42, !llvm.loop !14

169:                                              ; preds = %46
  br label %170

170:                                              ; preds = %169
  %171 = load i32, ptr %4, align 4, !tbaa !5
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %4, align 4, !tbaa !5
  br label %36, !llvm.loop !15

173:                                              ; preds = %40
  %174 = load i32, ptr @H, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %175
  %177 = load i32, ptr @W, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [3001 x i64], ptr %176, i64 0, i64 %178
  %180 = load i64, ptr %179, align 8, !tbaa !9
  %181 = sub nsw i64 %180, 1
  %182 = load i64, ptr @MOD, align 8, !tbaa !9
  %183 = add nsw i64 %181, %182
  %184 = load i64, ptr @MOD, align 8, !tbaa !9
  %185 = srem i64 %183, %184
  %186 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %185)
  %187 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %186, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %188 = load i32, ptr %1, align 4
  ret i32 %188
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #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: 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)) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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
@H = external dso_local global i32, align 4
@W = external dso_local global i32, align 4
@dp = external dso_local local_unnamed_addr global [3001 x [3001 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 nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @H)
  %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) @W)
  %3 = load i32, ptr @W, align 4, !tbaa !5
  %.not56 = icmp slt i32 %3, 0
  br i1 %.not56, label %.preheader54, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %4 = add nuw i32 %3, 1
  %wide.trip.count = zext i32 %4 to i64
  %min.iters.check = icmp ult i32 %3, 3
  br i1 %min.iters.check, label %.lr.ph.preheader99, label %vector.ph

.lr.ph.preheader99:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %wide.trip.count, 4294967292
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %5 = getelementptr inbounds [3001 x i64], ptr @dp, i64 0, i64 %index
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  store <2 x i64> <i64 1, i64 1>, ptr %5, align 16, !tbaa !9
  store <2 x i64> <i64 1, i64 1>, ptr %6, align 16, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %7 = icmp eq i64 %index.next, %n.vec
  br i1 %7, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.preheader54, label %.lr.ph.preheader99

.preheader54:                                     ; preds = %.lr.ph, %middle.block, %0
  %8 = load i32, ptr @H, align 4, !tbaa !5
  %.not5058 = icmp slt i32 %8, 0
  br i1 %.not5058, label %.preheader53.thread, label %.lr.ph60.preheader

.preheader53.thread:                              ; preds = %.preheader54
  %.pre94 = load i64, ptr @MOD, align 8
  br label %._crit_edge67

.lr.ph60.preheader:                               ; preds = %.preheader54
  %9 = add nuw i32 %8, 1
  %wide.trip.count74 = zext i32 %9 to i64
  %xtraiter = and i64 %wide.trip.count74, 3
  %10 = icmp ult i32 %8, 3
  br i1 %10, label %.preheader53.unr-lcssa, label %.lr.ph60.preheader.new

.lr.ph60.preheader.new:                           ; preds = %.lr.ph60.preheader
  %unroll_iter = and i64 %wide.trip.count74, 4294967292
  br label %.lr.ph60

.lr.ph:                                           ; preds = %.lr.ph.preheader99, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader99 ]
  %11 = getelementptr inbounds [3001 x i64], ptr @dp, i64 0, i64 %indvars.iv
  store i64 1, ptr %11, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader54, label %.lr.ph, !llvm.loop !15

.preheader53.unr-lcssa:                           ; preds = %.lr.ph60, %.lr.ph60.preheader
  %indvars.iv71.unr = phi i64 [ 0, %.lr.ph60.preheader ], [ %indvars.iv.next72.3, %.lr.ph60 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader53, label %.lr.ph60.epil

.lr.ph60.epil:                                    ; preds = %.preheader53.unr-lcssa, %.lr.ph60.epil
  %indvars.iv71.epil = phi i64 [ %indvars.iv.next72.epil, %.lr.ph60.epil ], [ %indvars.iv71.unr, %.preheader53.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph60.epil ], [ 0, %.preheader53.unr-lcssa ]
  %12 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %indvars.iv71.epil
  store i64 1, ptr %12, align 8, !tbaa !9
  %indvars.iv.next72.epil = add nuw nsw i64 %indvars.iv71.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader53, label %.lr.ph60.epil, !llvm.loop !16

.preheader53:                                     ; preds = %.lr.ph60.epil, %.preheader53.unr-lcssa
  %.not5165 = icmp eq i32 %8, 0
  %.pre = load i64, ptr @MOD, align 8
  %.not5262 = icmp slt i32 %3, 1
  %or.cond = or i1 %.not5165, %.not5262
  br i1 %or.cond, label %._crit_edge67, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader53
  %13 = add nuw i32 %3, 1
  %14 = add nuw i32 %8, 1
  %wide.trip.count91 = zext i32 %14 to i64
  %wide.trip.count79 = zext i32 %13 to i64
  %exitcond80.peel.not = icmp eq i32 %13, 2
  %wide.trip.count85 = zext i32 %13 to i64
  %exitcond86.peel.not = icmp eq i32 %13, 2
  br label %.preheader

.lr.ph60:                                         ; preds = %.lr.ph60, %.lr.ph60.preheader.new
  %indvars.iv71 = phi i64 [ 0, %.lr.ph60.preheader.new ], [ %indvars.iv.next72.3, %.lr.ph60 ]
  %niter = phi i64 [ 0, %.lr.ph60.preheader.new ], [ %niter.next.3, %.lr.ph60 ]
  %15 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %indvars.iv71
  store i64 1, ptr %15, align 16, !tbaa !9
  %indvars.iv.next72 = or disjoint i64 %indvars.iv71, 1
  %16 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %indvars.iv.next72
  store i64 1, ptr %16, align 8, !tbaa !9
  %indvars.iv.next72.1 = or disjoint i64 %indvars.iv71, 2
  %17 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %indvars.iv.next72.1
  store i64 1, ptr %17, align 16, !tbaa !9
  %indvars.iv.next72.2 = or disjoint i64 %indvars.iv71, 3
  %18 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %indvars.iv.next72.2
  store i64 1, ptr %18, align 8, !tbaa !9
  %indvars.iv.next72.3 = add nuw nsw i64 %indvars.iv71, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader53.unr-lcssa, label %.lr.ph60, !llvm.loop !18

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %indvars.iv88 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next89, %._crit_edge ]
  %19 = add nsw i64 %indvars.iv88, -1
  %20 = icmp ugt i64 %indvars.iv88, 1
  %21 = add nsw i64 %indvars.iv88, -2
  %22 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %19, i64 1
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %indvars.iv88, i64 1
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = add nsw i64 %25, %23
  %27 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %19, i64 0
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = shl nsw i64 %28, 2
  %30 = add nsw i64 %29, %26
  br i1 %20, label %33, label %31

31:                                               ; preds = %.preheader
  %32 = srem i64 %30, %.pre
  store i64 %32, ptr %24, align 8, !tbaa !9
  br i1 %exitcond80.peel.not, label %._crit_edge, label %.lr.ph64.split.peel.next

33:                                               ; preds = %.preheader
  %34 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %21, i64 0
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = mul nsw i64 %35, %19
  %37 = add nsw i64 %30, %36
  %38 = srem i64 %37, %.pre
  store i64 %38, ptr %24, align 8, !tbaa !9
  br i1 %exitcond86.peel.not, label %._crit_edge, label %.lr.ph64.split.us.peel.next

.lr.ph64.split.us.peel.next:                      ; preds = %33, %.lr.ph64.split.us.peel.next
  %39 = phi i64 [ %41, %.lr.ph64.split.us.peel.next ], [ %23, %33 ]
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %.lr.ph64.split.us.peel.next ], [ 2, %33 ]
  %40 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %19, i64 %indvars.iv82
  %41 = load i64, ptr %40, align 8, !tbaa !9
  %42 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %indvars.iv88, i64 %indvars.iv82
  %43 = load i64, ptr %42, align 8, !tbaa !9
  %44 = add nsw i64 %43, %41
  %45 = shl nsw i64 %indvars.iv82, 2
  %46 = add nsw i64 %indvars.iv82, -1
  %47 = mul nsw i64 %39, %45
  %48 = add nsw i64 %47, %44
  %49 = add nuw i64 %indvars.iv82, 4294967295
  %50 = mul i64 %49, %indvars.iv82
  %51 = lshr i64 %50, 1
  %52 = and i64 %51, 2147483647
  %53 = add nsw i64 %indvars.iv82, -2
  %54 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %19, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !9
  %56 = mul nsw i64 %55, %52
  %57 = add nsw i64 %56, %48
  %58 = mul nuw nsw i64 %indvars.iv82, %19
  %59 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %21, i64 %46
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = mul nsw i64 %60, %58
  %62 = add nsw i64 %57, %61
  %63 = srem i64 %62, %.pre
  store i64 %63, ptr %42, align 8, !tbaa !9
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %exitcond86.not = icmp eq i64 %indvars.iv.next83, %wide.trip.count85
  br i1 %exitcond86.not, label %._crit_edge, label %.lr.ph64.split.us.peel.next, !llvm.loop !19

._crit_edge67:                                    ; preds = %._crit_edge, %.preheader53.thread, %.preheader53
  %.pre95 = phi i64 [ %.pre94, %.preheader53.thread ], [ %.pre, %.preheader53 ], [ %.pre, %._crit_edge ]
  %64 = sext i32 %8 to i64
  %65 = sext i32 %3 to i64
  %66 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %64, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = add nsw i64 %67, -1
  %69 = add nsw i64 %68, %.pre95
  %70 = srem i64 %69, %.pre95
  %71 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %70)
  %72 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %71, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

._crit_edge:                                      ; preds = %.lr.ph64.split.peel.next, %.lr.ph64.split.us.peel.next, %31, %33
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %exitcond92.not = icmp eq i64 %indvars.iv.next89, %wide.trip.count91
  br i1 %exitcond92.not, label %._crit_edge67, label %.preheader, !llvm.loop !21

.lr.ph64.split.peel.next:                         ; preds = %31, %.lr.ph64.split.peel.next
  %73 = phi i64 [ %75, %.lr.ph64.split.peel.next ], [ %23, %31 ]
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %.lr.ph64.split.peel.next ], [ 2, %31 ]
  %74 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %19, i64 %indvars.iv76
  %75 = load i64, ptr %74, align 8, !tbaa !9
  %76 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %indvars.iv88, i64 %indvars.iv76
  %77 = load i64, ptr %76, align 8, !tbaa !9
  %78 = add nsw i64 %77, %75
  %79 = shl nsw i64 %indvars.iv76, 2
  %80 = mul nsw i64 %73, %79
  %81 = add nsw i64 %80, %78
  %82 = add nuw i64 %indvars.iv76, 4294967295
  %83 = mul i64 %82, %indvars.iv76
  %84 = lshr i64 %83, 1
  %85 = and i64 %84, 2147483647
  %86 = add nsw i64 %indvars.iv76, -2
  %87 = getelementptr inbounds [3001 x [3001 x i64]], ptr @dp, i64 0, i64 %19, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !9
  %89 = mul nsw i64 %88, %85
  %90 = add nsw i64 %89, %81
  %91 = srem i64 %90, %.pre
  store i64 %91, ptr %76, align 8, !tbaa !9
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %exitcond80.not = icmp eq i64 %indvars.iv.next77, %wide.trip.count79
  br i1 %exitcond80.not, label %._crit_edge, label %.lr.ph64.split.peel.next, !llvm.loop !22
}

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 uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #2 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 #2 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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !14, !13}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12, !20}
!20 = !{!"llvm.loop.peeled.count", i32 1}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12, !20}


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