; LLVM IR from eyangch/competitive-programming :: USACOtraining/4.2 (ditch)

; 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" }

@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@cap = external dso_local global [210 x [210 x i64]], align 16
@vis = external dso_local global [210 x i8], align 16
@prevnode = external dso_local global [210 x i64], align 16
@flow = external dso_local global [210 x i64], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %15 = load ptr, ptr @stdin, align 8, !tbaa !5
  %16 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %15)
  %17 = load ptr, ptr @stdout, align 8, !tbaa !5
  %18 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %17)
  %19 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %20 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %21 = getelementptr i8, ptr %20, i64 -24
  %22 = load i64, ptr %21, align 8
  %23 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %22
  %24 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %23, ptr noundef null)
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(8) @M)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %45, %0
  %28 = load i64, ptr %2, align 8, !tbaa !11
  %29 = load i64, ptr @N, align 8, !tbaa !11
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %48

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %33, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %34, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %36 = load i64, ptr %5, align 8, !tbaa !11
  %37 = load i64, ptr %3, align 8, !tbaa !11
  %38 = sub nsw i64 %37, 1
  %39 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %38
  %40 = load i64, ptr %4, align 8, !tbaa !11
  %41 = sub nsw i64 %40, 1
  %42 = getelementptr inbounds [210 x i64], ptr %39, i64 0, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !11
  %44 = add nsw i64 %43, %36
  store i64 %44, ptr %42, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %45

45:                                               ; preds = %32
  %46 = load i64, ptr %2, align 8, !tbaa !11
  %47 = add nsw i64 %46, 1
  store i64 %47, ptr %2, align 8, !tbaa !11
  br label %27, !llvm.loop !13

48:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %49

49:                                               ; preds = %183, %48
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %63, %50
  %52 = load i64, ptr %7, align 8, !tbaa !11
  %53 = load i64, ptr @M, align 8, !tbaa !11
  %54 = icmp slt i64 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %66

56:                                               ; preds = %51
  %57 = load i64, ptr %7, align 8, !tbaa !11
  %58 = getelementptr inbounds [210 x i64], ptr @prevnode, i64 0, i64 %57
  store i64 -1, ptr %58, align 8, !tbaa !11
  %59 = load i64, ptr %7, align 8, !tbaa !11
  %60 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %59
  store i64 0, ptr %60, align 8, !tbaa !11
  %61 = load i64, ptr %7, align 8, !tbaa !11
  %62 = getelementptr inbounds [210 x i8], ptr @vis, i64 0, i64 %61
  store i8 0, ptr %62, align 1, !tbaa !15
  br label %63

63:                                               ; preds = %56
  %64 = load i64, ptr %7, align 8, !tbaa !11
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr %7, align 8, !tbaa !11
  br label %51, !llvm.loop !17

66:                                               ; preds = %55
  store i64 1000000000000, ptr @flow, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 -1, ptr %9, align 8, !tbaa !11
  br label %67

67:                                               ; preds = %138, %66
  br label %68

68:                                               ; preds = %67
  store i64 0, ptr %8, align 8, !tbaa !11
  store i64 -1, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store i64 0, ptr %10, align 8, !tbaa !11
  br label %69

69:                                               ; preds = %91, %68
  %70 = load i64, ptr %10, align 8, !tbaa !11
  %71 = load i64, ptr @M, align 8, !tbaa !11
  %72 = icmp slt i64 %70, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %94

74:                                               ; preds = %69
  %75 = load i64, ptr %10, align 8, !tbaa !11
  %76 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !11
  %78 = load i64, ptr %8, align 8, !tbaa !11
  %79 = icmp sgt i64 %77, %78
  br i1 %79, label %80, label %90

80:                                               ; preds = %74
  %81 = load i64, ptr %10, align 8, !tbaa !11
  %82 = getelementptr inbounds [210 x i8], ptr @vis, i64 0, i64 %81
  %83 = load i8, ptr %82, align 1, !tbaa !15, !range !18, !noundef !19
  %84 = trunc i8 %83 to i1
  br i1 %84, label %90, label %85

85:                                               ; preds = %80
  %86 = load i64, ptr %10, align 8, !tbaa !11
  %87 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !11
  store i64 %88, ptr %8, align 8, !tbaa !11
  %89 = load i64, ptr %10, align 8, !tbaa !11
  store i64 %89, ptr %9, align 8, !tbaa !11
  br label %90

90:                                               ; preds = %85, %80, %74
  br label %91

91:                                               ; preds = %90
  %92 = load i64, ptr %10, align 8, !tbaa !11
  %93 = add nsw i64 %92, 1
  store i64 %93, ptr %10, align 8, !tbaa !11
  br label %69, !llvm.loop !20

94:                                               ; preds = %73
  %95 = load i64, ptr %9, align 8, !tbaa !11
  %96 = icmp eq i64 %95, -1
  br i1 %96, label %102, label %97

97:                                               ; preds = %94
  %98 = load i64, ptr %9, align 8, !tbaa !11
  %99 = load i64, ptr @M, align 8, !tbaa !11
  %100 = sub nsw i64 %99, 1
  %101 = icmp eq i64 %98, %100
  br i1 %101, label %102, label %103

102:                                              ; preds = %97, %94
  br label %139

103:                                              ; preds = %97
  %104 = load i64, ptr %9, align 8, !tbaa !11
  %105 = getelementptr inbounds [210 x i8], ptr @vis, i64 0, i64 %104
  store i8 1, ptr %105, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store i64 0, ptr %11, align 8, !tbaa !11
  br label %106

106:                                              ; preds = %135, %103
  %107 = load i64, ptr %11, align 8, !tbaa !11
  %108 = load i64, ptr @M, align 8, !tbaa !11
  %109 = icmp slt i64 %107, %108
  br i1 %109, label %111, label %110

110:                                              ; preds = %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %138

111:                                              ; preds = %106
  %112 = load i64, ptr %11, align 8, !tbaa !11
  %113 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %112
  %114 = load i64, ptr %113, align 8, !tbaa !11
  %115 = load i64, ptr %9, align 8, !tbaa !11
  %116 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %115
  %117 = load i64, ptr %11, align 8, !tbaa !11
  %118 = getelementptr inbounds [210 x i64], ptr %116, i64 0, i64 %117
  %119 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %118)
  %120 = load i64, ptr %119, align 8, !tbaa !11
  %121 = icmp slt i64 %114, %120
  br i1 %121, label %122, label %134

122:                                              ; preds = %111
  %123 = load i64, ptr %9, align 8, !tbaa !11
  %124 = load i64, ptr %11, align 8, !tbaa !11
  %125 = getelementptr inbounds [210 x i64], ptr @prevnode, i64 0, i64 %124
  store i64 %123, ptr %125, align 8, !tbaa !11
  %126 = load i64, ptr %9, align 8, !tbaa !11
  %127 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %126
  %128 = load i64, ptr %11, align 8, !tbaa !11
  %129 = getelementptr inbounds [210 x i64], ptr %127, i64 0, i64 %128
  %130 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %129)
  %131 = load i64, ptr %130, align 8, !tbaa !11
  %132 = load i64, ptr %11, align 8, !tbaa !11
  %133 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %132
  store i64 %131, ptr %133, align 8, !tbaa !11
  br label %134

134:                                              ; preds = %122, %111
  br label %135

135:                                              ; preds = %134
  %136 = load i64, ptr %11, align 8, !tbaa !11
  %137 = add nsw i64 %136, 1
  store i64 %137, ptr %11, align 8, !tbaa !11
  br label %106, !llvm.loop !21

138:                                              ; preds = %110
  br label %67, !llvm.loop !22

139:                                              ; preds = %102
  %140 = load i64, ptr %9, align 8, !tbaa !11
  %141 = icmp eq i64 %140, -1
  br i1 %141, label %142, label %143

142:                                              ; preds = %139
  store i32 6, ptr %12, align 4
  br label %181

143:                                              ; preds = %139
  %144 = load i64, ptr @M, align 8, !tbaa !11
  %145 = sub nsw i64 %144, 1
  %146 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %145
  %147 = load i64, ptr %146, align 8, !tbaa !11
  %148 = load i64, ptr %6, align 8, !tbaa !11
  %149 = add nsw i64 %148, %147
  store i64 %149, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %150 = load i64, ptr @M, align 8, !tbaa !11
  %151 = sub nsw i64 %150, 1
  store i64 %151, ptr %13, align 8, !tbaa !11
  br label %152

152:                                              ; preds = %155, %143
  %153 = load i64, ptr %13, align 8, !tbaa !11
  %154 = icmp ne i64 %153, 0
  br i1 %154, label %155, label %180

155:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %156 = load i64, ptr %13, align 8, !tbaa !11
  %157 = getelementptr inbounds [210 x i64], ptr @prevnode, i64 0, i64 %156
  %158 = load i64, ptr %157, align 8, !tbaa !11
  store i64 %158, ptr %14, align 8, !tbaa !11
  %159 = load i64, ptr @M, align 8, !tbaa !11
  %160 = sub nsw i64 %159, 1
  %161 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %160
  %162 = load i64, ptr %161, align 8, !tbaa !11
  %163 = load i64, ptr %14, align 8, !tbaa !11
  %164 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %163
  %165 = load i64, ptr %13, align 8, !tbaa !11
  %166 = getelementptr inbounds [210 x i64], ptr %164, i64 0, i64 %165
  %167 = load i64, ptr %166, align 8, !tbaa !11
  %168 = sub nsw i64 %167, %162
  store i64 %168, ptr %166, align 8, !tbaa !11
  %169 = load i64, ptr @M, align 8, !tbaa !11
  %170 = sub nsw i64 %169, 1
  %171 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %170
  %172 = load i64, ptr %171, align 8, !tbaa !11
  %173 = load i64, ptr %13, align 8, !tbaa !11
  %174 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %173
  %175 = load i64, ptr %14, align 8, !tbaa !11
  %176 = getelementptr inbounds [210 x i64], ptr %174, i64 0, i64 %175
  %177 = load i64, ptr %176, align 8, !tbaa !11
  %178 = add nsw i64 %177, %172
  store i64 %178, ptr %176, align 8, !tbaa !11
  %179 = load i64, ptr %14, align 8, !tbaa !11
  store i64 %179, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %152, !llvm.loop !23

180:                                              ; preds = %152
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  store i32 0, ptr %12, align 4
  br label %181

181:                                              ; preds = %180, %142
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %182 = load i32, ptr %12, align 4
  switch i32 %182, label %189 [
    i32 0, label %183
    i32 6, label %184
  ]

183:                                              ; preds = %181
  br label %49, !llvm.loop !24

184:                                              ; preds = %181
  %185 = load i64, ptr %6, align 8, !tbaa !11
  %186 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %185)
  %187 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %186, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  %188 = load i32, ptr %1, align 4
  ret i32 %188

189:                                              ; preds = %181
  unreachable
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #6

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 = { 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 #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 nosync 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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = distinct !{!17, !14}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}
!24 = distinct !{!24, !14}


; 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" }

@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@cap = external dso_local global [210 x [210 x i64]], align 16
@vis = external dso_local local_unnamed_addr global [210 x i8], align 16
@prevnode = external dso_local local_unnamed_addr global [210 x i64], align 16
@flow = external dso_local local_unnamed_addr global [210 x i64], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = load ptr, ptr @stdin, align 8, !tbaa !5
  %6 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %5)
  %7 = load ptr, ptr @stdout, align 8, !tbaa !5
  %8 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %7)
  %9 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %10 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %11 = getelementptr i8, ptr %10, i64 -24
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %12
  %14 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %13, ptr noundef null)
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %16 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(8) @M)
  %17 = load i64, ptr @N, align 8, !tbaa !11
  %18 = icmp sgt i64 %17, 0
  br i1 %18, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %0
  %.pre = load i64, ptr @M, align 8, !tbaa !11
  br label %33

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.04555 = phi i64 [ %30, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %22 = load i64, ptr %3, align 8, !tbaa !11
  %23 = load i64, ptr %1, align 8, !tbaa !11
  %24 = add nsw i64 %23, -1
  %25 = load i64, ptr %2, align 8, !tbaa !11
  %26 = add nsw i64 %25, -1
  %27 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %24, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = add nsw i64 %28, %22
  store i64 %29, ptr %27, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  %30 = add nuw nsw i64 %.04555, 1
  %31 = load i64, ptr @N, align 8, !tbaa !11
  %32 = icmp slt i64 %30, %31
  br i1 %32, label %.lr.ph, label %.preheader, !llvm.loop !13

33:                                               ; preds = %.preheader, %._crit_edge71
  %34 = phi i64 [ %42, %._crit_edge71 ], [ %.pre, %.preheader ]
  %35 = phi i64 [ %41, %._crit_edge71 ], [ %.pre, %.preheader ]
  %.043 = phi i64 [ %98, %._crit_edge71 ], [ 0, %.preheader ]
  %36 = icmp sgt i64 %35, 0
  br i1 %36, label %.lr.ph57.preheader, label %._crit_edge

.lr.ph57.preheader:                               ; preds = %33
  %37 = shl nuw i64 %35, 3
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @prevnode, i8 -1, i64 %37, i1 false), !tbaa !11
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @flow, i8 0, i64 %37, i1 false), !tbaa !11
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @vis, i8 0, i64 %35, i1 false), !tbaa !15
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph57.preheader, %33
  store i64 1000000000000, ptr @flow, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #8
  store i64 0, ptr %4, align 8, !tbaa !11
  %38 = icmp sgt i64 %35, 0
  br i1 %38, label %.lr.ph61.preheader, label %.thread

.loopexit:                                        ; preds = %90, %77
  %39 = phi i64 [ %42, %77 ], [ %92, %90 ]
  store i64 0, ptr %4, align 8, !tbaa !11
  %40 = icmp sgt i64 %39, 0
  br i1 %40, label %.lr.ph61.preheader, label %.thread, !llvm.loop !17

.lr.ph61.preheader:                               ; preds = %._crit_edge, %.loopexit
  %41 = phi i64 [ %39, %.loopexit ], [ %35, %._crit_edge ]
  %42 = phi i64 [ %39, %.loopexit ], [ %34, %._crit_edge ]
  %xtraiter = and i64 %41, 1
  %43 = icmp eq i64 %41, 1
  br i1 %43, label %._crit_edge62.unr-lcssa, label %.lr.ph61.preheader.new

.lr.ph61.preheader.new:                           ; preds = %.lr.ph61.preheader
  %unroll_iter = and i64 %41, 9223372036854775806
  br label %.lr.ph61

._crit_edge62.unr-lcssa:                          ; preds = %74, %.lr.ph61.preheader
  %.1.lcssa.ph = phi i64 [ poison, %.lr.ph61.preheader ], [ %.1.1, %74 ]
  %.04059.unr = phi i64 [ 0, %.lr.ph61.preheader ], [ %76, %74 ]
  %.04158.unr = phi i64 [ -1, %.lr.ph61.preheader ], [ %.1.1, %74 ]
  %.unr = phi i64 [ 0, %.lr.ph61.preheader ], [ %75, %74 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge62, label %.lr.ph61.epil

.lr.ph61.epil:                                    ; preds = %._crit_edge62.unr-lcssa
  %44 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %.04059.unr
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = icmp sgt i64 %45, %.unr
  br i1 %46, label %47, label %._crit_edge62

47:                                               ; preds = %.lr.ph61.epil
  %48 = getelementptr inbounds [210 x i8], ptr @vis, i64 0, i64 %.04059.unr
  %49 = load i8, ptr %48, align 1, !tbaa !15, !range !18, !noundef !19
  %50 = trunc nuw i8 %49 to i1
  br i1 %50, label %._crit_edge62, label %51

51:                                               ; preds = %47
  store i64 %45, ptr %4, align 8, !tbaa !11
  br label %._crit_edge62

._crit_edge62:                                    ; preds = %.lr.ph61.epil, %47, %51, %._crit_edge62.unr-lcssa
  %.1.lcssa = phi i64 [ %.1.lcssa.ph, %._crit_edge62.unr-lcssa ], [ %.04158.unr, %47 ], [ %.04059.unr, %51 ], [ %.04158.unr, %.lr.ph61.epil ]
  %52 = icmp eq i64 %.1.lcssa, -1
  %53 = add nsw i64 %41, -1
  %54 = icmp eq i64 %.1.lcssa, %53
  %or.cond = select i1 %52, i1 true, i1 %54
  br i1 %or.cond, label %94, label %77

.lr.ph61:                                         ; preds = %74, %.lr.ph61.preheader.new
  %.04059 = phi i64 [ 0, %.lr.ph61.preheader.new ], [ %76, %74 ]
  %.04158 = phi i64 [ -1, %.lr.ph61.preheader.new ], [ %.1.1, %74 ]
  %55 = phi i64 [ 0, %.lr.ph61.preheader.new ], [ %75, %74 ]
  %niter = phi i64 [ 0, %.lr.ph61.preheader.new ], [ %niter.next.1, %74 ]
  %56 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %.04059
  %57 = load i64, ptr %56, align 16, !tbaa !11
  %58 = icmp sgt i64 %57, %55
  br i1 %58, label %59, label %.lr.ph61.1

59:                                               ; preds = %.lr.ph61
  %60 = getelementptr inbounds [210 x i8], ptr @vis, i64 0, i64 %.04059
  %61 = load i8, ptr %60, align 2, !tbaa !15, !range !18, !noundef !19
  %62 = trunc nuw i8 %61 to i1
  br i1 %62, label %.lr.ph61.1, label %63

63:                                               ; preds = %59
  store i64 %57, ptr %4, align 8, !tbaa !11
  br label %.lr.ph61.1

.lr.ph61.1:                                       ; preds = %.lr.ph61, %59, %63
  %64 = phi i64 [ %55, %59 ], [ %57, %63 ], [ %55, %.lr.ph61 ]
  %.1 = phi i64 [ %.04158, %59 ], [ %.04059, %63 ], [ %.04158, %.lr.ph61 ]
  %65 = or disjoint i64 %.04059, 1
  %66 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !11
  %68 = icmp sgt i64 %67, %64
  br i1 %68, label %69, label %74

69:                                               ; preds = %.lr.ph61.1
  %70 = getelementptr inbounds [210 x i8], ptr @vis, i64 0, i64 %65
  %71 = load i8, ptr %70, align 1, !tbaa !15, !range !18, !noundef !19
  %72 = trunc nuw i8 %71 to i1
  br i1 %72, label %74, label %73

73:                                               ; preds = %69
  store i64 %67, ptr %4, align 8, !tbaa !11
  br label %74

74:                                               ; preds = %73, %69, %.lr.ph61.1
  %75 = phi i64 [ %64, %69 ], [ %67, %73 ], [ %64, %.lr.ph61.1 ]
  %.1.1 = phi i64 [ %.1, %69 ], [ %65, %73 ], [ %.1, %.lr.ph61.1 ]
  %76 = add nuw nsw i64 %.04059, 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_edge62.unr-lcssa, label %.lr.ph61, !llvm.loop !20

77:                                               ; preds = %._crit_edge62
  %78 = getelementptr inbounds [210 x i8], ptr @vis, i64 0, i64 %.1.lcssa
  store i8 1, ptr %78, align 1, !tbaa !15
  %79 = icmp sgt i64 %42, 0
  br i1 %79, label %.lr.ph66, label %.loopexit

.lr.ph66:                                         ; preds = %77, %90
  %.03964 = phi i64 [ %91, %90 ], [ 0, %77 ]
  %80 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %.03964
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %.1.lcssa, i64 %.03964
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %82)
  %84 = load i64, ptr %83, align 8, !tbaa !11
  %85 = icmp slt i64 %81, %84
  br i1 %85, label %86, label %90

86:                                               ; preds = %.lr.ph66
  %87 = getelementptr inbounds [210 x i64], ptr @prevnode, i64 0, i64 %.03964
  store i64 %.1.lcssa, ptr %87, align 8, !tbaa !11
  %88 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %82)
  %89 = load i64, ptr %88, align 8, !tbaa !11
  store i64 %89, ptr %80, align 8, !tbaa !11
  br label %90

90:                                               ; preds = %.lr.ph66, %86
  %91 = add nuw nsw i64 %.03964, 1
  %92 = load i64, ptr @M, align 8, !tbaa !11
  %93 = icmp slt i64 %91, %92
  br i1 %93, label %.lr.ph66, label %.loopexit, !llvm.loop !21

94:                                               ; preds = %._crit_edge62
  br i1 %52, label %.thread, label %95

95:                                               ; preds = %94
  %96 = getelementptr inbounds [210 x i64], ptr @flow, i64 0, i64 %53
  %97 = load i64, ptr %96, align 8, !tbaa !11
  %98 = add nsw i64 %97, %.043
  %.not67 = icmp eq i64 %53, 0
  br i1 %.not67, label %._crit_edge71, label %.lr.ph70

.lr.ph70:                                         ; preds = %95, %.lr.ph70
  %.068 = phi i64 [ %100, %.lr.ph70 ], [ %53, %95 ]
  %99 = getelementptr inbounds [210 x i64], ptr @prevnode, i64 0, i64 %.068
  %100 = load i64, ptr %99, align 8, !tbaa !11
  %101 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %100, i64 %.068
  %102 = load i64, ptr %101, align 8, !tbaa !11
  %103 = sub nsw i64 %102, %97
  store i64 %103, ptr %101, align 8, !tbaa !11
  %104 = getelementptr inbounds [210 x [210 x i64]], ptr @cap, i64 0, i64 %.068, i64 %100
  %105 = load i64, ptr %104, align 8, !tbaa !11
  %106 = add nsw i64 %105, %97
  store i64 %106, ptr %104, align 8, !tbaa !11
  %.not = icmp eq i64 %100, 0
  br i1 %.not, label %._crit_edge71, label %.lr.ph70, !llvm.loop !22

._crit_edge71:                                    ; preds = %.lr.ph70, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #8
  br label %33

.thread:                                          ; preds = %94, %._crit_edge, %.loopexit
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #8
  %107 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.043)
  %108 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %107, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7

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 = { 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 #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 nosync 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 = { 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }

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

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


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