; LLVM IR from eyangch/competitive-programming :: USACOcontests/gold/2015.12 (dream)

; 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" }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, std::pair<int, int>>, std::allocator<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, std::pair<int, int>>, std::allocator<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, std::pair<int, int>>, std::allocator<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, std::pair<int, int>>, std::allocator<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { %"struct.std::pair.0", %"struct.std::pair.0" }
%"struct.std::pair.0" = type { i32, i32 }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@b = external dso_local global [1000 x [1000 x i32]], align 16
@dista = external dso_local global [1000 x [1000 x [2 x i32]]], align 16
@vis = external dso_local global [1000 x [1000 x [2 x i8]]], align 16
@dx = external dso_local global [4 x i32], align 16
@dy = external dso_local global [4 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [9 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 [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7canMoveiib(i32 noundef, i32 noundef, i1 noundef zeroext) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 personality ptr @__gxx_personality_v0 {
  %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 i8, align 1
  %7 = alloca %"class.std::priority_queue", align 8
  %8 = alloca %"struct.std::pair", align 4
  %9 = alloca %"struct.std::pair.0", align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::pair.0", align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca %"struct.std::pair", align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca %"struct.std::pair", align 4
  %28 = alloca %"struct.std::pair.0", align 4
  %29 = alloca %"struct.std::pair.0", align 4
  %30 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %31 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %32 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %33 = getelementptr i8, ptr %32, i64 -24
  %34 = load i64, ptr %33, align 8
  %35 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %34
  %36 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %35, ptr noundef null)
  %37 = load ptr, ptr @stdin, align 8, !tbaa !8
  %38 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %37)
  %39 = load ptr, ptr @stdout, align 8, !tbaa !8
  %40 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %39)
  %41 = 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)
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %41, ptr noundef nonnull align 4 dereferenceable(4) @M)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %66, %0
  %44 = load i32, ptr %2, align 4, !tbaa !11
  %45 = load i32, ptr @N, align 4, !tbaa !11
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %69

48:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %49

49:                                               ; preds = %62, %48
  %50 = load i32, ptr %4, align 4, !tbaa !11
  %51 = load i32, ptr @M, align 4, !tbaa !11
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %49
  %55 = load i32, ptr %2, align 4, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1000 x [1000 x i32]], ptr @b, i64 0, i64 %56
  %58 = load i32, ptr %4, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1000 x i32], ptr %57, i64 0, i64 %59
  %61 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %60)
  br label %62

62:                                               ; preds = %54
  %63 = load i32, ptr %4, align 4, !tbaa !11
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %4, align 4, !tbaa !11
  br label %49, !llvm.loop !13

65:                                               ; preds = %53
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %2, align 4, !tbaa !11
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %2, align 4, !tbaa !11
  br label %43, !llvm.loop !15

69:                                               ; preds = %47
  %70 = load i32, ptr @N, align 4, !tbaa !11
  %71 = sub nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1000 x [1000 x [2 x i32]]], ptr @dista, i64 0, i64 %72
  %74 = load i32, ptr @M, align 4, !tbaa !11
  %75 = sub nsw i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1000 x [2 x i32]], ptr %73, i64 0, i64 %76
  %78 = getelementptr inbounds [2 x i32], ptr %77, i64 0, i64 0
  %79 = getelementptr inbounds i32, ptr %78, i64 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 2147483647, ptr %5, align 4, !tbaa !11
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef @dista, ptr noundef %79, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  %80 = load i32, ptr @N, align 4, !tbaa !11
  %81 = sub nsw i32 %80, 1
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1000 x [1000 x [2 x i8]]], ptr @vis, i64 0, i64 %82
  %84 = load i32, ptr @M, align 4, !tbaa !11
  %85 = sub nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1000 x [2 x i8]], ptr %83, i64 0, i64 %86
  %88 = getelementptr inbounds [2 x i8], ptr %87, i64 0, i64 0
  %89 = getelementptr inbounds i8, ptr %88, i64 2
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #8
  store i8 0, ptr %6, align 1, !tbaa !16
  call void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef @vis, ptr noundef %89, ptr noundef nonnull align 1 dereferenceable(1) %6)
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #8
  call void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EEC2IS5_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
  store i32 0, ptr @dista, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 0, ptr %11, align 4, !tbaa !11
  invoke void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8) %9, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
          to label %90 unwind label %131

90:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  store i32 0, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !11
  invoke void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8) %14, ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %16)
          to label %91 unwind label %135

91:                                               ; preds = %90
  %92 = invoke { i64, i64 } @_ZSt9make_pairISt4pairIiiES1_ES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %9, ptr noundef nonnull align 4 dereferenceable(8) %14)
          to label %93 unwind label %135

93:                                               ; preds = %91
  %94 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %95 = extractvalue { i64, i64 } %92, 0
  store i64 %95, ptr %94, align 4
  %96 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %97 = extractvalue { i64, i64 } %92, 1
  store i64 %97, ptr %96, align 4
  invoke void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(25) %7, ptr noundef nonnull align 4 dereferenceable(16) %8)
          to label %98 unwind label %135

98:                                               ; preds = %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #8
  br label %99

99:                                               ; preds = %286, %284, %98
  %100 = invoke noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
          to label %101 unwind label %140

101:                                              ; preds = %99
  %102 = xor i1 %100, true
  br i1 %102, label %103, label %288

103:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #8
  %104 = invoke noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
          to label %105 unwind label %144

105:                                              ; preds = %103
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %104, i64 16, i1 false)
  invoke void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %7)
          to label %106 unwind label %144

106:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  %107 = getelementptr inbounds %"struct.std::pair", ptr %17, i32 0, i32 1
  %108 = getelementptr inbounds %"struct.std::pair.0", ptr %107, i32 0, i32 0
  %109 = load i32, ptr %108, align 4, !tbaa !18
  store i32 %109, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  %110 = getelementptr inbounds %"struct.std::pair", ptr %17, i32 0, i32 1
  %111 = getelementptr inbounds %"struct.std::pair.0", ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !21
  store i32 %112, ptr %19, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #8
  %113 = getelementptr inbounds %"struct.std::pair", ptr %17, i32 0, i32 0
  %114 = getelementptr inbounds %"struct.std::pair.0", ptr %113, i32 0, i32 0
  %115 = load i32, ptr %114, align 4, !tbaa !22
  store i32 %115, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  %116 = getelementptr inbounds %"struct.std::pair", ptr %17, i32 0, i32 0
  %117 = getelementptr inbounds %"struct.std::pair.0", ptr %116, i32 0, i32 1
  %118 = load i32, ptr %117, align 4, !tbaa !23
  store i32 %118, ptr %21, align 4, !tbaa !11
  %119 = load i32, ptr %18, align 4, !tbaa !11
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [1000 x [1000 x [2 x i8]]], ptr @vis, i64 0, i64 %120
  %122 = load i32, ptr %19, align 4, !tbaa !11
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [1000 x [2 x i8]], ptr %121, i64 0, i64 %123
  %125 = load i32, ptr %21, align 4, !tbaa !11
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [2 x i8], ptr %124, i64 0, i64 %126
  %128 = load i8, ptr %127, align 1, !tbaa !16, !range !24, !noundef !25
  %129 = trunc i8 %128 to i1
  br i1 %129, label %130, label %148

130:                                              ; preds = %106
  store i32 8, ptr %3, align 4
  br label %284, !llvm.loop !26

131:                                              ; preds = %69
  %132 = landingpad { ptr, i32 }
          cleanup
  %133 = extractvalue { ptr, i32 } %132, 0
  store ptr %133, ptr %12, align 8
  %134 = extractvalue { ptr, i32 } %132, 1
  store i32 %134, ptr %13, align 4
  br label %139

135:                                              ; preds = %93, %91, %90
  %136 = landingpad { ptr, i32 }
          cleanup
  %137 = extractvalue { ptr, i32 } %136, 0
  store ptr %137, ptr %12, align 8
  %138 = extractvalue { ptr, i32 } %136, 1
  store i32 %138, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  br label %139

139:                                              ; preds = %135, %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #8
  br label %329

140:                                              ; preds = %99
  %141 = landingpad { ptr, i32 }
          cleanup
  %142 = extractvalue { ptr, i32 } %141, 0
  store ptr %142, ptr %12, align 8
  %143 = extractvalue { ptr, i32 } %141, 1
  store i32 %143, ptr %13, align 4
  br label %329

144:                                              ; preds = %105, %103
  %145 = landingpad { ptr, i32 }
          cleanup
  %146 = extractvalue { ptr, i32 } %145, 0
  store ptr %146, ptr %12, align 8
  %147 = extractvalue { ptr, i32 } %145, 1
  store i32 %147, ptr %13, align 4
  br label %287

148:                                              ; preds = %106
  %149 = load i32, ptr %18, align 4, !tbaa !11
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [1000 x [1000 x [2 x i8]]], ptr @vis, i64 0, i64 %150
  %152 = load i32, ptr %19, align 4, !tbaa !11
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [1000 x [2 x i8]], ptr %151, i64 0, i64 %153
  %155 = load i32, ptr %21, align 4, !tbaa !11
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [2 x i8], ptr %154, i64 0, i64 %156
  store i8 1, ptr %157, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #8
  store i32 0, ptr %22, align 4, !tbaa !11
  br label %158

158:                                              ; preds = %280, %148
  %159 = load i32, ptr %22, align 4, !tbaa !11
  %160 = icmp slt i32 %159, 4
  br i1 %160, label %162, label %161

161:                                              ; preds = %158
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  br label %283

162:                                              ; preds = %158
  %163 = load i32, ptr %18, align 4, !tbaa !11
  %164 = load i32, ptr %22, align 4, !tbaa !11
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [4 x i32], ptr @dx, i64 0, i64 %165
  %167 = load i32, ptr %166, align 4, !tbaa !11
  %168 = add nsw i32 %163, %167
  %169 = load i32, ptr %19, align 4, !tbaa !11
  %170 = load i32, ptr %22, align 4, !tbaa !11
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [4 x i32], ptr @dy, i64 0, i64 %171
  %173 = load i32, ptr %172, align 4, !tbaa !11
  %174 = add nsw i32 %169, %173
  %175 = load i32, ptr %21, align 4, !tbaa !11
  %176 = icmp ne i32 %175, 0
  %177 = call noundef zeroext i1 @_Z7canMoveiib(i32 noundef %168, i32 noundef %174, i1 noundef zeroext %176)
  br i1 %177, label %179, label %178

178:                                              ; preds = %162
  br label %280

179:                                              ; preds = %162
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #8
  %180 = load i32, ptr %18, align 4, !tbaa !11
  store i32 %180, ptr %23, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #8
  %181 = load i32, ptr %19, align 4, !tbaa !11
  store i32 %181, ptr %24, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #8
  %182 = load i32, ptr %20, align 4, !tbaa !11
  store i32 %182, ptr %25, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #8
  %183 = load i32, ptr %21, align 4, !tbaa !11
  store i32 %183, ptr %26, align 4, !tbaa !11
  br label %184

184:                                              ; preds = %225, %179
  %185 = load i32, ptr %23, align 4, !tbaa !11
  %186 = load i32, ptr %22, align 4, !tbaa !11
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [4 x i32], ptr @dx, i64 0, i64 %187
  %189 = load i32, ptr %188, align 4, !tbaa !11
  %190 = add nsw i32 %185, %189
  %191 = load i32, ptr %24, align 4, !tbaa !11
  %192 = load i32, ptr %22, align 4, !tbaa !11
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [4 x i32], ptr @dy, i64 0, i64 %193
  %195 = load i32, ptr %194, align 4, !tbaa !11
  %196 = add nsw i32 %191, %195
  %197 = load i32, ptr %26, align 4, !tbaa !11
  %198 = icmp ne i32 %197, 0
  %199 = call noundef zeroext i1 @_Z7canMoveiib(i32 noundef %190, i32 noundef %196, i1 noundef zeroext %198)
  br i1 %199, label %200, label %226

200:                                              ; preds = %184
  %201 = load i32, ptr %25, align 4, !tbaa !11
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %25, align 4, !tbaa !11
  %203 = load i32, ptr %22, align 4, !tbaa !11
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [4 x i32], ptr @dx, i64 0, i64 %204
  %206 = load i32, ptr %205, align 4, !tbaa !11
  %207 = load i32, ptr %23, align 4, !tbaa !11
  %208 = add nsw i32 %207, %206
  store i32 %208, ptr %23, align 4, !tbaa !11
  %209 = load i32, ptr %22, align 4, !tbaa !11
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [4 x i32], ptr @dy, i64 0, i64 %210
  %212 = load i32, ptr %211, align 4, !tbaa !11
  %213 = load i32, ptr %24, align 4, !tbaa !11
  %214 = add nsw i32 %213, %212
  store i32 %214, ptr %24, align 4, !tbaa !11
  %215 = load i32, ptr %23, align 4, !tbaa !11
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [1000 x [1000 x i32]], ptr @b, i64 0, i64 %216
  %218 = load i32, ptr %24, align 4, !tbaa !11
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [1000 x i32], ptr %217, i64 0, i64 %219
  %221 = load i32, ptr %220, align 4, !tbaa !11
  %222 = icmp ne i32 %221, 4
  br i1 %222, label %223, label %224

223:                                              ; preds = %200
  br label %226

224:                                              ; preds = %200
  store i32 0, ptr %26, align 4, !tbaa !11
  br label %225

225:                                              ; preds = %224
  br label %184, !llvm.loop !27

226:                                              ; preds = %223, %184
  %227 = load i32, ptr %23, align 4, !tbaa !11
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds [1000 x [1000 x i32]], ptr @b, i64 0, i64 %228
  %230 = load i32, ptr %24, align 4, !tbaa !11
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [1000 x i32], ptr %229, i64 0, i64 %231
  %233 = load i32, ptr %232, align 4, !tbaa !11
  %234 = icmp eq i32 %233, 2
  br i1 %234, label %235, label %236

235:                                              ; preds = %226
  store i32 1, ptr %26, align 4, !tbaa !11
  br label %236

236:                                              ; preds = %235, %226
  %237 = load i32, ptr %25, align 4, !tbaa !11
  %238 = load i32, ptr %23, align 4, !tbaa !11
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [1000 x [1000 x [2 x i32]]], ptr @dista, i64 0, i64 %239
  %241 = load i32, ptr %24, align 4, !tbaa !11
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [1000 x [2 x i32]], ptr %240, i64 0, i64 %242
  %244 = load i32, ptr %26, align 4, !tbaa !11
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [2 x i32], ptr %243, i64 0, i64 %245
  %247 = load i32, ptr %246, align 4, !tbaa !11
  %248 = icmp slt i32 %237, %247
  br i1 %248, label %249, label %278

249:                                              ; preds = %236
  %250 = load i32, ptr %25, align 4, !tbaa !11
  %251 = load i32, ptr %23, align 4, !tbaa !11
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [1000 x [1000 x [2 x i32]]], ptr @dista, i64 0, i64 %252
  %254 = load i32, ptr %24, align 4, !tbaa !11
  %255 = sext i32 %254 to i64
  %256 = getelementptr inbounds [1000 x [2 x i32]], ptr %253, i64 0, i64 %255
  %257 = load i32, ptr %26, align 4, !tbaa !11
  %258 = sext i32 %257 to i64
  %259 = getelementptr inbounds [2 x i32], ptr %256, i64 0, i64 %258
  store i32 %250, ptr %259, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %27) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #8
  invoke void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %28, ptr noundef nonnull align 4 dereferenceable(4) %25, ptr noundef nonnull align 4 dereferenceable(4) %26)
          to label %260 unwind label %269

260:                                              ; preds = %249
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #8
  invoke void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %29, ptr noundef nonnull align 4 dereferenceable(4) %23, ptr noundef nonnull align 4 dereferenceable(4) %24)
          to label %261 unwind label %273

261:                                              ; preds = %260
  %262 = invoke { i64, i64 } @_ZSt9make_pairISt4pairIiiES1_ES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %28, ptr noundef nonnull align 4 dereferenceable(8) %29)
          to label %263 unwind label %273

263:                                              ; preds = %261
  %264 = getelementptr inbounds { i64, i64 }, ptr %27, i32 0, i32 0
  %265 = extractvalue { i64, i64 } %262, 0
  store i64 %265, ptr %264, align 4
  %266 = getelementptr inbounds { i64, i64 }, ptr %27, i32 0, i32 1
  %267 = extractvalue { i64, i64 } %262, 1
  store i64 %267, ptr %266, align 4
  invoke void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(25) %7, ptr noundef nonnull align 4 dereferenceable(16) %27)
          to label %268 unwind label %273

268:                                              ; preds = %263
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %27) #8
  br label %279

269:                                              ; preds = %249
  %270 = landingpad { ptr, i32 }
          cleanup
  %271 = extractvalue { ptr, i32 } %270, 0
  store ptr %271, ptr %12, align 8
  %272 = extractvalue { ptr, i32 } %270, 1
  store i32 %272, ptr %13, align 4
  br label %277

273:                                              ; preds = %263, %261, %260
  %274 = landingpad { ptr, i32 }
          cleanup
  %275 = extractvalue { ptr, i32 } %274, 0
  store ptr %275, ptr %12, align 8
  %276 = extractvalue { ptr, i32 } %274, 1
  store i32 %276, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #8
  br label %277

277:                                              ; preds = %273, %269
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %27) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  br label %287

278:                                              ; preds = %236
  br label %279

279:                                              ; preds = %278, %268
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #8
  br label %280

280:                                              ; preds = %279, %178
  %281 = load i32, ptr %22, align 4, !tbaa !11
  %282 = add nsw i32 %281, 1
  store i32 %282, ptr %22, align 4, !tbaa !11
  br label %158, !llvm.loop !28

283:                                              ; preds = %161
  store i32 0, ptr %3, align 4
  br label %284

284:                                              ; preds = %283, %130
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #8
  %285 = load i32, ptr %3, align 4
  switch i32 %285, label %335 [
    i32 0, label %286
    i32 8, label %99
  ]

286:                                              ; preds = %284
  br label %99, !llvm.loop !26

287:                                              ; preds = %277, %144
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #8
  br label %329

288:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #8
  %289 = load i32, ptr @N, align 4, !tbaa !11
  %290 = sub nsw i32 %289, 1
  %291 = sext i32 %290 to i64
  %292 = getelementptr inbounds [1000 x [1000 x [2 x i32]]], ptr @dista, i64 0, i64 %291
  %293 = load i32, ptr @M, align 4, !tbaa !11
  %294 = sub nsw i32 %293, 1
  %295 = sext i32 %294 to i64
  %296 = getelementptr inbounds [1000 x [2 x i32]], ptr %292, i64 0, i64 %295
  %297 = getelementptr inbounds [2 x i32], ptr %296, i64 0, i64 0
  %298 = load i32, ptr @N, align 4, !tbaa !11
  %299 = sub nsw i32 %298, 1
  %300 = sext i32 %299 to i64
  %301 = getelementptr inbounds [1000 x [1000 x [2 x i32]]], ptr @dista, i64 0, i64 %300
  %302 = load i32, ptr @M, align 4, !tbaa !11
  %303 = sub nsw i32 %302, 1
  %304 = sext i32 %303 to i64
  %305 = getelementptr inbounds [1000 x [2 x i32]], ptr %301, i64 0, i64 %304
  %306 = getelementptr inbounds [2 x i32], ptr %305, i64 0, i64 1
  %307 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %297, ptr noundef nonnull align 4 dereferenceable(4) %306)
          to label %308 unwind label %317

308:                                              ; preds = %288
  %309 = load i32, ptr %307, align 4, !tbaa !11
  store i32 %309, ptr %30, align 4, !tbaa !11
  %310 = load i32, ptr %30, align 4, !tbaa !11
  %311 = icmp eq i32 %310, 2147483647
  br i1 %311, label %312, label %321

312:                                              ; preds = %308
  %313 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
          to label %314 unwind label %317

314:                                              ; preds = %312
  %315 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %313, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %316 unwind label %317

316:                                              ; preds = %314
  br label %327

317:                                              ; preds = %324, %321, %314, %312, %288
  %318 = landingpad { ptr, i32 }
          cleanup
  %319 = extractvalue { ptr, i32 } %318, 0
  store ptr %319, ptr %12, align 8
  %320 = extractvalue { ptr, i32 } %318, 1
  store i32 %320, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #8
  br label %329

321:                                              ; preds = %308
  %322 = load i32, ptr %30, align 4, !tbaa !11
  %323 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %322)
          to label %324 unwind label %317

324:                                              ; preds = %321
  %325 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %323, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %326 unwind label %317

326:                                              ; preds = %324
  br label %327

327:                                              ; preds = %326, %316
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #8
  call void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #8
  %328 = load i32, ptr %1, align 4
  ret i32 %328

329:                                              ; preds = %317, %287, %140, %139
  call void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #8
  br label %330

330:                                              ; preds = %329
  %331 = load ptr, ptr %12, align 8
  %332 = load i32, ptr %13, align 4
  %333 = insertvalue { ptr, i32 } poison, ptr %331, 0
  %334 = insertvalue { ptr, i32 } %333, i32 %332, 1
  resume { ptr, i32 } %334

335:                                              ; preds = %284
  unreachable
}

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

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

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

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

; Function Attrs: nocallback nofree 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 @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EEC2IS5_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(16)) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZSt9make_pairISt4pairIiiES1_ES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #7 align 2

attributes #0 = { 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 #1 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree 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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #8 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !10, i64 0}
!18 = !{!19, !12, i64 8}
!19 = !{!"_ZTSSt4pairIS_IiiES0_E", !20, i64 0, !20, i64 8}
!20 = !{!"_ZTSSt4pairIiiE", !12, i64 0, !12, i64 4}
!21 = !{!19, !12, i64 12}
!22 = !{!19, !12, i64 0}
!23 = !{!19, !12, i64 4}
!24 = !{i8 0, i8 2}
!25 = !{}
!26 = distinct !{!26, !14}
!27 = distinct !{!27, !14}
!28 = distinct !{!28, !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" }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, std::pair<int, int>>, std::allocator<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, std::pair<int, int>>, std::allocator<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, std::pair<int, int>>, std::allocator<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, std::pair<int, int>>, std::allocator<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { %"struct.std::pair.0", %"struct.std::pair.0" }
%"struct.std::pair.0" = type { i32, i32 }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@b = external dso_local global [1000 x [1000 x i32]], align 16
@dista = external dso_local global [1000 x [1000 x [2 x i32]]], align 16
@vis = external dso_local global [1000 x [1000 x [2 x i8]]], align 16
@dx = external dso_local local_unnamed_addr global [4 x i32], align 16
@dy = external dso_local local_unnamed_addr global [4 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [9 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 [10 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
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7canMoveiib(i32 noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i8, align 1
  %3 = alloca %"class.std::priority_queue", align 8
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca %"struct.std::pair.0", align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::pair.0", align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %"struct.std::pair", align 8
  %16 = alloca %"struct.std::pair.0", align 4
  %17 = alloca %"struct.std::pair.0", align 4
  %18 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %19 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %20 = getelementptr i8, ptr %19, i64 -24
  %21 = load i64, ptr %20, align 8
  %22 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %21
  %23 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %22, ptr noundef null)
  %24 = load ptr, ptr @stdin, align 8, !tbaa !8
  %25 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %24)
  %26 = load ptr, ptr @stdout, align 8, !tbaa !8
  %27 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %26)
  %28 = 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)
  %29 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %30 = load i32, ptr @N, align 4, !tbaa !11
  %31 = icmp sgt i32 %30, 0
  %.pre59 = load i32, ptr @M, align 4, !tbaa !11
  %32 = icmp sgt i32 %.pre59, 0
  %or.cond = select i1 %31, i1 %32, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge43

.preheader:                                       ; preds = %0, %._crit_edge
  %33 = phi i32 [ %52, %._crit_edge ], [ %30, %0 ]
  %34 = phi i32 [ %53, %._crit_edge ], [ %.pre59, %0 ]
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %._crit_edge ], [ 0, %0 ]
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %.lr.ph, label %._crit_edge

._crit_edge43:                                    ; preds = %._crit_edge, %0
  %36 = phi i32 [ %.pre59, %0 ], [ %53, %._crit_edge ]
  %.lcssa = phi i32 [ %30, %0 ], [ %52, %._crit_edge ]
  %37 = add nsw i32 %.lcssa, -1
  %38 = sext i32 %37 to i64
  %39 = add nsw i32 %36, -1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1000 x [1000 x [2 x i32]]], ptr @dista, i64 0, i64 %38, i64 %40
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 2147483647, ptr %1, align 4, !tbaa !11
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull @dista, ptr noundef nonnull %42, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %43 = load i32, ptr @N, align 4, !tbaa !11
  %44 = add nsw i32 %43, -1
  %45 = sext i32 %44 to i64
  %46 = load i32, ptr @M, align 4, !tbaa !11
  %47 = add nsw i32 %46, -1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1000 x [1000 x [2 x i8]]], ptr @vis, i64 0, i64 %45, i64 %48
  %50 = getelementptr inbounds i8, ptr %49, i64 2
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #7
  store i8 0, ptr %2, align 1, !tbaa !13
  call void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef nonnull @vis, ptr noundef nonnull %50, ptr noundef nonnull align 1 dereferenceable(1) %2)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #7
  call void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EEC2IS5_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %3)
  store i32 0, ptr @dista, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  store i32 0, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  store i32 0, ptr %7, align 4, !tbaa !11
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #7
  store i32 0, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #7
  store i32 0, ptr %10, align 4, !tbaa !11
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %51 = invoke { i64, i64 } @_ZSt9make_pairISt4pairIiiES1_ES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %8)
          to label %61 unwind label %77

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %52 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %33, %.preheader ]
  %53 = phi i32 [ %58, %._crit_edge.loopexit ], [ %34, %.preheader ]
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %54 = sext i32 %52 to i64
  %55 = icmp slt i64 %indvars.iv.next52, %54
  br i1 %55, label %.preheader, label %._crit_edge43, !llvm.loop !15

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %56 = getelementptr inbounds [1000 x [1000 x i32]], ptr @b, i64 0, i64 %indvars.iv51, i64 %indvars.iv
  %57 = 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) %56)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %58 = load i32, ptr @M, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = icmp slt i64 %indvars.iv.next, %59
  br i1 %60, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18

61:                                               ; preds = %._crit_edge43
  %62 = extractvalue { i64, i64 } %51, 0
  store i64 %62, ptr %4, align 8
  %63 = getelementptr inbounds i8, ptr %4, i64 8
  %64 = extractvalue { i64, i64 } %51, 1
  store i64 %64, ptr %63, align 8
  invoke void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(25) %3, ptr noundef nonnull align 4 dereferenceable(16) %4)
          to label %65 unwind label %77

65:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  %66 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %3)
  br i1 %66, label %._crit_edge47, label %.lr.ph46

.lr.ph46:                                         ; preds = %65
  %67 = getelementptr inbounds i8, ptr %15, i64 8
  br label %68

68:                                               ; preds = %.lr.ph46, %.loopexit
  %69 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %3)
  %.sroa.0.0.copyload = load i32, ptr %69, align 4
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %69, i64 4
  %.sroa.5.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 4
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %69, i64 8
  %.sroa.6.0.copyload = load i32, ptr %.sroa.6.0..sroa_idx, align 4
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %69, i64 12
  %.sroa.7.0.copyload = load i32, ptr %.sroa.7.0..sroa_idx, align 4
  invoke void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %3)
          to label %70 unwind label %79

70:                                               ; preds = %68
  %71 = sext i32 %.sroa.6.0.copyload to i64
  %72 = sext i32 %.sroa.7.0.copyload to i64
  %73 = sext i32 %.sroa.5.0.copyload to i64
  %74 = getelementptr inbounds [1000 x [1000 x [2 x i8]]], ptr @vis, i64 0, i64 %71, i64 %72, i64 %73
  %75 = load i8, ptr %74, align 1, !tbaa !13, !range !19, !noundef !20
  %76 = trunc nuw i8 %75 to i1
  br i1 %76, label %.loopexit, label %81, !llvm.loop !21

77:                                               ; preds = %61, %._crit_edge43
  %78 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  br label %168

79:                                               ; preds = %68
  %80 = landingpad { ptr, i32 }
          cleanup
  br label %168

81:                                               ; preds = %70
  store i8 1, ptr %74, align 1, !tbaa !13
  %82 = icmp ne i32 %.sroa.5.0.copyload, 0
  br label %83

83:                                               ; preds = %81, %149
  %indvars.iv56 = phi i64 [ 0, %81 ], [ %indvars.iv.next57, %149 ]
  %84 = getelementptr inbounds [4 x i32], ptr @dx, i64 0, i64 %indvars.iv56
  %85 = load i32, ptr %84, align 4, !tbaa !11
  %86 = add nsw i32 %85, %.sroa.6.0.copyload
  %87 = getelementptr inbounds [4 x i32], ptr @dy, i64 0, i64 %indvars.iv56
  %88 = load i32, ptr %87, align 4, !tbaa !11
  %89 = add nsw i32 %88, %.sroa.7.0.copyload
  %90 = call noundef zeroext i1 @_Z7canMoveiib(i32 noundef %86, i32 noundef %89, i1 noundef zeroext %82)
  br i1 %90, label %.peel.begin, label %149

.peel.begin:                                      ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #7
  store i32 %.sroa.6.0.copyload, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #7
  store i32 %.sroa.7.0.copyload, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #7
  store i32 %.sroa.0.0.copyload, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #7
  store i32 %.sroa.5.0.copyload, ptr %14, align 4, !tbaa !11
  %91 = load i32, ptr %84, align 4, !tbaa !11
  %92 = add nsw i32 %91, %.sroa.6.0.copyload
  %93 = load i32, ptr %87, align 4, !tbaa !11
  %94 = add nsw i32 %93, %.sroa.7.0.copyload
  %95 = call noundef zeroext i1 @_Z7canMoveiib(i32 noundef %92, i32 noundef %94, i1 noundef zeroext %82)
  %.pre61 = load i32, ptr %11, align 4, !tbaa !11
  %.pre63 = load i32, ptr %12, align 4, !tbaa !11
  br i1 %95, label %96, label %.loopexit55

96:                                               ; preds = %.peel.begin
  %97 = load i32, ptr %13, align 4, !tbaa !11
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %13, align 4, !tbaa !11
  %99 = load i32, ptr %84, align 4, !tbaa !11
  %100 = add nsw i32 %.pre61, %99
  store i32 %100, ptr %11, align 4, !tbaa !11
  %101 = load i32, ptr %87, align 4, !tbaa !11
  %102 = add nsw i32 %.pre63, %101
  store i32 %102, ptr %12, align 4, !tbaa !11
  %103 = sext i32 %100 to i64
  %104 = sext i32 %102 to i64
  %105 = getelementptr inbounds [1000 x [1000 x i32]], ptr @b, i64 0, i64 %103, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !11
  %.not.peel = icmp eq i32 %106, 4
  br i1 %.not.peel, label %.peel.next, label %.loopexit55

.peel.next:                                       ; preds = %96, %114
  %107 = phi i32 [ %119, %114 ], [ %101, %96 ]
  %108 = phi i32 [ %120, %114 ], [ %102, %96 ]
  %109 = phi i32 [ %117, %114 ], [ %99, %96 ]
  %110 = phi i32 [ %118, %114 ], [ %100, %96 ]
  store i32 0, ptr %14, align 4, !tbaa !11
  %111 = add nsw i32 %109, %110
  %112 = add nsw i32 %107, %108
  %113 = call noundef zeroext i1 @_Z7canMoveiib(i32 noundef %111, i32 noundef %112, i1 noundef zeroext false)
  %.pre60.pre = load i32, ptr %11, align 4, !tbaa !11
  %.pre62.pre = load i32, ptr %12, align 4, !tbaa !11
  br i1 %113, label %114, label %.loopexit55

114:                                              ; preds = %.peel.next
  %115 = load i32, ptr %13, align 4, !tbaa !11
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %13, align 4, !tbaa !11
  %117 = load i32, ptr %84, align 4, !tbaa !11
  %118 = add nsw i32 %.pre60.pre, %117
  store i32 %118, ptr %11, align 4, !tbaa !11
  %119 = load i32, ptr %87, align 4, !tbaa !11
  %120 = add nsw i32 %.pre62.pre, %119
  store i32 %120, ptr %12, align 4, !tbaa !11
  %121 = sext i32 %118 to i64
  %122 = sext i32 %120 to i64
  %123 = getelementptr inbounds [1000 x [1000 x i32]], ptr @b, i64 0, i64 %121, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !11
  %.not = icmp eq i32 %124, 4
  br i1 %.not, label %.peel.next, label %.loopexit55, !llvm.loop !22

.loopexit55:                                      ; preds = %114, %.peel.next, %96, %.peel.begin
  %125 = phi i32 [ %102, %96 ], [ %.pre63, %.peel.begin ], [ %120, %114 ], [ %.pre62.pre, %.peel.next ]
  %126 = phi i32 [ %100, %96 ], [ %.pre61, %.peel.begin ], [ %118, %114 ], [ %.pre60.pre, %.peel.next ]
  %127 = sext i32 %126 to i64
  %128 = sext i32 %125 to i64
  %129 = getelementptr inbounds [1000 x [1000 x i32]], ptr @b, i64 0, i64 %127, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !11
  %131 = icmp eq i32 %130, 2
  br i1 %131, label %132, label %._crit_edge64

._crit_edge64:                                    ; preds = %.loopexit55
  %.pre65 = load i32, ptr %14, align 4, !tbaa !11
  br label %133

132:                                              ; preds = %.loopexit55
  store i32 1, ptr %14, align 4, !tbaa !11
  br label %133

133:                                              ; preds = %._crit_edge64, %132
  %134 = phi i32 [ %.pre65, %._crit_edge64 ], [ 1, %132 ]
  %135 = load i32, ptr %13, align 4, !tbaa !11
  %136 = sext i32 %134 to i64
  %137 = getelementptr inbounds [1000 x [1000 x [2 x i32]]], ptr @dista, i64 0, i64 %127, i64 %128, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !11
  %139 = icmp slt i32 %135, %138
  br i1 %139, label %140, label %148

140:                                              ; preds = %133
  store i32 %135, ptr %137, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %15) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %16) #7
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %16, ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %17) #7
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %17, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %141 = invoke { i64, i64 } @_ZSt9make_pairISt4pairIiiES1_ES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %16, ptr noundef nonnull align 4 dereferenceable(8) %17)
          to label %142 unwind label %146

142:                                              ; preds = %140
  %143 = extractvalue { i64, i64 } %141, 0
  store i64 %143, ptr %15, align 8
  %144 = extractvalue { i64, i64 } %141, 1
  store i64 %144, ptr %67, align 8
  invoke void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(25) %3, ptr noundef nonnull align 4 dereferenceable(16) %15)
          to label %145 unwind label %146

145:                                              ; preds = %142
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %15) #7
  br label %148

146:                                              ; preds = %142, %140
  %147 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #7
  br label %168

148:                                              ; preds = %133, %145
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #7
  br label %149

149:                                              ; preds = %83, %148
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next57, 4
  br i1 %exitcond.not, label %.loopexit, label %83, !llvm.loop !24

.loopexit:                                        ; preds = %149, %70
  %150 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %3)
  br i1 %150, label %._crit_edge47, label %68

._crit_edge47:                                    ; preds = %.loopexit, %65
  %151 = load i32, ptr @N, align 4, !tbaa !11
  %152 = add nsw i32 %151, -1
  %153 = sext i32 %152 to i64
  %154 = load i32, ptr @M, align 4, !tbaa !11
  %155 = add nsw i32 %154, -1
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [1000 x [1000 x [2 x i32]]], ptr @dista, i64 0, i64 %153, i64 %156
  %158 = getelementptr inbounds i8, ptr %157, i64 4
  %159 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %157, ptr noundef nonnull align 4 dereferenceable(4) %158)
  %160 = load i32, ptr %159, align 4, !tbaa !11
  %161 = icmp eq i32 %160, 2147483647
  %162 = select i1 %161, i32 -1, i32 %160
  %163 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %162)
          to label %.invoke unwind label %164

164:                                              ; preds = %._crit_edge47, %.invoke
  %165 = landingpad { ptr, i32 }
          cleanup
  br label %168

.invoke:                                          ; preds = %._crit_edge47
  %166 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %163, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %167 unwind label %164

167:                                              ; preds = %.invoke
  call void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %3) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #7
  ret i32 0

168:                                              ; preds = %79, %146, %164, %77
  %.pn.pn = phi { ptr, i32 } [ %165, %164 ], [ %78, %77 ], [ %147, %146 ], [ %80, %79 ]
  call void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %3) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #7
  resume { ptr, i32 } %.pn.pn
}

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

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

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 #2

; 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 @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EEC2IS5_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZSt9make_pairISt4pairIiiES1_ES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #0 align 2

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIS0_IiiES1_ESt6vectorIS2_SaIS2_EESt7greaterIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #6 align 2

attributes #0 = { 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 #1 = { 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 #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 = { 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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !10, i64 0}
!15 = distinct !{!15, !16, !17}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.unswitch.partial.disable"}
!18 = distinct !{!18, !16}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !16}
!22 = distinct !{!22, !16, !23}
!23 = !{!"llvm.loop.peeled.count", i32 1}
!24 = distinct !{!24, !16}


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