; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/163 Division 2/Problem C (C)

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

@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@grid = external dso_local global [2001 x [2001 x i32]], align 16
@f = external dso_local global i32, align 4
@res = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 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 %"struct.std::pair", align 4
  %8 = alloca %"struct.std::pair.0", align 4
  %9 = alloca i32, align 4
  %10 = alloca { i64, i32 }, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::pair", align 4
  %15 = alloca %"struct.std::pair.0", align 4
  %16 = alloca i32, align 4
  %17 = alloca { i64, i32 }, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %34, %0
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %21
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @x, ptr noundef @y)
  %28 = load i32, ptr @x, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %29
  %31 = load i32, ptr @y, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2001 x i32], ptr %30, i64 0, i64 %32
  store i32 1, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %26
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !5
  br label %21, !llvm.loop !9

37:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %38

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

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

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

44:                                               ; preds = %108, %43
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = sub nsw i32 %46, %47
  %49 = add nsw i32 %48, 1
  %50 = icmp slt i32 %45, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %44
  store i32 8, ptr %4, align 4
  br label %111

52:                                               ; preds = %44
  store i32 0, ptr @f, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %72, %52
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sub nsw i32 %55, %56
  %58 = add nsw i32 %57, 1
  %59 = icmp sle i32 %54, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %53
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %75

61:                                               ; preds = %53
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %63
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [2001 x i32], ptr %64, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = icmp eq i32 %68, 1
  br i1 %69, label %70, label %71

70:                                               ; preds = %61
  store i32 1, ptr @f, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %70, %61
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %6, align 4, !tbaa !5
  br label %53, !llvm.loop !11

75:                                               ; preds = %60
  %76 = load i32, ptr @f, align 4, !tbaa !5
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %107

78:                                               ; preds = %75
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = sub nsw i32 %79, %80
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr @f, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 2, ptr %9, align 4, !tbaa !5
  %83 = 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) @f)
  store i64 %83, ptr %8, align 4
  %84 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiERiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store { i64, i32 } %84, ptr %10, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 8 %10, i64 12, i1 false)
  call void @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) @res, ptr noundef nonnull align 4 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %103, %78
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = icmp sle i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %106

90:                                               ; preds = %85
  %91 = load i32, ptr %11, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %92
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2001 x i32], ptr %93, i64 0, i64 %95
  %97 = load i32, ptr %11, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %98
  %100 = load i32, ptr @f, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [2001 x i32], ptr %99, i64 0, i64 %101
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %96, ptr noundef nonnull align 4 dereferenceable(4) %102) #7
  br label %103

103:                                              ; preds = %90
  %104 = load i32, ptr %11, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %11, align 4, !tbaa !5
  br label %85, !llvm.loop !12

106:                                              ; preds = %89
  store i32 8, ptr %4, align 4
  br label %111

107:                                              ; preds = %75
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %5, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %5, align 4, !tbaa !5
  br label %44, !llvm.loop !13

111:                                              ; preds = %106, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %112

112:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %113

113:                                              ; preds = %178, %112
  %114 = load i32, ptr %12, align 4, !tbaa !5
  %115 = load i32, ptr @n, align 4, !tbaa !5
  %116 = load i32, ptr %3, align 4, !tbaa !5
  %117 = sub nsw i32 %115, %116
  %118 = add nsw i32 %117, 1
  %119 = icmp slt i32 %114, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %113
  store i32 17, ptr %4, align 4
  br label %181

121:                                              ; preds = %113
  store i32 0, ptr @f, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %142, %121
  %123 = load i32, ptr %13, align 4, !tbaa !5
  %124 = load i32, ptr @n, align 4, !tbaa !5
  %125 = load i32, ptr %3, align 4, !tbaa !5
  %126 = sub nsw i32 %124, %125
  %127 = add nsw i32 %126, 1
  %128 = icmp sle i32 %123, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %122
  store i32 20, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %145

130:                                              ; preds = %122
  %131 = load i32, ptr %12, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %132
  %134 = load i32, ptr %13, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [2001 x i32], ptr %133, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = icmp eq i32 %137, 1
  br i1 %138, label %139, label %141

139:                                              ; preds = %130
  %140 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %140, ptr @f, align 4, !tbaa !5
  br label %141

141:                                              ; preds = %139, %130
  br label %142

142:                                              ; preds = %141
  %143 = load i32, ptr %13, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %13, align 4, !tbaa !5
  br label %122, !llvm.loop !14

145:                                              ; preds = %129
  %146 = load i32, ptr @f, align 4, !tbaa !5
  %147 = icmp sgt i32 %146, 0
  br i1 %147, label %148, label %177

148:                                              ; preds = %145
  %149 = load i32, ptr @n, align 4, !tbaa !5
  %150 = load i32, ptr %3, align 4, !tbaa !5
  %151 = sub nsw i32 %149, %150
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr @f, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 1, ptr %16, align 4, !tbaa !5
  %153 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) @f)
  store i64 %153, ptr %15, align 4
  %154 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiERiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(8) %15, ptr noundef nonnull align 4 dereferenceable(4) %12)
  store { i64, i32 } %154, ptr %17, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 8 %17, i64 12, i1 false)
  call void @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) @res, ptr noundef nonnull align 4 dereferenceable(12) %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store i32 1, ptr %18, align 4, !tbaa !5
  br label %155

155:                                              ; preds = %173, %148
  %156 = load i32, ptr %18, 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 23, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %176

160:                                              ; preds = %155
  %161 = load i32, ptr %12, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %162
  %164 = load i32, ptr %18, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [2001 x i32], ptr %163, i64 0, i64 %165
  %167 = load i32, ptr @f, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %168
  %170 = load i32, ptr %18, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [2001 x i32], ptr %169, i64 0, i64 %171
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %166, ptr noundef nonnull align 4 dereferenceable(4) %172) #7
  br label %173

173:                                              ; preds = %160
  %174 = load i32, ptr %18, align 4, !tbaa !5
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %18, align 4, !tbaa !5
  br label %155, !llvm.loop !15

176:                                              ; preds = %159
  store i32 17, ptr %4, align 4
  br label %181

177:                                              ; preds = %145
  br label %178

178:                                              ; preds = %177
  %179 = load i32, ptr %12, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %12, align 4, !tbaa !5
  br label %113, !llvm.loop !16

181:                                              ; preds = %176, %120
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %182

182:                                              ; preds = %181
  br label %183

183:                                              ; preds = %182
  %184 = load i32, ptr %3, align 4, !tbaa !5
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %3, align 4, !tbaa !5
  br label %38, !llvm.loop !17

186:                                              ; preds = %42
  %187 = call noundef i64 @_ZNKSt6vectorISt4pairIS0_IiiEiESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @res) #7
  %188 = trunc i64 %187 to i32
  %189 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %188)
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %190

190:                                              ; preds = %215, %186
  %191 = load i32, ptr %19, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = call noundef i64 @_ZNKSt6vectorISt4pairIS0_IiiEiESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @res) #7
  %194 = icmp ult i64 %192, %193
  br i1 %194, label %196, label %195

195:                                              ; preds = %190
  store i32 26, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %218

196:                                              ; preds = %190
  %197 = load i32, ptr %19, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @res, i64 noundef %198) #7
  %200 = getelementptr inbounds %"struct.std::pair", ptr %199, i32 0, i32 0
  %201 = getelementptr inbounds %"struct.std::pair.0", ptr %200, i32 0, i32 0
  %202 = load i32, ptr %201, align 4, !tbaa !18
  %203 = load i32, ptr %19, align 4, !tbaa !5
  %204 = sext i32 %203 to i64
  %205 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @res, i64 noundef %204) #7
  %206 = getelementptr inbounds %"struct.std::pair", ptr %205, i32 0, i32 0
  %207 = getelementptr inbounds %"struct.std::pair.0", ptr %206, i32 0, i32 1
  %208 = load i32, ptr %207, align 4, !tbaa !21
  %209 = load i32, ptr %19, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @res, i64 noundef %210) #7
  %212 = getelementptr inbounds %"struct.std::pair", ptr %211, i32 0, i32 1
  %213 = load i32, ptr %212, align 4, !tbaa !22
  %214 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %202, i32 noundef %208, i32 noundef %213)
  br label %215

215:                                              ; preds = %196
  %216 = load i32, ptr %19, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr %19, align 4, !tbaa !5
  br label %190, !llvm.loop !23

218:                                              ; preds = %195
  ret i32 0
}

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #6 align 2

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: readwrite) }
attributes #5 = { 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 #6 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = !{!19, !6, i64 0}
!19 = !{!"_ZTSSt4pairIS_IiiEiE", !20, i64 0, !6, i64 8}
!20 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!21 = !{!19, !6, i64 4}
!22 = !{!19, !6, i64 8}
!23 = distinct !{!23, !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<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { %"struct.std::pair.0", i32 }
%"struct.std::pair.0" = type { i32, i32 }

@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@grid = external dso_local global [2001 x [2001 x i32]], align 16
@f = external dso_local global i32, align 4
@res = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 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 %"struct.std::pair", align 8
  %3 = alloca %"struct.std::pair.0", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca %"struct.std::pair.0", align 8
  %8 = alloca i32, align 4
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 1
  br i1 %11, label %.lr.ph, label %._crit_edge101

.preheader:                                       ; preds = %.lr.ph
  %12 = icmp sgt i32 %20, 1
  br i1 %12, label %.lr.ph100, label %._crit_edge101

.lr.ph100:                                        ; preds = %.preheader
  %.sroa.219.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  br label %26

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.03452 = phi i32 [ %19, %.lr.ph ], [ 1, %0 ]
  %13 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %14 = load i32, ptr @x, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = load i32, ptr @y, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %15, i64 %17
  store i32 1, ptr %18, align 4, !tbaa !5
  %19 = add nuw nsw i32 %.03452, 1
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge101:                                   ; preds = %.loopexit, %0, %.preheader
  %22 = call noundef i64 @_ZNKSt6vectorISt4pairIS0_IiiEiESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @res) #6
  %23 = trunc i64 %22 to i32
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %23)
  %25 = call noundef i64 @_ZNKSt6vectorISt4pairIS0_IiiEiESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @res) #6
  %.not = icmp eq i64 %25, 0
  br i1 %.not, label %._crit_edge105, label %.lr.ph104

26:                                               ; preds = %.lr.ph100, %.loopexit
  %27 = phi i32 [ %20, %.lr.ph100 ], [ %120, %.loopexit ]
  %indvars.iv116 = phi i32 [ 0, %.lr.ph100 ], [ %indvars.iv.next117, %.loopexit ]
  %.03599 = phi i32 [ 1, %.lr.ph100 ], [ %121, %.loopexit ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %28 = sub nsw i32 %27, %.03599
  %.not57 = icmp slt i32 %28, 1
  br i1 %.not57, label %.loopexit49, label %.lr.ph60

.lr.ph60:                                         ; preds = %26
  %29 = add nuw nsw i32 %28, 1
  %30 = zext nneg i32 %28 to i64
  %31 = add i32 %27, %indvars.iv116
  %wide.trip.count = zext i32 %31 to i64
  %32 = add nuw nsw i64 %30, 1
  %min.iters.check153 = icmp ult i32 %28, 7
  %n.vec156 = and i64 %32, 4294967288
  %ind.end157 = or disjoint i64 %n.vec156, 1
  %cmp.n167 = icmp eq i64 %32, %n.vec156
  br label %.lr.ph55

.lr.ph55:                                         ; preds = %.lr.ph60, %87
  %indvars.iv113 = phi i64 [ 1, %.lr.ph60 ], [ %indvars.iv.next114, %87 ]
  br i1 %min.iters.check153, label %scalar.ph152.preheader, label %vector.body159

scalar.ph152.preheader:                           ; preds = %middle.block151, %.lr.ph55
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph55 ], [ %ind.end157, %middle.block151 ]
  %.ph171 = phi i32 [ 0, %.lr.ph55 ], [ %rdx.select166, %middle.block151 ]
  br label %scalar.ph152

vector.body159:                                   ; preds = %.lr.ph55, %vector.body159
  %index160 = phi i64 [ %index.next164, %vector.body159 ], [ 0, %.lr.ph55 ]
  %vec.phi161 = phi <4 x i1> [ %66, %vector.body159 ], [ zeroinitializer, %.lr.ph55 ]
  %vec.phi162 = phi <4 x i1> [ %67, %vector.body159 ], [ zeroinitializer, %.lr.ph55 ]
  %offset.idx163 = or disjoint i64 %index160, 1
  %33 = or disjoint i64 %index160, 2
  %34 = or disjoint i64 %index160, 3
  %35 = or disjoint i64 %index160, 4
  %36 = or disjoint i64 %index160, 5
  %37 = or disjoint i64 %index160, 6
  %38 = or disjoint i64 %index160, 7
  %39 = add i64 %index160, 8
  %40 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %offset.idx163, i64 %indvars.iv113
  %41 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %33, i64 %indvars.iv113
  %42 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %34, i64 %indvars.iv113
  %43 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %35, i64 %indvars.iv113
  %44 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %36, i64 %indvars.iv113
  %45 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %37, i64 %indvars.iv113
  %46 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %38, i64 %indvars.iv113
  %47 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %39, i64 %indvars.iv113
  %48 = load i32, ptr %40, align 4, !tbaa !5
  %49 = load i32, ptr %41, align 4, !tbaa !5
  %50 = load i32, ptr %42, align 4, !tbaa !5
  %51 = load i32, ptr %43, align 4, !tbaa !5
  %52 = insertelement <4 x i32> poison, i32 %48, i64 0
  %53 = insertelement <4 x i32> %52, i32 %49, i64 1
  %54 = insertelement <4 x i32> %53, i32 %50, i64 2
  %55 = insertelement <4 x i32> %54, i32 %51, i64 3
  %56 = load i32, ptr %44, align 4, !tbaa !5
  %57 = load i32, ptr %45, align 4, !tbaa !5
  %58 = load i32, ptr %46, align 4, !tbaa !5
  %59 = load i32, ptr %47, align 4, !tbaa !5
  %60 = insertelement <4 x i32> poison, i32 %56, i64 0
  %61 = insertelement <4 x i32> %60, i32 %57, i64 1
  %62 = insertelement <4 x i32> %61, i32 %58, i64 2
  %63 = insertelement <4 x i32> %62, i32 %59, i64 3
  %64 = icmp eq <4 x i32> %55, <i32 1, i32 1, i32 1, i32 1>
  %65 = icmp eq <4 x i32> %63, <i32 1, i32 1, i32 1, i32 1>
  %66 = or <4 x i1> %vec.phi161, %64
  %67 = or <4 x i1> %vec.phi162, %65
  %index.next164 = add nuw i64 %index160, 8
  %68 = icmp eq i64 %index.next164, %n.vec156
  br i1 %68, label %middle.block151, label %vector.body159, !llvm.loop !11

middle.block151:                                  ; preds = %vector.body159
  %bin.rdx165 = or <4 x i1> %67, %66
  %bin.rdx165.fr = freeze <4 x i1> %bin.rdx165
  %69 = bitcast <4 x i1> %bin.rdx165.fr to i4
  %.not169 = icmp ne i4 %69, 0
  %rdx.select166 = zext i1 %.not169 to i32
  br i1 %cmp.n167, label %._crit_edge, label %scalar.ph152.preheader

._crit_edge:                                      ; preds = %scalar.ph152, %middle.block151
  %spec.select.lcssa = phi i32 [ %rdx.select166, %middle.block151 ], [ %spec.select, %scalar.ph152 ]
  %70 = icmp eq i32 %spec.select.lcssa, 0
  br i1 %70, label %.split, label %87

scalar.ph152:                                     ; preds = %scalar.ph152.preheader, %scalar.ph152
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph152 ], [ %indvars.iv.ph, %scalar.ph152.preheader ]
  %71 = phi i32 [ %spec.select, %scalar.ph152 ], [ %.ph171, %scalar.ph152.preheader ]
  %72 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %indvars.iv, i64 %indvars.iv113
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = icmp eq i32 %73, 1
  %spec.select = select i1 %74, i32 1, i32 %71
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not42 = icmp ugt i64 %indvars.iv, %30
  br i1 %.not42, label %._crit_edge, label %scalar.ph152, !llvm.loop !14

.split:                                           ; preds = %._crit_edge
  %75 = trunc nuw nsw i64 %indvars.iv113 to i32
  store i32 %75, ptr %1, align 4, !tbaa !5
  store i32 %29, ptr @f, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  store i32 2, ptr %4, align 4, !tbaa !5
  %76 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__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) @f)
  store i64 %76, ptr %3, align 8
  %77 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiERiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %.fca.0.extract16 = extractvalue { i64, i32 } %77, 0
  %.fca.1.extract17 = extractvalue { i64, i32 } %77, 1
  store i64 %.fca.0.extract16, ptr %2, align 8
  store i32 %.fca.1.extract17, ptr %.sroa.219.0..sroa_idx, align 8
  call void @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) @res, ptr noundef nonnull align 4 dereferenceable(12) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #6
  %78 = load i32, ptr @n, align 4, !tbaa !5
  %.not4368 = icmp slt i32 %78, 1
  br i1 %.not4368, label %.loopexit49, label %.lr.ph71

.lr.ph71:                                         ; preds = %.split, %.lr.ph71
  %indvars.iv118 = phi i64 [ %indvars.iv.next119, %.lr.ph71 ], [ 1, %.split ]
  %79 = load i32, ptr %1, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %indvars.iv118, i64 %80
  %82 = load i32, ptr @f, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %indvars.iv118, i64 %83
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %81, ptr noundef nonnull align 4 dereferenceable(4) %84) #6
  %indvars.iv.next119 = add nuw nsw i64 %indvars.iv118, 1
  %85 = load i32, ptr @n, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %.not43.not = icmp slt i64 %indvars.iv118, %86
  br i1 %.not43.not, label %.lr.ph71, label %.loopexit49, !llvm.loop !15

87:                                               ; preds = %._crit_edge
  %indvars.iv.next114 = add nuw nsw i64 %indvars.iv113, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next114, %wide.trip.count
  br i1 %exitcond.not, label %..loopexit50_crit_edge.split, label %.lr.ph55, !llvm.loop !16

..loopexit50_crit_edge.split:                     ; preds = %87
  store i32 %spec.select.lcssa, ptr @f, align 4, !tbaa !5
  br label %.loopexit49

.loopexit49:                                      ; preds = %.lr.ph71, %26, %..loopexit50_crit_edge.split, %.split
  %88 = phi i32 [ %78, %.split ], [ %27, %..loopexit50_crit_edge.split ], [ %27, %26 ], [ %85, %.lr.ph71 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  %89 = sub nsw i32 %88, %.03599
  %.not4580 = icmp slt i32 %89, 1
  br i1 %.not4580, label %.loopexit, label %.lr.ph83

.lr.ph83:                                         ; preds = %.loopexit49
  %90 = add nuw nsw i32 %89, 1
  %91 = zext nneg i32 %89 to i64
  %92 = add i32 %88, %indvars.iv116
  %wide.trip.count127 = zext i32 %92 to i64
  %93 = add nuw nsw i64 %91, 1
  %min.iters.check = icmp ult i32 %89, 7
  %n.vec = and i64 %93, 4294967288
  %ind.end = or disjoint i64 %n.vec, 1
  %cmp.n = icmp eq i64 %93, %n.vec
  br label %.lr.ph75

.lr.ph75:                                         ; preds = %.lr.ph83, %119
  %indvars.iv124 = phi i64 [ 1, %.lr.ph83 ], [ %indvars.iv.next125, %119 ]
  %94 = trunc nuw nsw i64 %indvars.iv124 to i32
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph75
  %indvars.iv121.ph = phi i64 [ 1, %.lr.ph75 ], [ %ind.end, %middle.block ]
  %.ph = phi i32 [ 0, %.lr.ph75 ], [ %rdx.select, %middle.block ]
  br label %scalar.ph

vector.body:                                      ; preds = %.lr.ph75, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.lr.ph75 ]
  %vec.phi = phi <4 x i1> [ %99, %vector.body ], [ zeroinitializer, %.lr.ph75 ]
  %vec.phi149 = phi <4 x i1> [ %100, %vector.body ], [ zeroinitializer, %.lr.ph75 ]
  %offset.idx = or disjoint i64 %index, 1
  %95 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %indvars.iv124, i64 %offset.idx
  %96 = getelementptr inbounds i8, ptr %95, i64 16
  %wide.load = load <4 x i32>, ptr %95, align 4, !tbaa !5
  %wide.load150 = load <4 x i32>, ptr %96, align 4, !tbaa !5
  %97 = icmp eq <4 x i32> %wide.load, <i32 1, i32 1, i32 1, i32 1>
  %98 = icmp eq <4 x i32> %wide.load150, <i32 1, i32 1, i32 1, i32 1>
  %99 = or <4 x i1> %vec.phi, %97
  %100 = or <4 x i1> %vec.phi149, %98
  %index.next = add nuw i64 %index, 8
  %101 = icmp eq i64 %index.next, %n.vec
  br i1 %101, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %bin.rdx = or <4 x i1> %100, %99
  %bin.rdx.fr = freeze <4 x i1> %bin.rdx
  %102 = bitcast <4 x i1> %bin.rdx.fr to i4
  %.not170 = icmp eq i4 %102, 0
  %rdx.select = select i1 %.not170, i32 0, i32 %94
  br i1 %cmp.n, label %._crit_edge76, label %scalar.ph.preheader

._crit_edge76:                                    ; preds = %scalar.ph, %middle.block
  %spec.select106.lcssa = phi i32 [ %rdx.select, %middle.block ], [ %spec.select106, %scalar.ph ]
  %103 = icmp sgt i32 %spec.select106.lcssa, 0
  br i1 %103, label %.split89, label %119

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv121 = phi i64 [ %indvars.iv.next122, %scalar.ph ], [ %indvars.iv121.ph, %scalar.ph.preheader ]
  %104 = phi i32 [ %spec.select106, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %105 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %indvars.iv124, i64 %indvars.iv121
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = icmp eq i32 %106, 1
  %spec.select106 = select i1 %107, i32 %94, i32 %104
  %indvars.iv.next122 = add nuw nsw i64 %indvars.iv121, 1
  %.not46 = icmp ugt i64 %indvars.iv121, %91
  br i1 %.not46, label %._crit_edge76, label %scalar.ph, !llvm.loop !18

.split89:                                         ; preds = %._crit_edge76
  store i32 %94, ptr %5, align 4, !tbaa !5
  store i32 %90, ptr @f, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  store i32 1, ptr %8, align 4, !tbaa !5
  %108 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) @f)
  store i64 %108, ptr %7, align 8
  %109 = call { i64, i32 } @_ZSt9make_pairISt4pairIiiERiES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %.fca.0.extract = extractvalue { i64, i32 } %109, 0
  %.fca.1.extract = extractvalue { i64, i32 } %109, 1
  store i64 %.fca.0.extract, ptr %6, align 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  call void @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EE9push_backEOS2_(ptr noundef nonnull align 8 dereferenceable(24) @res, ptr noundef nonnull align 4 dereferenceable(12) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #6
  %110 = load i32, ptr @n, align 4, !tbaa !5
  %.not4795 = icmp slt i32 %110, 1
  br i1 %.not4795, label %.loopexit, label %.lr.ph98

.lr.ph98:                                         ; preds = %.split89, %.lr.ph98
  %indvars.iv129 = phi i64 [ %indvars.iv.next130, %.lr.ph98 ], [ 1, %.split89 ]
  %111 = load i32, ptr %5, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %112, i64 %indvars.iv129
  %114 = load i32, ptr @f, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [2001 x [2001 x i32]], ptr @grid, i64 0, i64 %115, i64 %indvars.iv129
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %113, ptr noundef nonnull align 4 dereferenceable(4) %116) #6
  %indvars.iv.next130 = add nuw nsw i64 %indvars.iv129, 1
  %117 = load i32, ptr @n, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %.not47.not = icmp slt i64 %indvars.iv129, %118
  br i1 %.not47.not, label %.lr.ph98, label %.loopexit, !llvm.loop !19

119:                                              ; preds = %._crit_edge76
  %indvars.iv.next125 = add nuw nsw i64 %indvars.iv124, 1
  %exitcond128.not = icmp eq i64 %indvars.iv.next125, %wide.trip.count127
  br i1 %exitcond128.not, label %..loopexit48_crit_edge.split, label %.lr.ph75, !llvm.loop !20

..loopexit48_crit_edge.split:                     ; preds = %119
  store i32 %spec.select106.lcssa, ptr @f, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph98, %.loopexit49, %..loopexit48_crit_edge.split, %.split89
  %120 = phi i32 [ %110, %.split89 ], [ %88, %..loopexit48_crit_edge.split ], [ %88, %.loopexit49 ], [ %117, %.lr.ph98 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  %121 = add nuw nsw i32 %.03599, 1
  %122 = icmp slt i32 %121, %120
  %indvars.iv.next117 = add nsw i32 %indvars.iv116, -1
  br i1 %122, label %26, label %._crit_edge101, !llvm.loop !21

._crit_edge105:                                   ; preds = %.lr.ph104, %._crit_edge101
  ret i32 0

.lr.ph104:                                        ; preds = %._crit_edge101, %.lr.ph104
  %indvars.iv132 = phi i64 [ %indvars.iv.next133, %.lr.ph104 ], [ 0, %._crit_edge101 ]
  %123 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @res, i64 noundef %indvars.iv132) #6
  %124 = load i32, ptr %123, align 4, !tbaa !22
  %125 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @res, i64 noundef %indvars.iv132) #6
  %126 = getelementptr inbounds i8, ptr %125, i64 4
  %127 = load i32, ptr %126, align 4, !tbaa !25
  %128 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @res, i64 noundef %indvars.iv132) #6
  %129 = getelementptr inbounds i8, ptr %128, i64 8
  %130 = load i32, ptr %129, align 4, !tbaa !26
  %131 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %124, i32 noundef %127, i32 noundef %130)
  %indvars.iv.next133 = add nuw nsw i64 %indvars.iv132, 1
  %132 = call noundef i64 @_ZNKSt6vectorISt4pairIS0_IiiEiESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @res) #6
  %133 = icmp ugt i64 %132, %indvars.iv.next133
  br i1 %133, label %.lr.ph104, label %._crit_edge105, !llvm.loop !27
}

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorISt4pairIS0_IiiEiESaIS2_EE4sizeEv(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(12) ptr @_ZNSt6vectorISt4pairIS0_IiiEiESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #5 align 2

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 = { 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 #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 = { 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 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10, !13, !12}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !12, !13}
!18 = distinct !{!18, !10, !13, !12}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = !{!23, !6, i64 0}
!23 = !{!"_ZTSSt4pairIS_IiiEiE", !24, i64 0, !6, i64 8}
!24 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!25 = !{!23, !6, i64 4}
!26 = !{!23, !6, i64 8}
!27 = distinct !{!27, !10}


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