; LLVM IR from tangjz/acm-icpc :: 51nod (1444)

; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@st = external dso_local global [4 x i32], align 16
@ll = external dso_local global [2 x i32], align 4
@dis = external dso_local global [3010 x [3010 x i32]], align 16
@que = external dso_local global [3010 x i32], align 16
@l = external dso_local global i32, align 4
@r = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@e = external dso_local global [3010 x %"class.std::vector"], align 16
@vis = external dso_local global [3010 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %30, %0
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3, ptr noundef %4)
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [3010 x %"class.std::vector"], ptr @e, i64 0, i64 %25
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [3010 x %"class.std::vector"], ptr @e, i64 0, i64 %28
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %29, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %30

30:                                               ; preds = %22
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !9

33:                                               ; preds = %21
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @st, ptr noundef getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 1), ptr noundef @ll)
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 2), ptr noundef getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 3), ptr noundef getelementptr inbounds ([2 x i32], ptr @ll, i64 0, i64 1))
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %112, %33
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %36
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 3010, i1 false)
  store i32 0, ptr @r, align 4, !tbaa !5
  store i32 0, ptr @l, align 4, !tbaa !5
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr @r, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr @r, align 4, !tbaa !5
  %45 = sext i32 %43 to i64
  %46 = getelementptr inbounds [3010 x i32], ptr @que, i64 0, i64 %45
  store i32 %42, ptr %46, align 4, !tbaa !5
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [3010 x i8], ptr @vis, i64 0, i64 %48
  store i8 1, ptr %49, align 1, !tbaa !11
  br label %50

50:                                               ; preds = %110, %41
  %51 = load i32, ptr @l, align 4, !tbaa !5
  %52 = load i32, ptr @r, align 4, !tbaa !5
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %54, label %111

54:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %55 = load i32, ptr @l, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr @l, align 4, !tbaa !5
  %57 = sext i32 %55 to i64
  %58 = getelementptr inbounds [3010 x i32], ptr @que, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  store i32 %59, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [3010 x %"class.std::vector"], ptr @e, i64 0, i64 %61
  %63 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %62) #7
  %64 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  store ptr %63, ptr %64, align 8
  br label %65

65:                                               ; preds = %108, %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [3010 x %"class.std::vector"], ptr @e, i64 0, i64 %67
  %69 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %68) #7
  %70 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %9, i32 0, i32 0
  store ptr %69, ptr %70, align 8
  %71 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br i1 %71, label %73, label %72

72:                                               ; preds = %65
  store i32 10, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %110

73:                                               ; preds = %65
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #7
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [3010 x i8], ptr @vis, i64 0, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !11, !range !13, !noundef !14
  %79 = trunc i8 %78 to i1
  br i1 %79, label %107, label %80

80:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %81 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #7
  store ptr %81, ptr %10, align 8, !tbaa !15
  %82 = load i32, ptr %5, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %83
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [3010 x i32], ptr %84, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %91
  %93 = load ptr, ptr %10, align 8, !tbaa !15
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [3010 x i32], ptr %92, i64 0, i64 %95
  store i32 %89, ptr %96, align 4, !tbaa !5
  %97 = load ptr, ptr %10, align 8, !tbaa !15
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = load i32, ptr @r, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr @r, align 4, !tbaa !5
  %101 = sext i32 %99 to i64
  %102 = getelementptr inbounds [3010 x i32], ptr @que, i64 0, i64 %101
  store i32 %98, ptr %102, align 4, !tbaa !5
  %103 = load ptr, ptr %10, align 8, !tbaa !15
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [3010 x i8], ptr @vis, i64 0, i64 %105
  store i8 1, ptr %106, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %107

107:                                              ; preds = %80, %73
  br label %108

108:                                              ; preds = %107
  %109 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #7
  br label %65, !llvm.loop !17

110:                                              ; preds = %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %50, !llvm.loop !18

111:                                              ; preds = %50
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %5, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %5, align 4, !tbaa !5
  br label %36, !llvm.loop !19

115:                                              ; preds = %40
  %116 = load i32, ptr @st, align 16, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %117
  %119 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 1), align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [3010 x i32], ptr %118, i64 0, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !5
  %123 = load i32, ptr @ll, align 4, !tbaa !5
  %124 = icmp sgt i32 %122, %123
  br i1 %124, label %135, label %125

125:                                              ; preds = %115
  %126 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 2), align 8, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %127
  %129 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 3), align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [3010 x i32], ptr %128, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = load i32, ptr getelementptr inbounds ([2 x i32], ptr @ll, i64 0, i64 1), align 4, !tbaa !5
  %134 = icmp sgt i32 %132, %133
  br i1 %134, label %135, label %137

135:                                              ; preds = %125, %115
  %136 = call i32 @puts(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  br label %367

137:                                              ; preds = %125
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %138 = load i32, ptr @st, align 16, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %139
  %141 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 1), align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [3010 x i32], ptr %140, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 2), align 8, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %146
  %148 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 3), align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [3010 x i32], ptr %147, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = add nsw i32 %144, %151
  store i32 %152, ptr %11, align 4, !tbaa !5
  %153 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %154 = load i32, ptr %153, align 4, !tbaa !5
  store i32 %154, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %155

155:                                              ; preds = %359, %137
  %156 = load i32, ptr %12, align 4, !tbaa !5
  %157 = load i32, ptr @n, align 4, !tbaa !5
  %158 = icmp sle i32 %156, %157
  br i1 %158, label %160, label %159

159:                                              ; preds = %155
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %362

160:                                              ; preds = %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %161

161:                                              ; preds = %355, %160
  %162 = load i32, ptr %13, align 4, !tbaa !5
  %163 = load i32, ptr @n, align 4, !tbaa !5
  %164 = icmp sle i32 %162, %163
  br i1 %164, label %166, label %165

165:                                              ; preds = %161
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %358

166:                                              ; preds = %161
  %167 = load i32, ptr @st, align 16, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %168
  %170 = load i32, ptr %12, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [3010 x i32], ptr %169, i64 0, i64 %171
  %173 = load i32, ptr %172, align 4, !tbaa !5
  %174 = load i32, ptr %12, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %175
  %177 = load i32, ptr %13, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [3010 x i32], ptr %176, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = add nsw i32 %173, %180
  %182 = load i32, ptr %13, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %183
  %185 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 1), align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [3010 x i32], ptr %184, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = add nsw i32 %181, %188
  %190 = load i32, ptr @ll, align 4, !tbaa !5
  %191 = icmp sle i32 %189, %190
  br i1 %191, label %192, label %260

192:                                              ; preds = %166
  %193 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 2), align 8, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %194
  %196 = load i32, ptr %12, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [3010 x i32], ptr %195, i64 0, i64 %197
  %199 = load i32, ptr %198, align 4, !tbaa !5
  %200 = load i32, ptr %12, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %201
  %203 = load i32, ptr %13, align 4, !tbaa !5
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [3010 x i32], ptr %202, i64 0, i64 %204
  %206 = load i32, ptr %205, align 4, !tbaa !5
  %207 = add nsw i32 %199, %206
  %208 = load i32, ptr %13, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %209
  %211 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 3), align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [3010 x i32], ptr %210, i64 0, i64 %212
  %214 = load i32, ptr %213, align 4, !tbaa !5
  %215 = add nsw i32 %207, %214
  %216 = load i32, ptr getelementptr inbounds ([2 x i32], ptr @ll, i64 0, i64 1), align 4, !tbaa !5
  %217 = icmp sle i32 %215, %216
  br i1 %217, label %218, label %260

218:                                              ; preds = %192
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %219 = load i32, ptr @st, align 16, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %220
  %222 = load i32, ptr %12, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [3010 x i32], ptr %221, i64 0, i64 %223
  %225 = load i32, ptr %224, align 4, !tbaa !5
  %226 = load i32, ptr %12, align 4, !tbaa !5
  %227 = sext i32 %226 to i64
  %228 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %227
  %229 = load i32, ptr %13, align 4, !tbaa !5
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds [3010 x i32], ptr %228, i64 0, i64 %230
  %232 = load i32, ptr %231, align 4, !tbaa !5
  %233 = add nsw i32 %225, %232
  %234 = load i32, ptr %13, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %235
  %237 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 1), align 4, !tbaa !5
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [3010 x i32], ptr %236, i64 0, i64 %238
  %240 = load i32, ptr %239, align 4, !tbaa !5
  %241 = add nsw i32 %233, %240
  %242 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 2), align 8, !tbaa !5
  %243 = sext i32 %242 to i64
  %244 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %243
  %245 = load i32, ptr %12, align 4, !tbaa !5
  %246 = sext i32 %245 to i64
  %247 = getelementptr inbounds [3010 x i32], ptr %244, i64 0, i64 %246
  %248 = load i32, ptr %247, align 4, !tbaa !5
  %249 = add nsw i32 %241, %248
  %250 = load i32, ptr %13, align 4, !tbaa !5
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %251
  %253 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 3), align 4, !tbaa !5
  %254 = sext i32 %253 to i64
  %255 = getelementptr inbounds [3010 x i32], ptr %252, i64 0, i64 %254
  %256 = load i32, ptr %255, align 4, !tbaa !5
  %257 = add nsw i32 %249, %256
  store i32 %257, ptr %14, align 4, !tbaa !5
  %258 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %259 = load i32, ptr %258, align 4, !tbaa !5
  store i32 %259, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %260

260:                                              ; preds = %218, %192, %166
  %261 = load i32, ptr @st, align 16, !tbaa !5
  %262 = sext i32 %261 to i64
  %263 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %262
  %264 = load i32, ptr %12, align 4, !tbaa !5
  %265 = sext i32 %264 to i64
  %266 = getelementptr inbounds [3010 x i32], ptr %263, i64 0, i64 %265
  %267 = load i32, ptr %266, align 4, !tbaa !5
  %268 = load i32, ptr %12, align 4, !tbaa !5
  %269 = sext i32 %268 to i64
  %270 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %269
  %271 = load i32, ptr %13, align 4, !tbaa !5
  %272 = sext i32 %271 to i64
  %273 = getelementptr inbounds [3010 x i32], ptr %270, i64 0, i64 %272
  %274 = load i32, ptr %273, align 4, !tbaa !5
  %275 = add nsw i32 %267, %274
  %276 = load i32, ptr %13, align 4, !tbaa !5
  %277 = sext i32 %276 to i64
  %278 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %277
  %279 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 1), align 4, !tbaa !5
  %280 = sext i32 %279 to i64
  %281 = getelementptr inbounds [3010 x i32], ptr %278, i64 0, i64 %280
  %282 = load i32, ptr %281, align 4, !tbaa !5
  %283 = add nsw i32 %275, %282
  %284 = load i32, ptr @ll, align 4, !tbaa !5
  %285 = icmp sle i32 %283, %284
  br i1 %285, label %286, label %354

286:                                              ; preds = %260
  %287 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 2), align 8, !tbaa !5
  %288 = sext i32 %287 to i64
  %289 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %288
  %290 = load i32, ptr %13, align 4, !tbaa !5
  %291 = sext i32 %290 to i64
  %292 = getelementptr inbounds [3010 x i32], ptr %289, i64 0, i64 %291
  %293 = load i32, ptr %292, align 4, !tbaa !5
  %294 = load i32, ptr %13, align 4, !tbaa !5
  %295 = sext i32 %294 to i64
  %296 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %295
  %297 = load i32, ptr %12, align 4, !tbaa !5
  %298 = sext i32 %297 to i64
  %299 = getelementptr inbounds [3010 x i32], ptr %296, i64 0, i64 %298
  %300 = load i32, ptr %299, align 4, !tbaa !5
  %301 = add nsw i32 %293, %300
  %302 = load i32, ptr %12, align 4, !tbaa !5
  %303 = sext i32 %302 to i64
  %304 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %303
  %305 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 3), align 4, !tbaa !5
  %306 = sext i32 %305 to i64
  %307 = getelementptr inbounds [3010 x i32], ptr %304, i64 0, i64 %306
  %308 = load i32, ptr %307, align 4, !tbaa !5
  %309 = add nsw i32 %301, %308
  %310 = load i32, ptr getelementptr inbounds ([2 x i32], ptr @ll, i64 0, i64 1), align 4, !tbaa !5
  %311 = icmp sle i32 %309, %310
  br i1 %311, label %312, label %354

312:                                              ; preds = %286
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %313 = load i32, ptr @st, align 16, !tbaa !5
  %314 = sext i32 %313 to i64
  %315 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %314
  %316 = load i32, ptr %12, align 4, !tbaa !5
  %317 = sext i32 %316 to i64
  %318 = getelementptr inbounds [3010 x i32], ptr %315, i64 0, i64 %317
  %319 = load i32, ptr %318, align 4, !tbaa !5
  %320 = load i32, ptr %12, align 4, !tbaa !5
  %321 = sext i32 %320 to i64
  %322 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %321
  %323 = load i32, ptr %13, align 4, !tbaa !5
  %324 = sext i32 %323 to i64
  %325 = getelementptr inbounds [3010 x i32], ptr %322, i64 0, i64 %324
  %326 = load i32, ptr %325, align 4, !tbaa !5
  %327 = add nsw i32 %319, %326
  %328 = load i32, ptr %13, align 4, !tbaa !5
  %329 = sext i32 %328 to i64
  %330 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %329
  %331 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 1), align 4, !tbaa !5
  %332 = sext i32 %331 to i64
  %333 = getelementptr inbounds [3010 x i32], ptr %330, i64 0, i64 %332
  %334 = load i32, ptr %333, align 4, !tbaa !5
  %335 = add nsw i32 %327, %334
  %336 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 2), align 8, !tbaa !5
  %337 = sext i32 %336 to i64
  %338 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %337
  %339 = load i32, ptr %13, align 4, !tbaa !5
  %340 = sext i32 %339 to i64
  %341 = getelementptr inbounds [3010 x i32], ptr %338, i64 0, i64 %340
  %342 = load i32, ptr %341, align 4, !tbaa !5
  %343 = add nsw i32 %335, %342
  %344 = load i32, ptr %12, align 4, !tbaa !5
  %345 = sext i32 %344 to i64
  %346 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %345
  %347 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @st, i64 0, i64 3), align 4, !tbaa !5
  %348 = sext i32 %347 to i64
  %349 = getelementptr inbounds [3010 x i32], ptr %346, i64 0, i64 %348
  %350 = load i32, ptr %349, align 4, !tbaa !5
  %351 = add nsw i32 %343, %350
  store i32 %351, ptr %15, align 4, !tbaa !5
  %352 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %353 = load i32, ptr %352, align 4, !tbaa !5
  store i32 %353, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %354

354:                                              ; preds = %312, %286, %260
  br label %355

355:                                              ; preds = %354
  %356 = load i32, ptr %13, align 4, !tbaa !5
  %357 = add nsw i32 %356, 1
  store i32 %357, ptr %13, align 4, !tbaa !5
  br label %161, !llvm.loop !20

358:                                              ; preds = %165
  br label %359

359:                                              ; preds = %358
  %360 = load i32, ptr %12, align 4, !tbaa !5
  %361 = add nsw i32 %360, 1
  store i32 %361, ptr %12, align 4, !tbaa !5
  br label %155, !llvm.loop !21

362:                                              ; preds = %159
  %363 = load i32, ptr @m, align 4, !tbaa !5
  %364 = load i32, ptr @ans, align 4, !tbaa !5
  %365 = sub nsw i32 %363, %364
  %366 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %365)
  store i32 0, ptr %1, align 4
  br label %367

367:                                              ; preds = %362, %135
  %368 = load i32, ptr %1, align 4
  ret i32 %368
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #3 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #5 align 2

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

declare i32 @puts(ptr noundef) #1

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

declare i32 @printf(ptr noundef, ...) #1

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@st = external dso_local global [4 x i32], align 16
@ll = external dso_local global [2 x i32], align 4
@dis = external dso_local local_unnamed_addr global [3010 x [3010 x i32]], align 16
@que = external dso_local local_unnamed_addr global [3010 x i32], align 16
@l = external dso_local local_unnamed_addr global i32, align 4
@r = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local global i32, align 4
@e = external dso_local global [3010 x %"class.std::vector"], align 16
@vis = external dso_local local_unnamed_addr global [3010 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %9 = load i32, ptr @m, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @st, ptr noundef nonnull getelementptr inbounds (i8, ptr @st, i64 4), ptr noundef nonnull @ll)
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @st, i64 8), ptr noundef nonnull getelementptr inbounds (i8, ptr @st, i64 12), ptr noundef nonnull getelementptr inbounds (i8, ptr @ll, i64 4))
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %.not64 = icmp slt i32 %13, 1
  br i1 %.not64, label %._crit_edge68, label %.lr.ph62.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.04857 = phi i32 [ %21, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [3010 x %"class.std::vector"], ptr @e, i64 0, i64 %16
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %17, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [3010 x %"class.std::vector"], ptr @e, i64 0, i64 %19
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %21 = add nuw nsw i32 %.04857, 1
  %22 = load i32, ptr @m, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge68:                                    ; preds = %._crit_edge63, %._crit_edge
  %24 = load i32, ptr @st, align 16, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 4), align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %25, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr @ll, align 4, !tbaa !5
  %31 = icmp sgt i32 %29, %30
  br i1 %31, label %84, label %75

.lr.ph62.preheader:                               ; preds = %._crit_edge, %._crit_edge63
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge63 ], [ 1, %._crit_edge ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(3010) @vis, i8 0, i64 3010, i1 false)
  store i32 1, ptr @r, align 4, !tbaa !5
  %32 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %32, ptr @que, align 16, !tbaa !5
  %33 = getelementptr inbounds [3010 x i8], ptr @vis, i64 0, i64 %indvars.iv
  store i8 1, ptr %33, align 1, !tbaa !11
  br label %.lr.ph62

.lr.ph62:                                         ; preds = %.lr.ph62.preheader, %._crit_edge60
  %34 = phi i32 [ %45, %._crit_edge60 ], [ 0, %.lr.ph62.preheader ]
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr @l, align 4, !tbaa !5
  %36 = sext i32 %34 to i64
  %37 = getelementptr inbounds [3010 x i32], ptr @que, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [3010 x %"class.std::vector"], ptr @e, i64 0, i64 %39
  %41 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #7
  store ptr %41, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %42 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #7
  store ptr %42, ptr %4, align 8
  %43 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br i1 %43, label %.lr.ph59, label %._crit_edge60

.lr.ph59:                                         ; preds = %.lr.ph62
  %44 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %indvars.iv, i64 %39
  br label %48

._crit_edge60:                                    ; preds = %70, %.lr.ph62
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %45 = load i32, ptr @l, align 4, !tbaa !5
  %46 = load i32, ptr @r, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %.lr.ph62, label %._crit_edge63, !llvm.loop !13

48:                                               ; preds = %.lr.ph59, %70
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #7
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [3010 x i8], ptr @vis, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !11, !range !14, !noundef !15
  %54 = trunc nuw i8 %53 to i1
  br i1 %54, label %70, label %55

55:                                               ; preds = %48
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #7
  %57 = load i32, ptr %44, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  %59 = load i32, ptr %56, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %indvars.iv, i64 %60
  store i32 %58, ptr %61, align 4, !tbaa !5
  %62 = load i32, ptr %56, align 4, !tbaa !5
  %63 = load i32, ptr @r, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr @r, align 4, !tbaa !5
  %65 = sext i32 %63 to i64
  %66 = getelementptr inbounds [3010 x i32], ptr @que, i64 0, i64 %65
  store i32 %62, ptr %66, align 4, !tbaa !5
  %67 = load i32, ptr %56, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [3010 x i8], ptr @vis, i64 0, i64 %68
  store i8 1, ptr %69, align 1, !tbaa !11
  br label %70

70:                                               ; preds = %48, %55
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %72 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #7
  store ptr %72, ptr %4, align 8
  %73 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br i1 %73, label %48, label %._crit_edge60, !llvm.loop !16

._crit_edge63:                                    ; preds = %._crit_edge60
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %74 = sext i32 %.pre to i64
  %.not.not = icmp slt i64 %indvars.iv, %74
  br i1 %.not.not, label %.lr.ph62.preheader, label %._crit_edge68, !llvm.loop !17

75:                                               ; preds = %._crit_edge68
  %76 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 8), align 8, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 12), align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %77, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = load i32, ptr getelementptr inbounds (i8, ptr @ll, i64 4), align 4, !tbaa !5
  %83 = icmp sgt i32 %81, %82
  br i1 %83, label %84, label %86

84:                                               ; preds = %75, %._crit_edge68
  %85 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %160

86:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %87 = add nsw i32 %81, %29
  store i32 %87, ptr %5, align 4, !tbaa !5
  %88 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %89 = load i32, ptr %88, align 4, !tbaa !5
  store i32 %89, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %.not5173 = icmp slt i32 %90, 1
  br i1 %.not5173, label %._crit_edge75, label %.preheader

.preheader:                                       ; preds = %86, %._crit_edge72
  %91 = phi i32 [ %97, %._crit_edge72 ], [ %89, %86 ]
  %92 = phi i32 [ %98, %._crit_edge72 ], [ %90, %86 ]
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %._crit_edge72 ], [ 1, %86 ]
  %.not5269 = icmp slt i32 %92, 1
  br i1 %.not5269, label %.preheader.._crit_edge72_crit_edge, label %.lr.ph71

.preheader.._crit_edge72_crit_edge:               ; preds = %.preheader
  %.pre104 = sext i32 %92 to i64
  br label %._crit_edge72

.lr.ph71:                                         ; preds = %.preheader
  %.pre85 = load i32, ptr @st, align 16, !tbaa !5
  %.pre87 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 4), align 4, !tbaa !5
  %.pre89 = load i32, ptr @ll, align 4, !tbaa !5
  br label %99

._crit_edge75:                                    ; preds = %._crit_edge72, %86
  %93 = phi i32 [ %89, %86 ], [ %97, %._crit_edge72 ]
  %94 = load i32, ptr @m, align 4, !tbaa !5
  %95 = sub nsw i32 %94, %93
  %96 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %95)
  br label %160

._crit_edge72:                                    ; preds = %153, %.preheader.._crit_edge72_crit_edge
  %.pre-phi105 = phi i64 [ %.pre104, %.preheader.._crit_edge72_crit_edge ], [ %159, %153 ]
  %97 = phi i32 [ %91, %.preheader.._crit_edge72_crit_edge ], [ %154, %153 ]
  %98 = phi i32 [ %92, %.preheader.._crit_edge72_crit_edge ], [ %158, %153 ]
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %.not51.not = icmp slt i64 %indvars.iv81, %.pre-phi105
  br i1 %.not51.not, label %.preheader, label %._crit_edge75, !llvm.loop !18

99:                                               ; preds = %.lr.ph71, %153
  %100 = phi i32 [ %91, %.lr.ph71 ], [ %154, %153 ]
  %101 = phi i32 [ %.pre89, %.lr.ph71 ], [ %155, %153 ]
  %102 = phi i32 [ %.pre87, %.lr.ph71 ], [ %156, %153 ]
  %103 = phi i32 [ %.pre85, %.lr.ph71 ], [ %157, %153 ]
  %indvars.iv78 = phi i64 [ 1, %.lr.ph71 ], [ %indvars.iv.next79, %153 ]
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %104, i64 %indvars.iv81
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %indvars.iv81, i64 %indvars.iv78
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = add nsw i32 %108, %106
  %110 = sext i32 %102 to i64
  %111 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %indvars.iv78, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = add nsw i32 %109, %112
  %.not53 = icmp sgt i32 %113, %101
  br i1 %.not53, label %130, label %114

114:                                              ; preds = %99
  %115 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 8), align 8, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %116, i64 %indvars.iv81
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 12), align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %indvars.iv78, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !5
  %123 = add i32 %122, %118
  %124 = add i32 %123, %108
  %125 = load i32, ptr getelementptr inbounds (i8, ptr @ll, i64 4), align 4, !tbaa !5
  %.not54 = icmp sgt i32 %124, %125
  br i1 %.not54, label %130, label %126

126:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  %127 = add i32 %123, %113
  store i32 %127, ptr %6, align 4, !tbaa !5
  %128 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %129 = load i32, ptr %128, align 4, !tbaa !5
  store i32 %129, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  %.pre90 = load i32, ptr @st, align 16, !tbaa !5
  %.pre91 = load i32, ptr %107, align 4, !tbaa !5
  %.pre92 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 4), align 4, !tbaa !5
  %.pre93 = load i32, ptr @ll, align 4, !tbaa !5
  %.pre94 = sext i32 %.pre90 to i64
  %.phi.trans.insert = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %.pre94, i64 %indvars.iv81
  %.pre95 = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  %.pre96 = sext i32 %.pre92 to i64
  %.phi.trans.insert98 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %indvars.iv78, i64 %.pre96
  %.pre99 = load i32, ptr %.phi.trans.insert98, align 4, !tbaa !5
  %.pre100 = add nsw i32 %.pre91, %.pre95
  %.pre102 = add nsw i32 %.pre100, %.pre99
  br label %130

130:                                              ; preds = %126, %114, %99
  %.pre-phi103 = phi i32 [ %.pre102, %126 ], [ %113, %114 ], [ %113, %99 ]
  %131 = phi i32 [ %129, %126 ], [ %100, %114 ], [ %100, %99 ]
  %132 = phi i32 [ %.pre93, %126 ], [ %101, %114 ], [ %101, %99 ]
  %133 = phi i32 [ %.pre92, %126 ], [ %102, %114 ], [ %102, %99 ]
  %134 = phi i32 [ %.pre90, %126 ], [ %103, %114 ], [ %103, %99 ]
  %.not55 = icmp sgt i32 %.pre-phi103, %132
  br i1 %.not55, label %153, label %135

135:                                              ; preds = %130
  %136 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 8), align 8, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %137, i64 %indvars.iv78
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %indvars.iv78, i64 %indvars.iv81
  %141 = load i32, ptr %140, align 4, !tbaa !5
  %142 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 12), align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [3010 x [3010 x i32]], ptr @dis, i64 0, i64 %indvars.iv81, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = add i32 %145, %139
  %147 = add i32 %146, %141
  %148 = load i32, ptr getelementptr inbounds (i8, ptr @ll, i64 4), align 4, !tbaa !5
  %.not56 = icmp sgt i32 %147, %148
  br i1 %.not56, label %153, label %149

149:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %150 = add i32 %146, %.pre-phi103
  store i32 %150, ptr %7, align 4, !tbaa !5
  %151 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %152 = load i32, ptr %151, align 4, !tbaa !5
  store i32 %152, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  %.pre84 = load i32, ptr @st, align 16, !tbaa !5
  %.pre86 = load i32, ptr getelementptr inbounds (i8, ptr @st, i64 4), align 4, !tbaa !5
  %.pre88 = load i32, ptr @ll, align 4, !tbaa !5
  br label %153

153:                                              ; preds = %130, %135, %149
  %154 = phi i32 [ %131, %130 ], [ %131, %135 ], [ %152, %149 ]
  %155 = phi i32 [ %132, %130 ], [ %132, %135 ], [ %.pre88, %149 ]
  %156 = phi i32 [ %133, %130 ], [ %133, %135 ], [ %.pre86, %149 ]
  %157 = phi i32 [ %134, %130 ], [ %134, %135 ], [ %.pre84, %149 ]
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %158 = load i32, ptr @n, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %.not52.not = icmp slt i64 %indvars.iv78, %159
  br i1 %.not52.not, label %99, label %._crit_edge72, !llvm.loop !20

160:                                              ; preds = %._crit_edge75, %84
  ret i32 0
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5 align 2

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

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

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10, !19}
!19 = !{!"llvm.loop.unswitch.partial.disable"}
!20 = distinct !{!20, !10}


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