; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/292 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::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<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 }
%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@cnt = external dso_local global i32, align 4
@s = external dso_local global [2001 x i8], align 16
@g = external dso_local global [2001 x [2001 x i32]], align 16
@r = external dso_local global [2001 x [2001 x i32]], align 16
@d = external dso_local global [2001 x [2001 x i32]], align 16
@q = external dso_local global %"class.std::queue", align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = 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 uwtable
declare dso_local void @_Z7getnextRiS_S_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #1

declare i32 @puts(ptr noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 %"struct.std::pair", align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::pair", align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair", align 4
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::pair", align 4
  %15 = alloca i32, align 4
  %16 = alloca %"struct.std::pair", align 4
  %17 = alloca i32, align 4
  %18 = alloca %"struct.std::pair", align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %63, %0
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %66

28:                                               ; preds = %23
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef @s)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %59, %28
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %62

35:                                               ; preds = %30
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [2001 x i8], ptr @s, i64 0, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !9
  %41 = sext i8 %40 to i32
  %42 = icmp eq i32 %41, 46
  %43 = zext i1 %42 to i32
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %45
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [2001 x i32], ptr %46, i64 0, i64 %48
  store i32 %43, ptr %49, align 4, !tbaa !5
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %51
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2001 x i32], ptr %52, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = load i32, ptr @cnt, align 4, !tbaa !5
  %58 = add nsw i32 %57, %56
  store i32 %58, ptr @cnt, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %35
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %4, align 4, !tbaa !5
  br label %30, !llvm.loop !10

62:                                               ; preds = %34
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %2, align 4, !tbaa !5
  br label %23, !llvm.loop !12

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

67:                                               ; preds = %200, %66
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = icmp sle i32 %68, %69
  br i1 %70, label %72, label %71

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

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

73:                                               ; preds = %196, %72
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = load i32, ptr @m, align 4, !tbaa !5
  %76 = icmp sle i32 %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %199

78:                                               ; preds = %73
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %80
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [2001 x i32], ptr %81, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %88, label %87

87:                                               ; preds = %78
  br label %196

88:                                               ; preds = %78
  %89 = load i32, ptr %5, align 4, !tbaa !5
  %90 = sub nsw i32 %89, 1
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %90, i32 noundef %91)
  br i1 %92, label %93, label %112

93:                                               ; preds = %88
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = sub nsw i32 %94, 1
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %96
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [2001 x i32], ptr %97, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %112

103:                                              ; preds = %93
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %105
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [2001 x i32], ptr %106, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %109, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %103, %93, %88
  %113 = load i32, ptr %5, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %114, i32 noundef %115)
  br i1 %116, label %117, label %136

117:                                              ; preds = %112
  %118 = load i32, ptr %5, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %120
  %122 = load i32, ptr %6, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [2001 x i32], ptr %121, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = icmp ne i32 %125, 0
  br i1 %126, label %127, label %136

127:                                              ; preds = %117
  %128 = load i32, ptr %5, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %129
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [2001 x i32], ptr %130, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %133, align 4, !tbaa !5
  br label %136

136:                                              ; preds = %127, %117, %112
  %137 = load i32, ptr %5, align 4, !tbaa !5
  %138 = load i32, ptr %6, align 4, !tbaa !5
  %139 = sub nsw i32 %138, 1
  %140 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %137, i32 noundef %139)
  br i1 %140, label %141, label %160

141:                                              ; preds = %136
  %142 = load i32, ptr %5, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %143
  %145 = load i32, ptr %6, align 4, !tbaa !5
  %146 = sub nsw i32 %145, 1
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [2001 x i32], ptr %144, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = icmp ne i32 %149, 0
  br i1 %150, label %151, label %160

151:                                              ; preds = %141
  %152 = load i32, ptr %5, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %153
  %155 = load i32, ptr %6, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [2001 x i32], ptr %154, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %157, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %151, %141, %136
  %161 = load i32, ptr %5, align 4, !tbaa !5
  %162 = load i32, ptr %6, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  %164 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %161, i32 noundef %163)
  br i1 %164, label %165, label %184

165:                                              ; preds = %160
  %166 = load i32, ptr %5, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %167
  %169 = load i32, ptr %6, align 4, !tbaa !5
  %170 = add nsw i32 %169, 1
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [2001 x i32], ptr %168, i64 0, i64 %171
  %173 = load i32, ptr %172, align 4, !tbaa !5
  %174 = icmp ne i32 %173, 0
  br i1 %174, label %175, label %184

175:                                              ; preds = %165
  %176 = load i32, ptr %5, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %177
  %179 = load i32, ptr %6, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [2001 x i32], ptr %178, i64 0, i64 %180
  %182 = load i32, ptr %181, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %181, align 4, !tbaa !5
  br label %184

184:                                              ; preds = %175, %165, %160
  %185 = load i32, ptr %5, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %186
  %188 = load i32, ptr %6, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [2001 x i32], ptr %187, i64 0, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  %192 = icmp eq i32 %191, 1
  br i1 %192, label %193, label %195

193:                                              ; preds = %184
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %194 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  store i64 %194, ptr %7, align 4
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %195

195:                                              ; preds = %193, %184
  br label %196

196:                                              ; preds = %195, %87
  %197 = load i32, ptr %6, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %6, align 4, !tbaa !5
  br label %73, !llvm.loop !13

199:                                              ; preds = %77
  br label %200

200:                                              ; preds = %199
  %201 = load i32, ptr %5, align 4, !tbaa !5
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %5, align 4, !tbaa !5
  br label %67, !llvm.loop !14

203:                                              ; preds = %71
  %204 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  br i1 %204, label %205, label %210

205:                                              ; preds = %203
  %206 = load i32, ptr @cnt, align 4, !tbaa !5
  %207 = icmp sgt i32 %206, 0
  br i1 %207, label %208, label %210

208:                                              ; preds = %205
  %209 = call i32 @puts(ptr noundef @.str)
  store i32 0, ptr %1, align 4
  br label %500

210:                                              ; preds = %205, %203
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  br label %211

211:                                              ; preds = %422, %420, %210
  %212 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %213 = xor i1 %212, true
  br i1 %213, label %214, label %423

214:                                              ; preds = %211
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %215 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %215, i64 8, i1 false)
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %216 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %217 = load i32, ptr %216, align 4, !tbaa !15
  store i32 %217, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %218 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  %219 = load i32, ptr %218, align 4, !tbaa !17
  store i32 %219, ptr %11, align 4, !tbaa !5
  %220 = load i32, ptr %10, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %221
  %223 = load i32, ptr %11, align 4, !tbaa !5
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [2001 x i32], ptr %222, i64 0, i64 %224
  %226 = load i32, ptr %225, align 4, !tbaa !5
  %227 = icmp ne i32 %226, 0
  br i1 %227, label %229, label %228

228:                                              ; preds = %214
  store i32 14, ptr %3, align 4
  br label %420, !llvm.loop !18

229:                                              ; preds = %214
  %230 = load i32, ptr @cnt, align 4, !tbaa !5
  %231 = sub nsw i32 %230, 2
  store i32 %231, ptr @cnt, align 4, !tbaa !5
  %232 = load i32, ptr %10, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %233
  %235 = load i32, ptr %11, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [2001 x i32], ptr %234, i64 0, i64 %236
  store i32 0, ptr %237, align 4, !tbaa !5
  %238 = load i32, ptr %10, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %239
  %241 = load i32, ptr %11, align 4, !tbaa !5
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [2001 x i32], ptr %240, i64 0, i64 %242
  store i32 0, ptr %243, align 4, !tbaa !5
  %244 = load i32, ptr %10, align 4, !tbaa !5
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [2001 x [2001 x i32]], ptr @r, i64 0, i64 %245
  %247 = load i32, ptr %11, align 4, !tbaa !5
  %248 = sext i32 %247 to i64
  %249 = getelementptr inbounds [2001 x i32], ptr %246, i64 0, i64 %248
  call void @_Z7getnextRiS_S_(ptr noundef nonnull align 4 dereferenceable(4) %249, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %250 = load i32, ptr %10, align 4, !tbaa !5
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %251
  %253 = load i32, ptr %11, align 4, !tbaa !5
  %254 = sext i32 %253 to i64
  %255 = getelementptr inbounds [2001 x i32], ptr %252, i64 0, i64 %254
  store i32 0, ptr %255, align 4, !tbaa !5
  %256 = load i32, ptr %10, align 4, !tbaa !5
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %257
  %259 = load i32, ptr %11, align 4, !tbaa !5
  %260 = sext i32 %259 to i64
  %261 = getelementptr inbounds [2001 x i32], ptr %258, i64 0, i64 %260
  %262 = load i32, ptr %261, align 4, !tbaa !5
  %263 = add nsw i32 %262, -1
  store i32 %263, ptr %261, align 4, !tbaa !5
  %264 = load i32, ptr %10, align 4, !tbaa !5
  %265 = sub nsw i32 %264, 1
  %266 = load i32, ptr %11, align 4, !tbaa !5
  %267 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %265, i32 noundef %266)
  br i1 %267, label %268, label %302

268:                                              ; preds = %229
  %269 = load i32, ptr %10, align 4, !tbaa !5
  %270 = sub nsw i32 %269, 1
  %271 = sext i32 %270 to i64
  %272 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %271
  %273 = load i32, ptr %11, align 4, !tbaa !5
  %274 = sext i32 %273 to i64
  %275 = getelementptr inbounds [2001 x i32], ptr %272, i64 0, i64 %274
  %276 = load i32, ptr %275, align 4, !tbaa !5
  %277 = icmp ne i32 %276, 0
  br i1 %277, label %278, label %302

278:                                              ; preds = %268
  %279 = load i32, ptr %10, align 4, !tbaa !5
  %280 = sub nsw i32 %279, 1
  %281 = sext i32 %280 to i64
  %282 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %281
  %283 = load i32, ptr %11, align 4, !tbaa !5
  %284 = sext i32 %283 to i64
  %285 = getelementptr inbounds [2001 x i32], ptr %282, i64 0, i64 %284
  %286 = load i32, ptr %285, align 4, !tbaa !5
  %287 = add nsw i32 %286, -1
  store i32 %287, ptr %285, align 4, !tbaa !5
  %288 = load i32, ptr %10, align 4, !tbaa !5
  %289 = sub nsw i32 %288, 1
  %290 = sext i32 %289 to i64
  %291 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %290
  %292 = load i32, ptr %11, align 4, !tbaa !5
  %293 = sext i32 %292 to i64
  %294 = getelementptr inbounds [2001 x i32], ptr %291, i64 0, i64 %293
  %295 = load i32, ptr %294, align 4, !tbaa !5
  %296 = icmp eq i32 %295, 1
  br i1 %296, label %297, label %301

297:                                              ; preds = %278
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %298 = load i32, ptr %10, align 4, !tbaa !5
  %299 = sub nsw i32 %298, 1
  store i32 %299, ptr %13, align 4, !tbaa !5
  %300 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %11)
  store i64 %300, ptr %12, align 4
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %12)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %301

301:                                              ; preds = %297, %278
  br label %302

302:                                              ; preds = %301, %268, %229
  %303 = load i32, ptr %10, align 4, !tbaa !5
  %304 = add nsw i32 %303, 1
  %305 = load i32, ptr %11, align 4, !tbaa !5
  %306 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %304, i32 noundef %305)
  br i1 %306, label %307, label %341

307:                                              ; preds = %302
  %308 = load i32, ptr %10, align 4, !tbaa !5
  %309 = add nsw i32 %308, 1
  %310 = sext i32 %309 to i64
  %311 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %310
  %312 = load i32, ptr %11, align 4, !tbaa !5
  %313 = sext i32 %312 to i64
  %314 = getelementptr inbounds [2001 x i32], ptr %311, i64 0, i64 %313
  %315 = load i32, ptr %314, align 4, !tbaa !5
  %316 = icmp ne i32 %315, 0
  br i1 %316, label %317, label %341

317:                                              ; preds = %307
  %318 = load i32, ptr %10, align 4, !tbaa !5
  %319 = add nsw i32 %318, 1
  %320 = sext i32 %319 to i64
  %321 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %320
  %322 = load i32, ptr %11, align 4, !tbaa !5
  %323 = sext i32 %322 to i64
  %324 = getelementptr inbounds [2001 x i32], ptr %321, i64 0, i64 %323
  %325 = load i32, ptr %324, align 4, !tbaa !5
  %326 = add nsw i32 %325, -1
  store i32 %326, ptr %324, align 4, !tbaa !5
  %327 = load i32, ptr %10, align 4, !tbaa !5
  %328 = add nsw i32 %327, 1
  %329 = sext i32 %328 to i64
  %330 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %329
  %331 = load i32, ptr %11, align 4, !tbaa !5
  %332 = sext i32 %331 to i64
  %333 = getelementptr inbounds [2001 x i32], ptr %330, i64 0, i64 %332
  %334 = load i32, ptr %333, align 4, !tbaa !5
  %335 = icmp eq i32 %334, 1
  br i1 %335, label %336, label %340

336:                                              ; preds = %317
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %337 = load i32, ptr %10, align 4, !tbaa !5
  %338 = add nsw i32 %337, 1
  store i32 %338, ptr %15, align 4, !tbaa !5
  %339 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %11)
  store i64 %339, ptr %14, align 4
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %340

340:                                              ; preds = %336, %317
  br label %341

341:                                              ; preds = %340, %307, %302
  %342 = load i32, ptr %10, align 4, !tbaa !5
  %343 = load i32, ptr %11, align 4, !tbaa !5
  %344 = sub nsw i32 %343, 1
  %345 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %342, i32 noundef %344)
  br i1 %345, label %346, label %380

346:                                              ; preds = %341
  %347 = load i32, ptr %10, align 4, !tbaa !5
  %348 = sext i32 %347 to i64
  %349 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %348
  %350 = load i32, ptr %11, align 4, !tbaa !5
  %351 = sub nsw i32 %350, 1
  %352 = sext i32 %351 to i64
  %353 = getelementptr inbounds [2001 x i32], ptr %349, i64 0, i64 %352
  %354 = load i32, ptr %353, align 4, !tbaa !5
  %355 = icmp ne i32 %354, 0
  br i1 %355, label %356, label %380

356:                                              ; preds = %346
  %357 = load i32, ptr %10, align 4, !tbaa !5
  %358 = sext i32 %357 to i64
  %359 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %358
  %360 = load i32, ptr %11, align 4, !tbaa !5
  %361 = sub nsw i32 %360, 1
  %362 = sext i32 %361 to i64
  %363 = getelementptr inbounds [2001 x i32], ptr %359, i64 0, i64 %362
  %364 = load i32, ptr %363, align 4, !tbaa !5
  %365 = add nsw i32 %364, -1
  store i32 %365, ptr %363, align 4, !tbaa !5
  %366 = load i32, ptr %10, align 4, !tbaa !5
  %367 = sext i32 %366 to i64
  %368 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %367
  %369 = load i32, ptr %11, align 4, !tbaa !5
  %370 = sub nsw i32 %369, 1
  %371 = sext i32 %370 to i64
  %372 = getelementptr inbounds [2001 x i32], ptr %368, i64 0, i64 %371
  %373 = load i32, ptr %372, align 4, !tbaa !5
  %374 = icmp eq i32 %373, 1
  br i1 %374, label %375, label %379

375:                                              ; preds = %356
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %376 = load i32, ptr %11, align 4, !tbaa !5
  %377 = sub nsw i32 %376, 1
  store i32 %377, ptr %17, align 4, !tbaa !5
  %378 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %17)
  store i64 %378, ptr %16, align 4
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %16)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %379

379:                                              ; preds = %375, %356
  br label %380

380:                                              ; preds = %379, %346, %341
  %381 = load i32, ptr %10, align 4, !tbaa !5
  %382 = load i32, ptr %11, align 4, !tbaa !5
  %383 = add nsw i32 %382, 1
  %384 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %381, i32 noundef %383)
  br i1 %384, label %385, label %419

385:                                              ; preds = %380
  %386 = load i32, ptr %10, align 4, !tbaa !5
  %387 = sext i32 %386 to i64
  %388 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %387
  %389 = load i32, ptr %11, align 4, !tbaa !5
  %390 = add nsw i32 %389, 1
  %391 = sext i32 %390 to i64
  %392 = getelementptr inbounds [2001 x i32], ptr %388, i64 0, i64 %391
  %393 = load i32, ptr %392, align 4, !tbaa !5
  %394 = icmp ne i32 %393, 0
  br i1 %394, label %395, label %419

395:                                              ; preds = %385
  %396 = load i32, ptr %10, align 4, !tbaa !5
  %397 = sext i32 %396 to i64
  %398 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %397
  %399 = load i32, ptr %11, align 4, !tbaa !5
  %400 = add nsw i32 %399, 1
  %401 = sext i32 %400 to i64
  %402 = getelementptr inbounds [2001 x i32], ptr %398, i64 0, i64 %401
  %403 = load i32, ptr %402, align 4, !tbaa !5
  %404 = add nsw i32 %403, -1
  store i32 %404, ptr %402, align 4, !tbaa !5
  %405 = load i32, ptr %10, align 4, !tbaa !5
  %406 = sext i32 %405 to i64
  %407 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %406
  %408 = load i32, ptr %11, align 4, !tbaa !5
  %409 = add nsw i32 %408, 1
  %410 = sext i32 %409 to i64
  %411 = getelementptr inbounds [2001 x i32], ptr %407, i64 0, i64 %410
  %412 = load i32, ptr %411, align 4, !tbaa !5
  %413 = icmp eq i32 %412, 1
  br i1 %413, label %414, label %418

414:                                              ; preds = %395
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %415 = load i32, ptr %11, align 4, !tbaa !5
  %416 = add nsw i32 %415, 1
  store i32 %416, ptr %19, align 4, !tbaa !5
  %417 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %19)
  store i64 %417, ptr %18, align 4
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %418

418:                                              ; preds = %414, %395
  br label %419

419:                                              ; preds = %418, %385, %380
  store i32 0, ptr %3, align 4
  br label %420

420:                                              ; preds = %419, %228
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %421 = load i32, ptr %3, align 4
  switch i32 %421, label %502 [
    i32 0, label %422
    i32 14, label %211
  ]

422:                                              ; preds = %420
  br label %211, !llvm.loop !18

423:                                              ; preds = %211
  %424 = load i32, ptr @cnt, align 4, !tbaa !5
  %425 = icmp sgt i32 %424, 0
  br i1 %425, label %426, label %428

426:                                              ; preds = %423
  %427 = call i32 @puts(ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %499

428:                                              ; preds = %423
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 1, ptr %20, align 4, !tbaa !5
  br label %429

429:                                              ; preds = %495, %428
  %430 = load i32, ptr %20, align 4, !tbaa !5
  %431 = load i32, ptr @n, align 4, !tbaa !5
  %432 = icmp sle i32 %430, %431
  br i1 %432, label %434, label %433

433:                                              ; preds = %429
  store i32 16, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %498

434:                                              ; preds = %429
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  store i32 1, ptr %21, align 4, !tbaa !5
  br label %435

435:                                              ; preds = %490, %434
  %436 = load i32, ptr %21, align 4, !tbaa !5
  %437 = load i32, ptr @m, align 4, !tbaa !5
  %438 = icmp sle i32 %436, %437
  br i1 %438, label %440, label %439

439:                                              ; preds = %435
  store i32 19, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  br label %493

440:                                              ; preds = %435
  %441 = load i32, ptr %20, align 4, !tbaa !5
  %442 = sext i32 %441 to i64
  %443 = getelementptr inbounds [2001 x [2001 x i32]], ptr @r, i64 0, i64 %442
  %444 = load i32, ptr %21, align 4, !tbaa !5
  %445 = sext i32 %444 to i64
  %446 = getelementptr inbounds [2001 x i32], ptr %443, i64 0, i64 %445
  %447 = load i32, ptr %446, align 4, !tbaa !5
  %448 = icmp eq i32 %447, 1
  br i1 %448, label %449, label %451

449:                                              ; preds = %440
  %450 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %489

451:                                              ; preds = %440
  %452 = load i32, ptr %20, align 4, !tbaa !5
  %453 = sext i32 %452 to i64
  %454 = getelementptr inbounds [2001 x [2001 x i32]], ptr @r, i64 0, i64 %453
  %455 = load i32, ptr %21, align 4, !tbaa !5
  %456 = sext i32 %455 to i64
  %457 = getelementptr inbounds [2001 x i32], ptr %454, i64 0, i64 %456
  %458 = load i32, ptr %457, align 4, !tbaa !5
  %459 = icmp eq i32 %458, 2
  br i1 %459, label %460, label %462

460:                                              ; preds = %451
  %461 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %488

462:                                              ; preds = %451
  %463 = load i32, ptr %20, align 4, !tbaa !5
  %464 = sext i32 %463 to i64
  %465 = getelementptr inbounds [2001 x [2001 x i32]], ptr @r, i64 0, i64 %464
  %466 = load i32, ptr %21, align 4, !tbaa !5
  %467 = sext i32 %466 to i64
  %468 = getelementptr inbounds [2001 x i32], ptr %465, i64 0, i64 %467
  %469 = load i32, ptr %468, align 4, !tbaa !5
  %470 = icmp eq i32 %469, 3
  br i1 %470, label %471, label %473

471:                                              ; preds = %462
  %472 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  br label %487

473:                                              ; preds = %462
  %474 = load i32, ptr %20, align 4, !tbaa !5
  %475 = sext i32 %474 to i64
  %476 = getelementptr inbounds [2001 x [2001 x i32]], ptr @r, i64 0, i64 %475
  %477 = load i32, ptr %21, align 4, !tbaa !5
  %478 = sext i32 %477 to i64
  %479 = getelementptr inbounds [2001 x i32], ptr %476, i64 0, i64 %478
  %480 = load i32, ptr %479, align 4, !tbaa !5
  %481 = icmp eq i32 %480, 4
  br i1 %481, label %482, label %484

482:                                              ; preds = %473
  %483 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %486

484:                                              ; preds = %473
  %485 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %486

486:                                              ; preds = %484, %482
  br label %487

487:                                              ; preds = %486, %471
  br label %488

488:                                              ; preds = %487, %460
  br label %489

489:                                              ; preds = %488, %449
  br label %490

490:                                              ; preds = %489
  %491 = load i32, ptr %21, align 4, !tbaa !5
  %492 = add nsw i32 %491, 1
  store i32 %492, ptr %21, align 4, !tbaa !5
  br label %435, !llvm.loop !19

493:                                              ; preds = %439
  %494 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %495

495:                                              ; preds = %493
  %496 = load i32, ptr %20, align 4, !tbaa !5
  %497 = add nsw i32 %496, 1
  store i32 %497, ptr %20, align 4, !tbaa !5
  br label %429, !llvm.loop !20

498:                                              ; preds = %433
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %499

499:                                              ; preds = %498, %426
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %500

500:                                              ; preds = %499, %208
  %501 = load i32, ptr %1, align 4
  ret i32 %501

502:                                              ; preds = %420
  unreachable
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_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)) #1

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

declare i32 @printf(ptr 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 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 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!17 = !{!16, !6, i64 4}
!18 = distinct !{!18, !11}
!19 = distinct !{!19, !11}
!20 = distinct !{!20, !11}


; 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::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<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 }
%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@cnt = external dso_local local_unnamed_addr global i32, align 4
@s = external dso_local global [2001 x i8], align 16
@g = external dso_local local_unnamed_addr global [2001 x [2001 x i32]], align 16
@r = external dso_local global [2001 x [2001 x i32]], align 16
@d = external dso_local local_unnamed_addr global [2001 x [2001 x i32]], align 16
@q = external dso_local global %"class.std::queue", align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@switch.table.main = private unnamed_addr constant [4 x ptr] [ptr @.str.4, ptr @.str.5, ptr @.str.6, ptr @.str.7], align 8

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::pair", align 8
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair", align 8
  %13 = alloca i32, align 4
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %.not49 = icmp slt i32 %15, 1
  br i1 %.not49, label %._crit_edge53.thread, label %.lr.ph52

._crit_edge53.thread:                             ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  br label %._crit_edge62

._crit_edge53:                                    ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 1, ptr %1, align 4, !tbaa !5
  %.not2959 = icmp slt i32 %36, 1
  %16 = load i32, ptr @m, align 4
  %17 = icmp slt i32 %16, 1
  %or.cond117 = select i1 %.not2959, i1 true, i1 %17
  br i1 %or.cond117, label %._crit_edge62, label %.lr.ph61.split

.lr.ph52:                                         ; preds = %0, %35
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %35 ], [ 1, %0 ]
  %18 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull @s)
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %.not4447 = icmp slt i32 %19, 1
  br i1 %.not4447, label %35, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph52
  %cnt.promoted = load i32, ptr @cnt, align 4, !tbaa !5
  %20 = add nuw i32 %19, 1
  %wide.trip.count = zext i32 %20 to i64
  %21 = zext nneg i32 %19 to i64
  %min.iters.check = icmp ult i32 %19, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  %.ph = phi i32 [ %cnt.promoted, %.lr.ph ], [ %34, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %21, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  %22 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %cnt.promoted, i64 0
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ %22, %vector.ph ], [ %31, %vector.body ]
  %vec.phi114 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %32, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %23 = getelementptr inbounds [2001 x i8], ptr @s, i64 0, i64 %index
  %24 = getelementptr inbounds i8, ptr %23, i64 4
  %wide.load = load <4 x i8>, ptr %23, align 8, !tbaa !9
  %wide.load115 = load <4 x i8>, ptr %24, align 4, !tbaa !9
  %25 = icmp eq <4 x i8> %wide.load, <i8 46, i8 46, i8 46, i8 46>
  %26 = icmp eq <4 x i8> %wide.load115, <i8 46, i8 46, i8 46, i8 46>
  %27 = zext <4 x i1> %25 to <4 x i32>
  %28 = zext <4 x i1> %26 to <4 x i32>
  %29 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv74, i64 %offset.idx
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  store <4 x i32> %27, ptr %29, align 4, !tbaa !5
  store <4 x i32> %28, ptr %30, align 4, !tbaa !5
  %31 = add <4 x i32> %vec.phi, %27
  %32 = add <4 x i32> %vec.phi114, %28
  %index.next = add nuw i64 %index, 8
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !10

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %32, %31
  %34 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %21
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge:                                      ; preds = %scalar.ph, %middle.block
  %.lcssa112 = phi i32 [ %34, %middle.block ], [ %45, %scalar.ph ]
  store i32 %.lcssa112, ptr @cnt, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %._crit_edge, %.lr.ph52
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %.not.not = icmp slt i64 %indvars.iv74, %37
  br i1 %.not.not, label %.lr.ph52, label %._crit_edge53, !llvm.loop !14

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %38 = phi i32 [ %45, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %39 = add nsw i64 %indvars.iv, -1
  %40 = getelementptr inbounds [2001 x i8], ptr @s, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !9
  %42 = icmp eq i8 %41, 46
  %43 = zext i1 %42 to i32
  %44 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %indvars.iv74, i64 %indvars.iv
  store i32 %43, ptr %44, align 4, !tbaa !5
  %45 = add nsw i32 %38, %43
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !15

._crit_edge62:                                    ; preds = %._crit_edge58, %._crit_edge53.thread, %._crit_edge53
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %46 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %47 = load i32, ptr @cnt, align 4
  %48 = icmp sgt i32 %47, 0
  %or.cond = select i1 %46, i1 %48, i1 false
  br i1 %or.cond, label %.loopexit.sink.split, label %.preheader46

.preheader46:                                     ; preds = %._crit_edge62
  %49 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  br i1 %49, label %._crit_edge65, label %.lr.ph64

.lr.ph61.split:                                   ; preds = %._crit_edge53, %._crit_edge58
  %50 = phi i32 [ %53, %._crit_edge58 ], [ %36, %._crit_edge53 ]
  %51 = phi i32 [ %56, %._crit_edge58 ], [ 1, %._crit_edge53 ]
  %52 = phi i32 [ %55, %._crit_edge58 ], [ %16, %._crit_edge53 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  %.not3854 = icmp slt i32 %52, 1
  br i1 %.not3854, label %._crit_edge58, label %.lr.ph57

._crit_edge58.loopexit:                           ; preds = %124
  %.pre92 = load i32, ptr %1, align 4, !tbaa !5
  %.pre93 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge58

._crit_edge58:                                    ; preds = %._crit_edge58.loopexit, %.lr.ph61.split
  %53 = phi i32 [ %.pre93, %._crit_edge58.loopexit ], [ %50, %.lr.ph61.split ]
  %54 = phi i32 [ %.pre92, %._crit_edge58.loopexit ], [ %51, %.lr.ph61.split ]
  %55 = phi i32 [ %127, %._crit_edge58.loopexit ], [ %52, %.lr.ph61.split ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %56 = add nsw i32 %54, 1
  store i32 %56, ptr %1, align 4, !tbaa !5
  %.not29.not = icmp slt i32 %54, %53
  br i1 %.not29.not, label %.lr.ph61.split, label %._crit_edge62, !llvm.loop !16

.lr.ph57:                                         ; preds = %.lr.ph61.split, %124
  %storemerge3755 = phi i32 [ %126, %124 ], [ 1, %.lr.ph61.split ]
  %57 = load i32, ptr %1, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = sext i32 %storemerge3755 to i64
  %60 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %58, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %.not39 = icmp eq i32 %61, 0
  br i1 %.not39, label %124, label %62

62:                                               ; preds = %.lr.ph57
  %63 = add nsw i32 %57, -1
  %64 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %63, i32 noundef %storemerge3755)
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  %.pre84 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %64, label %65, label %76

65:                                               ; preds = %62
  %66 = add nsw i32 %.pre, -1
  %67 = sext i32 %66 to i64
  %68 = sext i32 %.pre84 to i64
  %69 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %67, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %.not40 = icmp eq i32 %70, 0
  br i1 %.not40, label %76, label %71

71:                                               ; preds = %65
  %72 = sext i32 %.pre to i64
  %73 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %72, i64 %68
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %73, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %71, %65, %62
  %77 = add nsw i32 %.pre, 1
  %78 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %77, i32 noundef %.pre84)
  %.pre85 = load i32, ptr %1, align 4, !tbaa !5
  %.pre86 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %78, label %79, label %90

79:                                               ; preds = %76
  %80 = add nsw i32 %.pre85, 1
  %81 = sext i32 %80 to i64
  %82 = sext i32 %.pre86 to i64
  %83 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %81, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %.not41 = icmp eq i32 %84, 0
  br i1 %.not41, label %90, label %85

85:                                               ; preds = %79
  %86 = sext i32 %.pre85 to i64
  %87 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %86, i64 %82
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %87, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %85, %79, %76
  %91 = add nsw i32 %.pre86, -1
  %92 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %.pre85, i32 noundef %91)
  %.pre87 = load i32, ptr %1, align 4, !tbaa !5
  %.pre88 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %92, label %93, label %104

93:                                               ; preds = %90
  %94 = sext i32 %.pre87 to i64
  %95 = add nsw i32 %.pre88, -1
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %94, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %.not42 = icmp eq i32 %98, 0
  br i1 %.not42, label %104, label %99

99:                                               ; preds = %93
  %100 = sext i32 %.pre88 to i64
  %101 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %94, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %101, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %99, %93, %90
  %105 = add nsw i32 %.pre88, 1
  %106 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %.pre87, i32 noundef %105)
  %.pre89 = load i32, ptr %1, align 4, !tbaa !5
  %.pre90 = load i32, ptr %2, align 4, !tbaa !5
  %107 = sext i32 %.pre89 to i64
  br i1 %106, label %108, label %._crit_edge106

108:                                              ; preds = %104
  %109 = add nsw i32 %.pre90, 1
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %107, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %.not43 = icmp eq i32 %112, 0
  br i1 %.not43, label %._crit_edge106, label %113

113:                                              ; preds = %108
  %114 = sext i32 %.pre90 to i64
  %115 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %107, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %115, align 4, !tbaa !5
  br label %._crit_edge106

._crit_edge106:                                   ; preds = %104, %113, %108
  %118 = sext i32 %.pre90 to i64
  %119 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %107, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = icmp eq i32 %120, 1
  br i1 %121, label %122, label %124

122:                                              ; preds = %._crit_edge106
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %123 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  store i64 %123, ptr %3, align 8
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %.pre91 = load i32, ptr %2, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %._crit_edge106, %122, %.lr.ph57
  %125 = phi i32 [ %.pre90, %._crit_edge106 ], [ %.pre91, %122 ], [ %storemerge3755, %.lr.ph57 ]
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %2, align 4, !tbaa !5
  %127 = load i32, ptr @m, align 4, !tbaa !5
  %.not38.not = icmp slt i32 %125, %127
  br i1 %.not38.not, label %.lr.ph57, label %._crit_edge58.loopexit, !llvm.loop !18

.lr.ph64:                                         ; preds = %.preheader46, %217
  %128 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  %.sroa.0.0.copyload = load i32, ptr %128, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %128, i64 4
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 4
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  store i32 %.sroa.0.0.copyload, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  store i32 %.sroa.4.0.copyload, ptr %5, align 4, !tbaa !5
  %129 = sext i32 %.sroa.0.0.copyload to i64
  %130 = sext i32 %.sroa.4.0.copyload to i64
  %131 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %129, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %.not32 = icmp eq i32 %132, 0
  br i1 %.not32, label %217, label %133, !llvm.loop !19

133:                                              ; preds = %.lr.ph64
  %134 = load i32, ptr @cnt, align 4, !tbaa !5
  %135 = add nsw i32 %134, -2
  store i32 %135, ptr @cnt, align 4, !tbaa !5
  store i32 0, ptr %131, align 4, !tbaa !5
  %136 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %129, i64 %130
  store i32 0, ptr %136, align 4, !tbaa !5
  %137 = getelementptr inbounds [2001 x [2001 x i32]], ptr @r, i64 0, i64 %129, i64 %130
  call void @_Z7getnextRiS_S_(ptr noundef nonnull align 4 dereferenceable(4) %137, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %138 = load i32, ptr %4, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = load i32, ptr %5, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %139, i64 %141
  store i32 0, ptr %142, align 4, !tbaa !5
  %143 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %139, i64 %141
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = add nsw i32 %144, -1
  store i32 %145, ptr %143, align 4, !tbaa !5
  %146 = add nsw i32 %138, -1
  %147 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %146, i32 noundef %140)
  %.pre95 = load i32, ptr %4, align 4, !tbaa !5
  %.pre97 = load i32, ptr %5, align 4, !tbaa !5
  br i1 %147, label %148, label %161

148:                                              ; preds = %133
  %149 = add nsw i32 %.pre95, -1
  %150 = sext i32 %149 to i64
  %151 = sext i32 %.pre97 to i64
  %152 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %150, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %.not33 = icmp eq i32 %153, 0
  br i1 %.not33, label %161, label %154

154:                                              ; preds = %148
  %155 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %150, i64 %151
  %156 = load i32, ptr %155, align 4, !tbaa !5
  %157 = add nsw i32 %156, -1
  store i32 %157, ptr %155, align 4, !tbaa !5
  %158 = icmp eq i32 %157, 1
  br i1 %158, label %159, label %161

159:                                              ; preds = %154
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  store i32 %149, ptr %7, align 4, !tbaa !5
  %160 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store i64 %160, ptr %6, align 8
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %.pre94 = load i32, ptr %4, align 4, !tbaa !5
  %.pre96 = load i32, ptr %5, align 4, !tbaa !5
  br label %161

161:                                              ; preds = %154, %159, %148, %133
  %162 = phi i32 [ %.pre97, %154 ], [ %.pre96, %159 ], [ %.pre97, %148 ], [ %.pre97, %133 ]
  %163 = phi i32 [ %.pre95, %154 ], [ %.pre94, %159 ], [ %.pre95, %148 ], [ %.pre95, %133 ]
  %164 = add nsw i32 %163, 1
  %165 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %164, i32 noundef %162)
  %.pre99 = load i32, ptr %4, align 4, !tbaa !5
  %.pre101 = load i32, ptr %5, align 4, !tbaa !5
  br i1 %165, label %166, label %179

166:                                              ; preds = %161
  %167 = add nsw i32 %.pre99, 1
  %168 = sext i32 %167 to i64
  %169 = sext i32 %.pre101 to i64
  %170 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %168, i64 %169
  %171 = load i32, ptr %170, align 4, !tbaa !5
  %.not34 = icmp eq i32 %171, 0
  br i1 %.not34, label %179, label %172

172:                                              ; preds = %166
  %173 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %168, i64 %169
  %174 = load i32, ptr %173, align 4, !tbaa !5
  %175 = add nsw i32 %174, -1
  store i32 %175, ptr %173, align 4, !tbaa !5
  %176 = icmp eq i32 %175, 1
  br i1 %176, label %177, label %179

177:                                              ; preds = %172
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #6
  store i32 %167, ptr %9, align 4, !tbaa !5
  %178 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__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) %5)
  store i64 %178, ptr %8, align 8
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  %.pre98 = load i32, ptr %4, align 4, !tbaa !5
  %.pre100 = load i32, ptr %5, align 4, !tbaa !5
  br label %179

179:                                              ; preds = %172, %177, %166, %161
  %180 = phi i32 [ %.pre101, %172 ], [ %.pre100, %177 ], [ %.pre101, %166 ], [ %.pre101, %161 ]
  %181 = phi i32 [ %.pre99, %172 ], [ %.pre98, %177 ], [ %.pre99, %166 ], [ %.pre99, %161 ]
  %182 = add nsw i32 %180, -1
  %183 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %181, i32 noundef %182)
  %.pre103 = load i32, ptr %4, align 4, !tbaa !5
  %.pre105 = load i32, ptr %5, align 4, !tbaa !5
  br i1 %183, label %184, label %197

184:                                              ; preds = %179
  %185 = sext i32 %.pre103 to i64
  %186 = add nsw i32 %.pre105, -1
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %185, i64 %187
  %189 = load i32, ptr %188, align 4, !tbaa !5
  %.not35 = icmp eq i32 %189, 0
  br i1 %.not35, label %197, label %190

190:                                              ; preds = %184
  %191 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %185, i64 %187
  %192 = load i32, ptr %191, align 4, !tbaa !5
  %193 = add nsw i32 %192, -1
  store i32 %193, ptr %191, align 4, !tbaa !5
  %194 = icmp eq i32 %193, 1
  br i1 %194, label %195, label %197

195:                                              ; preds = %190
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #6
  store i32 %186, ptr %11, align 4, !tbaa !5
  %196 = 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) %11)
  store i64 %196, ptr %10, align 8
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #6
  %.pre102 = load i32, ptr %4, align 4, !tbaa !5
  %.pre104 = load i32, ptr %5, align 4, !tbaa !5
  br label %197

197:                                              ; preds = %190, %195, %184, %179
  %198 = phi i32 [ %.pre105, %190 ], [ %.pre104, %195 ], [ %.pre105, %184 ], [ %.pre105, %179 ]
  %199 = phi i32 [ %.pre103, %190 ], [ %.pre102, %195 ], [ %.pre103, %184 ], [ %.pre103, %179 ]
  %200 = add nsw i32 %198, 1
  %201 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %199, i32 noundef %200)
  br i1 %201, label %202, label %217

202:                                              ; preds = %197
  %203 = load i32, ptr %4, align 4, !tbaa !5
  %204 = sext i32 %203 to i64
  %205 = load i32, ptr %5, align 4, !tbaa !5
  %206 = add nsw i32 %205, 1
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds [2001 x [2001 x i32]], ptr @g, i64 0, i64 %204, i64 %207
  %209 = load i32, ptr %208, align 4, !tbaa !5
  %.not36 = icmp eq i32 %209, 0
  br i1 %.not36, label %217, label %210

210:                                              ; preds = %202
  %211 = getelementptr inbounds [2001 x [2001 x i32]], ptr @d, i64 0, i64 %204, i64 %207
  %212 = load i32, ptr %211, align 4, !tbaa !5
  %213 = add nsw i32 %212, -1
  store i32 %213, ptr %211, align 4, !tbaa !5
  %214 = icmp eq i32 %213, 1
  br i1 %214, label %215, label %217

215:                                              ; preds = %210
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #6
  store i32 %206, ptr %13, align 4, !tbaa !5
  %216 = 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) %13)
  store i64 %216, ptr %12, align 8
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @q, ptr noundef nonnull align 4 dereferenceable(8) %12)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #6
  br label %217

217:                                              ; preds = %197, %202, %215, %210, %.lr.ph64
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  %218 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) @q)
  br i1 %218, label %._crit_edge65, label %.lr.ph64

._crit_edge65:                                    ; preds = %217, %.preheader46
  %219 = load i32, ptr @cnt, align 4, !tbaa !5
  %220 = icmp sgt i32 %219, 0
  br i1 %220, label %.loopexit.sink.split, label %.preheader45

.preheader45:                                     ; preds = %._crit_edge65
  %221 = load i32, ptr @n, align 4, !tbaa !5
  %.not3070 = icmp slt i32 %221, 1
  br i1 %.not3070, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.preheader45, %._crit_edge69
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %._crit_edge69 ], [ 1, %.preheader45 ]
  %222 = load i32, ptr @m, align 4, !tbaa !5
  %.not3166 = icmp slt i32 %222, 1
  br i1 %.not3166, label %._crit_edge69, label %.lr.ph68

._crit_edge69:                                    ; preds = %230, %.preheader
  %223 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %224 = load i32, ptr @n, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %.not30.not = icmp slt i64 %indvars.iv81, %225
  br i1 %.not30.not, label %.preheader, label %.loopexit, !llvm.loop !20

.lr.ph68:                                         ; preds = %.preheader, %230
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %230 ], [ 1, %.preheader ]
  %226 = getelementptr inbounds [2001 x [2001 x i32]], ptr @r, i64 0, i64 %indvars.iv81, i64 %indvars.iv78
  %227 = load i32, ptr %226, align 4, !tbaa !5
  %switch.tableidx = add i32 %227, -1
  %228 = icmp ult i32 %switch.tableidx, 4
  br i1 %228, label %switch.lookup, label %230

switch.lookup:                                    ; preds = %.lr.ph68
  %229 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [4 x ptr], ptr @switch.table.main, i64 0, i64 %229
  %switch.load = load ptr, ptr %switch.gep, align 8
  br label %230

230:                                              ; preds = %.lr.ph68, %switch.lookup
  %.str.4.sink = phi ptr [ %switch.load, %switch.lookup ], [ @.str.8, %.lr.ph68 ]
  %231 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.4.sink)
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %232 = load i32, ptr @m, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %.not31.not = icmp slt i64 %indvars.iv78, %233
  br i1 %.not31.not, label %.lr.ph68, label %._crit_edge69, !llvm.loop !21

.loopexit.sink.split:                             ; preds = %._crit_edge65, %._crit_edge62
  %234 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str)
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge69, %.loopexit.sink.split, %.preheader45
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) 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) #4

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_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 #1

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #5

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 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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11, !12, !13}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11, !13, !12}
!16 = distinct !{!16, !11, !17}
!17 = !{!"llvm.loop.unswitch.partial.disable"}
!18 = distinct !{!18, !11}
!19 = distinct !{!19, !11}
!20 = distinct !{!20, !11}
!21 = distinct !{!21, !11}


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