; LLVM IR from Tunghohin/Competitive_Coding :: Codeforces/cf1695_C.ll (Z5solvev)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@mp = external dso_local global [1010 x [1010 x i32]], align 16
@min_path = external dso_local global [1010 x [1010 x i32]], align 16
@max_path = external dso_local global [1010 x [1010 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %33, %0
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = icmp sle i32 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %36

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

16:                                               ; preds = %29, %15
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %32

21:                                               ; preds = %16
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %23
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1010 x i32], ptr %24, i64 0, i64 %26
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %27)
  br label %29

29:                                               ; preds = %21
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %5, align 4, !tbaa !5
  br label %16, !llvm.loop !9

32:                                               ; preds = %20
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !5
  br label %10, !llvm.loop !11

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

37:                                               ; preds = %211, %36
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = icmp sle i32 %38, %39
  br i1 %40, label %42, label %41

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

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

43:                                               ; preds = %207, %42
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = icmp sle i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %210

48:                                               ; preds = %43
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 1
  br i1 %50, label %51, label %96

51:                                               ; preds = %48
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %53
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [1010 x i32], ptr %54, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %61
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [1010 x i32], ptr %62, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = add nsw i32 %59, %66
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %69
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1010 x i32], ptr %70, i64 0, i64 %72
  store i32 %67, ptr %73, align 4, !tbaa !5
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %75
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = sub nsw i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1010 x i32], ptr %76, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %83
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1010 x i32], ptr %84, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = add nsw i32 %81, %88
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %91
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [1010 x i32], ptr %92, i64 0, i64 %94
  store i32 %89, ptr %95, align 4, !tbaa !5
  br label %206

96:                                               ; preds = %48
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = icmp eq i32 %97, 1
  br i1 %98, label %99, label %144

99:                                               ; preds = %96
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = sub nsw i32 %100, 1
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %102
  %104 = load i32, ptr %7, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1010 x i32], ptr %103, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = load i32, ptr %6, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %109
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [1010 x i32], ptr %110, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = add nsw i32 %107, %114
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %117
  %119 = load i32, ptr %7, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [1010 x i32], ptr %118, i64 0, i64 %120
  store i32 %115, ptr %121, align 4, !tbaa !5
  %122 = load i32, ptr %6, align 4, !tbaa !5
  %123 = sub nsw i32 %122, 1
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %124
  %126 = load i32, ptr %7, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1010 x i32], ptr %125, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %131
  %133 = load i32, ptr %7, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1010 x i32], ptr %132, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = add nsw i32 %129, %136
  %138 = load i32, ptr %6, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %139
  %141 = load i32, ptr %7, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [1010 x i32], ptr %140, i64 0, i64 %142
  store i32 %137, ptr %143, align 4, !tbaa !5
  br label %205

144:                                              ; preds = %96
  %145 = load i32, ptr %6, align 4, !tbaa !5
  %146 = sub nsw i32 %145, 1
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %147
  %149 = load i32, ptr %7, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [1010 x i32], ptr %148, i64 0, i64 %150
  %152 = load i32, ptr %6, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %153
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = sub nsw i32 %155, 1
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [1010 x i32], ptr %154, i64 0, i64 %157
  %159 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %151, ptr noundef nonnull align 4 dereferenceable(4) %158)
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = load i32, ptr %6, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %162
  %164 = load i32, ptr %7, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [1010 x i32], ptr %163, i64 0, i64 %165
  %167 = load i32, ptr %166, align 4, !tbaa !5
  %168 = add nsw i32 %160, %167
  %169 = load i32, ptr %6, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %170
  %172 = load i32, ptr %7, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [1010 x i32], ptr %171, i64 0, i64 %173
  store i32 %168, ptr %174, align 4, !tbaa !5
  %175 = load i32, ptr %6, align 4, !tbaa !5
  %176 = sub nsw i32 %175, 1
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %177
  %179 = load i32, ptr %7, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [1010 x i32], ptr %178, i64 0, i64 %180
  %182 = load i32, ptr %6, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %183
  %185 = load i32, ptr %7, align 4, !tbaa !5
  %186 = sub nsw i32 %185, 1
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [1010 x i32], ptr %184, i64 0, i64 %187
  %189 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %181, ptr noundef nonnull align 4 dereferenceable(4) %188)
  %190 = load i32, ptr %189, align 4, !tbaa !5
  %191 = load i32, ptr %6, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %192
  %194 = load i32, ptr %7, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [1010 x i32], ptr %193, i64 0, i64 %195
  %197 = load i32, ptr %196, align 4, !tbaa !5
  %198 = add nsw i32 %190, %197
  %199 = load i32, ptr %6, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %200
  %202 = load i32, ptr %7, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [1010 x i32], ptr %201, i64 0, i64 %203
  store i32 %198, ptr %204, align 4, !tbaa !5
  br label %205

205:                                              ; preds = %144, %99
  br label %206

206:                                              ; preds = %205, %51
  br label %207

207:                                              ; preds = %206
  %208 = load i32, ptr %7, align 4, !tbaa !5
  %209 = add nsw i32 %208, 1
  store i32 %209, ptr %7, align 4, !tbaa !5
  br label %43, !llvm.loop !12

210:                                              ; preds = %47
  br label %211

211:                                              ; preds = %210
  %212 = load i32, ptr %6, align 4, !tbaa !5
  %213 = add nsw i32 %212, 1
  store i32 %213, ptr %6, align 4, !tbaa !5
  br label %37, !llvm.loop !13

214:                                              ; preds = %41
  %215 = load i32, ptr %1, align 4, !tbaa !5
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %216
  %218 = load i32, ptr %2, align 4, !tbaa !5
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [1010 x i32], ptr %217, i64 0, i64 %219
  %221 = load i32, ptr %220, align 4, !tbaa !5
  %222 = srem i32 %221, 2
  %223 = icmp eq i32 %222, 1
  br i1 %223, label %242, label %224

224:                                              ; preds = %214
  %225 = load i32, ptr %1, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %226
  %228 = load i32, ptr %2, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [1010 x i32], ptr %227, i64 0, i64 %229
  %231 = load i32, ptr %230, align 4, !tbaa !5
  %232 = icmp slt i32 %231, 0
  br i1 %232, label %242, label %233

233:                                              ; preds = %224
  %234 = load i32, ptr %1, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %235
  %237 = load i32, ptr %2, align 4, !tbaa !5
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [1010 x i32], ptr %236, i64 0, i64 %238
  %240 = load i32, ptr %239, align 4, !tbaa !5
  %241 = icmp sgt i32 %240, 0
  br i1 %241, label %242, label %244

242:                                              ; preds = %233, %224, %214
  %243 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  br label %246

244:                                              ; preds = %233
  %245 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  br label %246

246:                                              ; preds = %244, %242
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

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

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

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

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

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

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@mp = external dso_local global [1010 x [1010 x i32]], align 16
@min_path = external dso_local global [1010 x [1010 x i32]], align 16
@max_path = external dso_local global [1010 x [1010 x i32]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %.not63 = icmp slt i32 %5, 1
  %.pre94.pre = load i32, ptr %2, align 4, !tbaa !5
  %6 = icmp slt i32 %.pre94.pre, 1
  %or.cond112 = select i1 %.not63, i1 true, i1 %6
  br i1 %or.cond112, label %._crit_edge71, label %.preheader60

.preheader60:                                     ; preds = %0, %._crit_edge
  %7 = phi i32 [ %10, %._crit_edge ], [ %5, %0 ]
  %8 = phi i32 [ %11, %._crit_edge ], [ %.pre94.pre, %0 ]
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %._crit_edge ], [ 1, %0 ]
  %.not5861 = icmp slt i32 %8, 1
  br i1 %.not5861, label %._crit_edge, label %.lr.ph

.preheader59:                                     ; preds = %._crit_edge
  %.not5669 = icmp slt i32 %10, 1
  %9 = icmp slt i32 %11, 1
  %or.cond113 = or i1 %.not5669, %9
  br i1 %or.cond113, label %._crit_edge71, label %.preheader

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader60
  %10 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %7, %.preheader60 ]
  %11 = phi i32 [ %15, %._crit_edge.loopexit ], [ %8, %.preheader60 ]
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %12 = sext i32 %10 to i64
  %.not.not = icmp slt i64 %indvars.iv77, %12
  br i1 %.not.not, label %.preheader60, label %.preheader59, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader60, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.preheader60 ]
  %13 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %indvars.iv77, i64 %indvars.iv
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %.not58.not = icmp slt i64 %indvars.iv, %16
  br i1 %.not58.not, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !12

.preheader:                                       ; preds = %.preheader59, %._crit_edge68
  %.pre9396 = phi i32 [ %.pre9397, %._crit_edge68 ], [ %10, %.preheader59 ]
  %17 = phi i32 [ %65, %._crit_edge68 ], [ %10, %.preheader59 ]
  %18 = phi i32 [ %66, %._crit_edge68 ], [ %11, %.preheader59 ]
  %19 = phi i32 [ %67, %._crit_edge68 ], [ %11, %.preheader59 ]
  %20 = phi i32 [ %68, %._crit_edge68 ], [ %11, %.preheader59 ]
  %indvars.iv87 = phi i64 [ %indvars.iv.next88, %._crit_edge68 ], [ 1, %.preheader59 ]
  %.not5765 = icmp slt i32 %20, 1
  br i1 %.not5765, label %._crit_edge68, label %.lr.ph67

.lr.ph67:                                         ; preds = %.preheader
  %21 = icmp eq i64 %indvars.iv87, 1
  %22 = add nsw i64 %indvars.iv87, -1
  br i1 %21, label %.lr.ph67.split.us, label %23

23:                                               ; preds = %.lr.ph67
  %24 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %indvars.iv87, i64 1
  %25 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %22, i64 1
  %26 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %indvars.iv87, i64 1
  %27 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %indvars.iv87, i64 1
  %28 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %22, i64 1
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr %27, align 4, !tbaa !5
  %31 = add nsw i32 %30, %29
  store i32 %31, ptr %26, align 4, !tbaa !5
  %32 = load i32, ptr %25, align 4, !tbaa !5
  %33 = add nsw i32 %32, %30
  store i32 %33, ptr %24, align 4, !tbaa !5
  %.not57.not.peel = icmp sgt i32 %19, 1
  br i1 %.not57.not.peel, label %.lr.ph67.split.peel.next, label %._crit_edge68

.lr.ph67.split.us:                                ; preds = %.lr.ph67
  %smax = call i32 @llvm.smax.i32(i32 %18, i32 1)
  %.pre91 = load i32, ptr getelementptr inbounds (i8, ptr @max_path, i64 4040), align 8, !tbaa !5
  %.pre92 = load i32, ptr getelementptr inbounds (i8, ptr @min_path, i64 4040), align 8, !tbaa !5
  %34 = zext nneg i32 %smax to i64
  %xtraiter = and i64 %34, 1
  %35 = icmp slt i32 %18, 2
  br i1 %35, label %._crit_edge68.loopexit.unr-lcssa, label %.lr.ph67.split.us.new

.lr.ph67.split.us.new:                            ; preds = %.lr.ph67.split.us
  %unroll_iter = and i64 %34, 2147483646
  br label %36

36:                                               ; preds = %36, %.lr.ph67.split.us.new
  %37 = phi i32 [ %.pre92, %.lr.ph67.split.us.new ], [ %49, %36 ]
  %38 = phi i32 [ %.pre91, %.lr.ph67.split.us.new ], [ %47, %36 ]
  %indvars.iv84 = phi i64 [ 1, %.lr.ph67.split.us.new ], [ %indvars.iv.next85.1, %36 ]
  %niter = phi i64 [ 0, %.lr.ph67.split.us.new ], [ %niter.next.1, %36 ]
  %39 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @mp, i64 4040), i64 0, i64 %indvars.iv84
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = add nsw i32 %40, %38
  %42 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @max_path, i64 4040), i64 0, i64 %indvars.iv84
  store i32 %41, ptr %42, align 4, !tbaa !5
  %43 = add nsw i32 %37, %40
  %44 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @min_path, i64 4040), i64 0, i64 %indvars.iv84
  store i32 %43, ptr %44, align 4, !tbaa !5
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %45 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @mp, i64 4040), i64 0, i64 %indvars.iv.next85
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = add nsw i32 %46, %41
  %48 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @max_path, i64 4040), i64 0, i64 %indvars.iv.next85
  store i32 %47, ptr %48, align 4, !tbaa !5
  %49 = add nsw i32 %43, %46
  %50 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @min_path, i64 4040), i64 0, i64 %indvars.iv.next85
  store i32 %49, ptr %50, align 4, !tbaa !5
  %indvars.iv.next85.1 = add nuw nsw i64 %indvars.iv84, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge68.loopexit.unr-lcssa, label %36, !llvm.loop !13

._crit_edge71:                                    ; preds = %._crit_edge68, %0, %.preheader59
  %51 = phi i32 [ %11, %.preheader59 ], [ %.pre94.pre, %0 ], [ %66, %._crit_edge68 ]
  %.lcssa = phi i32 [ %10, %.preheader59 ], [ %5, %0 ], [ %65, %._crit_edge68 ]
  %52 = sext i32 %.lcssa to i64
  %53 = sext i32 %51 to i64
  %54 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %52, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = and i32 %55, -2147483647
  %57 = icmp eq i32 %56, 1
  %58 = icmp slt i32 %55, 0
  %or.cond = or i1 %58, %57
  br i1 %or.cond, label %91, label %87

._crit_edge68.loopexit72.loopexit:                ; preds = %.lr.ph67.split.peel.next
  %.pre93.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %._crit_edge68

._crit_edge68.loopexit.unr-lcssa:                 ; preds = %36, %.lr.ph67.split.us
  %.unr = phi i32 [ %.pre92, %.lr.ph67.split.us ], [ %49, %36 ]
  %.unr124 = phi i32 [ %.pre91, %.lr.ph67.split.us ], [ %47, %36 ]
  %indvars.iv84.unr = phi i64 [ 1, %.lr.ph67.split.us ], [ %indvars.iv.next85.1, %36 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge68, label %._crit_edge68.loopexit.epilog-lcssa

._crit_edge68.loopexit.epilog-lcssa:              ; preds = %._crit_edge68.loopexit.unr-lcssa
  %59 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @mp, i64 4040), i64 0, i64 %indvars.iv84.unr
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = add nsw i32 %60, %.unr124
  %62 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @max_path, i64 4040), i64 0, i64 %indvars.iv84.unr
  store i32 %61, ptr %62, align 4, !tbaa !5
  %63 = add nsw i32 %.unr, %60
  %64 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @min_path, i64 4040), i64 0, i64 %indvars.iv84.unr
  store i32 %63, ptr %64, align 4, !tbaa !5
  br label %._crit_edge68

._crit_edge68:                                    ; preds = %._crit_edge68.loopexit.epilog-lcssa, %._crit_edge68.loopexit.unr-lcssa, %23, %._crit_edge68.loopexit72.loopexit, %.preheader
  %.pre9397 = phi i32 [ %.pre9396, %.preheader ], [ %.pre93.pre, %._crit_edge68.loopexit72.loopexit ], [ %.pre9396, %23 ], [ %.pre9396, %._crit_edge68.loopexit.unr-lcssa ], [ %.pre9396, %._crit_edge68.loopexit.epilog-lcssa ]
  %65 = phi i32 [ %17, %.preheader ], [ %.pre93.pre, %._crit_edge68.loopexit72.loopexit ], [ %.pre9396, %23 ], [ %17, %._crit_edge68.loopexit.unr-lcssa ], [ %17, %._crit_edge68.loopexit.epilog-lcssa ]
  %66 = phi i32 [ %18, %.preheader ], [ %.pre90, %._crit_edge68.loopexit72.loopexit ], [ %18, %23 ], [ %18, %._crit_edge68.loopexit.unr-lcssa ], [ %18, %._crit_edge68.loopexit.epilog-lcssa ]
  %67 = phi i32 [ %19, %.preheader ], [ %.pre90, %._crit_edge68.loopexit72.loopexit ], [ %19, %23 ], [ %18, %._crit_edge68.loopexit.unr-lcssa ], [ %18, %._crit_edge68.loopexit.epilog-lcssa ]
  %68 = phi i32 [ %20, %.preheader ], [ %.pre90, %._crit_edge68.loopexit72.loopexit ], [ %19, %23 ], [ %18, %._crit_edge68.loopexit.unr-lcssa ], [ %18, %._crit_edge68.loopexit.epilog-lcssa ]
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %69 = sext i32 %65 to i64
  %.not56.not = icmp slt i64 %indvars.iv87, %69
  br i1 %.not56.not, label %.preheader, label %._crit_edge71, !llvm.loop !14

.lr.ph67.split.peel.next:                         ; preds = %23, %.lr.ph67.split.peel.next
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %.lr.ph67.split.peel.next ], [ 2, %23 ]
  %70 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %22, i64 %indvars.iv80
  %71 = add nsw i64 %indvars.iv80, -1
  %72 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %indvars.iv87, i64 %71
  %73 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %70, ptr noundef nonnull align 4 dereferenceable(4) %72)
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = getelementptr inbounds [1010 x [1010 x i32]], ptr @mp, i64 0, i64 %indvars.iv87, i64 %indvars.iv80
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = add nsw i32 %76, %74
  %78 = getelementptr inbounds [1010 x [1010 x i32]], ptr @max_path, i64 0, i64 %indvars.iv87, i64 %indvars.iv80
  store i32 %77, ptr %78, align 4, !tbaa !5
  %79 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %22, i64 %indvars.iv80
  %80 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %indvars.iv87, i64 %71
  %81 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %79, ptr noundef nonnull align 4 dereferenceable(4) %80)
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = load i32, ptr %75, align 4, !tbaa !5
  %84 = add nsw i32 %83, %82
  %85 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %indvars.iv87, i64 %indvars.iv80
  store i32 %84, ptr %85, align 4, !tbaa !5
  %.pre90 = load i32, ptr %2, align 4, !tbaa !5
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %86 = sext i32 %.pre90 to i64
  %.not57.not = icmp slt i64 %indvars.iv80, %86
  br i1 %.not57.not, label %.lr.ph67.split.peel.next, label %._crit_edge68.loopexit72.loopexit, !llvm.loop !15

87:                                               ; preds = %._crit_edge71
  %88 = getelementptr inbounds [1010 x [1010 x i32]], ptr @min_path, i64 0, i64 %52, i64 %53
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = icmp sgt i32 %89, 0
  %spec.select = select i1 %90, ptr @.str, ptr @.str.1
  br label %91

91:                                               ; preds = %87, %._crit_edge71
  %.str.1.sink = phi ptr [ @.str, %._crit_edge71 ], [ %spec.select, %87 ]
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull %.str.1.sink)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret void
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(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 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 #3

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

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

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

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

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


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