; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/LONG/JUNE15/STDYTAB (a)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@c = external dso_local global [4001 x [4001 x i64]], align 16
@dp = external dso_local global [2001 x [2001 x i64]], align 16
@MOD = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; 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
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %10

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

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

14:                                               ; preds = %10
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %16
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [4001 x i64], ptr %17, i64 0, i64 %19
  store i64 1, ptr %20, align 8, !tbaa !9
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %22
  %24 = getelementptr inbounds [4001 x i64], ptr %23, i64 0, i64 0
  store i64 1, ptr %24, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %14
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !11

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

29:                                               ; preds = %70, %28
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = icmp sle i32 %30, 4000
  br i1 %31, label %33, label %32

32:                                               ; preds = %29
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %73

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

34:                                               ; preds = %66, %33
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

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

39:                                               ; preds = %34
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %42
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [4001 x i64], ptr %43, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %51
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [4001 x i64], ptr %52, i64 0, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = add nsw i64 %48, %56
  %58 = load i64, ptr @MOD, align 8, !tbaa !9
  %59 = srem i64 %57, %58
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %61
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [4001 x i64], ptr %62, i64 0, i64 %64
  store i64 %59, ptr %65, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %39
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %5, align 4, !tbaa !5
  br label %34, !llvm.loop !13

69:                                               ; preds = %38
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !14

73:                                               ; preds = %32
  %74 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %84, %73
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = icmp sle i32 %76, 2000
  br i1 %77, label %79, label %78

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

79:                                               ; preds = %75
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %81
  %83 = getelementptr inbounds [2001 x i64], ptr %82, i64 0, i64 0
  store i64 1, ptr %83, align 8, !tbaa !9
  br label %84

84:                                               ; preds = %79
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %6, align 4, !tbaa !5
  br label %75, !llvm.loop !15

87:                                               ; preds = %78
  br label %88

88:                                               ; preds = %182, %87
  %89 = load i32, ptr @t, align 4, !tbaa !5
  %90 = add nsw i32 %89, -1
  store i32 %90, ptr @t, align 4, !tbaa !5
  %91 = icmp ne i32 %89, 0
  br i1 %91, label %92, label %192

92:                                               ; preds = %88
  %93 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %121, %92
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = load i32, ptr @m, align 4, !tbaa !5
  %97 = icmp sle i32 %95, %96
  br i1 %97, label %99, label %98

98:                                               ; preds = %94
  store i32 16, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %124

99:                                               ; preds = %94
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = sub nsw i32 %100, 1
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2001 x i64], ptr getelementptr inbounds ([2001 x [2001 x i64]], ptr @dp, i64 0, i64 1), i64 0, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !9
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = load i32, ptr @m, align 4, !tbaa !5
  %107 = add nsw i32 %105, %106
  %108 = sub nsw i32 %107, 1
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %109
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [4001 x i64], ptr %110, i64 0, i64 %112
  %114 = load i64, ptr %113, align 8, !tbaa !9
  %115 = add nsw i64 %104, %114
  %116 = load i64, ptr @MOD, align 8, !tbaa !9
  %117 = srem i64 %115, %116
  %118 = load i32, ptr %7, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [2001 x i64], ptr getelementptr inbounds ([2001 x [2001 x i64]], ptr @dp, i64 0, i64 1), i64 0, i64 %119
  store i64 %117, ptr %120, align 8, !tbaa !9
  br label %121

121:                                              ; preds = %99
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %7, align 4, !tbaa !5
  br label %94, !llvm.loop !16

124:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 2, ptr %8, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %179, %124
  %126 = load i32, ptr %8, align 4, !tbaa !5
  %127 = load i32, ptr @n, align 4, !tbaa !5
  %128 = icmp sle i32 %126, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %125
  store i32 19, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %182

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

131:                                              ; preds = %175, %130
  %132 = load i32, ptr %9, align 4, !tbaa !5
  %133 = load i32, ptr @m, align 4, !tbaa !5
  %134 = icmp sle i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  store i32 22, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %178

136:                                              ; preds = %131
  %137 = load i32, ptr %8, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %138
  %140 = load i32, ptr %9, align 4, !tbaa !5
  %141 = sub nsw i32 %140, 1
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [2001 x i64], ptr %139, i64 0, i64 %142
  %144 = load i64, ptr %143, align 8, !tbaa !9
  %145 = load i32, ptr %9, align 4, !tbaa !5
  %146 = load i32, ptr @m, align 4, !tbaa !5
  %147 = add nsw i32 %145, %146
  %148 = sub nsw i32 %147, 1
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %149
  %151 = load i32, ptr %9, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [4001 x i64], ptr %150, i64 0, i64 %152
  %154 = load i64, ptr %153, align 8, !tbaa !9
  %155 = load i32, ptr %8, align 4, !tbaa !5
  %156 = sub nsw i32 %155, 1
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %157
  %159 = load i32, ptr %9, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [2001 x i64], ptr %158, i64 0, i64 %160
  %162 = load i64, ptr %161, align 8, !tbaa !9
  %163 = mul nsw i64 %154, %162
  %164 = load i64, ptr @MOD, align 8, !tbaa !9
  %165 = srem i64 %163, %164
  %166 = add nsw i64 %144, %165
  %167 = load i64, ptr @MOD, align 8, !tbaa !9
  %168 = srem i64 %166, %167
  %169 = load i32, ptr %8, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %170
  %172 = load i32, ptr %9, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [2001 x i64], ptr %171, i64 0, i64 %173
  store i64 %168, ptr %174, align 8, !tbaa !9
  br label %175

175:                                              ; preds = %136
  %176 = load i32, ptr %9, align 4, !tbaa !5
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr %9, align 4, !tbaa !5
  br label %131, !llvm.loop !17

178:                                              ; preds = %135
  br label %179

179:                                              ; preds = %178
  %180 = load i32, ptr %8, align 4, !tbaa !5
  %181 = add nsw i32 %180, 1
  store i32 %181, ptr %8, align 4, !tbaa !5
  br label %125, !llvm.loop !18

182:                                              ; preds = %129
  %183 = load i32, ptr @n, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %184
  %186 = load i32, ptr @m, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [2001 x i64], ptr %185, i64 0, i64 %187
  %189 = load i64, ptr %188, align 8, !tbaa !9
  %190 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %189)
  %191 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %190, ptr noundef @.str.2)
  br label %88, !llvm.loop !19

192:                                              ; preds = %88
  ret i32 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

declare i32 @__isoc99_scanf(ptr noundef, ...) #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) #3

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

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 = { 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 = { 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 = { 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}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !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_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 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@c = external dso_local local_unnamed_addr global [4001 x [4001 x i64]], align 16
@dp = external dso_local local_unnamed_addr global [2001 x [2001 x i64]], align 16
@MOD = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  br label %2

.preheader52:                                     ; preds = %2
  %1 = load i64, ptr @MOD, align 8
  br label %.preheader51

2:                                                ; preds = %5, %0
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next.1, %5 ]
  %3 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %indvars.iv
  %4 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %indvars.iv, i64 %indvars.iv
  store i64 1, ptr %4, align 16, !tbaa !5
  store i64 1, ptr %3, align 16, !tbaa !5
  %exitcond.not = icmp eq i64 %indvars.iv, 4000
  br i1 %exitcond.not, label %.preheader52, label %5, !llvm.loop !9

5:                                                ; preds = %2
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %6 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %indvars.iv.next
  %7 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %indvars.iv.next, i64 %indvars.iv.next
  store i64 1, ptr %7, align 16, !tbaa !5
  store i64 1, ptr %6, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %2

.preheader51:                                     ; preds = %.preheader52, %._crit_edge
  %indvars.iv79 = phi i64 [ 0, %.preheader52 ], [ %indvars.iv.next80, %._crit_edge ]
  %8 = add nsw i64 %indvars.iv79, -1
  %9 = icmp ugt i64 %indvars.iv79, 1
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader51
  %10 = add nsw i64 %indvars.iv79, -1
  %.phi.trans.insert = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %10, i64 0
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !5
  %xtraiter = and i64 %8, 1
  %11 = icmp eq i64 %indvars.iv79, 2
  br i1 %11, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %8, -2
  br label %19

12:                                               ; preds = %._crit_edge
  %13 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  br label %33

._crit_edge.loopexit.unr-lcssa:                   ; preds = %19, %.lr.ph
  %.unr = phi i64 [ %.pre, %.lr.ph ], [ %27, %19 ]
  %indvars.iv75.unr = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next76.1, %19 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %14 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %10, i64 %indvars.iv75.unr
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = add nsw i64 %15, %.unr
  %17 = srem i64 %16, %1
  %18 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %indvars.iv79, i64 %indvars.iv75.unr
  store i64 %17, ptr %18, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.preheader51
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %exitcond82.not = icmp eq i64 %indvars.iv.next80, 4001
  br i1 %exitcond82.not, label %12, label %.preheader51, !llvm.loop !11

19:                                               ; preds = %19, %.lr.ph.new
  %20 = phi i64 [ %.pre, %.lr.ph.new ], [ %27, %19 ]
  %indvars.iv75 = phi i64 [ 1, %.lr.ph.new ], [ %indvars.iv.next76.1, %19 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %19 ]
  %21 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %10, i64 %indvars.iv75
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = add nsw i64 %22, %20
  %24 = srem i64 %23, %1
  %25 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %indvars.iv79, i64 %indvars.iv75
  store i64 %24, ptr %25, align 8, !tbaa !5
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %26 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %10, i64 %indvars.iv.next76
  %27 = load i64, ptr %26, align 8, !tbaa !5
  %28 = add nsw i64 %27, %22
  %29 = srem i64 %28, %1
  %30 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %indvars.iv79, i64 %indvars.iv.next76
  store i64 %29, ptr %30, align 8, !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_edge.loopexit.unr-lcssa, label %19, !llvm.loop !12

.preheader50:                                     ; preds = %33
  %31 = load i32, ptr @t, align 4, !tbaa !13
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr @t, align 4, !tbaa !13
  %.not70 = icmp eq i32 %31, 0
  br i1 %.not70, label %._crit_edge72, label %.lr.ph71

33:                                               ; preds = %33, %12
  %indvars.iv83 = phi i64 [ 1, %12 ], [ %indvars.iv.next84.4, %33 ]
  %34 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %indvars.iv83
  store i64 1, ptr %34, align 8, !tbaa !5
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %35 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %indvars.iv.next84
  store i64 1, ptr %35, align 8, !tbaa !5
  %indvars.iv.next84.1 = add nuw nsw i64 %indvars.iv83, 2
  %36 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %indvars.iv.next84.1
  store i64 1, ptr %36, align 8, !tbaa !5
  %indvars.iv.next84.2 = add nuw nsw i64 %indvars.iv83, 3
  %37 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %indvars.iv.next84.2
  store i64 1, ptr %37, align 8, !tbaa !5
  %indvars.iv.next84.3 = add nuw nsw i64 %indvars.iv83, 4
  %38 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %indvars.iv.next84.3
  store i64 1, ptr %38, align 8, !tbaa !5
  %indvars.iv.next84.4 = add nuw nsw i64 %indvars.iv83, 5
  %exitcond86.not.4 = icmp eq i64 %indvars.iv.next84.4, 2001
  br i1 %exitcond86.not.4, label %.preheader50, label %33, !llvm.loop !15

.lr.ph71:                                         ; preds = %.preheader50, %._crit_edge68
  %39 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %40 = load i32, ptr @m, align 4, !tbaa !13
  %.not4658 = icmp slt i32 %40, 1
  br i1 %.not4658, label %.preheader49.thread, label %.lr.ph61

.lr.ph61:                                         ; preds = %.lr.ph71
  %41 = load i64, ptr @MOD, align 8, !tbaa !5
  %.pre101 = load i64, ptr getelementptr inbounds (i8, ptr @dp, i64 16008), align 8, !tbaa !5
  %42 = zext nneg i32 %40 to i64
  %xtraiter106 = and i64 %42, 1
  %43 = icmp eq i32 %40, 1
  br i1 %43, label %.preheader49.unr-lcssa, label %.lr.ph61.new

.lr.ph61.new:                                     ; preds = %.lr.ph61
  %unroll_iter109 = and i64 %42, 2147483646
  br label %59

.preheader49.unr-lcssa:                           ; preds = %59, %.lr.ph61
  %.unr107 = phi i64 [ %.pre101, %.lr.ph61 ], [ %77, %59 ]
  %indvars.iv87.unr = phi i64 [ 1, %.lr.ph61 ], [ %indvars.iv.next88.1, %59 ]
  %lcmp.mod108.not = icmp eq i64 %xtraiter106, 0
  br i1 %lcmp.mod108.not, label %.preheader49, label %.preheader49.epilog-lcssa

.preheader49.epilog-lcssa:                        ; preds = %.preheader49.unr-lcssa
  %44 = trunc i64 %indvars.iv87.unr to i32
  %45 = add i32 %44, -1
  %46 = add i32 %45, %40
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %47, i64 %indvars.iv87.unr
  %49 = load i64, ptr %48, align 8, !tbaa !5
  %50 = add nsw i64 %49, %.unr107
  %51 = srem i64 %50, %41
  %52 = getelementptr inbounds [2001 x i64], ptr getelementptr inbounds (i8, ptr @dp, i64 16008), i64 0, i64 %indvars.iv87.unr
  store i64 %51, ptr %52, align 8, !tbaa !5
  br label %.preheader49

.preheader49:                                     ; preds = %.preheader49.unr-lcssa, %.preheader49.epilog-lcssa
  %53 = load i32, ptr @n, align 4, !tbaa !13
  %.not4766 = icmp slt i32 %53, 2
  br i1 %.not4766, label %._crit_edge68, label %.preheader.lr.ph

.preheader49.thread:                              ; preds = %.lr.ph71
  %54 = load i32, ptr @n, align 4, !tbaa !13
  br label %._crit_edge68

.preheader.lr.ph:                                 ; preds = %.preheader49
  %55 = add nsw i32 %40, -1
  %56 = load i64, ptr @MOD, align 8
  br i1 %.not4658, label %._crit_edge68, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %57 = add nuw i32 %40, 1
  %58 = add nuw i32 %53, 1
  %wide.trip.count99 = zext i32 %58 to i64
  %wide.trip.count94 = zext i32 %57 to i64
  br label %.preheader

59:                                               ; preds = %59, %.lr.ph61.new
  %60 = phi i64 [ %.pre101, %.lr.ph61.new ], [ %77, %59 ]
  %indvars.iv87 = phi i64 [ 1, %.lr.ph61.new ], [ %indvars.iv.next88.1, %59 ]
  %niter110 = phi i64 [ 0, %.lr.ph61.new ], [ %niter110.next.1, %59 ]
  %61 = trunc i64 %indvars.iv87 to i32
  %62 = add nsw i32 %61, -1
  %63 = add i32 %62, %40
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %64, i64 %indvars.iv87
  %66 = load i64, ptr %65, align 8, !tbaa !5
  %67 = add nsw i64 %66, %60
  %68 = srem i64 %67, %41
  %69 = getelementptr inbounds [2001 x i64], ptr getelementptr inbounds (i8, ptr @dp, i64 16008), i64 0, i64 %indvars.iv87
  store i64 %68, ptr %69, align 8, !tbaa !5
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %70 = trunc i64 %indvars.iv.next88 to i32
  %71 = add i32 %70, -1
  %72 = add i32 %71, %40
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %73, i64 %indvars.iv.next88
  %75 = load i64, ptr %74, align 8, !tbaa !5
  %76 = add nsw i64 %75, %68
  %77 = srem i64 %76, %41
  %78 = getelementptr inbounds [2001 x i64], ptr getelementptr inbounds (i8, ptr @dp, i64 16008), i64 0, i64 %indvars.iv.next88
  store i64 %77, ptr %78, align 8, !tbaa !5
  %indvars.iv.next88.1 = add nuw nsw i64 %indvars.iv87, 2
  %niter110.next.1 = add i64 %niter110, 2
  %niter110.ncmp.1 = icmp eq i64 %niter110.next.1, %unroll_iter109
  br i1 %niter110.ncmp.1, label %.preheader49.unr-lcssa, label %59, !llvm.loop !16

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge65
  %indvars.iv96 = phi i64 [ 2, %.preheader.preheader ], [ %indvars.iv.next97, %._crit_edge65 ]
  %79 = add nsw i64 %indvars.iv96, -1
  %.phi.trans.insert102 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %indvars.iv96, i64 0
  %.pre103 = load i64, ptr %.phi.trans.insert102, align 8, !tbaa !5
  br label %89

._crit_edge68:                                    ; preds = %._crit_edge65, %.preheader49.thread, %.preheader.lr.ph, %.preheader49
  %80 = phi i32 [ %53, %.preheader49 ], [ %53, %.preheader.lr.ph ], [ %54, %.preheader49.thread ], [ %53, %._crit_edge65 ]
  %81 = sext i32 %80 to i64
  %82 = sext i32 %40 to i64
  %83 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %81, i64 %82
  %84 = load i64, ptr %83, align 8, !tbaa !5
  %85 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %84)
  %86 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %85, ptr noundef nonnull @.str.2)
  %87 = load i32, ptr @t, align 4, !tbaa !13
  %88 = add nsw i32 %87, -1
  store i32 %88, ptr @t, align 4, !tbaa !13
  %.not = icmp eq i32 %87, 0
  br i1 %.not, label %._crit_edge72, label %.lr.ph71, !llvm.loop !17

._crit_edge65:                                    ; preds = %89
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %exitcond100.not = icmp eq i64 %indvars.iv.next97, %wide.trip.count99
  br i1 %exitcond100.not, label %._crit_edge68, label %.preheader, !llvm.loop !18

89:                                               ; preds = %.preheader, %89
  %90 = phi i64 [ %.pre103, %.preheader ], [ %101, %89 ]
  %indvars.iv91 = phi i64 [ 1, %.preheader ], [ %indvars.iv.next92, %89 ]
  %91 = trunc nuw nsw i64 %indvars.iv91 to i32
  %92 = add i32 %55, %91
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [4001 x [4001 x i64]], ptr @c, i64 0, i64 %93, i64 %indvars.iv91
  %95 = load i64, ptr %94, align 8, !tbaa !5
  %96 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %79, i64 %indvars.iv91
  %97 = load i64, ptr %96, align 8, !tbaa !5
  %98 = mul nsw i64 %97, %95
  %99 = srem i64 %98, %56
  %100 = add nsw i64 %99, %90
  %101 = srem i64 %100, %56
  %102 = getelementptr inbounds [2001 x [2001 x i64]], ptr @dp, i64 0, i64 %indvars.iv96, i64 %indvars.iv91
  store i64 %101, ptr %102, align 8, !tbaa !5
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  %exitcond95.not = icmp eq i64 %indvars.iv.next92, %wide.trip.count94
  br i1 %exitcond95.not, label %._crit_edge65, label %89, !llvm.loop !19

._crit_edge72:                                    ; preds = %._crit_edge68, %.preheader50
  ret i32 0
}

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

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

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 = { 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 #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" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


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