; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/192 Division 1/Problem B (B)

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"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" }
%"struct.std::pair" = type { %"struct.std::pair.3", i32 }
%"struct.std::pair.3" = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@grid = external dso_local global [1001 x [1001 x i32]], align 16
@v = external dso_local global [1001 x [1001 x i32]], align 16
@d = external dso_local global [1001 x [1001 x i32]], align 16
@ex = external dso_local global i32, align 4
@ey = external dso_local global i32, align 4
@px = external dso_local global i32, align 4
@py = external dso_local global i32, align 4
@_Z1sB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@q = external dso_local global %"class.std::queue", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

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

49:                                               ; preds = %137, %0
  %50 = load i32, ptr %2, align 4, !tbaa !8
  %51 = load i32, ptr @n, align 4, !tbaa !8
  %52 = icmp sle i32 %50, %51
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %49
  %55 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !8
  br label %56

56:                                               ; preds = %133, %54
  %57 = load i32, ptr %4, align 4, !tbaa !8
  %58 = load i32, ptr @m, align 4, !tbaa !8
  %59 = icmp sle i32 %57, %58
  br i1 %59, label %61, label %60

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

61:                                               ; preds = %56
  %62 = load i32, ptr %4, align 4, !tbaa !8
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %64)
  %66 = load i8, ptr %65, align 1, !tbaa !11
  %67 = sext i8 %66 to i32
  %68 = icmp eq i32 %67, 84
  br i1 %68, label %69, label %76

69:                                               ; preds = %61
  %70 = load i32, ptr %2, align 4, !tbaa !8
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %71
  %73 = load i32, ptr %4, align 4, !tbaa !8
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1001 x i32], ptr %72, i64 0, i64 %74
  store i32 -1, ptr %75, align 4, !tbaa !8
  br label %126

76:                                               ; preds = %61
  %77 = load i32, ptr %4, align 4, !tbaa !8
  %78 = sub nsw i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %79)
  %81 = load i8, ptr %80, align 1, !tbaa !11
  %82 = sext i8 %81 to i32
  %83 = icmp eq i32 %82, 83
  br i1 %83, label %84, label %93

84:                                               ; preds = %76
  %85 = load i32, ptr %2, align 4, !tbaa !8
  store i32 %85, ptr @px, align 4, !tbaa !8
  %86 = load i32, ptr %4, align 4, !tbaa !8
  store i32 %86, ptr @py, align 4, !tbaa !8
  %87 = load i32, ptr %2, align 4, !tbaa !8
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %88
  %90 = load i32, ptr %4, align 4, !tbaa !8
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1001 x i32], ptr %89, i64 0, i64 %91
  store i32 1, ptr %92, align 4, !tbaa !8
  br label %125

93:                                               ; preds = %76
  %94 = load i32, ptr %4, align 4, !tbaa !8
  %95 = sub nsw i32 %94, 1
  %96 = sext i32 %95 to i64
  %97 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %96)
  %98 = load i8, ptr %97, align 1, !tbaa !11
  %99 = sext i8 %98 to i32
  %100 = icmp eq i32 %99, 69
  br i1 %100, label %101, label %110

101:                                              ; preds = %93
  %102 = load i32, ptr %2, align 4, !tbaa !8
  store i32 %102, ptr @ex, align 4, !tbaa !8
  %103 = load i32, ptr %4, align 4, !tbaa !8
  store i32 %103, ptr @ey, align 4, !tbaa !8
  %104 = load i32, ptr %2, align 4, !tbaa !8
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %105
  %107 = load i32, ptr %4, align 4, !tbaa !8
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [1001 x i32], ptr %106, i64 0, i64 %108
  store i32 0, ptr %109, align 4, !tbaa !8
  br label %124

110:                                              ; preds = %93
  %111 = load i32, ptr %4, align 4, !tbaa !8
  %112 = sub nsw i32 %111, 1
  %113 = sext i32 %112 to i64
  %114 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %113)
  %115 = load i8, ptr %114, align 1, !tbaa !11
  %116 = sext i8 %115 to i32
  %117 = sub nsw i32 %116, 48
  %118 = load i32, ptr %2, align 4, !tbaa !8
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %119
  %121 = load i32, ptr %4, align 4, !tbaa !8
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [1001 x i32], ptr %120, i64 0, i64 %122
  store i32 %117, ptr %123, align 4, !tbaa !8
  br label %124

124:                                              ; preds = %110, %101
  br label %125

125:                                              ; preds = %124, %84
  br label %126

126:                                              ; preds = %125, %69
  %127 = load i32, ptr %2, align 4, !tbaa !8
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %128
  %130 = load i32, ptr %4, align 4, !tbaa !8
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [1001 x i32], ptr %129, i64 0, i64 %131
  store i32 10000000, ptr %132, align 4, !tbaa !8
  br label %133

133:                                              ; preds = %126
  %134 = load i32, ptr %4, align 4, !tbaa !8
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %4, align 4, !tbaa !8
  br label %56, !llvm.loop !12

136:                                              ; preds = %60
  br label %137

137:                                              ; preds = %136
  %138 = load i32, ptr %2, align 4, !tbaa !8
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %2, align 4, !tbaa !8
  br label %49, !llvm.loop !14

140:                                              ; preds = %53
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %141 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) @ex, ptr noundef nonnull align 4 dereferenceable(4) @ey)
  store i64 %141, ptr %6, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !8
  %142 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  store { i64, i32 } %142, ptr %8, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 8 %8, i64 12, i1 false)
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  br label %143

143:                                              ; preds = %228, %166, %140
  %144 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %145 = xor i1 %144, true
  br i1 %145, label %146, label %229

146:                                              ; preds = %143
  %147 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %148 = getelementptr inbounds %"struct.std::pair", ptr %147, i32 0, i32 0
  %149 = getelementptr inbounds %"struct.std::pair.3", ptr %148, i32 0, i32 0
  %150 = load i32, ptr %149, align 4, !tbaa !15
  store i32 %150, ptr %9, align 4, !tbaa !8
  %151 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %152 = getelementptr inbounds %"struct.std::pair", ptr %151, i32 0, i32 0
  %153 = getelementptr inbounds %"struct.std::pair.3", ptr %152, i32 0, i32 1
  %154 = load i32, ptr %153, align 4, !tbaa !18
  store i32 %154, ptr %10, align 4, !tbaa !8
  %155 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %156 = getelementptr inbounds %"struct.std::pair", ptr %155, i32 0, i32 1
  %157 = load i32, ptr %156, align 4, !tbaa !19
  store i32 %157, ptr %11, align 4, !tbaa !8
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %158 = load i32, ptr %9, align 4, !tbaa !8
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [1001 x [1001 x i32]], ptr @v, i64 0, i64 %159
  %161 = load i32, ptr %10, align 4, !tbaa !8
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [1001 x i32], ptr %160, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !8
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %166, label %167

166:                                              ; preds = %146
  br label %143, !llvm.loop !20

167:                                              ; preds = %146
  %168 = load i32, ptr %9, align 4, !tbaa !8
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [1001 x [1001 x i32]], ptr @v, i64 0, i64 %169
  %171 = load i32, ptr %10, align 4, !tbaa !8
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [1001 x i32], ptr %170, i64 0, i64 %172
  store i32 1, ptr %173, align 4, !tbaa !8
  %174 = load i32, ptr %11, align 4, !tbaa !8
  %175 = load i32, ptr %9, align 4, !tbaa !8
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %176
  %178 = load i32, ptr %10, align 4, !tbaa !8
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [1001 x i32], ptr %177, i64 0, i64 %179
  store i32 %174, ptr %180, align 4, !tbaa !8
  %181 = load i32, ptr %9, align 4, !tbaa !8
  %182 = add nsw i32 %181, 1
  %183 = load i32, ptr %10, align 4, !tbaa !8
  %184 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %182, i32 noundef %183)
  br i1 %184, label %185, label %192

185:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 12, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %186 = load i32, ptr %9, align 4, !tbaa !8
  %187 = add nsw i32 %186, 1
  store i32 %187, ptr %14, align 4, !tbaa !8
  %188 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %10)
  store i64 %188, ptr %13, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %189 = load i32, ptr %11, align 4, !tbaa !8
  %190 = add nsw i32 %189, 1
  store i32 %190, ptr %15, align 4, !tbaa !8
  %191 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %13, ptr noundef nonnull align 4 dereferenceable(4) %15)
  store { i64, i32 } %191, ptr %16, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 8 %16, i64 12, i1 false)
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %12)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %12) #7
  br label %192

192:                                              ; preds = %185, %167
  %193 = load i32, ptr %9, align 4, !tbaa !8
  %194 = sub nsw i32 %193, 1
  %195 = load i32, ptr %10, align 4, !tbaa !8
  %196 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %194, i32 noundef %195)
  br i1 %196, label %197, label %204

197:                                              ; preds = %192
  call void @llvm.lifetime.start.p0(i64 12, ptr %17) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  %198 = load i32, ptr %9, align 4, !tbaa !8
  %199 = sub nsw i32 %198, 1
  store i32 %199, ptr %19, align 4, !tbaa !8
  %200 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef nonnull align 4 dereferenceable(4) %10)
  store i64 %200, ptr %18, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  %201 = load i32, ptr %11, align 4, !tbaa !8
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %20, align 4, !tbaa !8
  %203 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %18, ptr noundef nonnull align 4 dereferenceable(4) %20)
  store { i64, i32 } %203, ptr %21, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 8 %21, i64 12, i1 false)
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %17)
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %17) #7
  br label %204

204:                                              ; preds = %197, %192
  %205 = load i32, ptr %9, align 4, !tbaa !8
  %206 = load i32, ptr %10, align 4, !tbaa !8
  %207 = add nsw i32 %206, 1
  %208 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %205, i32 noundef %207)
  br i1 %208, label %209, label %216

209:                                              ; preds = %204
  call void @llvm.lifetime.start.p0(i64 12, ptr %22) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  %210 = load i32, ptr %10, align 4, !tbaa !8
  %211 = add nsw i32 %210, 1
  store i32 %211, ptr %24, align 4, !tbaa !8
  %212 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %24)
  store i64 %212, ptr %23, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  %213 = load i32, ptr %11, align 4, !tbaa !8
  %214 = add nsw i32 %213, 1
  store i32 %214, ptr %25, align 4, !tbaa !8
  %215 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %23, ptr noundef nonnull align 4 dereferenceable(4) %25)
  store { i64, i32 } %215, ptr %26, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 8 %26, i64 12, i1 false)
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %22)
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %22) #7
  br label %216

216:                                              ; preds = %209, %204
  %217 = load i32, ptr %9, align 4, !tbaa !8
  %218 = load i32, ptr %10, align 4, !tbaa !8
  %219 = sub nsw i32 %218, 1
  %220 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %217, i32 noundef %219)
  br i1 %220, label %221, label %228

221:                                              ; preds = %216
  call void @llvm.lifetime.start.p0(i64 12, ptr %27) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #7
  %222 = load i32, ptr %10, align 4, !tbaa !8
  %223 = sub nsw i32 %222, 1
  store i32 %223, ptr %29, align 4, !tbaa !8
  %224 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %29)
  store i64 %224, ptr %28, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #7
  %225 = load i32, ptr %11, align 4, !tbaa !8
  %226 = add nsw i32 %225, 1
  store i32 %226, ptr %30, align 4, !tbaa !8
  %227 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_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(4) %30)
  store { i64, i32 } %227, ptr %31, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 8 %31, i64 12, i1 false)
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %27)
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %27) #7
  br label %228

228:                                              ; preds = %221, %216
  br label %143, !llvm.loop !20

229:                                              ; preds = %143
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #7
  %230 = load i32, ptr @px, align 4, !tbaa !8
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %231
  %233 = load i32, ptr @py, align 4, !tbaa !8
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [1001 x i32], ptr %232, i64 0, i64 %234
  %236 = load i32, ptr %235, align 4, !tbaa !8
  store i32 %236, ptr %32, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %33) #7
  store i32 0, ptr %33, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %34) #7
  store i32 1, ptr %34, align 4, !tbaa !8
  br label %237

237:                                              ; preds = %283, %229
  %238 = load i32, ptr %34, align 4, !tbaa !8
  %239 = load i32, ptr @n, align 4, !tbaa !8
  %240 = icmp sle i32 %238, %239
  br i1 %240, label %242, label %241

241:                                              ; preds = %237
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %34) #7
  br label %286

242:                                              ; preds = %237
  call void @llvm.lifetime.start.p0(i64 4, ptr %35) #7
  store i32 1, ptr %35, align 4, !tbaa !8
  br label %243

243:                                              ; preds = %279, %242
  %244 = load i32, ptr %35, align 4, !tbaa !8
  %245 = load i32, ptr @m, align 4, !tbaa !8
  %246 = icmp sle i32 %244, %245
  br i1 %246, label %248, label %247

247:                                              ; preds = %243
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %35) #7
  br label %282

248:                                              ; preds = %243
  %249 = load i32, ptr %34, align 4, !tbaa !8
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %250
  %252 = load i32, ptr %35, align 4, !tbaa !8
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [1001 x i32], ptr %251, i64 0, i64 %253
  %255 = load i32, ptr %254, align 4, !tbaa !8
  %256 = icmp ne i32 %255, -1
  br i1 %256, label %257, label %278

257:                                              ; preds = %248
  %258 = load i32, ptr %34, align 4, !tbaa !8
  %259 = sext i32 %258 to i64
  %260 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %259
  %261 = load i32, ptr %35, align 4, !tbaa !8
  %262 = sext i32 %261 to i64
  %263 = getelementptr inbounds [1001 x i32], ptr %260, i64 0, i64 %262
  %264 = load i32, ptr %263, align 4, !tbaa !8
  %265 = load i32, ptr %32, align 4, !tbaa !8
  %266 = icmp sle i32 %264, %265
  br i1 %266, label %267, label %277

267:                                              ; preds = %257
  %268 = load i32, ptr %34, align 4, !tbaa !8
  %269 = sext i32 %268 to i64
  %270 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %269
  %271 = load i32, ptr %35, align 4, !tbaa !8
  %272 = sext i32 %271 to i64
  %273 = getelementptr inbounds [1001 x i32], ptr %270, i64 0, i64 %272
  %274 = load i32, ptr %273, align 4, !tbaa !8
  %275 = load i32, ptr %33, align 4, !tbaa !8
  %276 = add nsw i32 %275, %274
  store i32 %276, ptr %33, align 4, !tbaa !8
  br label %277

277:                                              ; preds = %267, %257
  br label %278

278:                                              ; preds = %277, %248
  br label %279

279:                                              ; preds = %278
  %280 = load i32, ptr %35, align 4, !tbaa !8
  %281 = add nsw i32 %280, 1
  store i32 %281, ptr %35, align 4, !tbaa !8
  br label %243, !llvm.loop !21

282:                                              ; preds = %247
  br label %283

283:                                              ; preds = %282
  %284 = load i32, ptr %34, align 4, !tbaa !8
  %285 = add nsw i32 %284, 1
  store i32 %285, ptr %34, align 4, !tbaa !8
  br label %237, !llvm.loop !22

286:                                              ; preds = %241
  %287 = load i32, ptr %33, align 4, !tbaa !8
  %288 = sub nsw i32 %287, 1
  %289 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %288)
  %290 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %289, ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  %291 = load i32, ptr %1, align 4
  ret i32 %291
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(12)) #4 align 2

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #0 align 2

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

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #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 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!10, !10, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!16, !9, i64 0}
!16 = !{!"_ZTSSt4pairIS_IiiEiE", !17, i64 0, !9, i64 8}
!17 = !{!"_ZTSSt4pairIiiE", !9, i64 0, !9, i64 4}
!18 = !{!16, !9, i64 4}
!19 = !{!16, !9, i64 8}
!20 = distinct !{!20, !13}
!21 = distinct !{!21, !13}
!22 = distinct !{!22, !13}


; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"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" }
%"struct.std::pair" = type { %"struct.std::pair.3", i32 }
%"struct.std::pair.3" = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@grid = external dso_local local_unnamed_addr global [1001 x [1001 x i32]], align 16
@v = external dso_local local_unnamed_addr global [1001 x [1001 x i32]], align 16
@d = external dso_local local_unnamed_addr global [1001 x [1001 x i32]], align 16
@ex = external dso_local global i32, align 4
@ey = external dso_local global i32, align 4
@px = external dso_local local_unnamed_addr global i32, align 4
@py = external dso_local local_unnamed_addr global i32, align 4
@_Z1sB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@q = external dso_local global %"class.std::queue", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca %"struct.std::pair", align 8
  %2 = alloca %"struct.std::pair.3", align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca %"struct.std::pair.3", align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::pair", align 8
  %11 = alloca %"struct.std::pair.3", align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::pair", align 8
  %15 = alloca %"struct.std::pair.3", align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"struct.std::pair", align 8
  %19 = alloca %"struct.std::pair.3", align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %23 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %24 = getelementptr i8, ptr %23, i64 -24
  %25 = load i64, ptr %24, align 8
  %26 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %25
  %27 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %26, ptr noundef null)
  %28 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %29 = getelementptr i8, ptr %28, i64 -24
  %30 = load i64, ptr %29, align 8
  %31 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %30
  %32 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %31, ptr noundef null)
  %33 = 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)
  %34 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %33, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %35 = load i32, ptr @n, align 4, !tbaa !8
  %.not70 = icmp slt i32 %35, 1
  br i1 %.not70, label %._crit_edge74, label %.lr.ph73

._crit_edge74:                                    ; preds = %._crit_edge, %0
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %36 = tail call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) @ex, ptr noundef nonnull align 4 dereferenceable(4) @ey)
  store i64 %36, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  store i32 0, ptr %3, align 4, !tbaa !8
  %37 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %.fca.0.extract30 = extractvalue { i64, i32 } %37, 0
  %.fca.1.extract31 = extractvalue { i64, i32 } %37, 1
  store i64 %.fca.0.extract30, ptr %1, align 8
  %.sroa.233.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %.fca.1.extract31, ptr %.sroa.233.0..sroa_idx, align 8
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  %38 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  br i1 %38, label %._crit_edge77, label %.lr.ph76

.lr.ph76:                                         ; preds = %._crit_edge74
  %.sroa.224.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  %.sroa.220.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 8
  %.sroa.216.0..sroa_idx = getelementptr inbounds i8, ptr %14, i64 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %18, i64 8
  br label %72

.lr.ph73:                                         ; preds = %0, %._crit_edge
  %indvars.iv90 = phi i64 [ %indvars.iv.next91, %._crit_edge ], [ 1, %0 ]
  %39 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11)
  %40 = load i32, ptr @m, align 4, !tbaa !8
  %.not6768 = icmp slt i32 %40, 1
  br i1 %.not6768, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph73
  %41 = trunc nuw nsw i64 %indvars.iv90 to i32
  %42 = trunc nuw nsw i64 %indvars.iv90 to i32
  br label %45

._crit_edge:                                      ; preds = %67, %.lr.ph73
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %43 = load i32, ptr @n, align 4, !tbaa !8
  %44 = sext i32 %43 to i64
  %.not.not = icmp slt i64 %indvars.iv90, %44
  br i1 %.not.not, label %.lr.ph73, label %._crit_edge74, !llvm.loop !11

45:                                               ; preds = %.lr.ph, %67
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %67 ]
  %46 = add nsw i64 %indvars.iv, -1
  %47 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %46)
  %48 = load i8, ptr %47, align 1, !tbaa !13
  %49 = icmp eq i8 %48, 84
  br i1 %49, label %67, label %50

50:                                               ; preds = %45
  %51 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %46)
  %52 = load i8, ptr %51, align 1, !tbaa !13
  %53 = icmp eq i8 %52, 83
  br i1 %53, label %54, label %56

54:                                               ; preds = %50
  store i32 %42, ptr @px, align 4, !tbaa !8
  %55 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %55, ptr @py, align 4, !tbaa !8
  br label %67

56:                                               ; preds = %50
  %57 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %46)
  %58 = load i8, ptr %57, align 1, !tbaa !13
  %59 = icmp eq i8 %58, 69
  br i1 %59, label %60, label %62

60:                                               ; preds = %56
  store i32 %41, ptr @ex, align 4, !tbaa !8
  %61 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %61, ptr @ey, align 4, !tbaa !8
  br label %67

62:                                               ; preds = %56
  %63 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %46)
  %64 = load i8, ptr %63, align 1, !tbaa !13
  %65 = sext i8 %64 to i32
  %66 = add nsw i32 %65, -48
  br label %67

67:                                               ; preds = %45, %54, %62, %60
  %.sink = phi i32 [ 1, %54 ], [ %66, %62 ], [ 0, %60 ], [ -1, %45 ]
  %68 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %indvars.iv90, i64 %indvars.iv
  store i32 %.sink, ptr %68, align 4, !tbaa !8
  %69 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %indvars.iv90, i64 %indvars.iv
  store i32 10000000, ptr %69, align 4, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %70 = load i32, ptr @m, align 4, !tbaa !8
  %71 = sext i32 %70 to i64
  %.not67.not = icmp slt i64 %indvars.iv, %71
  br i1 %.not67.not, label %45, label %._crit_edge, !llvm.loop !14

72:                                               ; preds = %.lr.ph76, %.backedge
  %73 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %74 = load i32, ptr %73, align 4, !tbaa !15
  store i32 %74, ptr %4, align 4, !tbaa !8
  %75 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %76 = getelementptr inbounds i8, ptr %75, i64 4
  %77 = load i32, ptr %76, align 4, !tbaa !18
  store i32 %77, ptr %5, align 4, !tbaa !8
  %78 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %79 = getelementptr inbounds i8, ptr %78, i64 8
  %80 = load i32, ptr %79, align 4, !tbaa !19
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %81 = load i32, ptr %4, align 4, !tbaa !8
  %82 = sext i32 %81 to i64
  %83 = load i32, ptr %5, align 4, !tbaa !8
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1001 x [1001 x i32]], ptr @v, i64 0, i64 %82, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !8
  %.not66 = icmp eq i32 %86, 0
  br i1 %.not66, label %87, label %.backedge

87:                                               ; preds = %72
  store i32 1, ptr %85, align 4, !tbaa !8
  %88 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %82, i64 %84
  store i32 %80, ptr %88, align 4, !tbaa !8
  %89 = add nsw i32 %81, 1
  %90 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %89, i32 noundef %83)
  br i1 %90, label %91, label %97

91:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  %92 = load i32, ptr %4, align 4, !tbaa !8
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %8, align 4, !tbaa !8
  %94 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store i64 %94, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #6
  %95 = add nsw i32 %80, 1
  store i32 %95, ptr %9, align 4, !tbaa !8
  %96 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %.fca.0.extract21 = extractvalue { i64, i32 } %96, 0
  %.fca.1.extract22 = extractvalue { i64, i32 } %96, 1
  store i64 %.fca.0.extract21, ptr %6, align 8
  store i32 %.fca.1.extract22, ptr %.sroa.224.0..sroa_idx, align 8
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #6
  br label %97

97:                                               ; preds = %91, %87
  %98 = load i32, ptr %4, align 4, !tbaa !8
  %99 = add nsw i32 %98, -1
  %100 = load i32, ptr %5, align 4, !tbaa !8
  %101 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %99, i32 noundef %100)
  br i1 %101, label %102, label %108

102:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #6
  %103 = load i32, ptr %4, align 4, !tbaa !8
  %104 = add nsw i32 %103, -1
  store i32 %104, ptr %12, align 4, !tbaa !8
  %105 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store i64 %105, ptr %11, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #6
  %106 = add nsw i32 %80, 1
  store i32 %106, ptr %13, align 4, !tbaa !8
  %107 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %11, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %.fca.0.extract17 = extractvalue { i64, i32 } %107, 0
  %.fca.1.extract18 = extractvalue { i64, i32 } %107, 1
  store i64 %.fca.0.extract17, ptr %10, align 8
  store i32 %.fca.1.extract18, ptr %.sroa.220.0..sroa_idx, align 8
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #6
  br label %108

108:                                              ; preds = %102, %97
  %109 = load i32, ptr %4, align 4, !tbaa !8
  %110 = load i32, ptr %5, align 4, !tbaa !8
  %111 = add nsw i32 %110, 1
  %112 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %109, i32 noundef %111)
  br i1 %112, label %113, label %119

113:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %14) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %15) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %16) #6
  %114 = load i32, ptr %5, align 4, !tbaa !8
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %16, align 4, !tbaa !8
  %116 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %16)
  store i64 %116, ptr %15, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %17) #6
  %117 = add nsw i32 %80, 1
  store i32 %117, ptr %17, align 4, !tbaa !8
  %118 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %15, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %.fca.0.extract13 = extractvalue { i64, i32 } %118, 0
  %.fca.1.extract14 = extractvalue { i64, i32 } %118, 1
  store i64 %.fca.0.extract13, ptr %14, align 8
  store i32 %.fca.1.extract14, ptr %.sroa.216.0..sroa_idx, align 8
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %15) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %14) #6
  br label %119

119:                                              ; preds = %113, %108
  %120 = load i32, ptr %4, align 4, !tbaa !8
  %121 = load i32, ptr %5, align 4, !tbaa !8
  %122 = add nsw i32 %121, -1
  %123 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %120, i32 noundef %122)
  br i1 %123, label %124, label %.backedge

124:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %18) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %19) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %20) #6
  %125 = load i32, ptr %5, align 4, !tbaa !8
  %126 = add nsw i32 %125, -1
  store i32 %126, ptr %20, align 4, !tbaa !8
  %127 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %20)
  store i64 %127, ptr %19, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %21) #6
  %128 = add nsw i32 %80, 1
  store i32 %128, ptr %21, align 4, !tbaa !8
  %129 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiEiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(8) %19, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %.fca.0.extract = extractvalue { i64, i32 } %129, 0
  %.fca.1.extract = extractvalue { i64, i32 } %129, 1
  store i64 %.fca.0.extract, ptr %18, align 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  call void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(12) %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %19) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %18) #6
  br label %.backedge

.backedge:                                        ; preds = %119, %124, %72
  %130 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  br i1 %130, label %._crit_edge77, label %72, !llvm.loop !20

._crit_edge77:                                    ; preds = %.backedge, %._crit_edge74
  %131 = load i32, ptr @px, align 4, !tbaa !8
  %132 = sext i32 %131 to i64
  %133 = load i32, ptr @py, align 4, !tbaa !8
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %132, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !8
  %137 = load i32, ptr @n, align 4, !tbaa !8
  %.not6283 = icmp slt i32 %137, 1
  br i1 %.not6283, label %._crit_edge86, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %._crit_edge77
  %138 = load i32, ptr @m, align 4, !tbaa !8
  %.not6378 = icmp slt i32 %138, 1
  br i1 %.not6378, label %._crit_edge86, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %139 = add nuw i32 %137, 1
  %wide.trip.count99 = zext i32 %139 to i64
  %140 = zext nneg i32 %138 to i64
  %xtraiter = and i64 %140, 1
  %141 = icmp eq i32 %138, 1
  %unroll_iter = and i64 %140, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge82
  %indvars.iv96 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next97, %._crit_edge82 ]
  %.05884 = phi i32 [ 0, %.preheader.preheader ], [ %.2.lcssa, %._crit_edge82 ]
  br i1 %141, label %._crit_edge82.unr-lcssa, label %.preheader.new

._crit_edge86.loopexit88:                         ; preds = %._crit_edge82
  %142 = add nsw i32 %.2.lcssa, -1
  br label %._crit_edge86

._crit_edge86:                                    ; preds = %.preheader.lr.ph, %._crit_edge86.loopexit88, %._crit_edge77
  %.058.lcssa = phi i32 [ -1, %._crit_edge77 ], [ %142, %._crit_edge86.loopexit88 ], [ -1, %.preheader.lr.ph ]
  %143 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.058.lcssa)
  %144 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %143, ptr noundef nonnull @.str)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  ret i32 0

._crit_edge82.unr-lcssa:                          ; preds = %164, %.preheader
  %.2.lcssa.ph = phi i32 [ poison, %.preheader ], [ %.2.1, %164 ]
  %indvars.iv93.unr = phi i64 [ 1, %.preheader ], [ %indvars.iv.next94.1, %164 ]
  %.179.unr = phi i32 [ %.05884, %.preheader ], [ %.2.1, %164 ]
  br i1 %lcmp.mod.not, label %._crit_edge82, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge82.unr-lcssa
  %145 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %indvars.iv96, i64 %indvars.iv93.unr
  %146 = load i32, ptr %145, align 4, !tbaa !8
  %.not64.epil = icmp eq i32 %146, -1
  br i1 %.not64.epil, label %._crit_edge82, label %147

147:                                              ; preds = %.epil.preheader
  %148 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %indvars.iv96, i64 %indvars.iv93.unr
  %149 = load i32, ptr %148, align 4, !tbaa !8
  %.not65.epil = icmp sgt i32 %149, %136
  %150 = select i1 %.not65.epil, i32 0, i32 %146
  %spec.select.epil = add nsw i32 %150, %.179.unr
  br label %._crit_edge82

._crit_edge82:                                    ; preds = %.epil.preheader, %147, %._crit_edge82.unr-lcssa
  %.2.lcssa = phi i32 [ %.2.lcssa.ph, %._crit_edge82.unr-lcssa ], [ %.179.unr, %.epil.preheader ], [ %spec.select.epil, %147 ]
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %exitcond100.not = icmp eq i64 %indvars.iv.next97, %wide.trip.count99
  br i1 %exitcond100.not, label %._crit_edge86.loopexit88, label %.preheader, !llvm.loop !21

.preheader.new:                                   ; preds = %.preheader, %164
  %indvars.iv93 = phi i64 [ %indvars.iv.next94.1, %164 ], [ 1, %.preheader ]
  %.179 = phi i32 [ %.2.1, %164 ], [ %.05884, %.preheader ]
  %niter = phi i64 [ %niter.next.1, %164 ], [ 0, %.preheader ]
  %151 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %indvars.iv96, i64 %indvars.iv93
  %152 = load i32, ptr %151, align 4, !tbaa !8
  %.not64 = icmp eq i32 %152, -1
  br i1 %.not64, label %157, label %153

153:                                              ; preds = %.preheader.new
  %154 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %indvars.iv96, i64 %indvars.iv93
  %155 = load i32, ptr %154, align 4, !tbaa !8
  %.not65 = icmp sgt i32 %155, %136
  %156 = select i1 %.not65, i32 0, i32 %152
  %spec.select = add nsw i32 %156, %.179
  br label %157

157:                                              ; preds = %153, %.preheader.new
  %.2 = phi i32 [ %.179, %.preheader.new ], [ %spec.select, %153 ]
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %158 = getelementptr inbounds [1001 x [1001 x i32]], ptr @grid, i64 0, i64 %indvars.iv96, i64 %indvars.iv.next94
  %159 = load i32, ptr %158, align 4, !tbaa !8
  %.not64.1 = icmp eq i32 %159, -1
  br i1 %.not64.1, label %164, label %160

160:                                              ; preds = %157
  %161 = getelementptr inbounds [1001 x [1001 x i32]], ptr @d, i64 0, i64 %indvars.iv96, i64 %indvars.iv.next94
  %162 = load i32, ptr %161, align 4, !tbaa !8
  %.not65.1 = icmp sgt i32 %162, %136
  %163 = select i1 %.not65.1, i32 0, i32 %159
  %spec.select.1 = add nsw i32 %163, %.2
  br label %164

164:                                              ; preds = %160, %157
  %.2.1 = phi i32 [ %.2, %157 ], [ %spec.select.1, %160 ]
  %indvars.iv.next94.1 = add nuw nsw i64 %indvars.iv93, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge82.unr-lcssa, label %.preheader.new, !llvm.loop !22
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE4pushEOS2_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #4 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueISt4pairIS0_IiiEiESt5dequeIS2_SaIS2_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #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 = { 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 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 = { 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 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !10, i64 0}
!14 = distinct !{!14, !12}
!15 = !{!16, !9, i64 0}
!16 = !{!"_ZTSSt4pairIS_IiiEiE", !17, i64 0, !9, i64 8}
!17 = !{!"_ZTSSt4pairIiiE", !9, i64 0, !9, i64 4}
!18 = !{!16, !9, i64 4}
!19 = !{!16, !9, i64 8}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}


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