; LLVM IR from UtkarshPathrabe/Competitive-Coding :: SPOJ Solutions (DCEPC701)

; 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" }
%struct.pq = type { i32, i32, i32 }
%"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<pq, std::allocator<pq>>::_Vector_impl" }
%"struct.std::_Vector_base<pq, std::allocator<pq>>::_Vector_impl" = type { %"struct.std::_Vector_base<pq, std::allocator<pq>>::_Vector_impl_data" }
%"struct.std::_Vector_base<pq, std::allocator<pq>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@turnx = external dso_local global [4 x i32], align 16
@turny = external dso_local global [4 x i32], align 16
@a = external dso_local global [210 x [210 x i32]], align 16
@flag = external dso_local global [210 x [210 x i32]], align 16
@vis = external dso_local global [210 x [210 x i64]], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z10checkvalidii(i32 noundef, i32 noundef) #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 i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.pq, align 4
  %10 = alloca %struct.pq, align 4
  %11 = alloca [1000 x i8], align 16
  %12 = alloca %"class.std::priority_queue", align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %22

22:                                               ; preds = %276, %0
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, -1
  store i32 %24, ptr %2, align 4, !tbaa !5
  %25 = icmp ne i32 %23, 0
  br i1 %25, label %26, label %278

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #8
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #8
  call void @llvm.lifetime.start.p0(i64 1000, ptr %11) #8
  %27 = 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)
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef nonnull align 4 dereferenceable(4) @m)
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %36, %26
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %33, label %39

33:                                               ; preds = %29
  %34 = getelementptr inbounds [1000 x i8], ptr %11, i64 0, i64 0
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef %34)
  br label %36

36:                                               ; preds = %33
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !9

39:                                               ; preds = %29
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %73, %39
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %44, label %76

44:                                               ; preds = %40
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %69, %44
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = load i32, ptr @m, align 4, !tbaa !5
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %49, label %72

49:                                               ; preds = %45
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [210 x [210 x i32]], ptr @a, i64 0, i64 %51
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [210 x i32], ptr %52, i64 0, i64 %54
  %56 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %55)
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [210 x [210 x i32]], ptr @flag, i64 0, i64 %58
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [210 x i32], ptr %59, i64 0, i64 %61
  store i32 0, ptr %62, align 4, !tbaa !5
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %64
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [210 x i64], ptr %65, i64 0, i64 %67
  store i64 2147483647, ptr %68, align 8, !tbaa !11
  br label %69

69:                                               ; preds = %49
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %4, align 4, !tbaa !5
  br label %45, !llvm.loop !13

72:                                               ; preds = %45
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %3, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %3, align 4, !tbaa !5
  br label %40, !llvm.loop !14

76:                                               ; preds = %40
  %77 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %78 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %77, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %79 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %78, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %80 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %79, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %82
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [210 x i64], ptr %83, i64 0, i64 %85
  store i64 0, ptr %86, align 8, !tbaa !11
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %88
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [210 x i64], ptr %89, i64 0, i64 %91
  %93 = load i64, ptr %92, align 8, !tbaa !11
  %94 = trunc i64 %93 to i32
  %95 = getelementptr inbounds %struct.pq, ptr %9, i32 0, i32 0
  store i32 %94, ptr %95, align 4, !tbaa !15
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = getelementptr inbounds %struct.pq, ptr %9, i32 0, i32 1
  store i32 %96, ptr %97, align 4, !tbaa !17
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = getelementptr inbounds %struct.pq, ptr %9, i32 0, i32 2
  store i32 %98, ptr %99, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #8
  call void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %12)
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(25) %12, ptr noundef nonnull align 4 dereferenceable(12) %9)
          to label %100 unwind label %132

100:                                              ; preds = %76
  br label %101

101:                                              ; preds = %263, %261, %100
  %102 = invoke noundef zeroext i1 @_ZNKSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %12)
          to label %103 unwind label %132

103:                                              ; preds = %101
  br i1 %102, label %104, label %113

104:                                              ; preds = %103
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [210 x [210 x i32]], ptr @flag, i64 0, i64 %106
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [210 x i32], ptr %107, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = icmp ne i32 %111, 1
  br label %113

113:                                              ; preds = %104, %103
  %114 = phi i1 [ true, %103 ], [ %112, %104 ]
  br i1 %114, label %115, label %265

115:                                              ; preds = %113
  %116 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %12)
          to label %117 unwind label %132

117:                                              ; preds = %115
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %116, i64 12, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %118 = getelementptr inbounds %struct.pq, ptr %9, i32 0, i32 1
  %119 = load i32, ptr %118, align 4, !tbaa !17
  store i32 %119, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %120 = getelementptr inbounds %struct.pq, ptr %9, i32 0, i32 2
  %121 = load i32, ptr %120, align 4, !tbaa !18
  store i32 %121, ptr %16, align 4, !tbaa !5
  %122 = load i32, ptr %15, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [210 x [210 x i32]], ptr @flag, i64 0, i64 %123
  %125 = load i32, ptr %16, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [210 x i32], ptr %124, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = icmp eq i32 %128, 1
  br i1 %129, label %130, label %140

130:                                              ; preds = %117
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %12)
          to label %131 unwind label %136

131:                                              ; preds = %130
  store i32 13, ptr %17, align 4
  br label %261, !llvm.loop !20

132:                                              ; preds = %274, %265, %115, %101, %76
  %133 = landingpad { ptr, i32 }
          cleanup
  %134 = extractvalue { ptr, i32 } %133, 0
  store ptr %134, ptr %13, align 8
  %135 = extractvalue { ptr, i32 } %133, 1
  store i32 %135, ptr %14, align 4
  br label %277

136:                                              ; preds = %130
  %137 = landingpad { ptr, i32 }
          cleanup
  %138 = extractvalue { ptr, i32 } %137, 0
  store ptr %138, ptr %13, align 8
  %139 = extractvalue { ptr, i32 } %137, 1
  store i32 %139, ptr %14, align 4
  br label %264

140:                                              ; preds = %117
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %141

141:                                              ; preds = %251, %140
  %142 = load i32, ptr %3, align 4, !tbaa !5
  %143 = icmp slt i32 %142, 4
  br i1 %143, label %144, label %254

144:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  %145 = load i32, ptr %15, align 4, !tbaa !5
  %146 = load i32, ptr %3, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [4 x i32], ptr @turnx, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = add nsw i32 %145, %149
  store i32 %150, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  %151 = load i32, ptr %16, align 4, !tbaa !5
  %152 = load i32, ptr %3, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [4 x i32], ptr @turny, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = add nsw i32 %151, %155
  store i32 %156, ptr %19, align 4, !tbaa !5
  %157 = load i32, ptr %18, align 4, !tbaa !5
  %158 = load i32, ptr %19, align 4, !tbaa !5
  %159 = call noundef i32 @_Z10checkvalidii(i32 noundef %157, i32 noundef %158)
  %160 = icmp ne i32 %159, 0
  br i1 %160, label %161, label %250

161:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %162 = load i32, ptr %18, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [210 x [210 x i32]], ptr @a, i64 0, i64 %163
  %165 = load i32, ptr %19, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [210 x i32], ptr %164, i64 0, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = load i32, ptr %15, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %171
  %173 = load i32, ptr %16, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [210 x i64], ptr %172, i64 0, i64 %174
  %176 = load i64, ptr %175, align 8, !tbaa !11
  %177 = sub nsw i64 %169, %176
  %178 = icmp sle i64 %177, 1
  br i1 %178, label %179, label %180

179:                                              ; preds = %161
  store i64 1, ptr %20, align 8, !tbaa !11
  br label %197

180:                                              ; preds = %161
  %181 = load i32, ptr %18, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [210 x [210 x i32]], ptr @a, i64 0, i64 %182
  %184 = load i32, ptr %19, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [210 x i32], ptr %183, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = load i32, ptr %15, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %190
  %192 = load i32, ptr %16, align 4, !tbaa !5
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [210 x i64], ptr %191, i64 0, i64 %193
  %195 = load i64, ptr %194, align 8, !tbaa !11
  %196 = sub nsw i64 %188, %195
  store i64 %196, ptr %20, align 8, !tbaa !11
  br label %197

197:                                              ; preds = %180, %179
  %198 = load i32, ptr %18, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %199
  %201 = load i32, ptr %19, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [210 x i64], ptr %200, i64 0, i64 %202
  %204 = load i64, ptr %203, align 8, !tbaa !11
  %205 = load i64, ptr %20, align 8, !tbaa !11
  %206 = load i32, ptr %15, align 4, !tbaa !5
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %207
  %209 = load i32, ptr %16, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [210 x i64], ptr %208, i64 0, i64 %210
  %212 = load i64, ptr %211, align 8, !tbaa !11
  %213 = add nsw i64 %205, %212
  %214 = icmp sgt i64 %204, %213
  br i1 %214, label %215, label %249

215:                                              ; preds = %197
  %216 = load i64, ptr %20, align 8, !tbaa !11
  %217 = load i32, ptr %15, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %218
  %220 = load i32, ptr %16, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [210 x i64], ptr %219, i64 0, i64 %221
  %223 = load i64, ptr %222, align 8, !tbaa !11
  %224 = add nsw i64 %216, %223
  %225 = load i32, ptr %18, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %226
  %228 = load i32, ptr %19, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [210 x i64], ptr %227, i64 0, i64 %229
  store i64 %224, ptr %230, align 8, !tbaa !11
  %231 = load i32, ptr %18, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %232
  %234 = load i32, ptr %19, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [210 x i64], ptr %233, i64 0, i64 %235
  %237 = load i64, ptr %236, align 8, !tbaa !11
  %238 = trunc i64 %237 to i32
  %239 = getelementptr inbounds %struct.pq, ptr %10, i32 0, i32 0
  store i32 %238, ptr %239, align 4, !tbaa !15
  %240 = load i32, ptr %18, align 4, !tbaa !5
  %241 = getelementptr inbounds %struct.pq, ptr %10, i32 0, i32 1
  store i32 %240, ptr %241, align 4, !tbaa !17
  %242 = load i32, ptr %19, align 4, !tbaa !5
  %243 = getelementptr inbounds %struct.pq, ptr %10, i32 0, i32 2
  store i32 %242, ptr %243, align 4, !tbaa !18
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(25) %12, ptr noundef nonnull align 4 dereferenceable(12) %10)
          to label %244 unwind label %245

244:                                              ; preds = %215
  br label %249

245:                                              ; preds = %215
  %246 = landingpad { ptr, i32 }
          cleanup
  %247 = extractvalue { ptr, i32 } %246, 0
  store ptr %247, ptr %13, align 8
  %248 = extractvalue { ptr, i32 } %246, 1
  store i32 %248, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, 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 %264

249:                                              ; preds = %244, %197
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  br label %250

250:                                              ; preds = %249, %144
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  br label %251

251:                                              ; preds = %250
  %252 = load i32, ptr %3, align 4, !tbaa !5
  %253 = add nsw i32 %252, 1
  store i32 %253, ptr %3, align 4, !tbaa !5
  br label %141, !llvm.loop !21

254:                                              ; preds = %141
  %255 = load i32, ptr %15, align 4, !tbaa !5
  %256 = sext i32 %255 to i64
  %257 = getelementptr inbounds [210 x [210 x i32]], ptr @flag, i64 0, i64 %256
  %258 = load i32, ptr %16, align 4, !tbaa !5
  %259 = sext i32 %258 to i64
  %260 = getelementptr inbounds [210 x i32], ptr %257, i64 0, i64 %259
  store i32 1, ptr %260, align 4, !tbaa !5
  store i32 0, ptr %17, align 4
  br label %261

261:                                              ; preds = %254, %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  %262 = load i32, ptr %17, align 4
  switch i32 %262, label %285 [
    i32 0, label %263
    i32 13, label %101
  ]

263:                                              ; preds = %261
  br label %101, !llvm.loop !20

264:                                              ; preds = %245, %136
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %277

265:                                              ; preds = %113
  %266 = load i32, ptr %6, align 4, !tbaa !5
  %267 = sext i32 %266 to i64
  %268 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %267
  %269 = load i32, ptr %8, align 4, !tbaa !5
  %270 = sext i32 %269 to i64
  %271 = getelementptr inbounds [210 x i64], ptr %268, i64 0, i64 %270
  %272 = load i64, ptr %271, align 8, !tbaa !11
  %273 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %272)
          to label %274 unwind label %132

274:                                              ; preds = %265
  %275 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %273, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %276 unwind label %132

276:                                              ; preds = %274
  call void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %12) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 1000, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #8
  br label %22, !llvm.loop !22

277:                                              ; preds = %264, %132
  call void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %12) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 1000, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %280

278:                                              ; preds = %22
  store i32 0, ptr %1, align 4
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  %279 = load i32, ptr %1, align 4
  ret i32 %279

280:                                              ; preds = %277
  %281 = load ptr, ptr %13, align 8
  %282 = load i32, ptr %14, align 4
  %283 = insertvalue { ptr, i32 } poison, ptr %281, 0
  %284 = insertvalue { ptr, i32 } %283, i32 %282, 1
  resume { ptr, i32 } %284

285:                                              ; preds = %261
  unreachable
}

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

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_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_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #5 align 2

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #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_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS2pq", !6, i64 0, !6, i64 4, !6, i64 8}
!17 = !{!16, !6, i64 4}
!18 = !{!16, !6, i64 8}
!19 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}


; 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" }
%struct.pq = type { i32, i32, i32 }
%"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<pq, std::allocator<pq>>::_Vector_impl" }
%"struct.std::_Vector_base<pq, std::allocator<pq>>::_Vector_impl" = type { %"struct.std::_Vector_base<pq, std::allocator<pq>>::_Vector_impl_data" }
%"struct.std::_Vector_base<pq, std::allocator<pq>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@turnx = external dso_local local_unnamed_addr global [4 x i32], align 16
@turny = external dso_local local_unnamed_addr global [4 x i32], align 16
@a = external dso_local global [210 x [210 x i32]], align 16
@flag = external dso_local local_unnamed_addr global [210 x [210 x i32]], align 16
@vis = external dso_local local_unnamed_addr global [210 x [210 x i64]], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z10checkvalidii(i32 noundef, i32 noundef) 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 i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %struct.pq, align 4
  %7 = alloca %struct.pq, align 4
  %8 = alloca [1000 x i8], align 16
  %9 = alloca %"class.std::priority_queue", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #9
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr %1, align 4, !tbaa !5
  %.not70 = icmp eq i32 %11, 0
  br i1 %.not70, label %._crit_edge73, label %.lr.ph72

.lr.ph72:                                         ; preds = %0
  %13 = getelementptr inbounds i8, ptr %6, i64 4
  %14 = getelementptr inbounds i8, ptr %6, i64 8
  %15 = getelementptr inbounds i8, ptr %7, i64 4
  %16 = getelementptr inbounds i8, ptr %7, i64 8
  br label %17

17:                                               ; preds = %.lr.ph72, %162
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #9
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #9
  call void @llvm.lifetime.start.p0(i64 1000, ptr nonnull %8) #9
  %18 = 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)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph, label %._crit_edge68

.preheader62:                                     ; preds = %.lr.ph
  %22 = icmp sgt i32 %27, 0
  %23 = load i32, ptr @m, align 4
  %24 = icmp sgt i32 %23, 0
  %or.cond = select i1 %22, i1 %24, i1 false
  br i1 %or.cond, label %.preheader60, label %._crit_edge68

.lr.ph:                                           ; preds = %17, %.lr.ph
  %.04864 = phi i32 [ %26, %.lr.ph ], [ 0, %17 ]
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef %8)
  %26 = add nuw nsw i32 %.04864, 1
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %.lr.ph, label %.preheader62, !llvm.loop !9

.preheader60:                                     ; preds = %.preheader62, %._crit_edge
  %29 = phi i32 [ %39, %._crit_edge ], [ %27, %.preheader62 ]
  %30 = phi i32 [ %40, %._crit_edge ], [ %23, %.preheader62 ]
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %._crit_edge ], [ 0, %.preheader62 ]
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph66, label %._crit_edge

.lr.ph66:                                         ; preds = %.preheader60, %.lr.ph66
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph66 ], [ 0, %.preheader60 ]
  %32 = getelementptr inbounds [210 x [210 x i32]], ptr @a, i64 0, i64 %indvars.iv77, i64 %indvars.iv
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %32)
  %34 = getelementptr inbounds [210 x [210 x i32]], ptr @flag, i64 0, i64 %indvars.iv77, i64 %indvars.iv
  store i32 0, ptr %34, align 4, !tbaa !5
  %35 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %indvars.iv77, i64 %indvars.iv
  store i64 2147483647, ptr %35, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %36 = load i32, ptr @m, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next, %37
  br i1 %38, label %.lr.ph66, label %._crit_edge.loopexit, !llvm.loop !13

._crit_edge.loopexit:                             ; preds = %.lr.ph66
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader60
  %39 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %29, %.preheader60 ]
  %40 = phi i32 [ %36, %._crit_edge.loopexit ], [ %30, %.preheader60 ]
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %41 = sext i32 %39 to i64
  %42 = icmp slt i64 %indvars.iv.next78, %41
  br i1 %42, label %.preheader60, label %._crit_edge68, !llvm.loop !14

._crit_edge68:                                    ; preds = %._crit_edge, %17, %.preheader62
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %43, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %45, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %48, i64 %50
  store i64 0, ptr %51, align 8, !tbaa !11
  store i32 0, ptr %6, align 4, !tbaa !16
  store i32 %47, ptr %13, align 4, !tbaa !18
  store i32 %49, ptr %14, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #9
  call void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(25) %9, ptr noundef nonnull align 4 dereferenceable(12) %6)
          to label %.preheader61 unwind label %75

.preheader61:                                     ; preds = %._crit_edge68, %.preheader61.backedge
  %52 = call noundef zeroext i1 @_ZNKSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
  br i1 %52, label %53, label %.critedge

53:                                               ; preds = %.preheader61
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [210 x [210 x i32]], ptr @flag, i64 0, i64 %55, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %.not56 = icmp eq i32 %59, 1
  br i1 %.not56, label %156, label %.critedge

.critedge:                                        ; preds = %.preheader61, %53
  %60 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %60, i64 12, i1 false), !tbaa.struct !20
  %61 = load i32, ptr %13, align 4, !tbaa !18
  %62 = load i32, ptr %14, align 4, !tbaa !19
  %63 = sext i32 %61 to i64
  %64 = sext i32 %62 to i64
  %65 = getelementptr inbounds [210 x [210 x i32]], ptr @flag, i64 0, i64 %63, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = icmp eq i32 %66, 1
  br i1 %67, label %74, label %.preheader

.preheader:                                       ; preds = %.critedge
  %68 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %63, i64 %64
  %69 = load i32, ptr @turnx, align 16, !tbaa !5
  %70 = add nsw i32 %69, %61
  %71 = load i32, ptr @turny, align 16, !tbaa !5
  %72 = add nsw i32 %71, %62
  %73 = call noundef i32 @_Z10checkvalidii(i32 noundef %70, i32 noundef %72)
  %.not57 = icmp eq i32 %73, 0
  br i1 %.not57, label %95, label %79

74:                                               ; preds = %.critedge
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %9)
          to label %.preheader61.backedge unwind label %77

.preheader61.backedge:                            ; preds = %74, %155
  br label %.preheader61, !llvm.loop !21

75:                                               ; preds = %160, %156, %._crit_edge68
  %76 = landingpad { ptr, i32 }
          cleanup
  br label %165

77:                                               ; preds = %74
  %78 = landingpad { ptr, i32 }
          cleanup
  br label %165

79:                                               ; preds = %.preheader
  %80 = sext i32 %70 to i64
  %81 = sext i32 %72 to i64
  %82 = getelementptr inbounds [210 x [210 x i32]], ptr @a, i64 0, i64 %80, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = load i64, ptr %68, align 8, !tbaa !11
  %86 = sub nsw i64 %84, %85
  %. = call i64 @llvm.smax.i64(i64 %86, i64 1)
  %87 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %80, i64 %81
  %88 = load i64, ptr %87, align 8, !tbaa !11
  %89 = add nsw i64 %., %85
  %90 = icmp sgt i64 %88, %89
  br i1 %90, label %91, label %95

91:                                               ; preds = %79
  store i64 %89, ptr %87, align 8, !tbaa !11
  %92 = trunc i64 %89 to i32
  store i32 %92, ptr %7, align 4, !tbaa !16
  store i32 %70, ptr %15, align 4, !tbaa !18
  store i32 %72, ptr %16, align 4, !tbaa !19
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(25) %9, ptr noundef nonnull align 4 dereferenceable(12) %7)
          to label %95 unwind label %93

93:                                               ; preds = %153, %133, %113, %91
  %94 = landingpad { ptr, i32 }
          cleanup
  br label %165

95:                                               ; preds = %79, %91, %.preheader
  %96 = load i32, ptr getelementptr inbounds (i8, ptr @turnx, i64 4), align 4, !tbaa !5
  %97 = add nsw i32 %96, %61
  %98 = load i32, ptr getelementptr inbounds (i8, ptr @turny, i64 4), align 4, !tbaa !5
  %99 = add nsw i32 %98, %62
  %100 = call noundef i32 @_Z10checkvalidii(i32 noundef %97, i32 noundef %99)
  %.not57.1 = icmp eq i32 %100, 0
  br i1 %.not57.1, label %115, label %101

101:                                              ; preds = %95
  %102 = sext i32 %97 to i64
  %103 = sext i32 %99 to i64
  %104 = getelementptr inbounds [210 x [210 x i32]], ptr @a, i64 0, i64 %102, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = load i64, ptr %68, align 8, !tbaa !11
  %108 = sub nsw i64 %106, %107
  %..1 = call i64 @llvm.smax.i64(i64 %108, i64 1)
  %109 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %102, i64 %103
  %110 = load i64, ptr %109, align 8, !tbaa !11
  %111 = add nsw i64 %..1, %107
  %112 = icmp sgt i64 %110, %111
  br i1 %112, label %113, label %115

113:                                              ; preds = %101
  store i64 %111, ptr %109, align 8, !tbaa !11
  %114 = trunc i64 %111 to i32
  store i32 %114, ptr %7, align 4, !tbaa !16
  store i32 %97, ptr %15, align 4, !tbaa !18
  store i32 %99, ptr %16, align 4, !tbaa !19
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(25) %9, ptr noundef nonnull align 4 dereferenceable(12) %7)
          to label %115 unwind label %93

115:                                              ; preds = %113, %101, %95
  %116 = load i32, ptr getelementptr inbounds (i8, ptr @turnx, i64 8), align 8, !tbaa !5
  %117 = add nsw i32 %116, %61
  %118 = load i32, ptr getelementptr inbounds (i8, ptr @turny, i64 8), align 8, !tbaa !5
  %119 = add nsw i32 %118, %62
  %120 = call noundef i32 @_Z10checkvalidii(i32 noundef %117, i32 noundef %119)
  %.not57.2 = icmp eq i32 %120, 0
  br i1 %.not57.2, label %135, label %121

121:                                              ; preds = %115
  %122 = sext i32 %117 to i64
  %123 = sext i32 %119 to i64
  %124 = getelementptr inbounds [210 x [210 x i32]], ptr @a, i64 0, i64 %122, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = load i64, ptr %68, align 8, !tbaa !11
  %128 = sub nsw i64 %126, %127
  %..2 = call i64 @llvm.smax.i64(i64 %128, i64 1)
  %129 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %122, i64 %123
  %130 = load i64, ptr %129, align 8, !tbaa !11
  %131 = add nsw i64 %..2, %127
  %132 = icmp sgt i64 %130, %131
  br i1 %132, label %133, label %135

133:                                              ; preds = %121
  store i64 %131, ptr %129, align 8, !tbaa !11
  %134 = trunc i64 %131 to i32
  store i32 %134, ptr %7, align 4, !tbaa !16
  store i32 %117, ptr %15, align 4, !tbaa !18
  store i32 %119, ptr %16, align 4, !tbaa !19
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(25) %9, ptr noundef nonnull align 4 dereferenceable(12) %7)
          to label %135 unwind label %93

135:                                              ; preds = %133, %121, %115
  %136 = load i32, ptr getelementptr inbounds (i8, ptr @turnx, i64 12), align 4, !tbaa !5
  %137 = add nsw i32 %136, %61
  %138 = load i32, ptr getelementptr inbounds (i8, ptr @turny, i64 12), align 4, !tbaa !5
  %139 = add nsw i32 %138, %62
  %140 = call noundef i32 @_Z10checkvalidii(i32 noundef %137, i32 noundef %139)
  %.not57.3 = icmp eq i32 %140, 0
  br i1 %.not57.3, label %155, label %141

141:                                              ; preds = %135
  %142 = sext i32 %137 to i64
  %143 = sext i32 %139 to i64
  %144 = getelementptr inbounds [210 x [210 x i32]], ptr @a, i64 0, i64 %142, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = load i64, ptr %68, align 8, !tbaa !11
  %148 = sub nsw i64 %146, %147
  %..3 = call i64 @llvm.smax.i64(i64 %148, i64 1)
  %149 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %142, i64 %143
  %150 = load i64, ptr %149, align 8, !tbaa !11
  %151 = add nsw i64 %..3, %147
  %152 = icmp sgt i64 %150, %151
  br i1 %152, label %153, label %155

153:                                              ; preds = %141
  store i64 %151, ptr %149, align 8, !tbaa !11
  %154 = trunc i64 %151 to i32
  store i32 %154, ptr %7, align 4, !tbaa !16
  store i32 %137, ptr %15, align 4, !tbaa !18
  store i32 %139, ptr %16, align 4, !tbaa !19
  invoke void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushERKS0_(ptr noundef nonnull align 8 dereferenceable(25) %9, ptr noundef nonnull align 4 dereferenceable(12) %7)
          to label %155 unwind label %93

155:                                              ; preds = %153, %141, %135
  store i32 1, ptr %65, align 4, !tbaa !5
  br label %.preheader61.backedge

156:                                              ; preds = %53
  %157 = getelementptr inbounds [210 x [210 x i64]], ptr @vis, i64 0, i64 %55, i64 %57
  %158 = load i64, ptr %157, align 8, !tbaa !11
  %159 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %158)
          to label %160 unwind label %75

160:                                              ; preds = %156
  %161 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %159, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %162 unwind label %75

162:                                              ; preds = %160
  call void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %9) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 1000, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #9
  %163 = load i32, ptr %1, align 4, !tbaa !5
  %164 = add nsw i32 %163, -1
  store i32 %164, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %163, 0
  br i1 %.not, label %._crit_edge73, label %17, !llvm.loop !22

165:                                              ; preds = %77, %93, %75
  %.pn.pn = phi { ptr, i32 } [ %76, %75 ], [ %78, %77 ], [ %94, %93 ]
  call void @_ZNSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %9) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 1000, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #9
  resume { ptr, i32 } %.pn.pn

._crit_edge73:                                    ; preds = %162, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #9
  ret i32 0
}

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

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_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(12) ptr @_ZNKSt14priority_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress 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_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #5 align 2

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #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_queueI2pqSt6vectorIS0_SaIS0_EESt4lessIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #7 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #8

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #9 = { nounwind }

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

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


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