; LLVM IR from eyangch/competitive-programming :: USACOcontests/platinum/2016.12 (team)

; 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
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@fj = external dso_local global [1000 x i32], align 16
@fp = external dso_local global [1000 x i32], align 16
@dp = external dso_local global [1000 x [1001 x [10 x i64]]], align 16
@pfx = external dso_local global [1000 x [1001 x [10 x i64]]], align 16
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_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
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = load ptr, ptr @stdin, align 8, !tbaa !5
  %12 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %11)
  %13 = load ptr, ptr @stdout, align 8, !tbaa !5
  %14 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %13)
  %15 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %16 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = 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)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 4 dereferenceable(4) @K)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %34, %0
  %25 = load i32, ptr %2, align 4, !tbaa !11
  %26 = load i32, ptr @N, align 4, !tbaa !11
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

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

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !11
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [1000 x i32], ptr @fj, i64 0, i64 %31
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %32)
  br label %34

34:                                               ; preds = %29
  %35 = load i32, ptr %2, align 4, !tbaa !11
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !11
  br label %24, !llvm.loop !13

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

38:                                               ; preds = %48, %37
  %39 = load i32, ptr %3, align 4, !tbaa !11
  %40 = load i32, ptr @M, align 4, !tbaa !11
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %51

43:                                               ; preds = %38
  %44 = load i32, ptr %3, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1000 x i32], ptr @fp, i64 0, i64 %45
  %47 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %46)
  br label %48

48:                                               ; preds = %43
  %49 = load i32, ptr %3, align 4, !tbaa !11
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %3, align 4, !tbaa !11
  br label %38, !llvm.loop !15

51:                                               ; preds = %42
  %52 = load i32, ptr @N, align 4, !tbaa !11
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr @fj, i64 %53
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @fj, ptr noundef %54)
  %55 = load i32, ptr @M, align 4, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr @fp, i64 %56
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @fp, ptr noundef %57)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %58 = load i32, ptr @K, align 4, !tbaa !11
  %59 = sub nsw i32 %58, 1
  store i32 %59, ptr %4, align 4, !tbaa !11
  br label %60

60:                                               ; preds = %387, %51
  %61 = load i32, ptr %4, align 4, !tbaa !11
  %62 = icmp sge i32 %61, 0
  br i1 %62, label %64, label %63

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

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

65:                                               ; preds = %383, %64
  %66 = load i32, ptr %6, align 4, !tbaa !11
  %67 = load i32, ptr @N, align 4, !tbaa !11
  %68 = icmp slt i32 %66, %67
  br i1 %68, label %70, label %69

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

70:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 -1, ptr %7, align 4, !tbaa !11
  br label %71

71:                                               ; preds = %379, %70
  %72 = load i32, ptr %7, align 4, !tbaa !11
  %73 = load i32, ptr @M, align 4, !tbaa !11
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %71
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %382

76:                                               ; preds = %71
  %77 = load i32, ptr %7, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1000 x i32], ptr @fp, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !11
  %81 = load i32, ptr %6, align 4, !tbaa !11
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1000 x i32], ptr @fj, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !11
  %85 = icmp slt i32 %80, %84
  br i1 %85, label %86, label %217

86:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %87 = load i32, ptr %7, align 4, !tbaa !11
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !11
  %89 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %90 = load i32, ptr %89, align 4, !tbaa !11
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr @fp, i64 %91
  %93 = load i32, ptr @M, align 4, !tbaa !11
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i32, ptr @fp, i64 %94
  %96 = load i32, ptr %6, align 4, !tbaa !11
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1000 x i32], ptr @fj, i64 0, i64 %97
  %99 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef %92, ptr noundef %95, ptr noundef nonnull align 4 dereferenceable(4) %98)
  %100 = ptrtoint ptr %99 to i64
  %101 = sub i64 %100, ptrtoint (ptr @fp to i64)
  %102 = sdiv exact i64 %101, 4
  %103 = trunc i64 %102 to i32
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  store i32 %103, ptr %9, align 4, !tbaa !11
  %104 = load i32, ptr %4, align 4, !tbaa !11
  %105 = load i32, ptr @K, align 4, !tbaa !11
  %106 = sub nsw i32 %105, 1
  %107 = icmp eq i32 %104, %106
  br i1 %107, label %108, label %123

108:                                              ; preds = %86
  %109 = load i32, ptr %9, align 4, !tbaa !11
  %110 = load i32, ptr %8, align 4, !tbaa !11
  %111 = sub nsw i32 %109, %110
  %112 = sext i32 %111 to i64
  %113 = load i32, ptr %6, align 4, !tbaa !11
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %114
  %116 = load i32, ptr %7, align 4, !tbaa !11
  %117 = add nsw i32 %116, 1
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1001 x [10 x i64]], ptr %115, i64 0, i64 %118
  %120 = load i32, ptr %4, align 4, !tbaa !11
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [10 x i64], ptr %119, i64 0, i64 %121
  store i64 %112, ptr %122, align 8, !tbaa !16
  br label %216

123:                                              ; preds = %86
  %124 = load i32, ptr @N, align 4, !tbaa !11
  %125 = sub nsw i32 %124, 1
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %126
  %128 = load i32, ptr %9, align 4, !tbaa !11
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [1001 x [10 x i64]], ptr %127, i64 0, i64 %129
  %131 = load i32, ptr %4, align 4, !tbaa !11
  %132 = add nsw i32 %131, 1
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [10 x i64], ptr %130, i64 0, i64 %133
  %135 = load i64, ptr %134, align 8, !tbaa !16
  %136 = load i32, ptr %6, align 4, !tbaa !11
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %137
  %139 = load i32, ptr %7, align 4, !tbaa !11
  %140 = add nsw i32 %139, 1
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1001 x [10 x i64]], ptr %138, i64 0, i64 %141
  %143 = load i32, ptr %4, align 4, !tbaa !11
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [10 x i64], ptr %142, i64 0, i64 %144
  store i64 %135, ptr %145, align 8, !tbaa !16
  %146 = load i32, ptr %6, align 4, !tbaa !11
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %147
  %149 = load i32, ptr %9, align 4, !tbaa !11
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [1001 x [10 x i64]], ptr %148, i64 0, i64 %150
  %152 = load i32, ptr %4, align 4, !tbaa !11
  %153 = add nsw i32 %152, 1
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [10 x i64], ptr %151, i64 0, i64 %154
  %156 = load i64, ptr %155, align 8, !tbaa !16
  %157 = load i32, ptr %6, align 4, !tbaa !11
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %158
  %160 = load i32, ptr %7, align 4, !tbaa !11
  %161 = add nsw i32 %160, 1
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [1001 x [10 x i64]], ptr %159, i64 0, i64 %162
  %164 = load i32, ptr %4, align 4, !tbaa !11
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [10 x i64], ptr %163, i64 0, i64 %165
  %167 = load i64, ptr %166, align 8, !tbaa !16
  %168 = sub nsw i64 %167, %156
  store i64 %168, ptr %166, align 8, !tbaa !16
  %169 = load i32, ptr @N, align 4, !tbaa !11
  %170 = sub nsw i32 %169, 1
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %171
  %173 = load i32, ptr %8, align 4, !tbaa !11
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [1001 x [10 x i64]], ptr %172, i64 0, i64 %174
  %176 = load i32, ptr %4, align 4, !tbaa !11
  %177 = add nsw i32 %176, 1
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [10 x i64], ptr %175, i64 0, i64 %178
  %180 = load i64, ptr %179, align 8, !tbaa !16
  %181 = load i32, ptr %6, align 4, !tbaa !11
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %182
  %184 = load i32, ptr %7, align 4, !tbaa !11
  %185 = add nsw i32 %184, 1
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [1001 x [10 x i64]], ptr %183, i64 0, i64 %186
  %188 = load i32, ptr %4, align 4, !tbaa !11
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [10 x i64], ptr %187, i64 0, i64 %189
  %191 = load i64, ptr %190, align 8, !tbaa !16
  %192 = sub nsw i64 %191, %180
  store i64 %192, ptr %190, align 8, !tbaa !16
  %193 = load i32, ptr %6, align 4, !tbaa !11
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %194
  %196 = load i32, ptr %8, align 4, !tbaa !11
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [1001 x [10 x i64]], ptr %195, i64 0, i64 %197
  %199 = load i32, ptr %4, align 4, !tbaa !11
  %200 = add nsw i32 %199, 1
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [10 x i64], ptr %198, i64 0, i64 %201
  %203 = load i64, ptr %202, align 8, !tbaa !16
  %204 = load i32, ptr %6, align 4, !tbaa !11
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %205
  %207 = load i32, ptr %7, align 4, !tbaa !11
  %208 = add nsw i32 %207, 1
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [1001 x [10 x i64]], ptr %206, i64 0, i64 %209
  %211 = load i32, ptr %4, align 4, !tbaa !11
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [10 x i64], ptr %210, i64 0, i64 %212
  %214 = load i64, ptr %213, align 8, !tbaa !16
  %215 = add nsw i64 %214, %203
  store i64 %215, ptr %213, align 8, !tbaa !16
  br label %216

216:                                              ; preds = %123, %108
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %217

217:                                              ; preds = %216, %76
  %218 = load i32, ptr %6, align 4, !tbaa !11
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %219
  %221 = load i32, ptr %7, align 4, !tbaa !11
  %222 = add nsw i32 %221, 1
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [1001 x [10 x i64]], ptr %220, i64 0, i64 %223
  %225 = load i32, ptr %4, align 4, !tbaa !11
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [10 x i64], ptr %224, i64 0, i64 %226
  %228 = load i64, ptr %227, align 8, !tbaa !16
  %229 = load i64, ptr @MOD, align 8, !tbaa !16
  %230 = srem i64 %228, %229
  %231 = load i64, ptr @MOD, align 8, !tbaa !16
  %232 = add nsw i64 %230, %231
  %233 = load i64, ptr @MOD, align 8, !tbaa !16
  %234 = srem i64 %232, %233
  %235 = load i32, ptr %6, align 4, !tbaa !11
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %236
  %238 = load i32, ptr %7, align 4, !tbaa !11
  %239 = add nsw i32 %238, 1
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [1001 x [10 x i64]], ptr %237, i64 0, i64 %240
  %242 = load i32, ptr %4, align 4, !tbaa !11
  %243 = sext i32 %242 to i64
  %244 = getelementptr inbounds [10 x i64], ptr %241, i64 0, i64 %243
  store i64 %234, ptr %244, align 8, !tbaa !16
  %245 = load i32, ptr %6, align 4, !tbaa !11
  %246 = sext i32 %245 to i64
  %247 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %246
  %248 = load i32, ptr %7, align 4, !tbaa !11
  %249 = add nsw i32 %248, 1
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [1001 x [10 x i64]], ptr %247, i64 0, i64 %250
  %252 = load i32, ptr %4, align 4, !tbaa !11
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [10 x i64], ptr %251, i64 0, i64 %253
  %255 = load i64, ptr %254, align 8, !tbaa !16
  %256 = load i32, ptr %6, align 4, !tbaa !11
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %257
  %259 = load i32, ptr %7, align 4, !tbaa !11
  %260 = add nsw i32 %259, 1
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [1001 x [10 x i64]], ptr %258, i64 0, i64 %261
  %263 = load i32, ptr %4, align 4, !tbaa !11
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [10 x i64], ptr %262, i64 0, i64 %264
  store i64 %255, ptr %265, align 8, !tbaa !16
  %266 = load i32, ptr %6, align 4, !tbaa !11
  %267 = icmp sgt i32 %266, 0
  br i1 %267, label %268, label %293

268:                                              ; preds = %217
  %269 = load i32, ptr %6, align 4, !tbaa !11
  %270 = sub nsw i32 %269, 1
  %271 = sext i32 %270 to i64
  %272 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %271
  %273 = load i32, ptr %7, align 4, !tbaa !11
  %274 = add nsw i32 %273, 1
  %275 = sext i32 %274 to i64
  %276 = getelementptr inbounds [1001 x [10 x i64]], ptr %272, i64 0, i64 %275
  %277 = load i32, ptr %4, align 4, !tbaa !11
  %278 = sext i32 %277 to i64
  %279 = getelementptr inbounds [10 x i64], ptr %276, i64 0, i64 %278
  %280 = load i64, ptr %279, align 8, !tbaa !16
  %281 = load i32, ptr %6, align 4, !tbaa !11
  %282 = sext i32 %281 to i64
  %283 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %282
  %284 = load i32, ptr %7, align 4, !tbaa !11
  %285 = add nsw i32 %284, 1
  %286 = sext i32 %285 to i64
  %287 = getelementptr inbounds [1001 x [10 x i64]], ptr %283, i64 0, i64 %286
  %288 = load i32, ptr %4, align 4, !tbaa !11
  %289 = sext i32 %288 to i64
  %290 = getelementptr inbounds [10 x i64], ptr %287, i64 0, i64 %289
  %291 = load i64, ptr %290, align 8, !tbaa !16
  %292 = add nsw i64 %291, %280
  store i64 %292, ptr %290, align 8, !tbaa !16
  br label %293

293:                                              ; preds = %268, %217
  %294 = load i32, ptr %7, align 4, !tbaa !11
  %295 = add nsw i32 %294, 1
  %296 = icmp sgt i32 %295, 0
  br i1 %296, label %297, label %320

297:                                              ; preds = %293
  %298 = load i32, ptr %6, align 4, !tbaa !11
  %299 = sext i32 %298 to i64
  %300 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %299
  %301 = load i32, ptr %7, align 4, !tbaa !11
  %302 = sext i32 %301 to i64
  %303 = getelementptr inbounds [1001 x [10 x i64]], ptr %300, i64 0, i64 %302
  %304 = load i32, ptr %4, align 4, !tbaa !11
  %305 = sext i32 %304 to i64
  %306 = getelementptr inbounds [10 x i64], ptr %303, i64 0, i64 %305
  %307 = load i64, ptr %306, align 8, !tbaa !16
  %308 = load i32, ptr %6, align 4, !tbaa !11
  %309 = sext i32 %308 to i64
  %310 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %309
  %311 = load i32, ptr %7, align 4, !tbaa !11
  %312 = add nsw i32 %311, 1
  %313 = sext i32 %312 to i64
  %314 = getelementptr inbounds [1001 x [10 x i64]], ptr %310, i64 0, i64 %313
  %315 = load i32, ptr %4, align 4, !tbaa !11
  %316 = sext i32 %315 to i64
  %317 = getelementptr inbounds [10 x i64], ptr %314, i64 0, i64 %316
  %318 = load i64, ptr %317, align 8, !tbaa !16
  %319 = add nsw i64 %318, %307
  store i64 %319, ptr %317, align 8, !tbaa !16
  br label %320

320:                                              ; preds = %297, %293
  %321 = load i32, ptr %6, align 4, !tbaa !11
  %322 = icmp sgt i32 %321, 0
  br i1 %322, label %323, label %351

323:                                              ; preds = %320
  %324 = load i32, ptr %7, align 4, !tbaa !11
  %325 = add nsw i32 %324, 1
  %326 = icmp sgt i32 %325, 0
  br i1 %326, label %327, label %351

327:                                              ; preds = %323
  %328 = load i32, ptr %6, align 4, !tbaa !11
  %329 = sub nsw i32 %328, 1
  %330 = sext i32 %329 to i64
  %331 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %330
  %332 = load i32, ptr %7, align 4, !tbaa !11
  %333 = sext i32 %332 to i64
  %334 = getelementptr inbounds [1001 x [10 x i64]], ptr %331, i64 0, i64 %333
  %335 = load i32, ptr %4, align 4, !tbaa !11
  %336 = sext i32 %335 to i64
  %337 = getelementptr inbounds [10 x i64], ptr %334, i64 0, i64 %336
  %338 = load i64, ptr %337, align 8, !tbaa !16
  %339 = load i32, ptr %6, align 4, !tbaa !11
  %340 = sext i32 %339 to i64
  %341 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %340
  %342 = load i32, ptr %7, align 4, !tbaa !11
  %343 = add nsw i32 %342, 1
  %344 = sext i32 %343 to i64
  %345 = getelementptr inbounds [1001 x [10 x i64]], ptr %341, i64 0, i64 %344
  %346 = load i32, ptr %4, align 4, !tbaa !11
  %347 = sext i32 %346 to i64
  %348 = getelementptr inbounds [10 x i64], ptr %345, i64 0, i64 %347
  %349 = load i64, ptr %348, align 8, !tbaa !16
  %350 = sub nsw i64 %349, %338
  store i64 %350, ptr %348, align 8, !tbaa !16
  br label %351

351:                                              ; preds = %327, %323, %320
  %352 = load i32, ptr %6, align 4, !tbaa !11
  %353 = sext i32 %352 to i64
  %354 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %353
  %355 = load i32, ptr %7, align 4, !tbaa !11
  %356 = add nsw i32 %355, 1
  %357 = sext i32 %356 to i64
  %358 = getelementptr inbounds [1001 x [10 x i64]], ptr %354, i64 0, i64 %357
  %359 = load i32, ptr %4, align 4, !tbaa !11
  %360 = sext i32 %359 to i64
  %361 = getelementptr inbounds [10 x i64], ptr %358, i64 0, i64 %360
  %362 = load i64, ptr %361, align 8, !tbaa !16
  %363 = load i64, ptr @MOD, align 8, !tbaa !16
  %364 = srem i64 %362, %363
  %365 = load i64, ptr @MOD, align 8, !tbaa !16
  %366 = add nsw i64 %364, %365
  %367 = load i64, ptr @MOD, align 8, !tbaa !16
  %368 = srem i64 %366, %367
  %369 = load i32, ptr %6, align 4, !tbaa !11
  %370 = sext i32 %369 to i64
  %371 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %370
  %372 = load i32, ptr %7, align 4, !tbaa !11
  %373 = add nsw i32 %372, 1
  %374 = sext i32 %373 to i64
  %375 = getelementptr inbounds [1001 x [10 x i64]], ptr %371, i64 0, i64 %374
  %376 = load i32, ptr %4, align 4, !tbaa !11
  %377 = sext i32 %376 to i64
  %378 = getelementptr inbounds [10 x i64], ptr %375, i64 0, i64 %377
  store i64 %368, ptr %378, align 8, !tbaa !16
  br label %379

379:                                              ; preds = %351
  %380 = load i32, ptr %7, align 4, !tbaa !11
  %381 = add nsw i32 %380, 1
  store i32 %381, ptr %7, align 4, !tbaa !11
  br label %71, !llvm.loop !18

382:                                              ; preds = %75
  br label %383

383:                                              ; preds = %382
  %384 = load i32, ptr %6, align 4, !tbaa !11
  %385 = add nsw i32 %384, 1
  store i32 %385, ptr %6, align 4, !tbaa !11
  br label %65, !llvm.loop !19

386:                                              ; preds = %69
  br label %387

387:                                              ; preds = %386
  %388 = load i32, ptr %4, align 4, !tbaa !11
  %389 = add nsw i32 %388, -1
  store i32 %389, ptr %4, align 4, !tbaa !11
  br label %60, !llvm.loop !20

390:                                              ; preds = %63
  %391 = load i32, ptr @N, align 4, !tbaa !11
  %392 = sub nsw i32 %391, 1
  %393 = sext i32 %392 to i64
  %394 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %393
  %395 = getelementptr inbounds [1001 x [10 x i64]], ptr %394, i64 0, i64 0
  %396 = getelementptr inbounds [10 x i64], ptr %395, i64 0, i64 0
  %397 = load i64, ptr %396, align 16, !tbaa !16
  %398 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %397)
  %399 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %398, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

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

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

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

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

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

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

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

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}


; 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
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@fj = external dso_local global [1000 x i32], align 16
@fp = external dso_local global [1000 x i32], align 16
@dp = external dso_local local_unnamed_addr global [1000 x [1001 x [10 x i64]]], align 16
@pfx = external dso_local local_unnamed_addr global [1000 x [1001 x [10 x i64]]], align 16
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_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 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = load ptr, ptr @stdin, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %3)
  %5 = load ptr, ptr @stdout, align 8, !tbaa !5
  %6 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %5)
  %7 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %8 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %10
  %12 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  %13 = 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)
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 4 dereferenceable(4) @K)
  %16 = load i32, ptr @N, align 4, !tbaa !11
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %.preheader70

.preheader70:                                     ; preds = %.lr.ph, %0
  %18 = phi i32 [ %16, %0 ], [ %23, %.lr.ph ]
  %19 = load i32, ptr @M, align 4, !tbaa !11
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph73, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %21 = getelementptr inbounds [1000 x i32], ptr @fj, i64 0, i64 %indvars.iv
  %22 = 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) %21)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr @N, align 4, !tbaa !11
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %.lr.ph, label %.preheader70, !llvm.loop !13

._crit_edge.loopexit:                             ; preds = %.lr.ph73
  %.pre = load i32, ptr @N, align 4, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader70
  %26 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %18, %.preheader70 ]
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr @fj, i64 %27
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @fj, ptr noundef nonnull %28)
  %29 = load i32, ptr @M, align 4, !tbaa !11
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i32, ptr @fp, i64 %30
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @fp, ptr noundef nonnull %31)
  %32 = load i32, ptr @K, align 4, !tbaa !11
  %33 = icmp sgt i32 %32, 0
  %.pre102 = load i32, ptr @N, align 4, !tbaa !11
  %34 = icmp sgt i32 %.pre102, 0
  %or.cond = select i1 %33, i1 %34, i1 false
  br i1 %or.cond, label %.preheader.preheader, label %._crit_edge83

.preheader.preheader:                             ; preds = %._crit_edge
  %.06380 = add nsw i32 %32, -1
  %35 = zext nneg i32 %.06380 to i64
  %36 = zext nneg i32 %32 to i64
  br label %.preheader

.lr.ph73:                                         ; preds = %.preheader70, %.lr.ph73
  %indvars.iv87 = phi i64 [ %indvars.iv.next88, %.lr.ph73 ], [ 0, %.preheader70 ]
  %37 = getelementptr inbounds [1000 x i32], ptr @fp, i64 0, i64 %indvars.iv87
  %38 = 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) %37)
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %39 = load i32, ptr @M, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = icmp slt i64 %indvars.iv.next88, %40
  br i1 %41, label %.lr.ph73, label %._crit_edge.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %._crit_edge77, %.lr.ph79, %.preheader
  %42 = phi i32 [ %46, %.preheader ], [ %46, %.lr.ph79 ], [ %64, %._crit_edge77 ]
  %43 = phi i32 [ %47, %.preheader ], [ %47, %.lr.ph79 ], [ %64, %._crit_edge77 ]
  %44 = phi i32 [ %48, %.preheader ], [ %47, %.lr.ph79 ], [ %64, %._crit_edge77 ]
  %indvars.iv.next94 = add nsw i64 %indvars.iv93, -1
  %45 = icmp sgt i64 %indvars.iv93, 0
  %indvars.iv.next96 = add nsw i64 %indvars.iv95, -1
  br i1 %45, label %.preheader, label %._crit_edge83, !llvm.loop !16

.preheader:                                       ; preds = %.preheader.preheader, %.loopexit
  %46 = phi i32 [ %.pre102, %.preheader.preheader ], [ %42, %.loopexit ]
  %47 = phi i32 [ %.pre102, %.preheader.preheader ], [ %43, %.loopexit ]
  %48 = phi i32 [ %.pre102, %.preheader.preheader ], [ %44, %.loopexit ]
  %indvars.iv95 = phi i64 [ %36, %.preheader.preheader ], [ %indvars.iv.next96, %.loopexit ]
  %indvars.iv93 = phi i64 [ %35, %.preheader.preheader ], [ %indvars.iv.next94, %.loopexit ]
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %.lr.ph79, label %.loopexit

.lr.ph79:                                         ; preds = %.preheader
  %50 = load i32, ptr @M, align 4, !tbaa !11
  %51 = icmp sgt i32 %50, -1
  br i1 %51, label %.lr.ph79.split, label %.loopexit

._crit_edge83:                                    ; preds = %.loopexit, %._crit_edge
  %52 = phi i32 [ %.pre102, %._crit_edge ], [ %42, %.loopexit ]
  %53 = add nsw i32 %52, -1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %54
  %56 = load i64, ptr %55, align 16, !tbaa !18
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %56)
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.lr.ph79.split:                                   ; preds = %.lr.ph79, %._crit_edge77
  %59 = phi i32 [ %64, %._crit_edge77 ], [ %46, %.lr.ph79 ]
  %60 = phi i32 [ %65, %._crit_edge77 ], [ %50, %.lr.ph79 ]
  %indvars.iv90 = phi i64 [ %indvars.iv.next91, %._crit_edge77 ], [ 0, %.lr.ph79 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 -1, ptr %1, align 4, !tbaa !11
  %61 = icmp sgt i32 %60, -1
  br i1 %61, label %.lr.ph76, label %._crit_edge77

.lr.ph76:                                         ; preds = %.lr.ph79.split
  %62 = getelementptr inbounds [1000 x i32], ptr @fj, i64 0, i64 %indvars.iv90
  %.not = icmp eq i64 %indvars.iv90, 0
  %63 = add nsw i64 %indvars.iv90, -1
  br label %68

._crit_edge77.loopexit:                           ; preds = %.thread
  %.pre101 = load i32, ptr @N, align 4, !tbaa !11
  br label %._crit_edge77

._crit_edge77:                                    ; preds = %._crit_edge77.loopexit, %.lr.ph79.split
  %64 = phi i32 [ %.pre101, %._crit_edge77.loopexit ], [ %59, %.lr.ph79.split ]
  %65 = phi i32 [ %157, %._crit_edge77.loopexit ], [ %60, %.lr.ph79.split ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %66 = sext i32 %64 to i64
  %67 = icmp slt i64 %indvars.iv.next91, %66
  br i1 %67, label %.lr.ph79.split, label %.loopexit, !llvm.loop !20

68:                                               ; preds = %.lr.ph76, %.thread
  %storemerge74 = phi i32 [ -1, %.lr.ph76 ], [ %.pre-phi, %.thread ]
  %69 = sext i32 %storemerge74 to i64
  %70 = getelementptr inbounds [1000 x i32], ptr @fp, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = load i32, ptr %62, align 4, !tbaa !11
  %73 = icmp slt i32 %71, %72
  %74 = add nsw i32 %storemerge74, 1
  br i1 %73, label %75, label %._crit_edge100

._crit_edge100:                                   ; preds = %68
  %.pre104 = sext i32 %74 to i64
  br label %119

75:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 0, ptr %2, align 4, !tbaa !11
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i32, ptr @fp, i64 %78
  %80 = load i32, ptr @M, align 4, !tbaa !11
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i32, ptr @fp, i64 %81
  %83 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull %79, ptr noundef nonnull %82, ptr noundef nonnull align 4 dereferenceable(4) %62)
  %84 = ptrtoint ptr %83 to i64
  %85 = sub i64 %84, ptrtoint (ptr @fp to i64)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %86 = load i32, ptr @K, align 4, !tbaa !11
  %87 = zext i32 %86 to i64
  %88 = icmp eq i64 %indvars.iv95, %87
  br i1 %88, label %89, label %98

89:                                               ; preds = %75
  %90 = lshr exact i64 %85, 2
  %91 = trunc i64 %90 to i32
  %92 = sub nsw i32 %91, %74
  %93 = sext i32 %92 to i64
  %94 = load i32, ptr %1, align 4, !tbaa !11
  %95 = add nsw i32 %94, 1
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %indvars.iv90, i64 %96, i64 %indvars.iv93
  store i64 %93, ptr %97, align 8, !tbaa !18
  br label %119

98:                                               ; preds = %75
  %99 = load i32, ptr @N, align 4, !tbaa !11
  %100 = add nsw i32 %99, -1
  %101 = sext i32 %100 to i64
  %sext = shl i64 %85, 30
  %102 = ashr i64 %sext, 32
  %103 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %101, i64 %102, i64 %indvars.iv95
  %104 = load i64, ptr %103, align 8, !tbaa !18
  %105 = load i32, ptr %1, align 4, !tbaa !11
  %106 = add nsw i32 %105, 1
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %indvars.iv90, i64 %107, i64 %indvars.iv93
  %109 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %indvars.iv90, i64 %102, i64 %indvars.iv95
  %110 = load i64, ptr %109, align 8, !tbaa !18
  %111 = sext i32 %74 to i64
  %112 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %101, i64 %111, i64 %indvars.iv95
  %113 = load i64, ptr %112, align 8, !tbaa !18
  %114 = add i64 %110, %113
  %115 = sub i64 %104, %114
  %116 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %indvars.iv90, i64 %111, i64 %indvars.iv95
  %117 = load i64, ptr %116, align 8, !tbaa !18
  %118 = add nsw i64 %117, %115
  store i64 %118, ptr %108, align 8, !tbaa !18
  br label %119

119:                                              ; preds = %._crit_edge100, %89, %98
  %.pre-phi105 = phi i64 [ %.pre104, %._crit_edge100 ], [ %96, %89 ], [ %107, %98 ]
  %.pre-phi = phi i32 [ %74, %._crit_edge100 ], [ %95, %89 ], [ %106, %98 ]
  %120 = phi i32 [ %storemerge74, %._crit_edge100 ], [ %94, %89 ], [ %105, %98 ]
  %121 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @dp, i64 0, i64 %indvars.iv90, i64 %.pre-phi105, i64 %indvars.iv93
  %122 = load i64, ptr %121, align 8, !tbaa !18
  %123 = load i64, ptr @MOD, align 8, !tbaa !18
  %124 = srem i64 %122, %123
  %125 = add nsw i64 %124, %123
  %126 = srem i64 %125, %123
  store i64 %126, ptr %121, align 8, !tbaa !18
  %127 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %indvars.iv90, i64 %.pre-phi105, i64 %indvars.iv93
  store i64 %126, ptr %127, align 8, !tbaa !18
  br i1 %.not, label %128, label %.thread68

128:                                              ; preds = %119
  %129 = icmp sgt i32 %120, -1
  br i1 %129, label %134, label %.thread

.thread68:                                        ; preds = %119
  %130 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %63, i64 %.pre-phi105, i64 %indvars.iv93
  %131 = load i64, ptr %130, align 8, !tbaa !18
  %132 = add nsw i64 %131, %126
  store i64 %132, ptr %127, align 8, !tbaa !18
  %133 = icmp sgt i32 %120, -1
  br i1 %133, label %142, label %.thread

134:                                              ; preds = %128
  %135 = zext nneg i32 %120 to i64
  %136 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 0, i64 %135, i64 %indvars.iv93
  %137 = load i64, ptr %136, align 8, !tbaa !18
  %138 = zext nneg i32 %.pre-phi to i64
  %139 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 0, i64 %138, i64 %indvars.iv93
  %140 = load i64, ptr %139, align 8, !tbaa !18
  %141 = add nsw i64 %140, %137
  store i64 %141, ptr %139, align 8, !tbaa !18
  br label %.thread

142:                                              ; preds = %.thread68
  %143 = zext nneg i32 %120 to i64
  %144 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %indvars.iv90, i64 %143, i64 %indvars.iv93
  %145 = load i64, ptr %144, align 8, !tbaa !18
  %146 = zext nneg i32 %.pre-phi to i64
  %147 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %indvars.iv90, i64 %146, i64 %indvars.iv93
  %148 = load i64, ptr %147, align 8, !tbaa !18
  %149 = add nsw i64 %148, %145
  store i64 %149, ptr %147, align 8, !tbaa !18
  %150 = getelementptr inbounds [1000 x [1001 x [10 x i64]]], ptr @pfx, i64 0, i64 %63, i64 %143, i64 %indvars.iv93
  %151 = load i64, ptr %150, align 8, !tbaa !18
  %152 = sub nsw i64 %149, %151
  store i64 %152, ptr %147, align 8, !tbaa !18
  br label %.thread

.thread:                                          ; preds = %134, %.thread68, %128, %142
  %153 = load i64, ptr %127, align 8, !tbaa !18
  %154 = srem i64 %153, %123
  %155 = add nsw i64 %154, %123
  %156 = srem i64 %155, %123
  store i64 %156, ptr %127, align 8, !tbaa !18
  store i32 %.pre-phi, ptr %1, align 4, !tbaa !11
  %157 = load i32, ptr @M, align 4, !tbaa !11
  %158 = icmp slt i32 %.pre-phi, %157
  br i1 %158, label %68, label %._crit_edge77.loopexit, !llvm.loop !21
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

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

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

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

; 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 #6 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 #6 align 2

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14, !17}
!17 = !{!"llvm.loop.unswitch.partial.disable"}
!18 = !{!19, !19, i64 0}
!19 = !{!"long long", !7, i64 0}
!20 = distinct !{!20, !14, !17}
!21 = distinct !{!21, !14}


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